From 621fe2279b7834787ae19a9e9d71da1eab27e912 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 9 Jan 2011 12:35:06 -0800 Subject: [PATCH] Player brackets in chat can now be colored the same as the group prefix color, allowing quick and easy identification of a players group. --- TODO | 10 +++++----- vChat.java | 12 ++++++------ vCom.java | 16 +++++++++------- vConfig.java | 7 ++++++- vListener.java | 6 +++--- vmc.java | 47 +++++++++++++++++++++++++++++++++++++++++++---- 6 files changed, 72 insertions(+), 26 deletions(-) diff --git a/TODO b/TODO index 06b98f050..58b7499a5 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ vMinecraft v1 Todo: - + Brackets with group prefix colors in chat + Add permission toggle for using colors + Guilds + Party Leaders @@ -33,10 +32,11 @@ vMinecraft v2 Updates! how much longer they are probated for. DONE - +Party system - +Party Chat - +Fix death messages - +Added /freeze command to stop players from moving + + Brackets with group prefix colors in chat + + Party system + + Party Chat + + Fix death messages + + Added /freeze command to stop players from moving + Quick recode of /me to use the new getName function + Promote and Demote (ASAP) DIBS + Simple Fire Antigrief diff --git a/vChat.java b/vChat.java index c001c4e8e..4145c11be 100644 --- a/vChat.java +++ b/vChat.java @@ -478,8 +478,8 @@ public class vChat { public static boolean quote(Player player, String message) { //Format the name - String playerName = Colors.White + "<" + getName(player) - + Colors.White + "> "; + String playerName = vmc.getInstance().getGroupPrefix(player) + "<" + getName(player) + + vmc.getInstance().getGroupPrefix(player) + "> "; if(vConfig.getInstance().greentext()) { //Log the chat log.log(Level.INFO, "<"+player.getName()+"> " + message); @@ -501,8 +501,8 @@ public class vChat { public static boolean rage(Player player, String message) { //Format the name - String playerName = Colors.White + "<" - + getName(player) + Colors.White +"> "; + String playerName = vmc.getInstance().getGroupPrefix(player) + "<" + + getName(player) + vmc.getInstance().getGroupPrefix(player) +"> "; if (vConfig.getInstance().FFF()) { log.log(Level.INFO, "<"+player.getName()+"> "+message); @@ -523,8 +523,8 @@ public class vChat { public static boolean quakeColors(Player player, String message) { //Format the name - String playerName = Colors.White + "<" - + getName(player) + Colors.White +"> "; + String playerName = vmc.getInstance().getGroupPrefix(player) + "<" + + getName(player) + vmc.getInstance().getGroupPrefix(player) +"> "; if(vConfig.getInstance().quakeColors()) { String color = vUsers.getProfile(player).getColor(); diff --git a/vCom.java b/vCom.java index 5bc6ca659..f6982c068 100644 --- a/vCom.java +++ b/vCom.java @@ -260,13 +260,15 @@ private static HashMap hidden = new HashMap(); List playerList = etc.getServer().getPlayerList(); for (Player InvisiblePlayer : hidden.values()) { - for (Player p : playerList) - { - if (vmc.getDistance(InvisiblePlayer, p) <= vConfig.range && p.getUser() != InvisiblePlayer.getUser()) - { - p.getUser().a.b(new dv(InvisiblePlayer.getUser().g)); - } - } + for (Player p : playerList) + { + if(p != null){ + if (vmc.getDistance(InvisiblePlayer, p) <= vConfig.range && p.getUser() != InvisiblePlayer.getUser()) + { + p.getUser().a.b(new dv(InvisiblePlayer.getUser().g)); + } + } + } } } public static int party(Player player, String[] args){ diff --git a/vConfig.java b/vConfig.java index 9eff5907c..6e1541542 100644 --- a/vConfig.java +++ b/vConfig.java @@ -18,6 +18,7 @@ public class vConfig { //The feature settings static boolean toggle = true, adminChat = false, + groupcoloredbrackets = false, partyChat = false, greentext = false, FFF = false, @@ -81,10 +82,12 @@ public class vConfig { FileWriter writer = null; try { writer = new FileWriter(location); - writer.write("#This plugin is modular\r\n"); + writer.append("#This plugin is modular\r\n"); writer.write("#Turn any features you don't want to false and they won't be running\r\n"); writer.write("#If you edit this file and save it, then use /reload it will reload the settings\r\n"); writer.write("#Chat Options\r\n"); + writer.write("#Group prefix colors apply to player brackets\r\n"); + writer.write("groupcoloredbrackets=true\r\n"); writer.write("#Allows the use of color codes following ^ symbol\r\n"); writer.write("ColoredChat=true\r\n"); writer.write("#Require per player permission for quakecolors\r\n"); @@ -168,6 +171,7 @@ public class vConfig { } try { + groupcoloredbrackets = properties.getBoolean("groupcoloredbrackets",true); adminChat = properties.getBoolean("adminchat",true); partyChat = properties.getBoolean("partychat",true); playerspawn = properties.getBoolean("playerspawn",true); @@ -229,6 +233,7 @@ public class vConfig { //Use: Returns if the feature is enabled //===================================================================== public boolean adminchat() {return adminChat;} + public boolean groupcoloredbrackets(){return groupcoloredbrackets;} public boolean partyChat() {return partyChat;} public boolean adminChatToggle() {return cmdAdminToggle;} public boolean greentext() {return greentext;} diff --git a/vListener.java b/vListener.java index 1a9b48c64..f8446f819 100644 --- a/vListener.java +++ b/vListener.java @@ -14,13 +14,13 @@ public class vListener extends PluginListener { { if(split.length > 1){ String args = " " + etc.combineSplit(1, split, " "); - vChat.gmsg(server + args); + vChat.gmsg(server + " " + args); return true; } return false; } if(split[0].equalsIgnoreCase("stop")) - vChat.gmsg(server + "shutting down the server"); + vChat.gmsg(server + " shutting down the server"); return false; } @@ -192,7 +192,7 @@ public class vListener extends PluginListener { //Then we preceed to check if they are in the same party, the code for this is stored elsewhere if(vUsers.getProfile(dplayer).inParty()){ //If they are in the same party we tell onDamage to return true stopping the damage code from executing - if(vmc.inSameParty(aplayer, dplayer)){ + if(aplayer != null && vmc.inSameParty(aplayer, dplayer)){ return true; //if they aren't we tell it to return false, making the damage happen } else{ diff --git a/vmc.java b/vmc.java index 24595b9cc..db006f353 100644 --- a/vmc.java +++ b/vmc.java @@ -1,5 +1,12 @@ +import java.io.*; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; public class vmc { - +private static volatile vmc instance; +protected static final Logger log = Logger.getLogger("Minecraft"); +private PropertiesFile properties; +String location = "groups.txt"; //Check if two players are in the same party public static boolean inSameParty(Player playera, Player playerb){ if(vUsers.getProfile(playera).getParty().equals(vUsers.getProfile(playerb).getParty())){ @@ -18,7 +25,7 @@ public class vmc { public static void sendInvisible(Player player){ for (Player p : etc.getServer().getPlayerList()) { - if (vmc.getDistance(player, p) <= vConfig.range && p.getUser() != player.getUser()) + if (getDistance(player, p) <= vConfig.range && p.getUser() != player.getUser()) { p.getUser().a.b(new dv(player.getUser().g)); } @@ -28,10 +35,42 @@ public class vmc { public static void sendNotInvisible(Player player){ for (Player p : etc.getServer().getPlayerList()) { - if (vmc.getDistance(player, p) < vConfig.range && p.getUser() != player.getUser()) + if (getDistance(player, p) < vConfig.range && p.getUser() != player.getUser()) { p.getUser().a.b(new d(player.getUser())); } } - } + } + public String getGroupPrefix(Player player){ + String groups[] = player.getGroups(); + String groupline[] = null; + String prefix = Colors.White; + if(vConfig.getInstance().groupcoloredbrackets()){ + //Read the file + properties = new PropertiesFile(location); + try { + properties.load(); + } catch (IOException e) { + log.log(Level.SEVERE, "Exception while loading " + location, e); + } + //Grab the line with the same group as the player + if(!groups[0].isEmpty()) + groupline = properties.getString(groups[0]).split(":"); + //Check if the prefix is null or not + if(groupline[0] != null) + { + //vChat.colorChange(groupline[0].charAt(0)); + prefix = groupline[0]; + prefix = vChat.colorChange(prefix.charAt(0)); + } + } + return prefix; + } + + public static vmc getInstance() { + if (instance == null) { + instance = new vmc(); + } + return instance; + } }