From d70eb388486a88514b4bdf4cc0d53e83e59375b1 Mon Sep 17 00:00:00 2001 From: Gibstick Date: Thu, 18 Jul 2013 20:56:53 -0400 Subject: [PATCH] added /ds other command --- dist/DiscoSheep.jar | Bin 26851 -> 29945 bytes .../bukkit/discosheep/DiscoParty.java | 76 ++++++++-- .../bukkit/discosheep/DiscoSheep.java | 3 +- .../discosheep/DiscoSheepCommandExecutor.java | 138 ++++++++++++------ src/plugin.yml | 7 +- 5 files changed, 166 insertions(+), 58 deletions(-) diff --git a/dist/DiscoSheep.jar b/dist/DiscoSheep.jar index 158e26c07fe8ad9113a5bf63bce06d421be51ba6..21a6466f8448af12a0af1b2402fa5fae13b672fe 100644 GIT binary patch delta 11574 zcmZ`<3w%_?)j#L%X7AnIn|C&3^MF7C37dpqfItF-@CXpd3j)NT5&~I5OhRH3P;7NY zv8b(z+}4V=K9HK)YO9F^QVPCWZEe;1sJ7L%+S-2AYHMw6)gpZVGk3FDsD>YB=FXja z-sjBBnf>Dn{PEiy+pyZ<^bi?D>4P8K5}WVv4}S3QJTE)&Xf5Yl)pm1%YVY7uX@_6t z*WGdGEXmq&oR<2X0n%n1S#1tbYb7LX#qr*o=@Joc;! zGLojV-$QZsNV<$<2*?zWC19d}NdmInJej9>Ifrv~o+=~LJezYJygi&2`G`-vs{&A|G6sNlmEMJSy7q{&lWI8aF^;lS7y%>TxEi*+{^QM zfq;cVq(Z1`I!DqxFq z5oYPU)k7P>EVpscOFMX*Jhtn+T|Vyc(7*U%8R?W>mw;{$@8BNk^$NJe%YEE0V89!~ z_d7+zVgb9vNSEq-nPA#2;Bo<95b#9-SLl4DhXyz#O1esVdt~@(4`0K3h2v|z{3YHe zW7o;s>*etVnfzq|UlDMlfSYu_*-h7Q#eRXe2sj|X67W?4UlVYvfUgUV=xJke^|iKj?CfWX>E9j<_F5V1a)+;vKgIFx z{@_4ESL^OzAJfwO8f$Sy8qc@(v`n!Y<`|P>8wXmqcGkA`u4~=W6=d>a_OhLQtpgoB zJD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;ht<`Pq*VRx8uMd?-#P!d$`*>#g!uB94Wl}!;jM& z@T&Xf2=~p4&l;!^BUQLjA=fy5rANEu7$wJ&j31{kzWw=x_U9Az(Ikb*3R4uO5?np` z{Xwg=)7&wKQ6}Age#PQAe8Rxtj?oPqGw)b-_IkQ7I&wh{I0D73Bfji!K z(nDAq%4k@?7&?qGbvRSB5llTtGMO9A2sDQAXDpM+3G6kIf0KA)J2}KvJCz}EIzvJs zFPCQU%Ym89abjPqe}K*f;@oLvLCf_72~*BaO0dgEr?V0?>Pjqh=rCjz&7VzASbgk7G2xWh9D zcX>u)kLLp1B zM6_oHul{NnToXJ~nXT7wdQvSx^S%IGW5-Bzgf)vb+OU(-HJPnD9zeG+Vb8VL%2T;X}YI+iZ^D~bTJb7!w1T( zKcR5$Uo%vHL*blUGur*lMEBakZdq14+%0dbo#d7$YnT4=Cls^lrgzs7+RsejuGRk8 zyYbyzfZq)Ea!%F7yIs#YLbUh9-i_lXwRYus!kJbd?+&`SKHYl>w;%W0#ohI(Put&)$vQ%7N9@YnQKB)qnlU>RHnx^tjI%2%w1bx}j2Q{|A1bF!=xg diff --git a/src/gibstick/bukkit/discosheep/DiscoParty.java b/src/gibstick/bukkit/discosheep/DiscoParty.java index 95342c9..470c2e6 100644 --- a/src/gibstick/bukkit/discosheep/DiscoParty.java +++ b/src/gibstick/bukkit/discosheep/DiscoParty.java @@ -26,7 +26,7 @@ public class DiscoParty { private DiscoSheep ds; private Player player; private ArrayList sheepList = new ArrayList(); - private int duration, frequency = 20; + private int duration, period, radius, sheep; static int defaultDuration = 300; // ticks for entire party static int defaultPeriod = 10; // ticks per state change static int defaultRadius = 5; @@ -64,6 +64,56 @@ public class DiscoParty { return sheepList; } + public DiscoParty setPlayer(Player player) { + if (player != null) { + this.player = player; + return this; + } else { + throw new NullPointerException(); + } + } + + public DiscoParty setDuration(int duration) throws IllegalArgumentException { + if (duration < DiscoParty.maxDuration) { + this.duration = duration; + return this; + } else { + throw new IllegalArgumentException(); + } + } + + public DiscoParty setPeriod(int period) throws IllegalArgumentException { + if (period >= DiscoParty.minPeriod || period <= DiscoParty.maxPeriod) { + this.period = period; + return this; + } else { + throw new IllegalArgumentException(); + } + } + + public DiscoParty setRadius(int radius) throws IllegalArgumentException { + if (radius < DiscoParty.maxRadius) { + this.radius = radius; + return this; + } else { + throw new IllegalArgumentException(); + } + } + + public DiscoParty setSheep(int sheep) throws IllegalArgumentException { + if (sheep < DiscoParty.maxSheep) { + this.sheep = sheep; + return this; + } else { + throw new IllegalArgumentException(); + } + } + + public DiscoParty setDoFireworks(boolean doFireworks) { + this.doFireworks = doFireworks; + return this; + } + void spawnSheep(World world, Location loc) { Sheep newSheep = (Sheep) world.spawnEntity(loc, EntityType.SHEEP); newSheep.setColor(discoColours[(int) (Math.random() * (discoColours.length - 1))]); @@ -97,9 +147,9 @@ public class DiscoParty { // Mark all sheep in the sheep array for removal, then clear the array void removeAllSheep() { - for (Sheep sheep : getSheep()) { - sheep.setHealth(0); - sheep.remove(); + for (Sheep sheeple : getSheep()) { + sheeple.setHealth(0); + sheeple.remove(); } getSheep().clear(); } @@ -175,16 +225,16 @@ public class DiscoParty { void updateAllSheep() { int i = 0; - for (Sheep sheep : getSheep()) { - randomizeSheepColour(sheep); + for (Sheep sheeple : getSheep()) { + randomizeSheepColour(sheeple); if (doFireworks && state % 8 == 0) { - spawnRandomFireworkAtSheep(sheep); + spawnRandomFireworkAtSheep(sheeple); } if (doJump) { if (state % 2 == 0) { if (Math.random() < 0.5) { - jumpSheep(sheep); + jumpSheep(sheeple); } } } @@ -238,7 +288,7 @@ public class DiscoParty { if (duration > 0) { updateAllSheep(); playSounds(); - duration -= frequency; + duration -= period; this.scheduleUpdate(); this.state++; } else { @@ -248,16 +298,16 @@ public class DiscoParty { void scheduleUpdate() { updater = new DiscoUpdater(this); - updater.runTaskLater(ds, this.frequency); + updater.runTaskLater(ds, this.period); } - void startDisco(int duration, int sheepAmount, int radius, int frequency, boolean fireworks) { + void startDisco(int duration, int sheepAmount, int radius, int period, boolean fireworks) { if (this.duration > 0) { stopDisco(); } - this.doFireworks = fireworks; this.spawnSheep(sheepAmount, radius); - this.frequency = frequency; + this.doFireworks = fireworks; + this.period = period; this.duration = duration; this.scheduleUpdate(); ds.getPartyMap().put(this.player.getName(), this); diff --git a/src/gibstick/bukkit/discosheep/DiscoSheep.java b/src/gibstick/bukkit/discosheep/DiscoSheep.java index 3f79d5a..7ea8381 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheep.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheep.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.bukkit.configuration.Configuration; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -51,7 +50,7 @@ public final class DiscoSheep extends JavaPlugin { DiscoParty.defaultDuration = toTicks(getConfig().getInt("default.duration")); DiscoParty.defaultPeriod = getConfig().getInt("default.period-ticks"); } - + void reloadConfigFromDisk() { reloadConfig(); loadConfigFromDisk(); diff --git a/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java b/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java index d63622c..873e0b2 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java @@ -1,8 +1,8 @@ package gibstick.bukkit.discosheep; +import java.util.Arrays; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.CommandExecutor; @@ -20,13 +20,16 @@ public class DiscoSheepCommandExecutor implements CommandExecutor { private static final String PERMISSION_FIREWORKS = "discosheep.fireworks"; private static final String PERMISSION_STOP = "discosheep.stop"; private static final String PERMISSION_RELOAD = "discosheep.reload"; + private static final String PERMISSION_OTHER = "discosheep.partyother"; + //private static final String DELIM = "[ ]+"; private boolean senderHasPerm(CommandSender sender, String permission) { return sender.hasPermission(permission); } - private void noPermsMessage(CommandSender sender, String permission) { + private boolean noPermsMessage(CommandSender sender, String permission) { sender.sendMessage(ChatColor.RED + "You do not have the permission node " + ChatColor.GRAY + permission); + return false; } private boolean parseNextArg(String[] args, int i, String compare) { @@ -50,8 +53,92 @@ public class DiscoSheepCommandExecutor implements CommandExecutor { return -1.0d; } + // extract a list of players from a list of arguments + private String[] parsePlayerList(String[] args, int i) { + int j = i; + while (j < args.length && !args[i].startsWith("-")) { + ++j; + } + return Arrays.copyOfRange(args, i, j); + } + + /*-- Actual commands begin here --*/ + private boolean helpCommand(CommandSender sender) { + sender.sendMessage(ChatColor.YELLOW + "DiscoSheep Help\n" + + ChatColor.GRAY + " Subcommands\n" + ChatColor.WHITE + + "me: start a party for yourself\n" + + "all: start a party for all players on the server\n" + + "stop: stop all parties (takes no arguments)\n" + + "other : start a party for the space-delimited list of players\n" + + ChatColor.GRAY + " Arguments\n" + ChatColor.WHITE + + "-n : set the number of sheep per player that spawn\n" + + "-t : set the party duration in seconds\n" + + "-p : set the number of ticks between each disco beat\n" + + "-r : set radius of the area in which sheep can spawn\n" + + "-fw: enables fireworks"); + return true; + } + + private boolean reloadCommand(CommandSender sender) { + if (senderHasPerm(sender, PERMISSION_RELOAD)) { + parent.reloadConfigFromDisk(); + sender.sendMessage(ChatColor.GREEN + "DiscoSheep config reloaded from disk"); + return true; + } else { + return noPermsMessage(sender, PERMISSION_RELOAD); + } + } + + private boolean partyCommand(CommandSender sender, int _duration, int _sheepNumber, int _radius, int _period, boolean _fireworks) { + if (senderHasPerm(sender, PERMISSION_PARTY)) { + parent.startParty((Player) sender, _duration, _sheepNumber, _radius, _period, _fireworks); + return true; + } else { + return noPermsMessage(sender, PERMISSION_PARTY); + } + } + + private boolean partyAllCommand(CommandSender sender, int _duration, int _sheepNumber, int _radius, int _period, boolean _fireworks) { + if (senderHasPerm(sender, PERMISSION_ALL)) { + for (Player p : Bukkit.getServer().getOnlinePlayers()) { + parent.startParty(p, _duration, _sheepNumber, _radius, _period, _fireworks); + p.sendMessage(ChatColor.RED + "LET'S DISCO!"); + } + return true; + } else { + return noPermsMessage(sender, PERMISSION_ALL); + } + } + + private boolean stopCommand(CommandSender sender) { + if (senderHasPerm(sender, PERMISSION_STOP)) { + parent.stopAllParties(); + return true; + } else { + return noPermsMessage(sender, PERMISSION_STOP); + } + } + + private boolean partySelectCommand(String[] players, CommandSender sender, int _duration, int _sheepNumber, int _radius, int _period, boolean _fireworks) { + if (senderHasPerm(sender, PERMISSION_OTHER)) { + Player p; + for (String playerName : players) { + p = Bukkit.getServer().getPlayer(playerName); + if (p != null) { + parent.startParty(p, _duration, _sheepNumber, _radius, _period, _fireworks); + } else { + sender.sendMessage("Invalid player: " + playerName); + } + } + return true; + } else { + return noPermsMessage(sender, PERMISSION_OTHER); + } + } + @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + Player player = null; boolean isPlayer = false; boolean fireworks = false; @@ -112,50 +199,17 @@ public class DiscoSheepCommandExecutor implements CommandExecutor { if (args.length > 0) { if (args[0].equalsIgnoreCase("all")) { - if (senderHasPerm(sender, PERMISSION_ALL)) { - for (Player p : Bukkit.getServer().getOnlinePlayers()) { - parent.startParty(p, duration, sheepNumber, radius, period, fireworks); - p.sendMessage(ChatColor.RED + "LET'S DISCO!"); - } - } else { - noPermsMessage(sender, PERMISSION_ALL); - } - return true; + return partyAllCommand(player, duration, sheepNumber, radius, period, fireworks); } else if (args[0].equalsIgnoreCase("stop")) { - if (senderHasPerm(sender, PERMISSION_STOP)) { - parent.stopAllParties(); - } else { - noPermsMessage(sender, PERMISSION_STOP); - } - return true; + return stopCommand(sender); } else if (args[0].equalsIgnoreCase("me") && isPlayer) { - if (senderHasPerm(sender, PERMISSION_PARTY)) { - parent.startParty(player, duration, sheepNumber, radius, period, fireworks); - return true; - } else { - noPermsMessage(sender, PERMISSION_PARTY); - } + return partyCommand(player, duration, sheepNumber, radius, period, fireworks); + } else if (args[0].equalsIgnoreCase("other")) { + return partySelectCommand(parsePlayerList(args, 1), sender, duration, sheepNumber, radius, period, fireworks); } else if (args[0].equalsIgnoreCase("help")) { - sender.sendMessage(ChatColor.YELLOW + "DiscoSheep Help\n" - + ChatColor.GRAY + " Subcommands\n" + ChatColor.WHITE - + "me: start a party for yourself\n" - + "all: start a party for all players on the server\n" - + "stop: stop all parties (takes no arguments)\n" - + ChatColor.GRAY + " Arguments\n" + ChatColor.WHITE - + "-n : set the number of sheep per player that spawn\n" - + "-t : set the party duration in seconds\n" - + "-p : set the number of ticks between each disco beat\n" - + "-r : set radius of the area in which sheep can spawn\n" - + "-fw: enables fireworks"); - return true; + return helpCommand(sender); } else if (args[0].equalsIgnoreCase("reload")) { - if (senderHasPerm(sender, PERMISSION_RELOAD)) { - parent.reloadConfigFromDisk(); - sender.sendMessage(ChatColor.GREEN + "DiscoSheep config reloaded from disk"); - return true; - } else { - noPermsMessage(sender, PERMISSION_RELOAD); - } + return reloadCommand(sender); } else { sender.sendMessage(ChatColor.RED + "Invalid argument."); return false; diff --git a/src/plugin.yml b/src/plugin.yml index a79c424..81b1e23 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -32,4 +32,9 @@ permissions: default: op discosheep.reload: description: Allows a player to reload settings from config.yml - default: op \ No newline at end of file + default: op + discosheep.other: + description: Allows a player to call parties for other people, including themselves. + default: op + children: + discosheep.party: true \ No newline at end of file