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

View File

@ -195,14 +195,6 @@ public class vMinecraftCommands{
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
Player other = etc.getServer().matchPlayer(args[0]);
if(other == null)
@ -212,12 +204,32 @@ public class vMinecraftCommands{
return EXIT_SUCCESS;
}
if(args.length >= 2 && args[0] != null){
//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;
}
//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){
if(args.length >= 3 && args[1] != null)
{
vMinecraftUsers.players.findProfile(other).setTag(args[2]);
player.sendMessage(Colors.LightGreen + "Prefix changed");
}
@ -280,8 +292,17 @@ public class vMinecraftCommands{
+ "The player you specified could not be found");
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("");
player.sendMessage(Colors.LightGreen + "Prefix removed");
player.sendMessage(Colors.LightGreen + "Prefix Removed");
return EXIT_SUCCESS;
}
@ -296,7 +317,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(player).setTag("");
player.sendMessage(Colors.LightGreen + "Prefix removed");
player.sendMessage(Colors.LightGreen + "Prefix Removed");
return EXIT_SUCCESS;
}
@ -334,7 +355,17 @@ public class vMinecraftCommands{
+ "The player you specified could not be found");
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]);
player.sendMessage(Colors.LightGreen + "Nickname Set");
return EXIT_SUCCESS;
}
@ -358,6 +389,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(player).setNick(args[0]);
player.sendMessage(Colors.LightGreen + "Nickname Set");
return EXIT_SUCCESS;
}
@ -387,8 +419,17 @@ public class vMinecraftCommands{
+ "The player you specified could not be found");
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("");
player.sendMessage(Colors.LightGreen + "Nickname removed");
player.sendMessage(Colors.LightGreen + "Nickname Removed");
return EXIT_SUCCESS;
}
@ -403,7 +444,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(player).setNick("");
player.sendMessage(Colors.LightGreen + "Nickname removed");
player.sendMessage(Colors.LightGreen + "Nickname Removed");
return EXIT_SUCCESS;
}
@ -441,7 +482,16 @@ public class vMinecraftCommands{
+ "The player you specified could not be found");
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]);
player.sendMessage(Colors.LightGreen + "Suffix Set");
return EXIT_SUCCESS;
}
@ -464,6 +514,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(player).setSuffix(args[0]);
player.sendMessage(Colors.LightGreen + "Suffix Set");
return EXIT_SUCCESS;
}
@ -493,8 +544,16 @@ public class vMinecraftCommands{
+ "The player you specified could not be found");
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("");
player.sendMessage(Colors.LightGreen + "Suffix removed");
player.sendMessage(Colors.LightGreen + "Suffix Removed");
return EXIT_SUCCESS;
}
@ -509,7 +568,7 @@ public class vMinecraftCommands{
return EXIT_SUCCESS;
}
vMinecraftUsers.getProfile(player).setSuffix("");
player.sendMessage(Colors.LightGreen + "Suffix removed");
player.sendMessage(Colors.LightGreen + "Suffix Removed");
return EXIT_SUCCESS;
}
@ -524,8 +583,7 @@ public class vMinecraftCommands{
if(args.length > 0)
{
vMinecraftUsers.getProfile(player).setColor(args[0]);
vMinecraftChat.sendMessage(player, player,
vMinecraftChat.colorChange(args[0].charAt(0))
vMinecraftChat.sendMessage(player, player, "^" + args[0].charAt(0)
+ "Default chat color set.");
} else {
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.Gray + "8"
+ Colors.DarkPurple + "9"
+ Colors.LightGreen + "a"
+ Colors.LightBlue + "b"
+ Colors.Rose + "c"
+ Colors.LightPurple + "d"
+ Colors.Yellow + "e"
+ Colors.White + "f"
+ "^r" + "rrrrrrrrrrr");
+ Colors.LightGreen + "A"
+ Colors.LightBlue + "B"
+ Colors.Rose + "C"
+ Colors.LightPurple + "D"
+ Colors.Yellow + "E"
+ Colors.White + "F"
+ "^r" + "[R]ainbow");
}
return EXIT_SUCCESS;
}
@ -1331,9 +1389,9 @@ public class vMinecraftCommands{
if(player.canUseCommand("/vranks"))
{
vMinecraftChat.sendMessage(player, player, "/promote [Player]" +
" - Promotes a player");
" - Promotes a player one rank");
vMinecraftChat.sendMessage(player, player, "/demote [Player]" +
" - Demotes a player");
" - Demotes a player one rank");
}
return EXIT_SUCCESS;
}

View File

@ -91,6 +91,10 @@ public class vMinecraftListener extends PluginListener {
vMinecraftChat.sendMessage(player, player, Colors.Rose + "There are currently " + etc.getServer().getPlayerList().size() + " players online.");
vMinecraftUsers.addUser(player);
}
public void onDisconnect(Player player){
vMinecraftUsers.removeUser(player);
}
public boolean onIgnite(Block block, Player player) {
if(vMinecraftSettings.stopFire){

View File

@ -47,12 +47,22 @@ public class vMinecraftUsers {
//Function: addUser
//Input: Player player: The player to create a profile for
//Output: none
//Use: Creates the player profile
//Use: Loads the profile for the specified player
//=====================================================================
public static void addUser(Player 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
//Input: Player player: The player to find the profile for