Permalink
Browse files

Refactoring can be such a pain sometimes

  • Loading branch information...
1 parent 141d080 commit 81a1e5d58983e6fddf78c76eb679af8a6b415f59 @GuntherDW committed Jan 10, 2012
Showing with 875 additions and 596 deletions.
  1. +2 −1 plugin.yml
  2. +5 −5 src/com/guntherdw/bukkit/tweakcraft/Chat/AntiSpam.java
  3. +38 −30 src/com/guntherdw/bukkit/tweakcraft/Chat/ChatHandler.java
  4. +19 −10 src/com/guntherdw/bukkit/tweakcraft/Chat/ChatMode.java
  5. +2 −2 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/AdminChat.java
  6. +0 −1 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/GroupChat.java
  7. +5 −7 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/LocalChat.java
  8. +4 −1 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/RegionChat.java
  9. +134 −0 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/TCUtilsChat.java
  10. +5 −4 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/WorldChat.java
  11. +1 −2 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/ZoneChat.java
  12. +87 −26 src/com/guntherdw/bukkit/tweakcraft/Commands/CommandHandler.java
  13. +16 −10 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/AdminCommands.java
  14. +29 −15 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/ChatCommands.java
  15. +7 −1 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/DebugCommands.java
  16. +166 −148 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/EssentialsCommands.java
  17. +23 −17 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/GeneralCommands.java
  18. +144 −134 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/TeleportationCommands.java
  19. +11 −4 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/WeatherCommands.java
  20. +2 −0 src/com/guntherdw/bukkit/tweakcraft/Configuration/ConfigurationHandler.java
  21. +22 −9 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftPlayerListener.java
  22. +5 −5 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftWorldListener.java
  23. +6 −3 src/com/guntherdw/bukkit/tweakcraft/Packages/Argument.java
  24. +1 −1 src/com/guntherdw/bukkit/tweakcraft/Packages/Ban.java
  25. +7 −5 src/com/guntherdw/bukkit/tweakcraft/Packages/CraftIRCAdminEndPoint.java
  26. +11 −10 src/com/guntherdw/bukkit/tweakcraft/Packages/LocalPlayer.java
  27. +2 −2 src/com/guntherdw/bukkit/tweakcraft/Packages/LockdownLocation.java
  28. +86 −139 src/com/guntherdw/bukkit/tweakcraft/TweakcraftUtils.java
  29. +24 −4 src/com/guntherdw/bukkit/tweakcraft/Worlds/TweakWorld.java
  30. +5 −0 src/com/guntherdw/bukkit/tweakcraft/Worlds/WorldManager.java
  31. +6 −0 src/com/guntherdw/bukkit/tweakcraft/Worlds/iWorld.java
