v0.90.2 - Fixed a reward bug and added spawn-monsters=false support
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.1
|
version: 0.90.2
|
||||||
commands:
|
commands:
|
||||||
ma:
|
ma:
|
||||||
description: Base command for MobArena
|
description: Base command for MobArena
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class ArenaManager
|
|||||||
protected static boolean isProtected = true;
|
protected static boolean isProtected = true;
|
||||||
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;
|
protected static boolean checkUpdates, lightning, spawnMonsters;
|
||||||
|
|
||||||
// Location variables for the arena region.
|
// Location variables for the arena region.
|
||||||
protected static Location p1 = null;
|
protected static Location p1 = null;
|
||||||
@@ -88,12 +88,13 @@ public class ArenaManager
|
|||||||
if (instance != null)
|
if (instance != null)
|
||||||
{
|
{
|
||||||
// General variables.
|
// General variables.
|
||||||
config = MAUtils.getConfig();
|
config = MAUtils.getConfig();
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
server = plugin.getServer();
|
server = plugin.getServer();
|
||||||
world = MAUtils.getWorld();
|
world = MAUtils.getWorld();
|
||||||
lightning = MAUtils.getBoolean("settings.lightning", true);
|
lightning = MAUtils.getBoolean("settings.lightning", true);
|
||||||
repairDelay = MAUtils.getInt("settings.repairdelay", 5);
|
repairDelay = MAUtils.getInt("settings.repairdelay", 5);
|
||||||
|
spawnMonsters = MAUtils.spawnBypass(false);
|
||||||
|
|
||||||
// Class list and maps.
|
// Class list and maps.
|
||||||
classes = MAUtils.getClasses();
|
classes = MAUtils.getClasses();
|
||||||
@@ -159,6 +160,7 @@ public class ArenaManager
|
|||||||
{
|
{
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
readySet.clear();
|
readySet.clear();
|
||||||
|
MAUtils.spawnBypass(true);
|
||||||
|
|
||||||
// Clear the floor for good measure.
|
// Clear the floor for good measure.
|
||||||
clearEntities();
|
clearEntities();
|
||||||
@@ -184,13 +186,13 @@ public class ArenaManager
|
|||||||
{
|
{
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
server.getScheduler().cancelTask(spawnTaskId);
|
server.getScheduler().cancelTask(spawnTaskId);
|
||||||
|
MAUtils.spawnBypass(true);
|
||||||
|
|
||||||
killMonsters();
|
killMonsters();
|
||||||
clearBlocks();
|
clearBlocks();
|
||||||
clearEntities();
|
clearEntities();
|
||||||
giveRewards();
|
giveRewards();
|
||||||
|
|
||||||
// TO-DO: Fix this, maybe add a Set<Player> dead
|
|
||||||
tellAll("Arena finished.");
|
tellAll("Arena finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,16 +504,24 @@ public class ArenaManager
|
|||||||
*/
|
*/
|
||||||
public static void giveRewards()
|
public static void giveRewards()
|
||||||
{
|
{
|
||||||
for (Player p : rewardMap.keySet())
|
/* This has to be delayed for players to actually receive
|
||||||
{
|
* their rewards after they die. Not sure why. */
|
||||||
String r = rewardMap.get(p);
|
server.getScheduler().scheduleSyncDelayedTask(plugin,
|
||||||
if (r.isEmpty()) continue;
|
new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
for (Player p : rewardMap.keySet())
|
||||||
|
{
|
||||||
|
String r = rewardMap.get(p);
|
||||||
|
if (r.isEmpty()) continue;
|
||||||
|
|
||||||
tellPlayer(p, "Here are all of your rewards!");
|
tellPlayer(p, "Here are all of your rewards!");
|
||||||
MAUtils.giveItems(true, p, r);
|
MAUtils.giveItems(true, p, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
rewardMap.clear();
|
rewardMap.clear();
|
||||||
|
}}, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -14,9 +14,9 @@ import org.bukkit.event.entity.EntityDeathEvent;
|
|||||||
* By the end of the arena session, the rewards are given.
|
* By the end of the arena session, the rewards are given.
|
||||||
*/
|
*/
|
||||||
// TO-DO: Perhaps implement TeamFluff's respawn-packet-code.
|
// TO-DO: Perhaps implement TeamFluff's respawn-packet-code.
|
||||||
public class MADamageListener extends EntityListener
|
public class MADeathListener extends EntityListener
|
||||||
{
|
{
|
||||||
public MADamageListener(MobArena instance)
|
public MADeathListener(MobArena instance)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,12 +32,22 @@ public class MAMonsterListener extends EntityListener
|
|||||||
*/
|
*/
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||||
{
|
{
|
||||||
|
// If monster spawning is disabled, only spawn inside the region.
|
||||||
|
if (!ArenaManager.spawnMonsters)
|
||||||
|
{
|
||||||
|
if (ArenaManager.isRunning && MAUtils.inRegion(event.getLocation()))
|
||||||
|
return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, ignore spawns inside the region...
|
||||||
if (!MAUtils.inRegion(event.getLocation()))
|
if (!MAUtils.inRegion(event.getLocation()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(event.getEntity() instanceof LivingEntity))
|
if (!(event.getEntity() instanceof LivingEntity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// .. And cancel those inside the region if the arena isn't running.
|
||||||
if (!ArenaManager.isRunning)
|
if (!ArenaManager.isRunning)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -223,6 +224,35 @@ public class MAUtils
|
|||||||
return ArenaManager.server.getWorld(world);
|
return ArenaManager.server.getWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles all spawn-monster bypassing.
|
||||||
|
* If toggle is true, swap the allowMonsters field if possible. Otherwise, just
|
||||||
|
* return the current value.
|
||||||
|
*/
|
||||||
|
public static boolean spawnBypass(boolean toggle)
|
||||||
|
{
|
||||||
|
// Cast the world to an nmsWorld.
|
||||||
|
net.minecraft.server.World nmsWorld = ((CraftWorld) ArenaManager.world).getHandle();
|
||||||
|
|
||||||
|
// If not toggling, just return the current variable.
|
||||||
|
if (!toggle)
|
||||||
|
return nmsWorld.allowMonsters;
|
||||||
|
|
||||||
|
// If arena is running, allow monsters, otherwise don't.
|
||||||
|
if (ArenaManager.isRunning)
|
||||||
|
{
|
||||||
|
nmsWorld.allowMonsters = true;
|
||||||
|
nmsWorld.spawnMonsters = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nmsWorld.allowMonsters = false;
|
||||||
|
nmsWorld.spawnMonsters = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs the list of classes from the config-file. If no list is
|
* Grabs the list of classes from the config-file. If no list is
|
||||||
* found, generate a set of default classes.
|
* found, generate a set of default classes.
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class MobArena extends JavaPlugin
|
|||||||
PlayerListener teleportListener = new MATeleportListener(this);
|
PlayerListener teleportListener = new MATeleportListener(this);
|
||||||
PlayerListener discListener = new MADisconnectListener(this);
|
PlayerListener discListener = new MADisconnectListener(this);
|
||||||
BlockListener blockListener = new MABlockListener(this);
|
BlockListener blockListener = new MABlockListener(this);
|
||||||
EntityListener damageListener = new MADamageListener(this);
|
EntityListener deathListener = new MADeathListener(this);
|
||||||
EntityListener monsterListener = new MAMonsterListener(this);
|
EntityListener monsterListener = new MAMonsterListener(this);
|
||||||
// TO-DO: PlayerListener to check for kills/deaths.
|
// TO-DO: PlayerListener to check for kills/deaths.
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public class MobArena extends JavaPlugin
|
|||||||
pm.registerEvent(Event.Type.PLAYER_JOIN, discListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_JOIN, discListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_DEATH, damageListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_DEATH, deathListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, monsterListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_EXPLODE, monsterListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_COMBUST, monsterListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_COMBUST, monsterListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_TARGET, monsterListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_TARGET, monsterListener, Priority.Normal, this);
|
||||||
|
|||||||
Reference in New Issue
Block a user