mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Added /promote and /demote
This commit is contained in:
parent
b6396b9dc5
commit
dcebdfdf5e
@ -51,6 +51,8 @@ public class vMinecraftCommands{
|
||||
cl.register("/modify", "modify");
|
||||
cl.register("/rules", "rules", "Displays the rules");
|
||||
cl.register("/who", "who");
|
||||
cl.register("/promote", "promote", "Promote a player one rank");
|
||||
cl.register("/demote", "demote", "Demote a player one rank");
|
||||
|
||||
//Movement
|
||||
cl.register("/tp", "teleport");
|
||||
@ -1357,7 +1359,7 @@ public class vMinecraftCommands{
|
||||
//Input: Player player: The player using the command
|
||||
// String[] args: Player, Command, Arguments
|
||||
//Output: int: Exit Code
|
||||
//Use: List all invulnerable players
|
||||
//Use: Display help for modifying features of players
|
||||
//=====================================================================
|
||||
public static int modify(Player player, String[] args)
|
||||
{
|
||||
@ -1398,6 +1400,251 @@ public class vMinecraftCommands{
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
//Function: promote (/promote)
|
||||
//Input: Player player: The player using the command
|
||||
// String[] args: Player to promote
|
||||
//Output: int: Exit Code
|
||||
//Use: Attempt to promote a player one rank
|
||||
//=====================================================================
|
||||
public static int promote(Player player, String[] args)
|
||||
{
|
||||
//Check if they can promote
|
||||
if(!player.canUseCommand("/promote")) return EXIT_FAIL;
|
||||
|
||||
//Check if they specified a player
|
||||
if(args.length < 1)
|
||||
{
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + "Usage: /promote [Player] (Rank)");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//Try to find the player
|
||||
Player target = etc.getServer().matchPlayer(args[0]);
|
||||
if(target == null)
|
||||
{
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + "The player specified could not be found");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//Get the list of ranks
|
||||
String[] ranks = vMinecraftSettings.getInstance().getRanks();
|
||||
|
||||
//Find the targets current rank number
|
||||
String[] tarGroups = target.getGroups();
|
||||
int tarRank = 0,
|
||||
tarPos = 0;
|
||||
boolean leave = false;
|
||||
for(String rank : ranks)
|
||||
{
|
||||
for(String group : tarGroups)
|
||||
{
|
||||
if(rank.equalsIgnoreCase(group))
|
||||
{
|
||||
leave = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
tarPos++;
|
||||
}
|
||||
if(leave)
|
||||
break;
|
||||
tarRank++;
|
||||
tarPos = 0;
|
||||
}
|
||||
if(!leave)
|
||||
{
|
||||
tarRank = 0;
|
||||
tarPos = 0;
|
||||
if(tarGroups != null)
|
||||
{
|
||||
String[] tempGroups = new String[tarGroups.length + 1];
|
||||
System.arraycopy(tarGroups, 0, tempGroups, 1, tarGroups.length);
|
||||
tarGroups = tempGroups;
|
||||
} else
|
||||
tarGroups = new String[1];
|
||||
}
|
||||
|
||||
leave = false;
|
||||
//Get the player's rank
|
||||
String[] myGroups = player.getGroups();
|
||||
int myRank = 0;
|
||||
|
||||
for(String rank : ranks)
|
||||
{
|
||||
for(String group : myGroups)
|
||||
if(rank.equalsIgnoreCase(group))
|
||||
{
|
||||
leave = true;
|
||||
break;
|
||||
}
|
||||
if(leave)
|
||||
break;
|
||||
myRank++;
|
||||
}
|
||||
if(!leave)
|
||||
{
|
||||
myRank = 0;
|
||||
}
|
||||
|
||||
log.log(Level.INFO, myRank + " / " + tarRank);
|
||||
//Make sure they're not promoting to their rank or higher
|
||||
if(myRank <= tarRank + 1)
|
||||
{
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + "You cannot promote someone to" +
|
||||
" your rank or higher.");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
tarGroups[tarPos] = ranks[tarRank + 1];
|
||||
target.setGroups(tarGroups);
|
||||
|
||||
//Make sure the player is in the files
|
||||
FlatFileSource ffs = new FlatFileSource();
|
||||
if(!ffs.doesPlayerExist(target.getName()))
|
||||
{
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + "Adding player.");
|
||||
ffs.addPlayer(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffs.modifyPlayer(target);
|
||||
}
|
||||
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + target.getName()
|
||||
+ " has been promoted to " + ranks[tarRank + 1] + ".");
|
||||
vMinecraftChat.sendMessage(target, Colors.Rose + "You have been promoted to "
|
||||
+ ranks[tarRank + 1] + ".");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
//Function: demote (/demote)
|
||||
//Input: Player player: The player using the command
|
||||
// String[] args: Player to promote
|
||||
//Output: int: Exit Code
|
||||
//Use: Attempt to promote a player one rank
|
||||
//=====================================================================
|
||||
public static int demote(Player player, String[] args)
|
||||
{
|
||||
//Check if they can demote
|
||||
if(!player.canUseCommand("/demote")) return EXIT_FAIL;
|
||||
|
||||
//Check if they specified a player
|
||||
if(args.length < 1)
|
||||
{
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + "Usage: /demote [Player] (Rank)");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//Try to find the player
|
||||
Player target = etc.getServer().matchPlayer(args[0]);
|
||||
if(target == null)
|
||||
{
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + "The player specified could not be found");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//Get the list of ranks
|
||||
String[] ranks = vMinecraftSettings.getInstance().getRanks();
|
||||
|
||||
//Find the targets current rank number
|
||||
String[] tarGroups = target.getGroups();
|
||||
int tarRank = 0,
|
||||
tarPos = 0;
|
||||
boolean leave = false;
|
||||
for(String rank : ranks)
|
||||
{
|
||||
for(String group : tarGroups)
|
||||
{
|
||||
if(rank.equalsIgnoreCase(group))
|
||||
{
|
||||
leave = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
tarPos++;
|
||||
}
|
||||
if(leave)
|
||||
break;
|
||||
tarRank++;
|
||||
tarPos = 0;
|
||||
}
|
||||
if(!leave)
|
||||
{
|
||||
tarRank = 0;
|
||||
tarPos = 0;
|
||||
if(tarGroups != null)
|
||||
{
|
||||
String[] tempGroups = new String[tarGroups.length + 1];
|
||||
System.arraycopy(tarGroups, 0, tempGroups, 1, tarGroups.length);
|
||||
tarGroups = tempGroups;
|
||||
} else
|
||||
tarGroups = new String[1];
|
||||
}
|
||||
|
||||
leave = false;
|
||||
//Get the player's rank
|
||||
String[] myGroups = player.getGroups();
|
||||
int myRank = 0;
|
||||
|
||||
for(String rank : ranks)
|
||||
{
|
||||
for(String group : myGroups)
|
||||
if(rank.equalsIgnoreCase(group))
|
||||
{
|
||||
leave = true;
|
||||
break;
|
||||
}
|
||||
if(leave)
|
||||
break;
|
||||
myRank++;
|
||||
}
|
||||
if(!leave)
|
||||
{
|
||||
myRank = 0;
|
||||
}
|
||||
|
||||
//Make sure they're not demoting to their rank or higher
|
||||
if(myRank <= tarRank)
|
||||
{
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + "You cannot demote someone who is" +
|
||||
" your rank or higher.");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if(tarRank - 1 < 0)
|
||||
{
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + target.getName() + " is already the" +
|
||||
" lowest rank.");
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
tarGroups[tarPos] = ranks[tarRank - 1];
|
||||
target.setGroups(tarGroups);
|
||||
|
||||
//Make sure the player is in the files
|
||||
FlatFileSource ffs = new FlatFileSource();
|
||||
if(!ffs.doesPlayerExist(target.getName()))
|
||||
{
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + "Adding player.");
|
||||
ffs.addPlayer(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffs.modifyPlayer(target);
|
||||
}
|
||||
|
||||
vMinecraftChat.sendMessage(player, Colors.Rose + target.getName()
|
||||
+ " has been demoted to " + ranks[tarRank - 1] + ".");
|
||||
vMinecraftChat.sendMessage(target, Colors.Rose + "You have been demoted to "
|
||||
+ ranks[tarRank - 1] + ".");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
|
@ -19,11 +19,11 @@ public class vMinecraftSettings {
|
||||
greentext = false,
|
||||
FFF = false,
|
||||
quakeColors = false,
|
||||
prefix = false,
|
||||
suffix = false,
|
||||
ignore = false,
|
||||
colors = false,
|
||||
nick = false,
|
||||
prefix = false,
|
||||
suffix = false,
|
||||
ignore = false,
|
||||
colors = false,
|
||||
nick = false,
|
||||
cmdFabulous = false,
|
||||
cmdPromote = false,
|
||||
cmdDemote = false,
|
||||
@ -37,22 +37,23 @@ public class vMinecraftSettings {
|
||||
cmdWho = false,
|
||||
stopFire = false,
|
||||
stopTnt = false,
|
||||
cmdHeal = false,
|
||||
cmdSuicide = false,
|
||||
cmdAdminToggle = false,
|
||||
cmdHeal = false,
|
||||
cmdSuicide = false,
|
||||
cmdAdminToggle = false,
|
||||
cmdEzModo = false;
|
||||
//An array of players currently in ezmodo
|
||||
static ArrayList<String> ezModo = new ArrayList<String>();
|
||||
//An array of players currently toggled for admin chat
|
||||
static ArrayList<String> adminChatList = new ArrayList<String>();
|
||||
//An array of blocks that won't catch on fire
|
||||
//An array of players currently toggled for admin chat
|
||||
static ArrayList<String> adminChatList = new ArrayList<String>();
|
||||
//An array of blocks that won't catch on fire
|
||||
|
||||
|
||||
|
||||
private PropertiesFile properties;
|
||||
String file = "vminecraft.properties";
|
||||
public String rules[] = new String[0];
|
||||
public static String deathMessages[] = new String[0];
|
||||
public static String deathMessages[] = new String[0];
|
||||
public static String ranks[] = new String[0];
|
||||
|
||||
//=====================================================================
|
||||
//Function: loadSettings
|
||||
@ -72,32 +73,34 @@ public class vMinecraftSettings {
|
||||
writer.write("#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("#Allows the use of color codes following ^ symbol\r\n");
|
||||
writer.write("ColoredChat=true\r\n");
|
||||
writer.write("#Text following a > will be colored green to mimic quoting of popular internet message boards\r\n");
|
||||
writer.write("#Chat Options\r\n");
|
||||
writer.write("#Allows the use of color codes following ^ symbol\r\n");
|
||||
writer.write("ColoredChat=true\r\n");
|
||||
writer.write("#Text following a > will be colored green to mimic quoting of popular internet message boards\r\n");
|
||||
writer.write("QuotesAreGreen=true\r\n");
|
||||
writer.write("#Turns any chat message starting with FFF automagically blood red\r\n");
|
||||
writer.write("FFF=true\r\n");
|
||||
writer.write("#Admin Settings\r\n");
|
||||
writer.write("#Enables or disables the admin only chat\r\n");
|
||||
writer.write("adminchat=true\r\n");
|
||||
writer.write("#Lets non admins use admin chat if they have the /adminchat command permission\r\n");
|
||||
writer.write("/adminchat=true\r\n");
|
||||
writer.write("#Enables overriding of regular /tp and /tphere to make it so you can only teleport to players with lower permissions, and only bring players of lower permissions to you\r\n");
|
||||
writer.write("/tp=true\r\n");
|
||||
writer.write("/tphere=true\r\n");
|
||||
writer.write("#Mass Tp uses the same concept, anyone with this command only brings those with lower permissions to themselves\r\n");
|
||||
writer.write("/masstp=true\r\n");
|
||||
writer.write("#Server Settings\r\n");
|
||||
writer.write("#Enables or Disables the following commands, give groups/users permissions to use these commands for them to work\r\n");
|
||||
writer.write("#Turns any chat message starting with FFF automagically blood red\r\n");
|
||||
writer.write("FFF=true\r\n");
|
||||
writer.write("\r\n");
|
||||
writer.write("#Admin Settings\r\n");
|
||||
writer.write("#Enables or disables the admin only chat\r\n");
|
||||
writer.write("adminchat=true\r\n");
|
||||
writer.write("#Lets non admins use admin chat if they have the /adminchat command permission\r\n");
|
||||
writer.write("/adminchat=true\r\n");
|
||||
writer.write("#Enables overriding of regular /tp and /tphere to make it so you can only teleport to players with lower permissions, and only bring players of lower permissions to you\r\n");
|
||||
writer.write("/tp=true\r\n");
|
||||
writer.write("/tphere=true\r\n");
|
||||
writer.write("#Mass Tp uses the same concept, anyone with this command only brings those with lower permissions to themselves\r\n");
|
||||
writer.write("/masstp=true\r\n");
|
||||
writer.write("\r\n");
|
||||
writer.write("#Server Settings\r\n");
|
||||
writer.write("#Enables or Disables the following commands, give groups/users permissions to use these commands for them to work\r\n");
|
||||
writer.write("/fabulous=true\r\n");
|
||||
writer.write("/prefix=true\r\n");
|
||||
writer.write("/suffix=true\r\n");
|
||||
writer.write("/ignore=true\r\n");
|
||||
writer.write("/colors=true\r\n");
|
||||
writer.write("/prefix=true\r\n");
|
||||
writer.write("/suffix=true\r\n");
|
||||
writer.write("/ignore=true\r\n");
|
||||
writer.write("/colors=true\r\n");
|
||||
writer.write("/whois=true\r\n");
|
||||
writer.write("/nick=true\r\n");
|
||||
writer.write("/nick=true\r\n");
|
||||
writer.write("/who=true\r\n");
|
||||
writer.write("/promote=true\r\n");
|
||||
writer.write("/demote=true\r\n");
|
||||
@ -105,14 +108,18 @@ public class vMinecraftSettings {
|
||||
writer.write("/rules=true\r\n");
|
||||
writer.write("/suicide=true\r\n");
|
||||
writer.write("/ezmodo=true\r\n");
|
||||
writer.write("#Global Messages\r\n");
|
||||
writer.write("#Enable or Disable sending announcements about sensitive commands to the entire server\r\n");
|
||||
writer.write("globalmessages=true\r\n");
|
||||
writer.write("#Global Messages\r\n");
|
||||
writer.write("#Enable or Disable sending announcements about sensitive commands to the entire server\r\n");
|
||||
writer.write("globalmessages=true\r\n");
|
||||
writer.write("\r\n");
|
||||
writer.write("#Adding player names to this list will have them start off in ezmodo\r\n");
|
||||
writer.write("ezModo=\r\n");
|
||||
writer.write("Stop fire from spreading\r\n");
|
||||
writer.write("#Stop fire from spreading\r\n");
|
||||
writer.write("stopFire=false\r\n");
|
||||
writer.write("#Write the rules to be shown when /rules is used here, it works just like the MOTD does\r\n");
|
||||
writer.write("\r\n");
|
||||
writer.write("#Organize your player ranks from lowest to highest.\r\n");
|
||||
writer.write("ranks=default,trusted,mods,admins,superadmins\r\n");
|
||||
writer.write("#Write the rules to be shown when /rules is used here, it works just like the MOTD does\r\n");
|
||||
writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n");
|
||||
writer.write("#The Random Death messages, seperate them by comma. All death messages start with the player name and a space.\r\n");
|
||||
writer.write("deathMessages=is no more,died horribly,went peacefully\r\n");
|
||||
@ -142,11 +149,11 @@ public class vMinecraftSettings {
|
||||
greentext = properties.getBoolean("QuotesAreGreen",true);
|
||||
FFF = properties.getBoolean("FFF",true);
|
||||
quakeColors = properties.getBoolean("ColoredChat",true);
|
||||
prefix = properties.getBoolean("prefix",true);
|
||||
suffix = properties.getBoolean("suffix",true);
|
||||
ignore = properties.getBoolean("ignore",true);
|
||||
colors = properties.getBoolean("colors",true);
|
||||
nick = properties.getBoolean("nick",true);
|
||||
prefix = properties.getBoolean("prefix",true);
|
||||
suffix = properties.getBoolean("suffix",true);
|
||||
ignore = properties.getBoolean("ignore",true);
|
||||
colors = properties.getBoolean("colors",true);
|
||||
nick = properties.getBoolean("nick",true);
|
||||
cmdFabulous = properties.getBoolean("/fabulous",true);
|
||||
cmdPromote = properties.getBoolean("/promote",true);
|
||||
cmdDemote = properties.getBoolean("/demote",true);
|
||||
@ -170,6 +177,8 @@ public class vMinecraftSettings {
|
||||
for(String ezName : tempEz)
|
||||
ezModo.add(ezName);
|
||||
|
||||
ranks = properties.getString("ranks").split(",");
|
||||
|
||||
|
||||
|
||||
log.log(Level.INFO, "vminecraft plugin successfully loaded");
|
||||
@ -214,6 +223,8 @@ public class vMinecraftSettings {
|
||||
public boolean stopTnt() {return stopTnt;}
|
||||
public boolean cmdSuicide() {return cmdSuicide;}
|
||||
public boolean cmdHeal() {return cmdHeal;}
|
||||
|
||||
public String[] getRanks() {return ranks;}
|
||||
|
||||
//EzModo methods
|
||||
public boolean cmdEzModo() {return cmdEzModo;}
|
||||
|
Loading…
Reference in New Issue
Block a user