Added in checks to make sure lower rank players cannot change higher rank players prefix, suffix, nickname. Added in default chat color to /colors

This commit is contained in:
cerevisiae 2010-12-12 15:01:17 -06:00
parent ebdda3afc0
commit f608ee7080
4 changed files with 109 additions and 37 deletions

View File

@ -336,10 +336,10 @@ public class vMinecraftChat {
color = Colors.White; color = Colors.White;
break; break;
case 'R': case 'R':
color = "~"; color = "^r";
break; break;
case 'r': case 'r':
color = "~"; color = "^r";
break; break;
default: default:
color = null; color = null;
@ -382,8 +382,7 @@ public class vMinecraftChat {
} }
//So you can read adminchat from the server console //So you can read adminchat from the server console
log.log(Level.INFO, "@" + "<" + player.getName() log.log(Level.INFO, "@" + "<" + player.getName() + "> " + message);
+ Colors.White +"> " + message);
return true; return true;
} }
return false; return false;
@ -448,11 +447,12 @@ public class vMinecraftChat {
+ getName(player) + Colors.White +"> "; + getName(player) + Colors.White +"> ";
if(vMinecraftSettings.getInstance().quakeColors()) { if(vMinecraftSettings.getInstance().quakeColors()) {
String color = vMinecraftUsers.getProfile(player).getColor();
//Log the chat //Log the chat
log.log(Level.INFO, "<"+player.getName()+"> " + message); log.log(Level.INFO, "<"+player.getName()+"> " + message);
//Output the message //Output the message
gmsg(player, playerName + message); gmsg(player, playerName + color + message);
//Loop through the string finding the color codes and inserting them //Loop through the string finding the color codes and inserting them
return true; return true;
@ -495,7 +495,7 @@ public class vMinecraftChat {
{ {
//Start the line with the most recent color //Start the line with the most recent color
String temp = ""; String temp = "";
if(!recentColor.equals("~") && recentColor != null) if(!recentColor.equals("^r") && recentColor != null)
temp += recentColor; temp += recentColor;
//Loop through looking for a color code //Loop through looking for a color code
@ -514,10 +514,10 @@ public class vMinecraftChat {
recentColor = vMinecraftChat.colorChange(msg.charAt(x+1)); recentColor = vMinecraftChat.colorChange(msg.charAt(x+1));
//If the color specified is rainbow //If the color specified is rainbow
if(taste || recentColor.equals("~")) if(taste || recentColor.equals("^r"))
{ {
//Skip the quake code for rainbow //Skip the quake code for rainbow
if(recentColor.equals("~")) if(recentColor.equals("^r"))
{ {
x += 2; x += 2;
} }

View File

@ -195,14 +195,6 @@ public class vMinecraftCommands{
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
//Check if the prefix is too long
if(vMinecraftChat.msgLength(args[1]) > 60)
{
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "The prefix you entered was too long.");
return EXIT_SUCCESS;
}
//Check if the player exists //Check if the player exists
Player other = etc.getServer().matchPlayer(args[0]); Player other = etc.getServer().matchPlayer(args[0]);
if(other == null) if(other == null)
@ -212,12 +204,32 @@ public class vMinecraftCommands{
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if(args.length >= 2 && args[0] != null){ //Check if they are a higher rank than the other person
other.setPrefix(args[1]); if(other.hasControlOver(player))
player.sendMessage(Colors.Rose + "Name color changed"); {
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "The player you specified is a higher rank than you.");
return EXIT_SUCCESS;
} }
if(args.length >= 3 && args[1] != null){
//Check if the prefix is too long
if(vMinecraftChat.msgLength(args[1]) > 60)
{
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "The prefix you entered was too long.");
return EXIT_SUCCESS;
}
if(args.length >= 2 && args[0] != null)
{
other.setPrefix(args[1]);
player.sendMessage(Colors.Rose + "Name color changed");
FlatFileSource ffs = new FlatFileSource();
ffs.modifyPlayer(other);
}
if(args.length >= 3 && args[1] != null)
{
vMinecraftUsers.players.findProfile(other).setTag(args[2]); vMinecraftUsers.players.findProfile(other).setTag(args[2]);
player.sendMessage(Colors.LightGreen + "Prefix changed"); player.sendMessage(Colors.LightGreen + "Prefix changed");
} }
@ -280,8 +292,17 @@ public class vMinecraftCommands{
+ "The player you specified could not be found"); + "The player you specified could not be found");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
//Check if they are a higher rank than the other person
if(other.hasControlOver(player))
{
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "The player you specified is a higher rank than you.");
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(other).setTag(""); vMinecraftUsers.getProfile(other).setTag("");
player.sendMessage(Colors.LightGreen + "Prefix removed"); player.sendMessage(Colors.LightGreen + "Prefix Removed");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -296,7 +317,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
vMinecraftUsers.getProfile(player).setTag(""); vMinecraftUsers.getProfile(player).setTag("");
player.sendMessage(Colors.LightGreen + "Prefix removed"); player.sendMessage(Colors.LightGreen + "Prefix Removed");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -334,7 +355,17 @@ public class vMinecraftCommands{
+ "The player you specified could not be found"); + "The player you specified could not be found");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
//Check if they are a higher rank than the other person
if(other.hasControlOver(player))
{
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "The player you specified is a higher rank than you.");
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(other).setNick(args[1]); vMinecraftUsers.getProfile(other).setNick(args[1]);
player.sendMessage(Colors.LightGreen + "Nickname Set");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -358,6 +389,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
vMinecraftUsers.getProfile(player).setNick(args[0]); vMinecraftUsers.getProfile(player).setNick(args[0]);
player.sendMessage(Colors.LightGreen + "Nickname Set");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -387,8 +419,17 @@ public class vMinecraftCommands{
+ "The player you specified could not be found"); + "The player you specified could not be found");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
//Check if they are a higher rank than the other person
if(other.hasControlOver(player))
{
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "The player you specified is a higher rank than you.");
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(other).setNick(""); vMinecraftUsers.getProfile(other).setNick("");
player.sendMessage(Colors.LightGreen + "Nickname removed"); player.sendMessage(Colors.LightGreen + "Nickname Removed");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -403,7 +444,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
vMinecraftUsers.getProfile(player).setNick(""); vMinecraftUsers.getProfile(player).setNick("");
player.sendMessage(Colors.LightGreen + "Nickname removed"); player.sendMessage(Colors.LightGreen + "Nickname Removed");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -441,7 +482,16 @@ public class vMinecraftCommands{
+ "The player you specified could not be found"); + "The player you specified could not be found");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
//Check if they are a higher rank than the other person
if(other.hasControlOver(player))
{
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "The player you specified is a higher rank than you.");
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(other).setSuffix(args[1]); vMinecraftUsers.getProfile(other).setSuffix(args[1]);
player.sendMessage(Colors.LightGreen + "Suffix Set");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -464,6 +514,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
vMinecraftUsers.getProfile(player).setSuffix(args[0]); vMinecraftUsers.getProfile(player).setSuffix(args[0]);
player.sendMessage(Colors.LightGreen + "Suffix Set");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -493,8 +544,16 @@ public class vMinecraftCommands{
+ "The player you specified could not be found"); + "The player you specified could not be found");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
//Check if they are a higher rank than the other person
if(other.hasControlOver(player))
{
vMinecraftChat.sendMessage(player, player, Colors.Rose
+ "The player you specified is a higher rank than you.");
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(other).setSuffix(""); vMinecraftUsers.getProfile(other).setSuffix("");
player.sendMessage(Colors.LightGreen + "Suffix removed"); player.sendMessage(Colors.LightGreen + "Suffix Removed");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -509,7 +568,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
vMinecraftUsers.getProfile(player).setSuffix(""); vMinecraftUsers.getProfile(player).setSuffix("");
player.sendMessage(Colors.LightGreen + "Suffix removed"); player.sendMessage(Colors.LightGreen + "Suffix Removed");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -524,8 +583,7 @@ public class vMinecraftCommands{
if(args.length > 0) if(args.length > 0)
{ {
vMinecraftUsers.getProfile(player).setColor(args[0]); vMinecraftUsers.getProfile(player).setColor(args[0]);
vMinecraftChat.sendMessage(player, player, vMinecraftChat.sendMessage(player, player, "^" + args[0].charAt(0)
vMinecraftChat.colorChange(args[0].charAt(0))
+ "Default chat color set."); + "Default chat color set.");
} else { } else {
player.sendMessage(Colors.Rose + "You use these color codes like in quake or MW2."); player.sendMessage(Colors.Rose + "You use these color codes like in quake or MW2.");
@ -543,13 +601,13 @@ public class vMinecraftCommands{
+ Colors.LightGray + "7" + Colors.LightGray + "7"
+ Colors.Gray + "8" + Colors.Gray + "8"
+ Colors.DarkPurple + "9" + Colors.DarkPurple + "9"
+ Colors.LightGreen + "a" + Colors.LightGreen + "A"
+ Colors.LightBlue + "b" + Colors.LightBlue + "B"
+ Colors.Rose + "c" + Colors.Rose + "C"
+ Colors.LightPurple + "d" + Colors.LightPurple + "D"
+ Colors.Yellow + "e" + Colors.Yellow + "E"
+ Colors.White + "f" + Colors.White + "F"
+ "^r" + "rrrrrrrrrrr"); + "^r" + "[R]ainbow");
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -1331,9 +1389,9 @@ public class vMinecraftCommands{
if(player.canUseCommand("/vranks")) if(player.canUseCommand("/vranks"))
{ {
vMinecraftChat.sendMessage(player, player, "/promote [Player]" + vMinecraftChat.sendMessage(player, player, "/promote [Player]" +
" - Promotes a player"); " - Promotes a player one rank");
vMinecraftChat.sendMessage(player, player, "/demote [Player]" + vMinecraftChat.sendMessage(player, player, "/demote [Player]" +
" - Demotes a player"); " - Demotes a player one rank");
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -92,6 +92,10 @@ public class vMinecraftListener extends PluginListener {
vMinecraftUsers.addUser(player); vMinecraftUsers.addUser(player);
} }
public void onDisconnect(Player player){
vMinecraftUsers.removeUser(player);
}
public boolean onIgnite(Block block, Player player) { public boolean onIgnite(Block block, Player player) {
if(vMinecraftSettings.stopFire){ if(vMinecraftSettings.stopFire){
if(block.getStatus() == 3 || block.getStatus() == 1){ if(block.getStatus() == 3 || block.getStatus() == 1){

View File

@ -47,12 +47,22 @@ public class vMinecraftUsers {
//Function: addUser //Function: addUser
//Input: Player player: The player to create a profile for //Input: Player player: The player to create a profile for
//Output: none //Output: none
//Use: Creates the player profile //Use: Loads the profile for the specified player
//===================================================================== //=====================================================================
public static void addUser(Player player){ public static void addUser(Player player){
players.addPlayer(player); players.addPlayer(player);
} }
//=====================================================================
//Function: removeUser
//Input: Player player: The player to stop following
//Output: none
//Use: Creates the player profile
//=====================================================================
public static void removeUser(Player player){
players.removePlayer(player);
}
//===================================================================== //=====================================================================
//Function: getProfile //Function: getProfile
//Input: Player player: The player to find the profile for //Input: Player player: The player to find the profile for