From 4d730dbd00a6e234776af462e25ba3602f30a37f Mon Sep 17 00:00:00 2001 From: cerevisiae Date: Fri, 10 Dec 2010 03:15:39 -0600 Subject: [PATCH] Added removeNick, removeSuffix, and removePrefix to remove each respective feature --- TODO | 2 +- vMinecraftChat.java | 12 ++-- vMinecraftCommands.java | 153 ++++++++++++++++++++++++++++++++++++++-- vMinecraftUsers.java | 20 +++++- 4 files changed, 175 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 07512d02d..4b876e990 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,7 @@ Vminecraft b8 Todo: + Finish work on the flat file system + Antigriefs Working on this - + Time manipulation Working on this + ? Time manipulation Working on this * Have time changes not be instant but move the sky faster to get to the time entered * Loop through specific times of the day and then rewind diff --git a/vMinecraftChat.java b/vMinecraftChat.java index d903d9311..8b4c6b7f6 100644 --- a/vMinecraftChat.java +++ b/vMinecraftChat.java @@ -465,11 +465,11 @@ public class vMinecraftChat { //Output: boolean: If this feature is enabled //Use: /me but with our custom colors applied //===================================================================== - public static boolean emote(Player player, String message) - { - gmsg(player, "* " + getName(player) + " " + Colors.White + message); - return true; - } + public static boolean emote(Player player, String message) + { + gmsg(player, "* " + getName(player) + " " + Colors.White + message); + return true; + } //===================================================================== @@ -501,7 +501,7 @@ public class vMinecraftChat { { //If the char is a ^ or � if(taste || msg.charAt(x) == '^' - || msg.charAt(x) == Colors.White.charAt(0)) + || msg.charAt(x) == Colors.Red.charAt(0)) { if(x != msg.length() - 1) { diff --git a/vMinecraftCommands.java b/vMinecraftCommands.java index 02d97a934..938dad333 100644 --- a/vMinecraftCommands.java +++ b/vMinecraftCommands.java @@ -38,8 +38,11 @@ public class vMinecraftCommands{ //Administrative cl.register("/prefix", "prefix"); + cl.register("/rprefix", "removePrefix"); cl.register("/nick", "nickName"); + cl.register("/rnick", "removeNick"); cl.register("/suffix", "suffix"); + cl.register("/rsuffix", "removeSuffix"); cl.register("/vminecraft", "vminecrafthelp"); cl.register("/reload", "reload"); cl.register("/whois", "whois", "/whois [user]"); @@ -251,6 +254,50 @@ public class vMinecraftCommands{ return EXIT_SUCCESS; } + //===================================================================== + //Function: removeTag (/rprefix) + //Input: Player player: The player using the command + // String[] args: Ignored + //Output: int: Exit Code + //Use: Removes your prefix + //===================================================================== + public static int removeTag(Player player, String[] args){ + + //if the player can suffix others + if(player.canUseCommand("/prefixother")){ + if(args.length < 1){ + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "Usage is /rprefix [Player]"); + return EXIT_SUCCESS; + } + + //Check if the player exists + Player other = etc.getServer().matchPlayer(args[0]); + if(other == null) + { + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "The player you specified could not be found"); + return EXIT_SUCCESS; + } + vMinecraftUsers.getProfile(other).setTag(""); + + return EXIT_SUCCESS; + } + + //Check if the player can set their own prefix. + if(!player.canUseCommand("/prefix")){ + return EXIT_FAIL; + } + if(args.length < 1){ + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "Usage is /rprefix"); + return EXIT_SUCCESS; + } + vMinecraftUsers.getProfile(player).setTag(""); + + return EXIT_SUCCESS; + } + //===================================================================== //Function: nickName (/nick) //Input: Player player: The player using the command @@ -272,7 +319,7 @@ public class vMinecraftCommands{ if(vMinecraftChat.msgLength(args[1]) > 85) { vMinecraftChat.sendMessage(player, player, Colors.Rose - + "The suffix you entered was too long."); + + "The nick you entered was too long."); return EXIT_SUCCESS; } @@ -298,7 +345,7 @@ public class vMinecraftCommands{ if(vMinecraftChat.msgLength(args[1]) > 85) { vMinecraftChat.sendMessage(player, player, Colors.Rose - + "The suffix you entered was too long."); + + "The nick you entered was too long."); return EXIT_SUCCESS; } @@ -312,10 +359,54 @@ public class vMinecraftCommands{ return EXIT_SUCCESS; } + //===================================================================== + //Function: removeNick (/rnick) + //Input: Player player: The player using the command + // String[] args: Ignored + //Output: int: Exit Code + //Use: Removes your nick + //===================================================================== + public static int removeNick(Player player, String[] args){ + + //if the player can nick others + if(player.canUseCommand("/nickother")){ + if(args.length < 1){ + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "Usage is /rnick [Player]"); + return EXIT_SUCCESS; + } + + //Check if the player exists + Player other = etc.getServer().matchPlayer(args[0]); + if(other == null) + { + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "The player you specified could not be found"); + return EXIT_SUCCESS; + } + vMinecraftUsers.getProfile(other).setNick(""); + + return EXIT_SUCCESS; + } + + //Check if the player can set their own nick. + if(!player.canUseCommand("/nick")){ + return EXIT_FAIL; + } + if(args.length < 1){ + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "Usage is /rnick"); + return EXIT_SUCCESS; + } + vMinecraftUsers.getProfile(player).setNick(""); + + return EXIT_SUCCESS; + } + //===================================================================== //Function: suffix (/suffix) //Input: Player player: The player using the command - // String[] args: The color and the prefix + // String[] args: The color and the suffix //Output: int: Exit Code //Use: Changes your suffix //===================================================================== @@ -372,6 +463,50 @@ public class vMinecraftCommands{ return EXIT_SUCCESS; } + //===================================================================== + //Function: removeSuffix (/rsuffix) + //Input: Player player: The player using the command + // String[] args: Ignored + //Output: int: Exit Code + //Use: Removes your suffix + //===================================================================== + public static int removeSuffix(Player player, String[] args){ + + //if the player can suffix others + if(player.canUseCommand("/suffixother")){ + if(args.length < 1){ + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "Usage is /rsuffix [Player]"); + return EXIT_SUCCESS; + } + + //Check if the player exists + Player other = etc.getServer().matchPlayer(args[0]); + if(other == null) + { + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "The player you specified could not be found"); + return EXIT_SUCCESS; + } + vMinecraftUsers.getProfile(other).setSuffix(""); + + return EXIT_SUCCESS; + } + + //Check if the player can set their own suffix. + if(!player.canUseCommand("/suffix")){ + return EXIT_FAIL; + } + if(args.length < 1){ + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "Usage is /rsuffix"); + return EXIT_SUCCESS; + } + vMinecraftUsers.getProfile(player).setSuffix(""); + + return EXIT_SUCCESS; + } + //===================================================================== //Function: colors (/colors) //Input: Player player: The player using the command @@ -379,7 +514,10 @@ public class vMinecraftCommands{ //Use: Displays a list of all colors and color codes //===================================================================== public static int colors(Player player, String[] args){ - player.sendMessage(Colors.Rose + "You use these color codes like in quake or MW2, ^4 would make text red, ^a would make it light green."); + player.sendMessage(Colors.Rose + "You use these color codes like in quake or MW2."); + player.sendMessage(Colors.Rose + "^4 would make text " + Colors.Red + + "red" + Colors.Rose + ", ^a would make it " + Colors.LightGreen + + "light green" + Colors.Rose + "."); vMinecraftChat.sendMessage(player, player, Colors.Black + "0" + Colors.Navy + "1" @@ -537,6 +675,13 @@ public class vMinecraftCommands{ return EXIT_SUCCESS; } + if(ignore.hasControlOver(player)) + { + vMinecraftChat.sendMessage(player, player, Colors.Rose + + "You can't ignore someone a higher rank than you."); + return EXIT_SUCCESS; + } + //Don't let the player ignore themselves if(!ignore.getName().equalsIgnoreCase(player.getName())) { diff --git a/vMinecraftUsers.java b/vMinecraftUsers.java index dd5ffe903..05b7c2322 100644 --- a/vMinecraftUsers.java +++ b/vMinecraftUsers.java @@ -164,7 +164,9 @@ class PlayerList lastMessage, nickName, tag, - suffix; + suffix, + defaultColor; + private ArrayList ignoreList; private commandList aliasList; @@ -429,6 +431,22 @@ class PlayerList //===================================================================== public String getSuffix() { return suffix; } + //===================================================================== + //Function: setColor + //Input: String newTag: The color to set for the player + //Output: None + //Use: Sets a player color + //===================================================================== + public void setColor(String newColor){ defaultColor = newColor; } + + //===================================================================== + //Function: getColor + //Input: None + //Output: String: The player color + //Use: Gets a player color + //===================================================================== + public String getColor() { return defaultColor; } + //===================================================================== //Function: setMessage //Input: String newName: The name of the player they last messaged