Added Spout support for announcements and reverted to old spawn algorithm
This commit is contained in:
Binary file not shown.
+11
-2
@@ -1,7 +1,7 @@
|
||||
name: MobArena
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: 0.93.5
|
||||
softdepend: [Permissions,MultiVerse,XcraftGate,Towny]
|
||||
version: 0.94
|
||||
softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny]
|
||||
commands:
|
||||
ma:
|
||||
description: Base command for MobArena
|
||||
@@ -74,6 +74,9 @@ permissions:
|
||||
mobarena.setup.spawnpoints: true
|
||||
mobarena.setup.addspawn: true
|
||||
mobarena.setup.delspawn: true
|
||||
mobarena.setup.containers: true
|
||||
mobarena.setup.addcontainer: true
|
||||
mobarena.setup.delcontainer: true
|
||||
mobarena.setup.checkdata: true
|
||||
mobarena.setup.autogenerate: true
|
||||
mobarena.setup.autodegenerate: true
|
||||
@@ -107,6 +110,12 @@ permissions:
|
||||
default: false
|
||||
mobarena.setup.delspawn:
|
||||
default: false
|
||||
mobarena.setup.containers:
|
||||
default: false
|
||||
mobarena.setup.addcontainer:
|
||||
default: false
|
||||
mobarena.setup.delcontainer:
|
||||
default: false
|
||||
mobarena.setup.checkdata:
|
||||
default: false
|
||||
mobarena.setup.autogenerate:
|
||||
|
||||
+21
-15
@@ -32,7 +32,7 @@ classes:
|
||||
items: iron_sword, grilled_pork:3, apple
|
||||
armor: 310,311,312,313
|
||||
Archer:
|
||||
items: wood_sword, bow, arrow:64, arrow:64, grilled_pork, bone:2
|
||||
items: wood_sword, bow, arrow:256, grilled_pork, bone
|
||||
armor: 298,299,300,301
|
||||
Chef:
|
||||
items: stone_sword, bread:6, grilled_pork:4, mushroom_soup, cake:5
|
||||
@@ -81,20 +81,26 @@ arenas:
|
||||
special-modulo: 4
|
||||
max-idle-time: 0
|
||||
waves:
|
||||
default:
|
||||
zombies: 10
|
||||
skeletons: 10
|
||||
spiders: 10
|
||||
creepers: 10
|
||||
wolves: 10
|
||||
special:
|
||||
powered-creepers: 10
|
||||
zombie-pigmen: 10
|
||||
angry-wolves: 10
|
||||
slimes: 10
|
||||
humans: 10
|
||||
giants: 0
|
||||
ghasts: 0
|
||||
recurrent:
|
||||
def1:
|
||||
type: default
|
||||
priority: 1
|
||||
frequency: 1
|
||||
monsters:
|
||||
zombies: 10
|
||||
skeletons: 10
|
||||
spiders: 10
|
||||
creepers: 10
|
||||
wolves: 10
|
||||
spec1:
|
||||
type: special
|
||||
priority: 2
|
||||
frequency: 4
|
||||
monsters:
|
||||
powered-creepers: 10
|
||||
zombie-pigmen: 10
|
||||
angry-wolves: 10
|
||||
humans: 10
|
||||
rewards:
|
||||
waves:
|
||||
every:
|
||||
|
||||
@@ -70,7 +70,6 @@ public class Arena
|
||||
protected int spawnTaskId, sheepTaskId, waveDelay, waveInterval, specialModulo, spawnMonstersInt, maxIdleTime;
|
||||
protected MASpawnThread spawnThread;
|
||||
protected Map<Integer,List<ItemStack>> everyWaveMap, afterWaveMap;
|
||||
protected Map<String,Integer> distDefault, distSpecial;
|
||||
protected Map<Player,String> classMap;
|
||||
protected Map<String,List<ItemStack>> classItems, classArmor;
|
||||
protected List<ItemStack> entryFee;
|
||||
@@ -197,7 +196,7 @@ public class Arena
|
||||
log.start();
|
||||
|
||||
// Announce and notify.
|
||||
MAUtils.tellAll(this, Msg.ARENA_START.get());
|
||||
MAUtils.tellAll(this, Msg.ARENA_START);
|
||||
for (MobArenaListener listener : plugin.getAM().listeners)
|
||||
listener.onArenaStart(this);
|
||||
|
||||
@@ -238,7 +237,7 @@ public class Arena
|
||||
restoreContainerContents();
|
||||
|
||||
// Announce and clear sets.
|
||||
MAUtils.tellAll(this, Msg.ARENA_END.get(), true);
|
||||
MAUtils.tellAll(this, Msg.ARENA_END, true);
|
||||
arenaPlayers.clear();
|
||||
notifyPlayers.clear();
|
||||
rewardedPlayers.clear();
|
||||
@@ -351,7 +350,7 @@ public class Arena
|
||||
if (running && spawnThread != null)
|
||||
spawnThread.updateTargets();
|
||||
|
||||
MAUtils.tellAll(this, Msg.PLAYER_DIED.get(p.getName()));
|
||||
MAUtils.tellAll(this, Msg.PLAYER_DIED, p.getName());
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new Runnable()
|
||||
{
|
||||
@@ -802,9 +801,7 @@ public class Arena
|
||||
waveInterval = config.getInt(arenaPath + "wave-interval", 20) * 20;
|
||||
specialModulo = config.getInt(arenaPath + "special-modulo", 4);
|
||||
maxIdleTime = config.getInt(arenaPath + "max-idle-time", 0) * 20;
|
||||
|
||||
distDefault = MAUtils.getArenaDistributions(config, configName, "default");
|
||||
distSpecial = MAUtils.getArenaDistributions(config, configName, "special");
|
||||
|
||||
everyWaveMap = MAUtils.getArenaRewardMap(config, configName, "every");
|
||||
afterWaveMap = MAUtils.getArenaRewardMap(config, configName, "after");
|
||||
entryFee = MAUtils.getEntryFee(config, configName);
|
||||
|
||||
@@ -1114,7 +1114,7 @@ public class MACommands implements CommandExecutor
|
||||
}
|
||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma addchest <container name>");
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma addcontainer <container name>");
|
||||
return true;
|
||||
}
|
||||
if (!(p.getTargetBlock(null, 50).getState() instanceof ContainerBlock))
|
||||
|
||||
@@ -368,7 +368,7 @@ public class MAListener implements ArenaListener
|
||||
}
|
||||
else if (arena.bossWave.getHealth() <= 100 && !arena.bossWave.isLowHealthAnnounced())
|
||||
{
|
||||
MAUtils.tellAll(arena, Msg.WAVE_BOSS_LOW_HEALTH.get());
|
||||
MAUtils.tellAll(arena, Msg.WAVE_BOSS_LOW_HEALTH);
|
||||
arena.bossWave.setLowHealthAnnounced(true);
|
||||
}
|
||||
}
|
||||
@@ -548,7 +548,7 @@ public class MAListener implements ArenaListener
|
||||
// Set the player's class.
|
||||
arena.assignClass(p, className);
|
||||
if (!className.equalsIgnoreCase("random"))
|
||||
MAUtils.tellPlayer(p, Msg.LOBBY_CLASS_PICKED, className);
|
||||
MAUtils.tellPlayer(p, Msg.LOBBY_CLASS_PICKED, className, arena.classItems.get(className).get(0).getType());
|
||||
else
|
||||
MAUtils.tellPlayer(p, Msg.LOBBY_CLASS_RANDOM);
|
||||
|
||||
|
||||
@@ -7,38 +7,40 @@ import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class MAMessages
|
||||
{
|
||||
public static enum Msg
|
||||
{
|
||||
ARENA_START("Let the slaughter begin!"),
|
||||
ARENA_END("Arena finished."),
|
||||
ARENA_DOES_NOT_EXIST("That arena does not exist. Type /ma arenas for a list."),
|
||||
JOIN_NOT_ENABLED("MobArena is not enabled."),
|
||||
JOIN_IN_OTHER_ARENA("You are already in an arena! Leave that one first."),
|
||||
JOIN_ARENA_NOT_ENABLED("This arena is not enabled."),
|
||||
JOIN_ARENA_NOT_SETUP("This arena has not been set up yet."),
|
||||
JOIN_ARENA_EDIT_MODE("This arena is in edit mode."),
|
||||
JOIN_ARENA_PERMISSION("You don't have permission to join this arena."),
|
||||
JOIN_FEE_REQUIRED("Insufficient funds. Price: %"),
|
||||
JOIN_FEE_PAID("Price to join was: %"),
|
||||
JOIN_ARENA_IS_RUNNING("This arena is in already progress."),
|
||||
JOIN_ALREADY_PLAYING("You are already playing!"),
|
||||
ARENA_START("Let the slaughter begin!", "Arena started!", Material.REDSTONE_TORCH_ON),
|
||||
ARENA_END("Arena finished.", "Arena finished.", Material.REDSTONE_TORCH_OFF),
|
||||
ARENA_DOES_NOT_EXIST("That arena does not exist. Type /ma arenas for a list.", "Can't find arena."),
|
||||
JOIN_NOT_ENABLED("MobArena is not enabled.", "MobArena disabled.", Material.REDSTONE_TORCH_OFF),
|
||||
JOIN_IN_OTHER_ARENA("You are already in an arena! Leave that one first.", "In another arena."),
|
||||
JOIN_ARENA_NOT_ENABLED("This arena is not enabled.", "Arena disabled.", Material.REDSTONE_TORCH_OFF),
|
||||
JOIN_ARENA_NOT_SETUP("This arena has not been set up yet.", "Arena not set up.", Material.REDSTONE_TORCH_OFF),
|
||||
JOIN_ARENA_EDIT_MODE("This arena is in edit mode.", "Arena in edit mode.", Material.IRON_SPADE),
|
||||
JOIN_ARENA_PERMISSION("You don't have permission to join this arena.", "No permission!", Material.FENCE),
|
||||
JOIN_FEE_REQUIRED("Insufficient funds. Price: %", "Price: %", Material.DIAMOND),
|
||||
JOIN_FEE_PAID("Price to join was: %", "Paid: %", Material.DIAMOND),
|
||||
JOIN_ARENA_IS_RUNNING("This arena is in already progress.", "Already running!", Material.GOLD_RECORD),
|
||||
JOIN_ALREADY_PLAYING("You are already playing!", "Already playing!", Material.GOLD_RECORD),
|
||||
JOIN_ARG_NEEDED("You must specify an arena. Type /ma arenas for a list."),
|
||||
JOIN_TOO_FAR("You are too far away from the arena to join/spectate."),
|
||||
JOIN_EMPTY_INV("You must empty your inventory to join the arena."),
|
||||
JOIN_PLAYER_LIMIT_REACHED("The player limit of this arena has been reached."),
|
||||
JOIN_TOO_FAR("You are too far away from the arena to join/spectate.", "Too far from arena.", Material.COMPASS),
|
||||
JOIN_EMPTY_INV("You must empty your inventory to join the arena.", "Empty your inventory.", Material.CHEST),
|
||||
JOIN_PLAYER_LIMIT_REACHED("The player limit of this arena has been reached.", "No spots left.", Material.MILK_BUCKET),
|
||||
JOIN_STORE_INV_FAIL("Failed to store inventory. Try again."),
|
||||
JOIN_EXISTING_INV_RESTORED("Your old inventory items have been restored."),
|
||||
JOIN_PLAYER_JOINED("You joined the arena. Have fun!"),
|
||||
LEAVE_NOT_PLAYING("You are not in the arena."),
|
||||
LEAVE_PLAYER_LEFT("You left the arena. Thanks for playing!"),
|
||||
PLAYER_DIED("% died!"),
|
||||
SPEC_PLAYER_SPECTATE("Enjoy the show!"),
|
||||
SPEC_NOT_RUNNING("This arena isn't running."),
|
||||
SPEC_ARG_NEEDED("You must specify an arena. Type /ma arenas for a list."),
|
||||
SPEC_EMPTY_INV("Empty your inventory first!"),
|
||||
SPEC_ALREADY_PLAYING("Can't spectate when in the arena!"),
|
||||
JOIN_PLAYER_JOINED("You joined the arena. Have fun!", "Joined arena.", Material.IRON_SWORD),
|
||||
LEAVE_NOT_PLAYING("You are not in the arena.", "Not in arena."),
|
||||
LEAVE_PLAYER_LEFT("You left the arena. Thanks for playing!", "Left arena.", Material.WOOD_DOOR),
|
||||
PLAYER_DIED("% died!", "% died!", Material.BONE),
|
||||
SPEC_PLAYER_SPECTATE("Enjoy the show!", "Enjoy the show!"),
|
||||
SPEC_NOT_RUNNING("This arena isn't running.", "Arena not running.", Material.REDSTONE_TORCH_OFF),
|
||||
SPEC_ARG_NEEDED("You must specify an arena. Type /ma arenas for a list.", "Arena name required."),
|
||||
SPEC_EMPTY_INV("Empty your inventory first!", "Empty your inventory.", Material.CHEST),
|
||||
SPEC_ALREADY_PLAYING("Can't spectate when in the arena!", "Already playing!"),
|
||||
NOT_READY_PLAYERS("Not ready: %"),
|
||||
FORCE_START_RUNNING("Arena has already started."),
|
||||
FORCE_START_NOT_READY("Can't force start, no players are ready."),
|
||||
@@ -47,34 +49,47 @@ public class MAMessages
|
||||
FORCE_END_ENDED("Forced arena end."),
|
||||
FORCE_END_IDLE("You weren't quick enough!"),
|
||||
REWARDS_GIVE("Here are all of your rewards!"),
|
||||
LOBBY_DROP_ITEM("No sharing allowed at this time!"),
|
||||
LOBBY_PLAYER_READY("You have been flagged as ready!"),
|
||||
LOBBY_PICK_CLASS("You must first pick a class!"),
|
||||
LOBBY_NOT_ENOUGH_PLAYERS("Not enough players to start. Need at least % players."),
|
||||
LOBBY_RIGHT_CLICK("Punch the sign. Don't right-click."),
|
||||
LOBBY_CLASS_PICKED("You have chosen % as your class!"),
|
||||
LOBBY_DROP_ITEM("No sharing allowed at this time!", "Can't drop items here."),
|
||||
LOBBY_PLAYER_READY("You have been flagged as ready!", "Flagged as ready!"),
|
||||
LOBBY_PICK_CLASS("You must first pick a class!", "Pick a class first!"),
|
||||
LOBBY_NOT_ENOUGH_PLAYERS("Not enough players to start. Need at least % players.", "Need more players."),
|
||||
LOBBY_RIGHT_CLICK("Punch the sign. Don't right-click.", "Punch the sign."),
|
||||
LOBBY_CLASS_PICKED("You have chosen % as your class!", "%"),
|
||||
LOBBY_CLASS_RANDOM("You will get a random class on arena start."),
|
||||
LOBBY_CLASS_PERMISSION("You don't have permission to use this class!"),
|
||||
LOBBY_CLASS_PERMISSION("You don't have permission to use this class!", "No permission!", Material.FENCE),
|
||||
WARP_TO_ARENA("Can't warp to the arena during battle!"),
|
||||
WARP_FROM_ARENA("Warping not allowed in the arena!"),
|
||||
WAVE_DEFAULT("Wave #%!"),
|
||||
WAVE_SPECIAL("Wave #%! [SPECIAL]"),
|
||||
WAVE_SWARM("Wave #%! [SWARM]"),
|
||||
WAVE_BOSS("Wave #%! [BOSS]"),
|
||||
WAVE_BOSS_ABILITY("Boss used ability: %!"),
|
||||
WAVE_BOSS_LOW_HEALTH("Boss is almost dead!"),
|
||||
WAVE_REWARD("You just earned a reward: %"),
|
||||
WAVE_DEFAULT("Wave #%!", "Wave #%!", Material.YELLOW_FLOWER),
|
||||
WAVE_SPECIAL("Wave #%! [SPECIAL]", "Wave #%! [SPECIAL]", Material.RED_ROSE),
|
||||
WAVE_SWARM("Wave #%! [SWARM]", "Wave #%! [SWARM]", Material.LONG_GRASS),
|
||||
WAVE_BOSS("Wave #%! [BOSS]", "Wave #%! [BOSS]", Material.FIRE),
|
||||
WAVE_BOSS_ABILITY("Boss used ability: %!", "Boss: %", Material.FIRE),
|
||||
WAVE_BOSS_LOW_HEALTH("Boss is almost dead!", "Boss almost dead!", Material.FIRE),
|
||||
WAVE_REWARD("You just earned a reward: %", "Reward: %"),
|
||||
MISC_LIST_PLAYERS("Live players: %"),
|
||||
MISC_LIST_ARENAS("Available arenas: %"),
|
||||
MISC_COMMAND_NOT_ALLOWED("You can't use that command in the arena!"),
|
||||
MISC_NO_ACCESS("You don't have access to this command."),
|
||||
MISC_NONE("<none>");
|
||||
|
||||
private String msg;
|
||||
private String msg, spoutMsg;
|
||||
private Material logo;
|
||||
|
||||
private Msg(String msg)
|
||||
{
|
||||
this.msg = msg;
|
||||
this(msg, null);
|
||||
}
|
||||
|
||||
private Msg(String msg, String spoutMsg)
|
||||
{
|
||||
this(msg, spoutMsg, null);
|
||||
}
|
||||
|
||||
private Msg(String msg, String spoutMsg, Material logo)
|
||||
{
|
||||
this.msg = msg;
|
||||
this.spoutMsg = spoutMsg;
|
||||
this.logo = logo;
|
||||
}
|
||||
|
||||
public String get()
|
||||
@@ -84,7 +99,38 @@ public class MAMessages
|
||||
|
||||
public String get(String s)
|
||||
{
|
||||
return msg.replace("%", s);
|
||||
return (s != null) ? msg.replace("%", s) : msg;
|
||||
}
|
||||
|
||||
public String getSpout(String s)
|
||||
{
|
||||
if (spoutMsg == null)
|
||||
return get(s);
|
||||
|
||||
return (s != null) ? spoutMsg.replace("%", s) : spoutMsg;
|
||||
}
|
||||
|
||||
public void set(String msg)
|
||||
{
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public void setSpout(String spoutMsg)
|
||||
{
|
||||
this.spoutMsg = spoutMsg;
|
||||
|
||||
if (spoutMsg == null)
|
||||
logo = null;
|
||||
}
|
||||
|
||||
public boolean hasSpoutMsg()
|
||||
{
|
||||
return spoutMsg != null;
|
||||
}
|
||||
|
||||
public Material getLogo()
|
||||
{
|
||||
return logo == null ? Material.SLIME_BALL : logo;
|
||||
}
|
||||
|
||||
public static String get(Msg m)
|
||||
@@ -97,11 +143,6 @@ public class MAMessages
|
||||
return m.msg.replace("%", s);
|
||||
}
|
||||
|
||||
public void set(String msg)
|
||||
{
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static void set(Msg m, String msg)
|
||||
{
|
||||
m.msg = msg;
|
||||
@@ -131,7 +172,11 @@ public class MAMessages
|
||||
|
||||
for (Msg m : Msg.values())
|
||||
{
|
||||
bw.write(m + "=" + m.msg);
|
||||
if (m.hasSpoutMsg())
|
||||
bw.write(m.name() + "=" + m.msg + "|" + m.spoutMsg);
|
||||
else
|
||||
bw.write(m.name() + "=" + m.msg);
|
||||
|
||||
bw.newLine();
|
||||
}
|
||||
|
||||
@@ -176,7 +221,7 @@ public class MAMessages
|
||||
private static void process(String s)
|
||||
{
|
||||
// If the line ends with =, just add a space
|
||||
if (s.endsWith("=")) s += " ";
|
||||
if (s.endsWith("=") || s.endsWith("|")) s += " ";
|
||||
|
||||
// Split the string by the equals-sign.
|
||||
String[] split = s.split("=");
|
||||
@@ -186,14 +231,19 @@ public class MAMessages
|
||||
return;
|
||||
}
|
||||
|
||||
// Split the value by the pipe-sign.
|
||||
String[] vals = split[1].split("\\|");
|
||||
|
||||
// For simplicity...
|
||||
String key = split[0];
|
||||
String val = split[1];
|
||||
String val = vals.length == 2 ? vals[0] : split[1];
|
||||
String spoutVal = vals.length == 2 ? vals[1] : null;
|
||||
|
||||
try
|
||||
{
|
||||
Msg msg = Msg.valueOf(key);
|
||||
msg.set(val);
|
||||
msg.setSpout(spoutVal);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -204,7 +204,7 @@ public class MASpawnThread implements Runnable
|
||||
}
|
||||
else
|
||||
{
|
||||
MAUtils.tellPlayer(p, Msg.WAVE_REWARD, MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount());
|
||||
MAUtils.tellPlayer(p, Msg.WAVE_REWARD, MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount(), reward.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.garbagemule.MobArena.MAMessages.Msg;
|
||||
import com.garbagemule.MobArena.util.EntityPosition;
|
||||
@@ -276,55 +278,6 @@ public class MAUtils
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the distribution coefficients from the config-file. If
|
||||
* no coefficients are found, defaults (10) are added.
|
||||
*/
|
||||
public static Map<String,Integer> getArenaDistributions(Configuration config, String arena, String wave)
|
||||
{
|
||||
String arenaPath = "arenas." + arena + ".waves." + wave;
|
||||
Map<String,Integer> result = new HashMap<String,Integer>();
|
||||
List<String> dists = (config.getKeys(arenaPath) != null) ? config.getKeys(arenaPath) : new LinkedList<String>();
|
||||
|
||||
String[] monsters = (wave.equals("default")) ? new String[]{"zombies", "skeletons", "spiders", "creepers", "wolves"}
|
||||
: new String[]{"powered-creepers", "zombie-pigmen", "slimes", "humans", "angry-wolves", "giants", "ghasts"};
|
||||
boolean update = false;
|
||||
for (String monster : monsters)
|
||||
{
|
||||
if (dists.contains(monster))
|
||||
continue;
|
||||
|
||||
//if (config.getInt(arenaPath + "." + m, -1) == -1)
|
||||
config.setProperty(arenaPath + "." + monster, (monster.equals("giants") || monster.equals("ghasts")) ? 0 : 10);
|
||||
update = true;
|
||||
}
|
||||
|
||||
if (update)
|
||||
{
|
||||
config.save();
|
||||
dists = config.getKeys(arenaPath);
|
||||
}
|
||||
|
||||
for (String monster : dists)
|
||||
{
|
||||
int value = config.getInt(arenaPath + "." + monster, -1);
|
||||
|
||||
// If no distribution value was found, set one.
|
||||
if (value == -1)
|
||||
{
|
||||
value = 10;
|
||||
if (monster.equals("giant") || monster.equals("ghast"))
|
||||
value = 0;
|
||||
|
||||
config.setProperty(arenaPath + "." + monster, value);
|
||||
}
|
||||
config.save();
|
||||
|
||||
result.put(monster, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<String> getAllowedCommands(Configuration config)
|
||||
{
|
||||
String commands = config.getString("global-settings.allowed-commands");
|
||||
@@ -1035,32 +988,84 @@ public class MAUtils
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////// */
|
||||
|
||||
/**
|
||||
* Sends a message to a player.
|
||||
*/
|
||||
public static boolean tellSpoutPlayer(Player p, Msg msg, String s, Material logo)
|
||||
{
|
||||
// Grab the SpoutPlayer.
|
||||
SpoutPlayer sp = MobArena.hasSpout ? SpoutManager.getPlayer(p) : null;
|
||||
|
||||
if (msg.hasSpoutMsg() && sp != null && sp.isSpoutCraftEnabled())
|
||||
{
|
||||
// Grab the message text.
|
||||
String text = msg.getSpout(s);
|
||||
|
||||
// If more than 26 characters, truncate.
|
||||
if (text.length() > 26)
|
||||
text = text.substring(0, 26);
|
||||
|
||||
// If the logo is null, use an iron sword.
|
||||
if (logo == null)
|
||||
logo = msg.getLogo();
|
||||
|
||||
// Send the notification.
|
||||
sp.sendNotification("MobArena", text, logo, (short) 0, 2000);
|
||||
return true;
|
||||
}
|
||||
else return tellPlayer(p, msg.get(s));
|
||||
}
|
||||
|
||||
public static boolean tellSpoutPlayer(Player p, Msg msg, Material logo)
|
||||
{
|
||||
return tellSpoutPlayer(p, msg, null, logo);
|
||||
}
|
||||
|
||||
public static boolean tellSpoutPlayer(Player p, Msg msg, String s)
|
||||
{
|
||||
return tellSpoutPlayer(p, msg, s, null);
|
||||
}
|
||||
|
||||
public static boolean tellSpoutPlayer(Player p, Msg msg)
|
||||
{
|
||||
return tellSpoutPlayer(p, msg, null, null);
|
||||
}
|
||||
|
||||
public static boolean tellPlayer(CommandSender p, String msg)
|
||||
{
|
||||
// If the input sender is null or the string is empty, return.
|
||||
if (p == null || msg.equals(" "))
|
||||
return false;
|
||||
|
||||
// Otherwise, send the message with the [MobArena] tag.
|
||||
p.sendMessage(ChatColor.GREEN + "[MobArena] " + ChatColor.WHITE + msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean tellPlayer(CommandSender p, Msg msg)
|
||||
public static boolean tellPlayer(CommandSender p, Msg msg, String s, boolean spout, Material logo)
|
||||
{
|
||||
return tellPlayer(p, msg.get());
|
||||
if (spout && p instanceof Player)
|
||||
return tellSpoutPlayer((Player) p, msg, s, logo);
|
||||
|
||||
return tellPlayer(p, msg.get(s));
|
||||
}
|
||||
|
||||
public static boolean tellPlayer(CommandSender p, Msg msg, String s, Material logo)
|
||||
{
|
||||
return tellPlayer(p, msg, s, MobArena.hasSpout, logo);
|
||||
}
|
||||
|
||||
public static boolean tellPlayer(CommandSender p, Msg msg, String s)
|
||||
{
|
||||
return tellPlayer(p, msg.get(s));
|
||||
return tellPlayer(p, msg, s, MobArena.hasSpout, null);
|
||||
}
|
||||
|
||||
public static boolean tellPlayer(CommandSender p, Msg msg)
|
||||
{
|
||||
return tellPlayer(p, msg, null, MobArena.hasSpout, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to all players in and around the arena.
|
||||
*/
|
||||
public static void tellAll(Arena arena, String msg, boolean notifyPlayers)
|
||||
public static void tellAll(Arena arena, Msg msg, String s, boolean notifyPlayers)
|
||||
{
|
||||
Set<Player> tmp = new HashSet<Player>();
|
||||
tmp.addAll(arena.arenaPlayers);
|
||||
@@ -1070,12 +1075,22 @@ public class MAUtils
|
||||
tmp.addAll(arena.specPlayers);
|
||||
if (notifyPlayers) tmp.addAll(arena.notifyPlayers);
|
||||
for (Player p : tmp)
|
||||
tellPlayer(p, msg);
|
||||
tellPlayer(p, msg, s);
|
||||
}
|
||||
|
||||
public static void tellAll(Arena arena, String msg)
|
||||
public static void tellAll(Arena arena, Msg msg, String s)
|
||||
{
|
||||
tellAll(arena, msg, false);
|
||||
tellAll(arena, msg, s, false);
|
||||
}
|
||||
|
||||
public static void tellAll(Arena arena, Msg msg, boolean notifyPlayers)
|
||||
{
|
||||
tellAll(arena, msg, null, notifyPlayers);
|
||||
}
|
||||
|
||||
public static void tellAll(Arena arena, Msg msg)
|
||||
{
|
||||
tellAll(arena, msg, null, false);
|
||||
}
|
||||
|
||||
public static Player getClosestPlayer(Entity e, Arena arena)
|
||||
|
||||
@@ -46,6 +46,7 @@ public class MobArena extends JavaPlugin// implements ArenaPlugin
|
||||
public static final double MIN_PLAYER_DISTANCE = 15.0;
|
||||
public static final double MIN_PLAYER_DISTANCE_SQUARED = MIN_PLAYER_DISTANCE * MIN_PLAYER_DISTANCE;
|
||||
public static final int ECONOMY_MONEY_ID = -29;
|
||||
public static boolean hasSpout;
|
||||
public static Random random = new Random();
|
||||
|
||||
public void onEnable()
|
||||
@@ -67,6 +68,7 @@ public class MobArena extends JavaPlugin// implements ArenaPlugin
|
||||
// Set up permissions and economy
|
||||
setupPermissions();
|
||||
setupRegister();
|
||||
setupSpout();
|
||||
|
||||
// Set up the ArenaMaster and the announcements
|
||||
am = new ArenaMaster(this);
|
||||
@@ -82,6 +84,9 @@ public class MobArena extends JavaPlugin// implements ArenaPlugin
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
// Disable Spout features.
|
||||
hasSpout = false;
|
||||
|
||||
// Force all arenas to end.
|
||||
if (am == null) return;
|
||||
for (Arena arena : am.arenas)
|
||||
@@ -177,6 +182,15 @@ public class MobArena extends JavaPlugin// implements ArenaPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private void setupSpout()
|
||||
{
|
||||
if (hasSpout)
|
||||
return;
|
||||
|
||||
Plugin spoutPlugin = this.getServer().getPluginManager().getPlugin("Spout");
|
||||
hasSpout = spoutPlugin != null;
|
||||
}
|
||||
|
||||
public Configuration getConfig() { return config; }
|
||||
public ArenaMaster getAM() { return am; } // More convenient.
|
||||
public ArenaMaster getArenaMaster() { return am; }
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.garbagemule.MobArena.Arena;
|
||||
import com.garbagemule.MobArena.MAUtils;
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
import com.garbagemule.MobArena.waves.*;
|
||||
import com.garbagemule.MobArena.waves.Wave.*;
|
||||
@@ -27,9 +26,21 @@ public class WaveUtils
|
||||
//long start = System.nanoTime();
|
||||
List<Location> result = new ArrayList<Location>();
|
||||
|
||||
double x1 = Double.NaN, y1 = Double.NaN, z1 = Double.NaN, // Bottom
|
||||
x2 = Double.NaN, y2 = Double.NaN, z2 = Double.NaN; // Top
|
||||
//double x1 = Double.NaN, y1 = Double.NaN, z1 = Double.NaN, // Bottom
|
||||
// x2 = Double.NaN, y2 = Double.NaN, z2 = Double.NaN; // Top
|
||||
|
||||
for (Location l : arena.getSpawnpoints())
|
||||
{
|
||||
for (Player p : players)
|
||||
{
|
||||
if (l.distanceSquared(p.getLocation()) >= MobArena.MIN_PLAYER_DISTANCE_SQUARED)
|
||||
continue;
|
||||
|
||||
result.add(l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
// Get the region that the players span.
|
||||
for (Player p : players)
|
||||
{
|
||||
@@ -65,7 +76,7 @@ public class WaveUtils
|
||||
for (Location s : arena.getAllSpawnpoints())
|
||||
if (MAUtils.inRegion(s, x1, y1, z1, x2, y2, z2))
|
||||
result.add(s);
|
||||
|
||||
*/
|
||||
// If no players are in range, just use all the spawnpoints.
|
||||
if (result.isEmpty())
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ public class BossWave extends AbstractWave
|
||||
public void spawn(int wave)
|
||||
{
|
||||
// Announce spawning
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_BOSS.get(""+wave));
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_BOSS, ""+wave);
|
||||
|
||||
// Spawn the boss and set the arena
|
||||
bossCreature = boss.spawn(getArena(), getWorld(), getArena().getBossSpawnpoint());
|
||||
@@ -106,7 +106,7 @@ public class BossWave extends AbstractWave
|
||||
|
||||
// Announce it
|
||||
if (abilityAnnounce)
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_BOSS_ABILITY.get(ability.toString()));
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_BOSS_ABILITY, ability.toString());
|
||||
|
||||
// Activate!
|
||||
ability.run(getArena(), bossCreature);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DefaultWave extends NormalWave
|
||||
public void spawn(int wave)
|
||||
{
|
||||
// Announce spawning
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_DEFAULT.get(""+wave));
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_DEFAULT, ""+wave);
|
||||
|
||||
// Get the valid spawnpoints, and initialize counter
|
||||
List<Location> validSpawnpoints = WaveUtils.getValidSpawnpoints(getArena(), getArena().getLivingPlayers());
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SpecialWave extends NormalWave
|
||||
public void spawn(int wave)
|
||||
{
|
||||
// Announce spawning
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_SPECIAL.get(""+wave));
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_SPECIAL, ""+wave);
|
||||
|
||||
// Get the valid spawnpoints, and initialize counter
|
||||
List<Location> validSpawnpoints = WaveUtils.getValidSpawnpoints(getArena(), getArena().getLivingPlayers());
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SwarmWave extends AbstractWave
|
||||
public void spawn(int wave)
|
||||
{
|
||||
// Announce spawning
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_SWARM.get(""+wave));
|
||||
MAUtils.tellAll(getArena(), Msg.WAVE_SWARM, ""+wave);
|
||||
|
||||
// Get the valid spawnpoints, and initialize counter
|
||||
List<Location> validSpawnpoints = WaveUtils.getValidSpawnpoints(getArena(), getArena().getLivingPlayers());
|
||||
|
||||
Reference in New Issue
Block a user