v0.91 - Added API and fixed a few bugs.
This commit is contained in:
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
name: MobArena
|
name: MobArena
|
||||||
main: com.garbagemule.MobArena.MobArena
|
main: com.garbagemule.MobArena.MobArena
|
||||||
version: 0.90.2
|
version: 0.91
|
||||||
softdepend: [MultiVerse]
|
softdepend: [MultiVerse]
|
||||||
commands:
|
commands:
|
||||||
ma:
|
ma:
|
||||||
|
|||||||
@@ -34,9 +34,12 @@ public class ArenaManager
|
|||||||
protected static boolean isSetup = false;
|
protected static boolean isSetup = false;
|
||||||
protected static boolean isEnabled = true;
|
protected static boolean isEnabled = true;
|
||||||
protected static boolean isProtected = true;
|
protected static boolean isProtected = true;
|
||||||
|
protected static int wave = 0;
|
||||||
protected static int spawnTaskId = -1;
|
protected static int spawnTaskId = -1;
|
||||||
protected static int waveDelay, waveInterval, specialModulo, repairDelay;
|
protected static int waveDelay, waveInterval, specialModulo, repairDelay;
|
||||||
protected static boolean checkUpdates, lightning, spawnMonsters;
|
protected static boolean checkUpdates, lightning, spawnMonsters;
|
||||||
|
protected static int spawnMonstersInt;
|
||||||
|
protected static MASpawnThread spawnThread = null;
|
||||||
|
|
||||||
// Location variables for the arena region.
|
// Location variables for the arena region.
|
||||||
protected static Location p1 = null;
|
protected static Location p1 = null;
|
||||||
@@ -71,6 +74,9 @@ public class ArenaManager
|
|||||||
protected static Set<LivingEntity> monsterSet = new HashSet<LivingEntity>();
|
protected static Set<LivingEntity> monsterSet = new HashSet<LivingEntity>();
|
||||||
protected static Set<Block> blockSet = new HashSet<Block>();
|
protected static Set<Block> blockSet = new HashSet<Block>();
|
||||||
|
|
||||||
|
// Hook listeners
|
||||||
|
protected static Set<MobArenaListener> listeners = new HashSet<MobArenaListener>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ///////////////////////////////////////////////////////////////////// //
|
/* ///////////////////////////////////////////////////////////////////// //
|
||||||
@@ -171,10 +177,13 @@ public class ArenaManager
|
|||||||
rewardMap.put(p,"");
|
rewardMap.put(p,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
MASpawnThread thread = new MASpawnThread();
|
spawnThread = new MASpawnThread();
|
||||||
spawnTaskId = server.getScheduler().scheduleSyncRepeatingTask(plugin,thread,(long)waveDelay,(long)waveInterval);
|
spawnTaskId = server.getScheduler().scheduleSyncRepeatingTask(plugin,spawnThread,(long)waveDelay,(long)waveInterval);
|
||||||
|
|
||||||
tellAll("Let the slaughter begin!");
|
tellAll("Let the slaughter begin!");
|
||||||
|
|
||||||
|
for (MobArenaListener m : listeners)
|
||||||
|
m.onArenaStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,6 +194,7 @@ public class ArenaManager
|
|||||||
public static void endArena()
|
public static void endArena()
|
||||||
{
|
{
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
|
wave = 0;
|
||||||
server.getScheduler().cancelTask(spawnTaskId);
|
server.getScheduler().cancelTask(spawnTaskId);
|
||||||
MAUtils.spawnBypass(true);
|
MAUtils.spawnBypass(true);
|
||||||
|
|
||||||
@@ -194,6 +204,9 @@ public class ArenaManager
|
|||||||
giveRewards();
|
giveRewards();
|
||||||
|
|
||||||
tellAll("Arena finished.");
|
tellAll("Arena finished.");
|
||||||
|
|
||||||
|
for (MobArenaListener m : listeners)
|
||||||
|
m.onArenaEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -239,6 +252,9 @@ public class ArenaManager
|
|||||||
p.teleport(lobbyLoc);
|
p.teleport(lobbyLoc);
|
||||||
|
|
||||||
tellPlayer(p, "You joined the arena. Have fun!");
|
tellPlayer(p, "You joined the arena. Have fun!");
|
||||||
|
|
||||||
|
for (MobArenaListener m : listeners)
|
||||||
|
m.onPlayerJoin(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -270,6 +286,9 @@ public class ArenaManager
|
|||||||
startArena();
|
startArena();
|
||||||
|
|
||||||
tellPlayer(p, "You left the arena. Thanks for playing!");
|
tellPlayer(p, "You left the arena. Thanks for playing!");
|
||||||
|
|
||||||
|
for (MobArenaListener m : listeners)
|
||||||
|
m.onPlayerLeave(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -302,6 +321,9 @@ public class ArenaManager
|
|||||||
|
|
||||||
if (isRunning && playerSet.isEmpty())
|
if (isRunning && playerSet.isEmpty())
|
||||||
endArena();
|
endArena();
|
||||||
|
|
||||||
|
for (MobArenaListener m : listeners)
|
||||||
|
m.onPlayerDeath(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -92,14 +92,19 @@ public class MASpawnThread implements Runnable
|
|||||||
if (wave % modulo == 0)
|
if (wave % modulo == 0)
|
||||||
{
|
{
|
||||||
ArenaManager.tellAll("Get ready for wave #" + wave + "! [SPECIAL]");
|
ArenaManager.tellAll("Get ready for wave #" + wave + "! [SPECIAL]");
|
||||||
|
for (MobArenaListener m : ArenaManager.listeners)
|
||||||
|
m.onSpecialWave(wave, wave/modulo);
|
||||||
specialWave();
|
specialWave();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ArenaManager.tellAll("Get ready for wave #" + wave + "!");
|
ArenaManager.tellAll("Get ready for wave #" + wave + "!");
|
||||||
|
for (MobArenaListener m : ArenaManager.listeners)
|
||||||
|
m.onDefaultWave(wave);
|
||||||
defaultWave();
|
defaultWave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArenaManager.wave = wave;
|
||||||
wave++;
|
wave++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,10 @@ public class MAUtils
|
|||||||
|
|
||||||
// If not toggling, just return the current variable.
|
// If not toggling, just return the current variable.
|
||||||
if (!toggle)
|
if (!toggle)
|
||||||
|
{
|
||||||
|
ArenaManager.spawnMonstersInt = nmsWorld.spawnMonsters;
|
||||||
return nmsWorld.allowMonsters;
|
return nmsWorld.allowMonsters;
|
||||||
|
}
|
||||||
|
|
||||||
// If arena is running, allow monsters, otherwise don't.
|
// If arena is running, allow monsters, otherwise don't.
|
||||||
if (ArenaManager.isRunning)
|
if (ArenaManager.isRunning)
|
||||||
@@ -247,7 +250,7 @@ public class MAUtils
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
nmsWorld.allowMonsters = false;
|
nmsWorld.allowMonsters = false;
|
||||||
nmsWorld.spawnMonsters = 0;
|
nmsWorld.spawnMonsters = ArenaManager.spawnMonstersInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.block.BlockListener;
|
import org.bukkit.event.block.BlockListener;
|
||||||
@@ -41,6 +43,8 @@ public class MobArena extends JavaPlugin
|
|||||||
getCommand("ma").setExecutor(new MACommands());
|
getCommand("ma").setExecutor(new MACommands());
|
||||||
getCommand("marena").setExecutor(new MACommands());
|
getCommand("marena").setExecutor(new MACommands());
|
||||||
getCommand("mobarena").setExecutor(new MACommands());
|
getCommand("mobarena").setExecutor(new MACommands());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create event listeners.
|
// Create event listeners.
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
@@ -79,4 +83,9 @@ public class MobArena extends JavaPlugin
|
|||||||
|
|
||||||
ArenaManager.forceEnd(null);
|
ArenaManager.forceEnd(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPlaying(Player p)
|
||||||
|
{
|
||||||
|
return ArenaManager.playerSet.contains(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class MobArenaHandler
|
||||||
|
{
|
||||||
|
public MobArenaHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there is an active arena session running.
|
||||||
|
public boolean isRunning() { return ArenaManager.isRunning; }
|
||||||
|
|
||||||
|
// Check if the specified player is in the arena/lobby.
|
||||||
|
public boolean isPlaying(Player p) { return ArenaManager.playerSet.contains(p); }
|
||||||
|
|
||||||
|
// Get a list of all players currently in the arena.
|
||||||
|
public List<Player> getPlayers() { return new LinkedList<Player>(ArenaManager.playerSet); }
|
||||||
|
|
||||||
|
// Get the warp locations.
|
||||||
|
public Location getArenaLocation() { return ArenaManager.arenaLoc; }
|
||||||
|
public Location getLobbyLocation() { return ArenaManager.lobbyLoc; }
|
||||||
|
public Location getSpectatorLocation() { return ArenaManager.spectatorLoc; }
|
||||||
|
|
||||||
|
// Get the current wave number.
|
||||||
|
public int getWave() { return ArenaManager.wave; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class MobArenaListener
|
||||||
|
{
|
||||||
|
protected MobArena plugin;
|
||||||
|
|
||||||
|
public MobArenaListener()
|
||||||
|
{
|
||||||
|
plugin = ArenaManager.plugin;
|
||||||
|
ArenaManager.listeners.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onArenaStart() {}
|
||||||
|
public void onArenaEnd() {}
|
||||||
|
public void onDefaultWave(int waveNumber) {}
|
||||||
|
public void onSpecialWave(int waveNumber, int specialwaveNumber) {}
|
||||||
|
public void onPlayerJoin(Player p) {}
|
||||||
|
public void onPlayerLeave(Player p) {}
|
||||||
|
public void onPlayerDeath(Player p) {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user