View
3 plugin.yml
@@ -1,5 +1,7 @@
name: TweakcraftUtils
main: com.guntherdw.bukkit.tweakcraft.TweakcraftUtils
+softdepend: [ 'CraftIRC' ]
+#depend: [ CraftIRC ]
version: 2.8.0-git
authors:
- GuntherDW
@@ -9,7 +11,6 @@ authors:
website: https://github.com/GuntherDW/TweakcraftUtils
description: A general usage plugin primarily aimed at Tweakcraft, but can be used by any server
database: true
-softdepend: [ 'CraftIRC' ]
commands:
tweakcraft:
description: General tweakcraftutils command
View
10 src/com/guntherdw/bukkit/tweakcraft/Chat/AntiSpam.java
@@ -45,21 +45,21 @@ public AntiSpam(ChatHandler instance, ConfigurationHandler config) {
}
public int checkSpam(Player player, String message) {
- if(!ch.getTCUtilsInstance().check(player, "spam")) {
+ if (!ch.getTCUtilsInstance().check(player, "spam")) {
LocalPlayer lp = ch.getTCUtilsInstance().wrapPlayer(player);
-
+
String playername = player.getName().toLowerCase();
long currenttime = System.currentTimeMillis();
int oldspamcounter = lp.getSpamcounter();
- if(lp.getLastmessagetime() > currenttime-watchtime) {
- lp.setSpamcounter(oldspamcounter+1);
+ if (lp.getLastmessagetime() > currenttime - watchtime) {
+ lp.setSpamcounter(oldspamcounter + 1);
} else {
lp.setSpamcounter(0);
}
lp.setLastmessagetime(currenttime);
-
+
return lp.getSpamcounter();
}
return 0;
View
68 src/com/guntherdw/bukkit/tweakcraft/Chat/ChatHandler.java
@@ -36,20 +36,28 @@
private Map<String, ChatMode> chatmodes = new HashMap<String, ChatMode>();
private Map<String, String> playerchatmode = new HashMap<String, String>();
private Map<String, Long> mutedPlayers = new HashMap<String, Long>();
-
public ChatHandler(TweakcraftUtils instance) {
plugin = instance;
chatmodes.clear();
- chatmodes.put("admin", new AdminChat(this)); /* This one has a higher priority! */
- chatmodes.put("local", new LocalChat(this));
- chatmodes.put("region", new RegionChat(this));
- chatmodes.put("zones", new ZoneChat(this));
- chatmodes.put("world", new WorldChat(this));
+ this.registerChatMode("admin", new AdminChat(this)); /* This one has a higher priority! */
+ this.registerChatMode("local", new LocalChat(this));
+ this.registerChatMode("region", new RegionChat(this));
+ this.registerChatMode("zones", new ZoneChat(this));
+ this.registerChatMode("world", new WorldChat(this));
+
+ this.registerChatMode("tcutils", new TCUtilsChat(this)); /* IRC extra stuff */
+ }
+
+ public boolean registerChatMode(String chatModeLabel, ChatMode chatMode) {
+ if(chatmodes.containsValue(chatMode)) return false;
+
+ chatmodes.put(chatModeLabel, chatMode);
+ return true;
}
public void enableAntiSpam() {
- if(plugin.getConfigHandler().enableSpamControl && antispam==null)
+ if (plugin.getConfigHandler().enableSpamControl && antispam == null)
this.antispam = new AntiSpam(this, plugin.getConfigHandler());
}
@@ -74,8 +82,8 @@ public TweakcraftUtils getTCUtilsInstance() {
public List<String> listChatModes() {
List<String> l = new ArrayList<String>();
- for(String s : chatmodes.keySet()) {
- if((chatmodes.get(s)).isEnabled())
+ for (String s : chatmodes.keySet()) {
+ if ((chatmodes.get(s)).isEnabled() && !((chatmodes.get(s)).isHidden()))
l.add(s);
}
return l;
@@ -123,9 +131,9 @@ public void setPlayerchatmode(String player, String mode) throws ChatModeExcepti
}
playerchatmode.put(player, mode);
}
- if(plugin.getConfigHandler().enableCUI) {
+ if (plugin.getConfigHandler().enableCUI) {
Player p = plugin.getServer().getPlayer(player);
- if(p!=null)
+ if (p != null)
plugin.sendCUIChatMode(p);
}
}
@@ -144,38 +152,38 @@ public AntiSpam getAntiSpam() {
public void addMute(String player, Long duration) {
Long toTime = null;
-
- if(player!=null) player = player.toLowerCase(); /* Sanity checks */
+
+ if (player != null) player = player.toLowerCase(); /* Sanity checks */
else return;
- if(duration != null) {
- toTime = Calendar.getInstance().getTime().getTime();
- toTime += duration*1000;
+ if (duration != null) {
+ toTime = Calendar.getInstance().getTime().getTime();
+ toTime += duration * 1000;
}
- if(plugin.getConfigHandler().enablePersistence) {
+ if (plugin.getConfigHandler().enablePersistence) {
PlayerOptions po = plugin.getDatabase().find(PlayerOptions.class).where().ieq("name", player).ieq("optionname", "mute").findUnique();
- if(po==null) {
+ if (po == null) {
po = new PlayerOptions();
po.setName(player);
po.setOptionname("mute");
}
-
- po.setOptionvalue(toTime==null?null:toTime.toString());
+
+ po.setOptionvalue(toTime == null ? null : toTime.toString());
plugin.getDatabase().save(po);
}
mutedPlayers.put(player, toTime);
}
public boolean canTalk(String player) {
- if(mutedPlayers.containsKey(player.toLowerCase())) {
+ if (mutedPlayers.containsKey(player.toLowerCase())) {
Long checktime = Calendar.getInstance().getTime().getTime();
Long muteTime = mutedPlayers.get(player.toLowerCase());
- if(muteTime == null || checktime < muteTime) {
+ if (muteTime == null || checktime < muteTime) {
return false;
}
- if(checktime > muteTime) {
- if(plugin.getConfigHandler().enableDebug)
- plugin.getLogger().info("[TweakcraftUtils] Mutes: auto-unmuting "+player+", his mutetime was over!");
+ if (checktime > muteTime) {
+ if (plugin.getConfigHandler().enableDebug)
+ plugin.getLogger().info("[TweakcraftUtils] Mutes: auto-unmuting " + player + ", his mutetime was over!");
removeMute(player);
}
}
@@ -186,9 +194,9 @@ public void removeMute(String player) {
if (mutedPlayers.containsKey(player)) {
mutedPlayers.remove(player);
}
- if(plugin.getConfigHandler().enablePersistence) {
+ if (plugin.getConfigHandler().enablePersistence) {
PlayerOptions po = plugin.getDatabase().find(PlayerOptions.class).where().ieq("name", player).ieq("optionname", "mute").findUnique();
- if(po!=null)
+ if (po != null)
plugin.getDatabase().delete(po);
}
}
@@ -198,11 +206,11 @@ public void removeMute(String player) {
}
public Long getRemaining(String player) {
- if(canTalk(player)) return null;
+ if (canTalk(player)) return null;
Long remain = mutedPlayers.get(player);
- if(remain == null) return null;
+ if (remain == null) return null;
Long checktime = Calendar.getInstance().getTime().getTime();
- Double dres = Math.floor((remain - checktime)/1000);
+ Double dres = Math.floor((remain - checktime) / 1000);
return dres.longValue();
}
View
29 src/com/guntherdw/bukkit/tweakcraft/Chat/ChatMode.java
@@ -50,8 +50,8 @@ public ChatMode(ChatHandler instance) {
*/
public boolean sendMessage(CommandSender sender, String message) {
- String playerMessage = String.format(getChatFormatString(), sender instanceof Player?((Player)sender).getDisplayName(): ChatColor.LIGHT_PURPLE+"CONSOLE"+ChatColor.WHITE, message);
- for(Player player : getRecipients(sender)) {
+ String playerMessage = String.format(getChatFormatString(), sender instanceof Player ? ((Player) sender).getDisplayName() : ChatColor.LIGHT_PURPLE + "CONSOLE" + ChatColor.WHITE, message);
+ for (Player player : getRecipients(sender)) {
player.sendMessage(playerMessage);
}
@@ -139,22 +139,31 @@ public boolean isEnabled() {
public abstract String getPrefix();
/**
- *
+ * Should this ChatMode show up in /chatmode list?
+ *
+ * @return boolean true if it should show up in /chatmode list
+ */
+ public boolean isHidden() {
+ return false;
+ }
+
+ /**
+ *
*/
public String getLoggingFormatString() {
- String name = this.chatModeName==null?getClass().getSimpleName():chatModeName;
- return name+": <%1$s> %2$s";
+ String name = this.chatModeName == null ? getClass().getSimpleName() : chatModeName;
+ return name + ": <%1$s> %2$s";
}
-
+
public String getChatFormatString() {
String prefix = getPrefix();
- return (prefix!=null?prefix+": ":"")+ "[%1$s] %2$s";
+ return (prefix != null ? prefix + ": " : "") + "[%1$s] %2$s";
}
-
+
public void logChat(CommandSender sender, String message) {
String logFormat = getLoggingFormatString();
- if(logFormat!=null) {
- String logMessage = String.format(logFormat, sender instanceof Player?((Player)sender).getName(): "CONSOLE", message);
+ if (logFormat != null) {
+ String logMessage = String.format(logFormat, sender instanceof Player ? ((Player) sender).getName() : "CONSOLE", message);
logger.info(logMessage);
}
}
View
4 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/AdminChat.java
@@ -69,8 +69,8 @@ public boolean sendMessage(CommandSender sender, String message) {
String targetmsg = plugin.getConfigHandler().AIRCMessageFormat;
targetmsg = targetmsg.replace("%name%", cleanname).
- replace("%message%", message).
- replace("%dispname%", ChatColor.stripColor(sendername));
+ replace("%message%", message).
+ replace("%dispname%", ChatColor.stripColor(sendername));
targetmsg = targetmsg.replace("%clearcolors%", Character.toString((char) 3));
RelayedMessage rmsg = plugin.getCraftIRC().newMsgToTag(plugin.getAdminEndPoint(), plugin.getConfigHandler().AIRCtag, "generic");
View
1 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/GroupChat.java
@@ -23,7 +23,6 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import java.util.List;
import java.util.Set;
/**
View
12 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/LocalChat.java
@@ -26,9 +26,7 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
/**
@@ -46,12 +44,12 @@ public LocalChat(ChatHandler instance) {
@Override
public boolean sendMessage(CommandSender sender, String message) {
-
- if(!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.YELLOW+"What were you trying to do?");
+
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.YELLOW + "What were you trying to do?");
return true;
}
-
+
super.sendMessage(sender, message);
if (getRecipients(sender).size() < 2)
sender.sendMessage(ChatColor.GOLD + "No one can hear you!");
@@ -107,6 +105,6 @@ public String getColor() {
}
public String getPrefix() {
- return this.getColor() + "L"+ChatColor.WHITE;
+ return this.getColor() + "L" + ChatColor.WHITE;
}
}
View
5 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/RegionChat.java
@@ -31,7 +31,10 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
/**
* @author GuntherDW
View
134 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/TCUtilsChat.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2012 GuntherDW
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package com.guntherdw.bukkit.tweakcraft.Chat.Modes;
+
+import com.ensifera.animosity.craftirc.CraftIRC;
+import com.ensifera.animosity.craftirc.EndPoint;
+import com.ensifera.animosity.craftirc.RelayedMessage;
+import com.guntherdw.bukkit.tweakcraft.Chat.ChatHandler;
+import com.guntherdw.bukkit.tweakcraft.Chat.ChatMode;
+import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author GuntherDW
+ */
+public class TCUtilsChat extends ChatMode {
+
+ private TweakcraftUtils plugin;
+ // private EndPoint tcendpoint = null;
+ private CraftIRC circ = null;
+ private Set<Player> emptyHashSet = new HashSet<Player>();
+
+ public TCUtilsChat(ChatHandler instance) {
+ super(instance);
+ this.plugin = instance.getTCUtilsInstance();
+ // this.tcendpoint = plugin.getEndPoint();
+ if (plugin.getConfigHandler().enableIRC) {
+ this.circ = plugin.getCraftIRC();
+ circ.registerEndPoint("tcutils", plugin.getEndPoint());
+
+ // this.tcendpoint =
+ }
+ }
+
+ @Override
+ public Set<Player> getRecipients(CommandSender sender) {
+ return emptyHashSet;
+ }
+
+ @Override
+ public boolean broadcastMessage(CommandSender sender, String message) {
+ String msg = message;
+ if (sender instanceof Player) {
+ sender.sendMessage(msg);
+ }
+ for (Player p : getRecipients(sender)) {
+ p.sendMessage(msg);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean sendMessage(CommandSender sender, String message) {
+ String sendername = "";
+ String pcolor = "";
+ String cleanname;
+
+ if(plugin.getConfigHandler().enableIRC) {
+
+ if (sender instanceof Player) {
+ sendername = ((Player) sender).getDisplayName(); // ((Player)sender).getName();
+ pcolor = ""; // getDisplayName handles this one!
+ cleanname = ((Player) sender).getName();
+ } else {
+ sendername = "CONSOLE";
+ cleanname = sendername;
+ pcolor = ChatColor.LIGHT_PURPLE.toString();
+ }
+ String targetmsg = plugin.getConfigHandler().GIRCMessageFormat;
+ targetmsg = targetmsg.replace("%name%", cleanname).
+ replace("%message%", message).
+ replace("%dispname%", ChatColor.stripColor(sendername));
+ RelayedMessage rmsg = plugin.getCraftIRC().newMsgToTag(plugin.getAdminEndPoint(), plugin.getConfigHandler().GIRCtag, "generic");
+ rmsg.setField("sender", pcolor + sendername);
+ rmsg.setField("realSender", cleanname);
+ rmsg.setField("message", targetmsg);
+ if (sender instanceof Player) {
+ Player p = (Player) sender;
+ // World w = p.getWorld();
+ rmsg.setField("world", p.getWorld().getName());
+ rmsg.setField("prefix", plugin.getPermissions().getResolver().getUserPrefix(p.getWorld().getName(), p));
+ rmsg.setField("suffix", plugin.getPermissions().getResolver().getUserSuffix(p.getWorld().getName(), p));
+ }
+ rmsg.post();
+ }
+ return true;
+ }
+
+ @Override
+ public boolean isHidden() {
+ return true;
+ }
+
+ @Override
+ public String getDescription() {
+ return "CraftIRC extra endpoint";
+ }
+
+ @Override
+ public String getColor() {
+ return ChatColor.WHITE.toString();
+ }
+
+ @Override
+ public String getPrefix() {
+ return "TCIRC";
+ }
+}
View
9 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/WorldChat.java
@@ -26,7 +26,8 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author GuntherDW
@@ -43,13 +44,13 @@ public WorldChat(ChatHandler instance) {
@Override
public boolean sendMessage(CommandSender sender, String message) {
- if(!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.YELLOW+"What were you trying to do?");
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.YELLOW + "What were you trying to do?");
return true;
}
super.sendMessage(sender, message);
- if(getRecipients(sender).size() < 2)
+ if (getRecipients(sender).size() < 2)
sender.sendMessage(ChatColor.GOLD + "No one can hear you!");
return true;
View
3 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/ZoneChat.java
@@ -26,7 +26,6 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -59,7 +58,7 @@ public boolean sendMessage(CommandSender sender, String message) {
}
} else {
- sender.sendMessage(ChatColor.YELLOW+"What were you trying to do?");
+ sender.sendMessage(ChatColor.YELLOW + "What were you trying to do?");
}
return true;
}
View
113 src/com/guntherdw/bukkit/tweakcraft/Commands/CommandHandler.java
@@ -19,9 +19,14 @@
package com.guntherdw.bukkit.tweakcraft.Commands;
import com.guntherdw.bukkit.tweakcraft.Commands.Commands.*;
-import com.guntherdw.bukkit.tweakcraft.Exceptions.*;
+import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandException;
+import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandSenderException;
+import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException;
+import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
+import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import java.lang.reflect.InvocationTargetException;
@@ -38,14 +43,8 @@
private Map<String, iCommand> commandMap = new HashMap<String, iCommand>();
private Map<String, Method> newCommandMap = new HashMap<String, Method>();
+ private Map<String, Method> aliasCommandMap = new HashMap<String, Method>();
private Map<Method, Object> instanceMap = new HashMap<Method, Object>();
- /*private AdminCommands adminCommands;
- private ChatCommands chatcommands;
- private DebugCommands debugCommands;
- private EssentialsCommands essentialsCommands;
- private GeneralCommands generalCommands;
- private TeleportationCommands teleportationCommands;
- private WeatherCommands weatherCommands;*/
private Logger logger = Logger.getLogger("Minecraft");
private TweakcraftUtils plugin;
@@ -61,24 +60,24 @@ public CommandHandler(TweakcraftUtils instance) {
commandMap.clear();
newCommandMap.clear();
- addCommandClass(new AdminCommands());
- addCommandClass(new ChatCommands());
- addCommandClass(new DebugCommands());
- addCommandClass(new EssentialsCommands());
- addCommandClass(new GeneralCommands());
- addCommandClass(new TeleportationCommands());
- addCommandClass(new WeatherCommands());
+ addCommandClass(new AdminCommands(instance));
+ addCommandClass(new ChatCommands(instance));
+ addCommandClass(new DebugCommands(instance));
+ addCommandClass(new EssentialsCommands(instance));
+ addCommandClass(new GeneralCommands(instance));
+ addCommandClass(new TeleportationCommands(instance));
+ addCommandClass(new WeatherCommands(instance));
}
- private void addCommandClass(Object instance) {
+ public void addCommandClass(Object instance) {
for (Method m : instance.getClass().getDeclaredMethods()) {
if (m.getAnnotation(aCommand.class) != null)
injectCommand(m, instance);
}
}
- private void injectCommand(Method method, Object instance) {
+ public void injectCommand(Method method, Object instance) {
aCommand annotation = method.getAnnotation(aCommand.class);
String[] aliases = annotation.aliases();
if (aliases.length > 0) {
@@ -88,7 +87,14 @@ private void injectCommand(Method method, Object instance) {
logger.warning("[TweakcraftUtils] Command : " + aliases[0] + "!");
return;
}
- newCommandMap.put(aliases[0], method);
+ for (int x = 0; x < aliases.length; x++) {
+
+ if (x == 0)
+ newCommandMap.put(aliases[x], method);
+ else
+ aliasCommandMap.put(aliases[x], method);
+ }
+
instanceMap.put(method, instance);
}
}
@@ -100,7 +106,7 @@ public void checkCommands() {
Map<String, Object> pluginCommands = (Map<String, Object>) pdFile.getCommands();
Set<String> cmds = pluginCommands.keySet();
for (String c : cmds) {
- if (!this.newCommandMap.containsKey(c))
+ if (!this.newCommandMap.containsKey(c) && !this.aliasCommandMap.containsKey(c))
logger.warning("[TweakcraftUtils] WARNING: Unmapped command : " + c);
}
}
@@ -114,20 +120,75 @@ public TweakcraftUtils getPlugin() {
return newCommandMap;
}
- public iCommand getCommand(String command) throws CommandNotFoundException {
- if (commandMap.containsKey(command)) {
- return commandMap.get(command);
+ public boolean isInjected(String commandName) {
+ return plugin.getCommand(commandName) != null;
+ /* for(Map.Entry<String, Method> entry : getCommandMap().entrySet()) {
+ if(plugin.getCommand())
+ } */
+ }
+
+ public Method getCommand(String command) {
+ if (newCommandMap.containsKey(command)) {
+ return newCommandMap.get(command);
+ } else if (aliasCommandMap.containsKey(command)) {
+ return aliasCommandMap.get(command);
} else {
- throw new CommandNotFoundException(command);
+ return null;
+ }
+ }
+
+ public boolean executeCommand(CommandSender sender, String name, String[] args) {
+
+ String mess = "";
+ if (args.length > 1) {
+ for (String m : args)
+ mess += m + " ";
+
+ mess = mess.substring(0, mess.length() - 1);
+ } else if (args.length == 1) {
+ mess = args[0];
}
+
+ // Method
+
+ if (newCommandMap.containsKey(name) || aliasCommandMap.containsKey(name)) {
+ try {
+ /* iCommand command = commandHandler.getCommand(cmd.getName()); */
+ // public abstract boolean executeCommand(Server server, CommandSender sender, String command, String[] args, TweakcraftUtils plugin);
+
+ if (!runMethod(sender, name, args)) {
+ sender.sendMessage("This command did not go as intended!");
+ }
+ if (sender instanceof Player)
+ plugin.getLogger().info("[TweakcraftUtils] " + sender.getName() + " issued: /" + name + " " + mess);
+ else
+ plugin.getLogger().info("[TweakcraftUtils] CONSOLE issued: /" + name + " " + mess);
+ return true;
+ } /*catch (CommandNotFoundException e) {
+ sender.sendMessage("TweakcraftUtils error, command not found!");
+ }*/ catch (PermissionsException e) {
+ sender.sendMessage(ChatColor.RED + "You do not have the correct permissions for this command or usage!");
+ if (sender instanceof Player) {
+ plugin.getLogger().info("[TweakcraftUtils] " + ((Player) sender).getName() + " tried: /" + name + " " + mess);
+ }
+ } catch (CommandUsageException e) {
+ sender.sendMessage(ChatColor.YELLOW + e.getMessage());
+ } catch (CommandSenderException e) {
+ sender.sendMessage(ChatColor.YELLOW + e.getMessage());
+ } catch (CommandException e) {
+ sender.sendMessage(ChatColor.YELLOW + e.getMessage());
+ plugin.getLogger().info("[TweakcraftUtils] " + (sender instanceof Player ? ((Player) sender).getName() : "CONSOLE") + " got a CommandException on : /" + name + " " + mess);
+ }
+ }
+ return false;
}
- public boolean executeCommand(CommandSender sender, String name, String[] args, TweakcraftUtils tweakcraftUtils)
+ public boolean runMethod(CommandSender sender, String name, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
- Method command = newCommandMap.get(name);
try {
- return (Boolean) command.invoke(getMethodInstance(command), sender, name, args, tweakcraftUtils);
+ Method command = getCommand(name);
+ return (Boolean) command.invoke(getMethodInstance(command), sender, name, args);
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof PermissionsException)
View
26 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/AdminCommands.java
@@ -45,13 +45,19 @@
*/
public class AdminCommands {
+ TweakcraftUtils plugin;
+
+ public AdminCommands(TweakcraftUtils instance) {
+ this.plugin = instance;
+ }
+
@aCommand(
aliases = { "admin", "a" },
permissionBase = "admin",
description = "Send message to admins",
section = "admin"
)
- public boolean admin(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean admin(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
boolean onlist = false;
try {
@@ -88,7 +94,7 @@ public boolean admin(CommandSender sender, String command, String[] args, Tweakc
description = "Adds a player to the admin-msg list",
section = "admin"
)
- public boolean admin_add(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean admin_add(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandException, CommandUsageException {
if (sender instanceof Player) {
if (!plugin.check((Player) sender, "admon"))
@@ -139,7 +145,7 @@ public boolean admin_add(CommandSender sender, String command, String[] args, Tw
description = "Removes a player from the admin-msg list",
section = "admin"
)
- public boolean admin_remove(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean admin_remove(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) {
if (!plugin.check((Player) sender, "admon"))
@@ -202,7 +208,7 @@ public boolean admin_remove(CommandSender sender, String command, String[] args,
description = "Show the current admin-msg list",
section = "admin"
)
- public boolean admin_list(CommandSender sender, String command, String[] args, TweakcraftUtils plugin) throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
+ public boolean admin_list(CommandSender sender, String command, String[] args) throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) {
if (!plugin.check((Player) sender, "admon"))
throw new PermissionsException(command);
@@ -239,7 +245,7 @@ public boolean admin_list(CommandSender sender, String command, String[] args, T
description = "Makes you chat like normal again",
section = "admin"
)
- public boolean admoff(CommandSender sender, String command, String[] args, TweakcraftUtils plugin) throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
+ public boolean admoff(CommandSender sender, String command, String[] args) throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) {
Player player = (Player) sender;
try {
@@ -267,7 +273,7 @@ public boolean admoff(CommandSender sender, String command, String[] args, Tweak
description = "Automatically sends any msg as an admin message",
section = "admin"
)
- public boolean admon(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean admon(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandException, CommandUsageException {
if (sender instanceof Player) {
try {
@@ -297,7 +303,7 @@ public boolean admon(CommandSender sender, String command, String[] args, Tweakc
description = "Clear a player's inventory",
section = "admin"
)
- public boolean clearinventory(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean clearinventory(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandException, CommandUsageException {
if(sender instanceof Player)
if(!plugin.check((Player)sender, "clearinventory"))
@@ -329,7 +335,7 @@ else if(args.length!=0) {
description = "Shows who has /tpoff",
section = "admin"
)
- public boolean tplist(CommandSender sender, String command, String[] args, TweakcraftUtils plugin) throws PermissionsException, CommandSenderException {
+ public boolean tplist(CommandSender sender, String command, String[] args) throws PermissionsException, CommandSenderException {
if (sender instanceof Player) {
if (!plugin.check((Player) sender, "tplist"))
@@ -360,7 +366,7 @@ public boolean tplist(CommandSender sender, String command, String[] args, Tweak
description = "ViewDistance control!",
section = "admin"
)
- public boolean viewdistance(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin)
+ public boolean viewdistance(CommandSender sender, String command, String[] realargs)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player)
if(!plugin.check((Player)sender, "viewdistance"))
@@ -421,7 +427,7 @@ public boolean viewdistance(CommandSender sender, String command, String[] reala
description = "General tweakcraftutils command",
section = "admin"
)
- public boolean tweakcraft(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean tweakcraft(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("version")) {
View
44 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/ChatCommands.java
@@ -38,18 +38,24 @@
*/
public class ChatCommands {
+ TweakcraftUtils plugin;
+
+ public ChatCommands(TweakcraftUtils instance) {
+ this.plugin = instance;
+ }
+
@aCommand(
aliases = {"chatmode", "cm"},
permissionBase = "chat",
description = "ChatMode control",
section = "chat"
)
- public boolean chatmode(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean chatmode(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (args.length == 0) {
throw new CommandUsageException("/" + command + " <list|[chatmode]|...>");
}
- return this.chatCommand(sender, command, null, args, plugin);
+ return this.chatCommand(sender, command, null, args);
}
@aCommand(
@@ -58,10 +64,10 @@ public boolean chatmode(CommandSender sender, String command, String[] args, Twe
description = "Remove ChatMode subscription",
section = "chat"
)
- public boolean globalChat(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean globalChat(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
- this.chatCommand(sender, command, "global", args, plugin);
+ this.chatCommand(sender, command, "global", args);
return true;
}
@@ -72,14 +78,14 @@ public boolean globalChat(CommandSender sender, String command, String[] args, T
description = "Toggle local chat",
section = "chat"
)
- public boolean localChat(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean localChat(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (!plugin.getConfigHandler().enableLocalChat) {
throw new CommandUsageException("LocalChat not enabled!");
}
- this.chatCommand(sender, command, "local", args, plugin);
+ this.chatCommand(sender, command, "local", args);
return true;
}
@@ -90,14 +96,14 @@ public boolean localChat(CommandSender sender, String command, String[] args, Tw
description = "Toggle region chat",
section = "chat"
)
- public boolean regionChat(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean regionChat(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (!plugin.getConfigHandler().enableWorldGuard) {
throw new CommandUsageException("WorldGuard not enabled!");
}
- this.chatCommand(sender, command, "region", args, plugin);
+ this.chatCommand(sender, command, "region", args);
return true;
}
@@ -108,14 +114,14 @@ public boolean regionChat(CommandSender sender, String command, String[] args, T
description = "Toggle world chat",
section = "chat"
)
- public boolean worldChat(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean worldChat(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (!plugin.getConfigHandler().enableWorldChat) {
throw new CommandUsageException("WorldChat not enabled!");
}
- this.chatCommand(sender, command, "world", args, plugin);
+ this.chatCommand(sender, command, "world", args);
return true;
}
@@ -127,19 +133,19 @@ public boolean worldChat(CommandSender sender, String command, String[] args, Tw
description = "Toggle Zone chat",
section = "chat"
)
- public boolean zoneChat(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean zoneChat(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (plugin.getConfigHandler().enableZones == false) {
throw new CommandUsageException("Zones not enabled!");
}
- this.chatCommand(sender, command, "zones", args, plugin);
+ this.chatCommand(sender, command, "zones", args);
return true;
}
- public boolean chatCommand(CommandSender sender, String command, String chatModeName, String[] realargs, TweakcraftUtils plugin)
+ public boolean chatCommand(CommandSender sender, String command, String chatModeName, String[] realargs)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
ChatHandler ch = plugin.getChathandler();
@@ -228,8 +234,16 @@ public boolean chatCommand(CommandSender sender, String command, String chatMode
if (cm.isEnabled()) {
ChatMode oldcm = ch.getPlayerChatMode(player);
- if (oldcm != null)
- oldcm.removeRecipient(player.getName());
+
+ if (oldcm != null) {
+ if(oldcm.equals(cm)) {
+ ch.setPlayerchatmode(player.getName(), null);
+ lp.setChatMode(null);
+ sender.sendMessage(ChatColor.GOLD + "You will now chat globally");
+ return true;
+ } else
+ oldcm.removeRecipient(player.getName());
+ }
ch.setPlayerchatmode(player.getName(), chatMode);
cm.addRecipient(player.getName());
View
8 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/DebugCommands.java
@@ -34,13 +34,19 @@
*/
public class DebugCommands {
+ TweakcraftUtils plugin;
+
+ public DebugCommands(TweakcraftUtils instance) {
+ this.plugin = instance;
+ }
+
@aCommand(
aliases = { "debug" },
permissionBase = "debug",
description = "Various debug commands",
section = "debug"
)
- public boolean debug(final CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean debug(final CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player)
if(!plugin.check((Player) sender, "debug"))
View
314 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/EssentialsCommands.java
@@ -53,13 +53,20 @@
*/
public class EssentialsCommands {
+
+ TweakcraftUtils plugin;
+
+ public EssentialsCommands(TweakcraftUtils instance) {
+ this.plugin = instance;
+ }
+
@aCommand(
aliases = {"ban"},
permissionBase = "ban",
description = "Bans a player with a reason",
section = "essentials"
)
- public boolean ban(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin)
+ public boolean ban(CommandSender sender, String command, String[] realargs)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player)
if (!plugin.check((Player) sender, "ban"))
@@ -133,7 +140,7 @@ public boolean ban(CommandSender sender, String command, String[] realargs, Twea
description = "Lists the current bans",
section = "essentials"
)
- public boolean banlist(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean banlist(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player)
if (!plugin.check((Player) sender, "ban"))
@@ -172,7 +179,7 @@ public boolean banlist(CommandSender sender, String command, String[] args, Twea
description = "Shows your current orientation",
section = "essentials"
)
- public boolean compass(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean compass(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) {
Player player = (Player) sender;
@@ -191,7 +198,7 @@ public boolean compass(CommandSender sender, String command, String[] args, Twea
description = "Shows your current position",
section = "essentials"
)
- public boolean getpos(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean getpos(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player)
if (!plugin.check((Player) sender, "getpos"))
@@ -250,24 +257,33 @@ public boolean getpos(CommandSender sender, String command, String[] args, Tweak
description = "What you're reading right now",
section = "essentials"
)
- public boolean help(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean help(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
List<String> cma = new ArrayList<String>();
CommandHandler commh = plugin.getCommandHandler();
boolean aliases = true;
String toadd = "";
- for (String cname : commh.getCommandMap().keySet()) {
- Method commandMethod = commh.getCommandMap().get(cname);
+ for (Map.Entry<String, Method> entry : commh.getCommandMap().entrySet()) {
+ // Method commandMethod = commh.getCommandMap().get(cname);
// aCommand annotation = commandMethod.getAnnotation(aCommand.class);
+ if (plugin.getCommand(entry.getKey()) == null) {
+ System.out.println("Nullpointer for " + entry.getKey());
+ continue;
+ }
- if (addCommandToList(sender, commandMethod, plugin)) {
+ if (addCommandToList(sender, entry.getValue())) {
// Fuck minecraft's font :<
- toadd = ChatColor.GOLD + cname + ChatColor.WHITE +
- " : " + ChatColor.YELLOW + plugin.getCommand(cname).getDescription();
+ Method m = entry.getValue();
+ aCommand annotation = m.getAnnotation(aCommand.class);
+
+ if (annotation == null) continue;
+
+ toadd = ChatColor.GOLD + entry.getKey() + ChatColor.WHITE +
+ " : " + ChatColor.YELLOW + annotation.description();
if (aliases) {
- List<String> aliaseslist = plugin.getCommand(cname).getAliases();
+ List<String> aliaseslist = plugin.getCommand(entry.getKey()).getAliases();
if (aliaseslist.size() > 0) {
toadd += ChatColor.WHITE + " (";
for (String alias : aliaseslist) {
@@ -295,7 +311,7 @@ public boolean help(CommandSender sender, String command, String[] args, Tweakcr
String perm = (String) cmds.get(cmd).get("_permission");
if (perm == null)
perm = (String) cmds.get(cmd).get("permissions"); // Added for WorldEdit support
- if (addExtCommandToList(sender, perm, plugin)) {
+ if (addExtCommandToList(sender, perm)) {
toadd = ChatColor.GOLD + cmd + ChatColor.WHITE +
" : " + ChatColor.YELLOW + ((String) cmds.get(cmd).get("description"));
if (aliases) {
@@ -345,7 +361,7 @@ public boolean help(CommandSender sender, String command, String[] args, Tweakcr
return true;
}
- protected boolean addCommandToList(CommandSender sender, Method command, TweakcraftUtils plugin) {
+ protected boolean addCommandToList(CommandSender sender, Method command) {
if (sender instanceof Player) {
aCommand annotation = command.getAnnotation(aCommand.class);
if (annotation == null) {
@@ -358,7 +374,7 @@ protected boolean addCommandToList(CommandSender sender, Method command, Tweakcr
}
}
- protected boolean addExtCommandToList(CommandSender sender, String perm, TweakcraftUtils plugin) {
+ protected boolean addExtCommandToList(CommandSender sender, String perm) {
if (sender instanceof Player) {
if (perm == null) {
return true;
@@ -376,7 +392,7 @@ protected boolean addExtCommandToList(CommandSender sender, String perm, Tweakcr
description = "Give yourself an item of choice",
section = "essentials"
)
- public boolean item(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin)
+ public boolean item(CommandSender sender, String command, String[] realargs)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player)
@@ -503,7 +519,7 @@ public boolean item(CommandSender sender, String command, String[] realargs, Twe
description = "Kicks a player with reason",
section = "essentials"
)
- public boolean kick(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean kick(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player)
if (!plugin.check((Player) sender, "kick"))
@@ -545,7 +561,7 @@ public boolean kick(CommandSender sender, String command, String[] args, Tweakcr
description = "Lists the currently active worlds",
section = "essentials"
)
- public boolean listworlds(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean listworlds(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) // Give the player a list of worlds he has access to!
{
@@ -608,7 +624,7 @@ else if (env == World.Environment.THE_END)
description = "Broadcasts a message in third person",
section = "essentials"
)
- public boolean me(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean me(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) {
Player player = (Player) sender;
@@ -649,7 +665,7 @@ public boolean me(CommandSender sender, String command, String[] args, Tweakcraf
description = "Shows the message of the day!",
section = "essentials"
)
- public boolean motd(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean motd(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
@@ -677,7 +693,7 @@ public boolean motd(CommandSender sender, String command, String[] args, Tweakcr
description = "Send a message to a player",
section = "essentials"
)
- public boolean msg(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean msg(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
String senderName = "";
@@ -725,7 +741,7 @@ public boolean msg(CommandSender sender, String command, String[] args, Tweakcra
description = "Mute a player",
section = "essentials"
)
- public boolean mute(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean mute(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player)
if (!plugin.check((Player) sender, "mute"))
@@ -781,7 +797,7 @@ public boolean mute(CommandSender sender, String command, String[] args, Tweakcr
description = "General plugin command",
section = "essentials"
)
- public boolean plugin(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean plugin(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player)
if (!plugin.check((Player) sender, "plugins"))
@@ -859,7 +875,7 @@ public boolean plugin(CommandSender sender, String command, String[] args, Tweak
description = "Reply to the last msg",
section = "essentials"
)
- public boolean reply(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean reply(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) {
if (args.length > 0) {
@@ -900,7 +916,7 @@ public boolean reply(CommandSender sender, String command, String[] args, Tweakc
description = "Sets the spawn of the current world",
section = "essentials"
)
- public boolean setSpawn(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean setSpawn(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) {
Player player = (Player) sender;
@@ -927,7 +943,7 @@ public boolean setSpawn(CommandSender sender, String command, String[] args, Twe
description = "Sends you to the spawn of the world you're in",
section = "essentials"
)
- public boolean spawn(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean spawn(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) {
Player player = (Player) sender;
@@ -954,150 +970,152 @@ public boolean spawn(CommandSender sender, String command, String[] args, Tweakc
description = "Spawns mobs at your crosshair",
section = "essentials"
)
- public boolean spawnMob(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin)
+ public boolean spawnMob(CommandSender sender, String command, String[] realargs)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
- if (sender instanceof Player) {
- Player player = (Player) sender;
- if (!plugin.check(player, "spawnmob"))
+ /* if (sender instanceof Player) {
+ Player player = (Player) sender; */
+ if (sender instanceof Player)
+ if (!plugin.check((Player) sender, "spawnmob"))
throw new PermissionsException(command);
- Location loc = player.getTargetBlock((HashSet<Byte>) null, 200).getLocation();
- ArgumentParser ap = new ArgumentParser(realargs);
-
- Random rnd = new Random();
-
- int slimesize = ap.getInteger("s", -1);
- int health = ap.getInteger("h", -1);
- boolean powered = ap.getBoolean("p", false);
- boolean shoven = ap.getBoolean("sh", false);
- String sheepcolor = ap.getString("sc", null);
- int age = ap.getInteger("a", -1);
- String[] args = ap.getUnusedArgs();
-
- loc.setY(loc.getY() + 1); // Do not spawn them into the ground, silly!
- String mobName;
- String mobRider;
- Integer amount = 1;
- String victim = null;
- CreatureType type = null;
- CreatureType rider = null;
- Player victimplayer = player;
- LivingEntity lent = null;
- List<CreatureType> riders = null;
-
- if (args.length > 0) // only a mobname!
+ Location loc = null;
+ ArgumentParser ap = new ArgumentParser(realargs);
+
+ Random rnd = new Random();
+
+ int slimesize = ap.getInteger("s", -1);
+ int health = ap.getInteger("h", -1);
+ boolean powered = ap.getBoolean("pow", false);
+ boolean shoven = ap.getBoolean("sh", false);
+ String sheepcolor = ap.getString("sc", null);
+ String victim = ap.getString("p", null);
+ int age = ap.getInteger("a", -1);
+ String[] args = ap.getUnusedArgs();
+
+ String mobName;
+ String mobRider;
+ Integer amount = 1;
+ CreatureType type = null;
+ CreatureType rider = null;
+ Player victimplayer = null;
+ LivingEntity lent = null;
+ List<CreatureType> riders = null;
+
+ if (args.length > 0) // only a mobname!
+ {
+ mobName = "";
+ amount = 1;
+ if (args[0].length() > 2)
+ mobName = args[0].substring(0, 1).toUpperCase() + args[0].substring(1, args[0].length());
+ type = CreatureType.fromName(mobName);
+ if (type == null) {
+ sender.sendMessage("Tried : " + mobName);
+ throw new CommandUsageException("Can't find that creature!");
+ }
+ if (args.length > 1) // amount
{
- mobName = "";
- amount = 1;
- if (args[0].length() > 2)
- mobName = args[0].substring(0, 1).toUpperCase() + args[0].substring(1, args[0].length());
- type = CreatureType.fromName(mobName);
- if (type == null) {
- sender.sendMessage("Tried : " + mobName);
- throw new CommandUsageException("Can't find that creature!");
- }
- if (args.length > 1) // amount
- {
- try {
- amount = Integer.parseInt(args[1]);
- if (amount > 100) {
- amount = 100; // This should be more than enough before your client starts to lag!
- }
- } catch (NumberFormatException e) {
- throw new CommandUsageException("I need an amount, not a string!");
- }
+ try {
+ amount = Math.min(Math.max(0, Integer.parseInt(args[1])), 100);
+ } catch (NumberFormatException e) {
+ throw new CommandUsageException("I need an amount, not a string!");
}
- if (args.length > 2) // Riders and/or player!
- {
- riders = new ArrayList<CreatureType>();
- CreatureType tmpRider;
- String tmpRiderString;
- for (int x = 2; x < args.length; x++) {
-
- if (x == args.length - 1) {
- // Check to see if the last argument contains a playername
+ }
+ if (args.length > 2) { // Riders
+ riders = new ArrayList<CreatureType>();
+ CreatureType tmpRider;
+ String tmpRiderString;
+ for (int x = 2; x < args.length; x++) {
+
+ /*if (x == args.length - 1) {
+ // Check to see if the last argument contains a playername
+ if(victim==null)
victim = plugin.findPlayer(args[args.length - 1]);
- victimplayer = plugin.getServer().getPlayer(victim);
- /* if (victimplayer == null) {
- throw new CommandUsageException("Can't find that player!");
- } */
- if (victimplayer != null) {
-
- loc = victimplayer.getLocation();
- }
- }
- if (x < args.length - 1 ||
- (x == args.length - 1 && victimplayer == null)) {
- tmpRiderString = args[x];
- if (args[x].length() > 2)
- tmpRiderString = args[x].substring(0, 1).toUpperCase() + args[x].substring(1, args[x].length());
- rider = CreatureType.fromName(tmpRiderString);
- if (rider == null) {
- sender.sendMessage(ChatColor.YELLOW + "Didn't find one of the specified extra riders!");
- // throw new CommandUsageException("Can't find rider creature!");
- } else {
- riders.add(rider);
- }
+
+ victimplayer = plugin.getServer().getPlayer(victim);
+ if (victimplayer != null) {
+ loc = victimplayer.getLocation();
}
}
-
+ if (x < args.length - 1 ||
+ (x == args.length - 1 && victimplayer == null)) { */
+ tmpRiderString = args[x];
+ if (args[x].length() > 2)
+ tmpRiderString = args[x].substring(0, 1).toUpperCase() + args[x].substring(1, args[x].length());
+ rider = CreatureType.fromName(tmpRiderString);
+ if (rider == null) {
+ sender.sendMessage(ChatColor.YELLOW + "Didn't find one of the specified extra riders!");
+ // throw new CommandUsageException("Can't find rider creature!");
+ } else {
+ riders.add(rider);
+ }
+ // }
}
+ }
- // if (args.length > 3) // victim!
- // {
-
- // }
+ // Find that player
+ if (victim != null) {
+ victimplayer = plugin.findPlayerasPlayer(victim);
+ if (victimplayer != null) {
+ loc = victimplayer.getLocation();
+ } else {
+ throw new CommandException("Couldn't find player!");
+ }
+ }
- // We're finally here
- // Creature crea = new
- if (victimplayer == null)
- victimplayer = player;
+ if (victimplayer == null) {
+ if (sender instanceof Player) {
+ victimplayer = (Player) sender;
+ loc = victimplayer.getTargetBlock((HashSet<Byte>) null, 200).getLocation();
+ } else {
+ throw new CommandException("If you're a console, at least tell me who i need to scare?");
+ }
+ }
- if (type != null) {
- LivingEntity rid = null;
- for (int x = 0; x < amount; x++) {
- lent = victimplayer.getWorld().spawnCreature(loc, type);
- if (health > 0)
- lent.setHealth(health);
+ if (type != null) {
+ LivingEntity rid = null;
+ for (int x = 0; x < amount; x++) {
+ lent = victimplayer.getWorld().spawnCreature(loc, type);
+ if (health > 0)
+ lent.setHealth(health);
- if (lent instanceof Animals && age != -1)
- ((Animals) lent).setAge(age);
+ if (lent instanceof Animals && age != -1)
+ ((Animals) lent).setAge(age);
- if (lent instanceof Slime && slimesize > 0)
- ((Slime) lent).setSize(slimesize);
+ if (lent instanceof Slime && slimesize > 0)
+ ((Slime) lent).setSize(slimesize);
- if (lent instanceof Creeper && powered)
- ((Creeper) lent).setPowered(powered);
+ if (lent instanceof Creeper && powered)
+ ((Creeper) lent).setPowered(powered);
- if (lent instanceof Sheep && shoven || sheepcolor != null) {
- ((Sheep) lent).setSheared(shoven);
+ if (lent instanceof Sheep && shoven || sheepcolor != null) {
+ ((Sheep) lent).setSheared(shoven);
- if (sheepcolor != null) {
- DyeColor dc = null;
- if (sheepcolor.equalsIgnoreCase("random")) {
- dc = DyeColor.getByData((byte) rnd.nextInt(16));
- } else {
- dc = DyeColor.valueOf(sheepcolor.toUpperCase());
- }
- if (dc != null) ((Sheep) lent).setColor(dc);
+ if (sheepcolor != null) {
+ DyeColor dc = null;
+ if (sheepcolor.equalsIgnoreCase("random")) {
+ dc = DyeColor.getByData((byte) rnd.nextInt(16));
+ } else {
+ dc = DyeColor.valueOf(sheepcolor.toUpperCase());
}
+ if (dc != null) ((Sheep) lent).setColor(dc);
}
+ }
- if (riders != null && riders.size() != 0) {
- for (CreatureType t : riders) {
- rid = victimplayer.getWorld().spawnCreature(loc, t);
- if (lent != null) lent.setPassenger(rid);
- lent = rid; // This makes the currently added mob the new "to-ride-along" mob
- }
+ if (riders != null && riders.size() != 0) {
+ for (CreatureType t : riders) {
+ rid = victimplayer.getWorld().spawnCreature(loc, t);
+ if (lent != null) lent.setPassenger(rid);
+ lent = rid; // This makes the currently added mob the new "to-ride-along" mob
}
}
- } else {
- sender.sendMessage(ChatColor.YELLOW + "Error trying to spawn creature!");
}
+ } else {
+ sender.sendMessage(ChatColor.YELLOW + "Error trying to spawn creature!");
}
- } else {
- throw new CommandSenderException("What were you trying to do? :3");
}
+ /* } else {
+ throw new CommandSenderException("What were you trying to do? :3");
+ } */
return true;
}
@@ -1107,7 +1125,7 @@ public boolean spawnMob(CommandSender sender, String command, String[] realargs,
description = "Sets the time",
section = "essentials"
)
- public boolean time(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean time(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player)
if (!plugin.check((Player) sender, "time"))
@@ -1165,7 +1183,7 @@ public boolean time(CommandSender sender, String command, String[] args, Tweakcr
description = "Unban a player",
section = "essentials"
)
- public boolean unban(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean unban(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player)
if (!plugin.check((Player) sender, "ban"))
@@ -1191,7 +1209,7 @@ public boolean unban(CommandSender sender, String command, String[] args, Tweakc
description = "List of currently connected players",
section = "essentials"
)
- public boolean who(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin)
+ public boolean who(CommandSender sender, String command, String[] realargs)
throws PermissionsException, CommandSenderException, CommandUsageException {
@@ -1273,7 +1291,7 @@ public int compare(Player p1, Player p2) {
description = "Teleports you to a world of choice",
section = "essentials"
)
- public boolean world(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean world(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if (sender instanceof Player) {
Player player = (Player) sender;
View
40 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/GeneralCommands.java
@@ -51,13 +51,19 @@
*/
public class GeneralCommands {
+ TweakcraftUtils plugin;
+
+ public GeneralCommands(TweakcraftUtils instance) {
+ this.plugin = instance;
+ }
+
@aCommand(
aliases = { "addexp", "adde" },
permissionBase = "addexp",
description = "Adds experience to you or someone else",
section = "general"
)
- public boolean addExperience(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean addExperience(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player)
if(!plugin.check((Player)sender, "addexp"))
@@ -111,7 +117,7 @@ public boolean addExperience(CommandSender sender, String command, String[] args
description = "Manually toggle your AFK status",
section = "general"
)
- public boolean setAFK(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean setAFK(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(!(sender instanceof Player))
throw new CommandSenderException("Now what do you think you're doing?");
@@ -129,7 +135,7 @@ public boolean setAFK(CommandSender sender, String command, String[] args, Tweak
description = "Broadcasts said message to the server",
section = "general"
)
- public boolean broadcast(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin)
+ public boolean broadcast(CommandSender sender, String command, String[] realargs)
throws PermissionsException, CommandSenderException, CommandUsageException {
if (sender instanceof Player)
if (!plugin.check((Player) sender, "broadcast"))
@@ -190,7 +196,7 @@ public boolean broadcast(CommandSender sender, String command, String[] realargs
description = "Toggle mounting access",
section = "general"
)
- public boolean doNotMount(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean doNotMount(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player) {
@@ -221,7 +227,7 @@ public boolean doNotMount(CommandSender sender, String command, String[] args, T
description = "Eject your freeloader!",
section = "general"
)
- public boolean eject(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean eject(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player) {
Player player = (Player) sender;
@@ -253,7 +259,7 @@ public boolean eject(CommandSender sender, String command, String[] args, Tweakc
description = "Adds an enchantment to your current item",
section = "general"
)
- public boolean enchant(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean enchant(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player) {
String permNode = "enchant";
@@ -338,7 +344,7 @@ public boolean enchant(CommandSender sender, String command, String[] args, Twea
description = "Extinguish yourself or someone else",
section = "general"
)
- public boolean extinguish(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean extinguish(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException {
ExtMode modus = ExtMode.SELF;
@@ -479,7 +485,7 @@ public boolean extinguish(CommandSender sender, String command, String[] args, T
description = "Gets the spawn location for the world",
section = "general"
)
- public boolean getSpawn(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin)
+ public boolean getSpawn(CommandSender sender, String command, String[] realargs)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
@@ -547,7 +553,7 @@ public boolean getSpawn(CommandSender sender, String command, String[] realargs,
description = "Put someone on fire",
section = "general"
)
- public boolean ignite(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean ignite(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException {
IgniteMode modus = IgniteMode.SELF;
if (args.length > 0) {
@@ -692,7 +698,7 @@ else if (args[0].equalsIgnoreCase("mobs"))
description = "List of currently connected players in-range (localchat)",
section = "general"
)
- public boolean localWho(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean localWho(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(!plugin.getConfigHandler().enableLocalChat) {
@@ -729,7 +735,7 @@ public boolean localWho(CommandSender sender, String command, String[] args, Twe
description = "Give someone a nick",
section = "general"
)
- public boolean setNick(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean setNick(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player)
if(!plugin.check((Player)sender, "nick"))
@@ -791,7 +797,7 @@ public boolean setNick(CommandSender sender, String command, String[] args, Twea
description = "Report the last logout time of the player",
section = "general"
)
- public boolean seen(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean seen(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException {
if (args.length < 1) {
throw new CommandUsageException("You did not specify a name!");
@@ -874,7 +880,7 @@ public boolean seen(CommandSender sender, String command, String[] args, Tweakcr
description = "Tamer tool control",
section = "general"
)
- public boolean tamer(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean tamer(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player) {
@@ -955,7 +961,7 @@ public boolean tamer(CommandSender sender, String command, String[] args, Tweakc
description = "Toggles the use of TNT Arrows.",
section = "general"
)
- public boolean setTNTArrow(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean setTNTArrow(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(!plugin.getConfigHandler().enableTNTArrows)
@@ -984,7 +990,7 @@ public boolean setTNTArrow(CommandSender sender, String command, String[] args,
description = "Find out who's behind that nick!",
section = "general"
)
- public boolean whois(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
+ public boolean whois(CommandSender sender, String command, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
// First search for a nick
Boolean getIP = true;
@@ -1008,7 +1014,7 @@ public boolean whois(CommandSender sender, String command, String[] args, Tweakc
// sender.sendMessage(nick.toString());
String gname = null;
// Group g = null;
- Player sp = findPlayer(args[0], plugin);
+ Player sp = findPlayer(args[0]);
Player who = nick==null?sp:nick;
String groups = "";
@@ -1082,7 +1088,7 @@ public boolean whois(CommandSender sender, String command, String[] args, Tweakc
return true;
}
- private Player findPlayer(String playername, TweakcraftUtils plugin) {
+ private Player findPlayer(String playername) {
for(Player p : plugin.getServer().matchPlayer(playername)) {
if(p.getName().toLowerCase().contains(playername.toLowerCase())) {
return p;
View
278 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/TeleportationCommands.java
@@ -40,13 +40,19 @@
*/
public class TeleportationCommands {
+ TweakcraftUtils plugin;
+
+ public TeleportationCommands(TweakcraftUtils instance) {
+ this.plugin = instance;
+ }
+
@aCommand(
- aliases = { "tele" },
+ aliases = {"tele"},
permissionBase = "tele",
description = "Teleport to a specific location",
section = "teleport"
)
- public boolean teleportToLocation(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin)
+ public boolean teleportToLocation(CommandSender sender, String command, String[] realargs)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
boolean isPlayer = false;
ArgumentParser ap = new ArgumentParser(realargs);
@@ -71,64 +77,64 @@ public boolean teleportToLocation(CommandSender sender, String command, String[]
Integer z = null; */
World world = null;
- if(args.length == 0) {
+ if (args.length == 0) {
throw new CommandUsageException("Usage: /tele up|x z (y) <world> or /tele chunk x y (z) <world>");
- } else if(args.length==1 && args[0].equalsIgnoreCase("up")) {
- Location l = ((Player)sender).getLocation().clone();
- x = (int)l.getX();
+ } else if (args.length == 1 && args[0].equalsIgnoreCase("up")) {
+ Location l = ((Player) sender).getLocation().clone();
+ x = (int) l.getX();
y = 129;
- z = (int)l.getZ();
+ z = (int) l.getZ();
world = l.getWorld();
- } else if(args.length>0 && args[0].equalsIgnoreCase("chunk")) {
- if(args.length<3) {
+ } else if (args.length > 0 && args[0].equalsIgnoreCase("chunk")) {
+ if (args.length < 3) {
throw new CommandUsageException("I need at least 2 variables!");
}
try {
- if(isPlayer)
+ if (isPlayer)
world = ((Player) sender).getWorld();
- x = Integer.parseInt(args[1])<<4;
- z = Integer.parseInt(args[2])<<4;
- if(args.length>3) {
+ x = Integer.parseInt(args[1]) << 4;
+ z = Integer.parseInt(args[2]) << 4;
+ if (args.length > 3) {
y = Integer.parseInt(args[3]);
} else {
y = 129;
}
- if(args.length>4 || w!= null) {
- if(w==null) w=args[4];
+ if (args.length > 4 || w != null) {
+ if (w == null) w = args[4];
if (plugin.getServer().getWorlds().contains(plugin.getServer().getWorld(w))) {
world = plugin.getServer().getWorld(w);
} else {
- if(isPlayer)
+ if (isPlayer)
world = ((Player) sender).getWorld();
else
throw new CommandException("World not found!");
}
}
- } catch(NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
throw new CommandException("I need numbers not strings!");
- } catch(NullPointerException ex) {
+ } catch (NullPointerException ex) {
throw new CommandException("I can't find that world!");
}
} else {
- try{
- if (x==null) x = Integer.parseInt(args[0]);
- if (z==null) z = Integer.parseInt(args[1]);
+ try {
+ if (x == null) x = Integer.parseInt(args[0]);
+ if (z == null) z = Integer.parseInt(args[1]);
if (args.length == 3) {
- if (y==null) y = Integer.parseInt(args[2]);
+ if (y == null) y = Integer.parseInt(args[2]);
} else {
y = 129;
}
- } catch(NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
throw new CommandException("I need numbers not strings!");
}
- if (args.length > 3 || w!=null) {
- if(w==null) w=args[3];
+ if (args.length > 3 || w != null) {
+ if (w == null) w = args[3];
try {
if (plugin.getServer().getWorlds().contains(plugin.getServer().getWorld(w))) {
world = plugin.getServer().getWorld(w);
} else {
- if(isPlayer)
+ if (isPlayer)
world = ((Player) sender).getWorld();
else
throw new CommandException("World not found!");
@@ -137,28 +143,28 @@ public boolean teleportToLocation(CommandSender sender, String command, String[]
throw new CommandUsageException("Can't find world with name " + w);
}
} else {
- if(isPlayer)
+ if (isPlayer)
world = ((Player) sender).getWorld();
}
}
- if(args.length == 5 || p!=null) // Added victim
+ if (args.length == 5 || p != null) // Added victim
{
- if(p==null) p=args[4];
+ if (p == null) p = args[4];
victim = plugin.findPlayerasPlayer(p);
}
- if(world!=null) {
- if(isPlayer) {
+ if (world != null) {
+ if