mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Merge branch 'master' of github.com:nossr50/vminecraft-plugin
Conflicts: vminecraftCommands.java
This commit is contained in:
commit
6848a1d705
@ -71,34 +71,22 @@ public class vminecraftChat {
|
|||||||
int length = 0;
|
int length = 0;
|
||||||
for(int x = 0; x<str.length(); x++)
|
for(int x = 0; x<str.length(); x++)
|
||||||
{
|
{
|
||||||
if("i;,.:|!".indexOf(str.charAt(x)) != -1)
|
if(str.charAt(x) == '§')
|
||||||
{
|
x++;
|
||||||
|
else if("i;,.:|!".indexOf(str.charAt(x)) != -1)
|
||||||
length+=2;
|
length+=2;
|
||||||
}
|
|
||||||
else if("l'".indexOf(str.charAt(x)) != -1)
|
else if("l'".indexOf(str.charAt(x)) != -1)
|
||||||
{
|
|
||||||
length+=3;
|
length+=3;
|
||||||
}
|
|
||||||
else if("tI[]".indexOf(str.charAt(x)) != -1)
|
else if("tI[]".indexOf(str.charAt(x)) != -1)
|
||||||
{
|
|
||||||
length+=4;
|
length+=4;
|
||||||
}
|
|
||||||
else if("kf{}<>\"*()".indexOf(str.charAt(x)) != -1)
|
else if("kf{}<>\"*()".indexOf(str.charAt(x)) != -1)
|
||||||
{
|
|
||||||
length+=5;
|
length+=5;
|
||||||
}
|
|
||||||
else if("hequcbrownxjmpsvazydgTHEQUCKBROWNFXJMPSVLAZYDG1234567890#\\/?$%-=_+&".indexOf(str.charAt(x)) != -1)
|
else if("hequcbrownxjmpsvazydgTHEQUCKBROWNFXJMPSVLAZYDG1234567890#\\/?$%-=_+&".indexOf(str.charAt(x)) != -1)
|
||||||
{
|
|
||||||
length+=6;
|
length+=6;
|
||||||
}
|
|
||||||
else if("@~".indexOf(str.charAt(x)) != -1)
|
else if("@~".indexOf(str.charAt(x)) != -1)
|
||||||
{
|
|
||||||
length+=7;
|
length+=7;
|
||||||
}
|
|
||||||
else if(str.charAt(x)==' ')
|
else if(str.charAt(x)==' ')
|
||||||
{
|
|
||||||
length+=4;
|
length+=4;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
@ -107,9 +95,9 @@ public class vminecraftChat {
|
|||||||
public static String rainbow(String msg){
|
public static String rainbow(String msg){
|
||||||
String temp = "";
|
String temp = "";
|
||||||
//The array of colors to use
|
//The array of colors to use
|
||||||
String[] rainbow = new String[] {Colors.Red, Colors.Rose,
|
String[] rainbow = new String[] {Colors.Red, Colors.Rose, Colors.Gold,
|
||||||
Colors.Yellow, Colors.Green, Colors.Blue,
|
Colors.Yellow, Colors.LightGreen, Colors.Green, Colors.Blue,
|
||||||
Colors.LightPurple, Colors.Purple};
|
Colors.Navy, Colors.DarkPurple, Colors.Purple, Colors.LightPurple};
|
||||||
int counter=0;
|
int counter=0;
|
||||||
//Loop through the message applying the colors
|
//Loop through the message applying the colors
|
||||||
for(int x=0; x<msg.length(); x++)
|
for(int x=0; x<msg.length(); x++)
|
||||||
@ -117,7 +105,7 @@ public class vminecraftChat {
|
|||||||
temp+=rainbow[counter]+msg.charAt(x);
|
temp+=rainbow[counter]+msg.charAt(x);
|
||||||
|
|
||||||
if(msg.charAt(x)!=' ') counter++;
|
if(msg.charAt(x)!=' ') counter++;
|
||||||
if(counter==7) counter = 0;
|
if(counter==rainbow.length) counter = 0;
|
||||||
}
|
}
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
@ -128,7 +116,22 @@ public class vminecraftChat {
|
|||||||
//Use: Returns the colored name;
|
//Use: Returns the colored name;
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static String nameColor(Player player){
|
public static String nameColor(Player player){
|
||||||
return player.getColor() + player.getName();
|
|
||||||
|
//Get the prefix
|
||||||
|
String[] playerPrefix = new String[]{player.getPrefix()};
|
||||||
|
|
||||||
|
//Add the name
|
||||||
|
String output = player.getName();
|
||||||
|
|
||||||
|
//Add the color if there is one
|
||||||
|
if(player.getColor() != null && player.getColor() != "")
|
||||||
|
output = player.getColor().substring(0,2) + output;
|
||||||
|
//Add the prefix if there is one
|
||||||
|
if(playerPrefix[0] != null && playerPrefix[0] != "")
|
||||||
|
output = applyColors(playerPrefix)[0].substring(3) + output;
|
||||||
|
|
||||||
|
//Return the name
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
@ -243,12 +246,7 @@ public class vminecraftChat {
|
|||||||
if (p.isAdmin() || (p.canUseCommand("/adminchat"))) {
|
if (p.isAdmin() || (p.canUseCommand("/adminchat"))) {
|
||||||
|
|
||||||
//Output the first line
|
//Output the first line
|
||||||
p.sendMessage(adminchat + msg[0]);
|
for(String str: msg)
|
||||||
|
|
||||||
//Get the rest of the lines and display them.
|
|
||||||
String[] tempOut = new String[msg.length - 1];
|
|
||||||
System.arraycopy(msg, 1, tempOut, 0, tempOut.length);
|
|
||||||
for(String str: tempOut)
|
|
||||||
p.sendMessage(str);
|
p.sendMessage(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,7 +325,7 @@ public class vminecraftChat {
|
|||||||
//Format the name
|
//Format the name
|
||||||
String playerName = Colors.White + "<"
|
String playerName = Colors.White + "<"
|
||||||
+ nameColor(player) + Colors.White +"> ";
|
+ nameColor(player) + Colors.White +"> ";
|
||||||
if(vminecraftSettings.getInstance().quakeColors() && message.length()>2) {
|
if(vminecraftSettings.getInstance().quakeColors()) {
|
||||||
|
|
||||||
//Log the chat
|
//Log the chat
|
||||||
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
||||||
|
@ -12,6 +12,9 @@ import java.util.logging.Logger;
|
|||||||
public class vminecraftCommands{
|
public class vminecraftCommands{
|
||||||
//Log output
|
//Log output
|
||||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
static final int EXIT_FAIL = 0,
|
||||||
|
EXIT_SUCCESS = 1,
|
||||||
|
EXIT_CONTINUE = 2;
|
||||||
|
|
||||||
//The list of commands for vminecraft
|
//The list of commands for vminecraft
|
||||||
public static commandList cl = new commandList();
|
public static commandList cl = new commandList();
|
||||||
@ -35,8 +38,12 @@ public class vminecraftCommands{
|
|||||||
cl.register("/slay", "slay", "Kill target player");
|
cl.register("/slay", "slay", "Kill target player");
|
||||||
cl.register("/ezmodo", "invuln", "Toggle invulnerability");
|
cl.register("/ezmodo", "invuln", "Toggle invulnerability");
|
||||||
cl.register("/ezlist", "ezlist", "List invulnerable players");
|
cl.register("/ezlist", "ezlist", "List invulnerable players");
|
||||||
|
|
||||||
cl.register("/heal", "heal", "heal yourself or other players");
|
cl.register("/heal", "heal", "heal yourself or other players");
|
||||||
cl.register("/suicide", "suicide", "kill yourself... you loser");
|
cl.register("/suicide", "suicide", "kill yourself... you loser");
|
||||||
|
|
||||||
|
cl.register("/modify", "modifySplit");
|
||||||
|
|
||||||
cl.registerAlias("/playerlist", "/who");
|
cl.registerAlias("/playerlist", "/who");
|
||||||
cl.registerAlias("/suicide", "/wrists");
|
cl.registerAlias("/suicide", "/wrists");
|
||||||
}
|
}
|
||||||
@ -84,11 +91,10 @@ public class vminecraftCommands{
|
|||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: The arguments for the command. Should be a
|
// String[] args: The arguments for the command. Should be a
|
||||||
// player name
|
// player name
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Teleports the user to another player
|
//Use: Teleports the user to another player
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean teleport(Player player, String[] args)
|
public static int teleport(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//Get if the command is enabled
|
//Get if the command is enabled
|
||||||
if(vminecraftSettings.getInstance().cmdTp())
|
if(vminecraftSettings.getInstance().cmdTp())
|
||||||
@ -123,20 +129,19 @@ public class vminecraftCommands{
|
|||||||
//Otherwise inform the user that the player doesn't exist
|
//Otherwise inform the user that the player doesn't exist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: masstp (/masstp)
|
//Function: masstp (/masstp)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: Should be empty or is ignored
|
// String[] args: Should be empty or is ignored
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Teleports all players to the user
|
//Use: Teleports all players to the user
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean masstp(Player player, String[] args)
|
public static int masstp(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//If the command is enabled
|
//If the command is enabled
|
||||||
if(vminecraftSettings.getInstance().cmdMasstp()) {
|
if(vminecraftSettings.getInstance().cmdMasstp()) {
|
||||||
@ -149,9 +154,9 @@ public class vminecraftCommands{
|
|||||||
//Inform the user that the command has executed successfully
|
//Inform the user that the command has executed successfully
|
||||||
player.sendMessage(Colors.Blue+"Summoning successful.");
|
player.sendMessage(Colors.Blue+"Summoning successful.");
|
||||||
|
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
@ -159,11 +164,10 @@ public class vminecraftCommands{
|
|||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: The arguments for the command. Should be a
|
// String[] args: The arguments for the command. Should be a
|
||||||
// player name
|
// player name
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Teleports the user to another player
|
//Use: Teleports the user to another player
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean tphere(Player player, String[] args)
|
public static int tphere(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//Check if the command is enabled.
|
//Check if the command is enabled.
|
||||||
if (vminecraftSettings.getInstance().cmdTphere()) {
|
if (vminecraftSettings.getInstance().cmdTphere()) {
|
||||||
@ -189,34 +193,32 @@ public class vminecraftCommands{
|
|||||||
playerTarget.teleportTo(player);
|
playerTarget.teleportTo(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: reload (/reload)
|
//Function: reload (/reload)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: Ignored
|
// String[] args: Ignored
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Reloads the settings for vminecraft
|
//Use: Reloads the settings for vminecraft
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean reload(Player player, String[] args)
|
public static int reload(Player player, String[] args)
|
||||||
{
|
{
|
||||||
vminecraftSettings.getInstance().loadSettings();
|
vminecraftSettings.getInstance().loadSettings();
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: rules (/rules)
|
//Function: rules (/rules)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: Ignored
|
// String[] args: Ignored
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Lists the rules
|
//Use: Lists the rules
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean rules(Player player, String[] args)
|
public static int rules(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//If the rules exist
|
//If the rules exist
|
||||||
if(vminecraftSettings.getInstance().cmdRules()
|
if(vminecraftSettings.getInstance().cmdRules()
|
||||||
@ -226,20 +228,19 @@ public class vminecraftCommands{
|
|||||||
if(str.isEmpty())
|
if(str.isEmpty())
|
||||||
player.sendMessage(Colors.Blue+str);
|
player.sendMessage(Colors.Blue+str);
|
||||||
}
|
}
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: fabulous (/fabulous)
|
//Function: fabulous (/fabulous)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: The message to apply the effect to
|
// String[] args: The message to apply the effect to
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Makes the text rainbow colored
|
//Use: Makes the text rainbow colored
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean fabulous(Player player, String[] args)
|
public static int fabulous(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//If the command is enabled
|
//If the command is enabled
|
||||||
if(vminecraftSettings.getInstance().cmdFabulous()) {
|
if(vminecraftSettings.getInstance().cmdFabulous()) {
|
||||||
@ -248,7 +249,7 @@ public class vminecraftCommands{
|
|||||||
String playerName = Colors.White + "<"
|
String playerName = Colors.White + "<"
|
||||||
+ vminecraftChat.nameColor(player) + Colors.White +"> ";
|
+ vminecraftChat.nameColor(player) + Colors.White +"> ";
|
||||||
//Make sure a message has been specified
|
//Make sure a message has been specified
|
||||||
if (args.length < 1) {return false;}
|
if (args.length < 1) {return EXIT_FAIL;}
|
||||||
String str = " ";
|
String str = " ";
|
||||||
|
|
||||||
//Merge the message again
|
//Merge the message again
|
||||||
@ -264,27 +265,26 @@ public class vminecraftCommands{
|
|||||||
for(String msg: message)
|
for(String msg: message)
|
||||||
{
|
{
|
||||||
if (msg.contains(playerName))
|
if (msg.contains(playerName))
|
||||||
vminecraftChat.gmsg(
|
vminecraftChat.gmsg( playerName
|
||||||
vminecraftChat.rainbow(
|
+ vminecraftChat.rainbow(
|
||||||
msg.substring(playerName.length() - 1)));
|
msg.substring(playerName.length())));
|
||||||
else
|
else
|
||||||
vminecraftChat.gmsg(msg);
|
vminecraftChat.gmsg(vminecraftChat.rainbow(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: whois (/whois)
|
//Function: whois (/whois)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: The player to find info on
|
// String[] args: The player to find info on
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Displays information about the player specified
|
//Use: Displays information about the player specified
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean whois(Player player, String[] args)
|
public static int whois(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//If the command is enabled
|
//If the command is enabled
|
||||||
if (vminecraftSettings.getInstance().cmdWhoIs()) {
|
if (vminecraftSettings.getInstance().cmdWhoIs()) {
|
||||||
@ -324,20 +324,19 @@ public class vminecraftCommands{
|
|||||||
player.sendMessage(Colors.Rose+"Player not found.");
|
player.sendMessage(Colors.Rose+"Player not found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: who (/who)
|
//Function: who (/who)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: Ignored
|
// String[] args: Ignored
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Displays the connected players
|
//Use: Displays the connected players
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean who(Player player, String[] args)
|
public static int who(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//If the command is enabled
|
//If the command is enabled
|
||||||
if (vminecraftSettings.getInstance().cmdWho()) {
|
if (vminecraftSettings.getInstance().cmdWho()) {
|
||||||
@ -368,20 +367,19 @@ public class vminecraftCommands{
|
|||||||
for(String msg: tempOut)
|
for(String msg: tempOut)
|
||||||
player.sendMessage( msg );
|
player.sendMessage( msg );
|
||||||
|
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: say (/say)
|
//Function: say (/say)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: The message to apply the effect to
|
// String[] args: The message to apply the effect to
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Announces the message to all players
|
//Use: Announces the message to all players
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean say(Player player, String[] args)
|
public static int say(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//If the command is enabled
|
//If the command is enabled
|
||||||
if (vminecraftSettings.getInstance().cmdSay()) {
|
if (vminecraftSettings.getInstance().cmdSay()) {
|
||||||
@ -391,20 +389,19 @@ public class vminecraftCommands{
|
|||||||
}
|
}
|
||||||
//Display the message globally
|
//Display the message globally
|
||||||
vminecraftChat.gmsg(Colors.Yellow + etc.combineSplit(0, args, " "));
|
vminecraftChat.gmsg(Colors.Yellow + etc.combineSplit(0, args, " "));
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: slay (/slay)
|
//Function: slay (/slay)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: The target for the command
|
// String[] args: The target for the command
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Kill the target player
|
//Use: Kill the target player
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean slay(Player player, String[] args)
|
public static int slay(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//Check if the command is enabled
|
//Check if the command is enabled
|
||||||
if(vminecraftSettings.getInstance().cmdEzModo()) {
|
if(vminecraftSettings.getInstance().cmdEzModo()) {
|
||||||
@ -412,29 +409,30 @@ public class vminecraftCommands{
|
|||||||
Player playerTarget = etc.getServer().matchPlayer(args[0]);
|
Player playerTarget = etc.getServer().matchPlayer(args[0]);
|
||||||
//If the player doesn't exist don't run
|
//If the player doesn't exist don't run
|
||||||
if(playerTarget == null)
|
if(playerTarget == null)
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
//If the player isn't invulnerable kill them
|
//If the player isn't invulnerable kill them
|
||||||
if (!vminecraftSettings.getInstance().isEzModo(playerTarget.getName())) {
|
if (!vminecraftSettings.getInstance().isEzModo(playerTarget.getName())) {
|
||||||
playerTarget.setHealth(0);
|
playerTarget.setHealth(0);
|
||||||
vminecraftChat.gmsg(player.getColor() + player.getName() + Colors.LightBlue + " has slain " + playerTarget.getColor() + playerTarget.getName());
|
vminecraftChat.gmsg(vminecraftChat.nameColor(player)
|
||||||
|
+ Colors.LightBlue + " has slain "
|
||||||
|
+ vminecraftChat.nameColor(playerTarget));
|
||||||
//Otherwise output error to the user
|
//Otherwise output error to the user
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Colors.Rose + "That player is currently in ezmodo! Hahahaha");
|
player.sendMessage(Colors.Rose + "That player is currently in ezmodo! Hahahaha");
|
||||||
}
|
}
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: invuln (/ezmodo)
|
//Function: invuln (/ezmodo)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: The target for the command
|
// String[] args: The target for the command
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: Kill the target player
|
//Use: Kill the target player
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean invuln(Player player, String[] args)
|
public static int invuln(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//If the command is enabled
|
//If the command is enabled
|
||||||
if (vminecraftSettings.getInstance().cmdEzModo()) {
|
if (vminecraftSettings.getInstance().cmdEzModo()) {
|
||||||
@ -451,29 +449,56 @@ public class vminecraftCommands{
|
|||||||
vminecraftSettings.getInstance().addEzModo(player.getName());
|
vminecraftSettings.getInstance().addEzModo(player.getName());
|
||||||
player.setHealth(vminecraftSettings.getInstance().ezModoHealth());
|
player.setHealth(vminecraftSettings.getInstance().ezModoHealth());
|
||||||
}
|
}
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: ezlist (/ezlist)
|
//Function: ezlist (/ezlist)
|
||||||
//Input: Player player: The player using the command
|
//Input: Player player: The player using the command
|
||||||
// String[] args: Ignored
|
// String[] args: Ignored
|
||||||
//Output: boolean: If the user has access to the command
|
//Output: int: Exit Code
|
||||||
// and it is enabled
|
|
||||||
//Use: List all invulnerable players
|
//Use: List all invulnerable players
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public static boolean ezlist(Player player, String[] args)
|
public static int ezlist(Player player, String[] args)
|
||||||
{
|
{
|
||||||
//If the feature is enabled list the players
|
//If the feature is enabled list the players
|
||||||
if(vminecraftSettings.getInstance().cmdEzModo()) {
|
if(vminecraftSettings.getInstance().cmdEzModo()) {
|
||||||
player.sendMessage("Ezmodo: " + vminecraftSettings.getInstance().ezModoList());
|
player.sendMessage("Ezmodo: " + vminecraftSettings.getInstance().ezModoList());
|
||||||
return true;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: modifySplit (/modify)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: Player, Command, Arguments
|
||||||
|
//Output: int: Exit Code
|
||||||
|
//Use: List all invulnerable players
|
||||||
|
//=====================================================================
|
||||||
|
public static int modifySplit(Player player, String[] args)
|
||||||
|
{
|
||||||
|
//Exploit fix for people giving themselves commands
|
||||||
|
if(args[1].equals("commands"))
|
||||||
|
return EXIT_FAIL;
|
||||||
|
else if (args[1].equals("tag"))
|
||||||
|
playerTag(player, args);
|
||||||
|
return EXIT_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
//Function: playerTag (/modify player tag *)
|
||||||
|
//Input: Player player: The player using the command
|
||||||
|
// String[] args: Player, Command, Arguments
|
||||||
|
//Output: int: Exit Code
|
||||||
|
//Use: List all invulnerable players
|
||||||
|
//=====================================================================
|
||||||
|
public static int playerTag(Player player, String[] args)
|
||||||
|
{
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
//Disable using /modify to add commands (need to make a boolean settings for this)
|
//Disable using /modify to add commands (need to make a boolean settings for this)
|
||||||
|
|
||||||
@ -603,6 +628,9 @@ log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+"
|
|||||||
class commandList {
|
class commandList {
|
||||||
command[] commands;
|
command[] commands;
|
||||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
static final int EXIT_FAIL = 0,
|
||||||
|
EXIT_SUCCESS = 1,
|
||||||
|
EXIT_CONTINUE = 2;
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Function: commandList
|
//Function: commandList
|
||||||
@ -738,10 +766,10 @@ class commandList {
|
|||||||
//Output: boolean: If the command was called successfully
|
//Output: boolean: If the command was called successfully
|
||||||
//Use: Attempts to call a command
|
//Use: Attempts to call a command
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
public boolean call(String name, Player player, String[] arg){
|
public int call(String name, Player player, String[] arg){
|
||||||
//Make sure the user has access to the command
|
//Make sure the user has access to the command
|
||||||
if(!player.canUseCommand(name)) {
|
if(!player.canUseCommand(name)) {
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
//Search for the command
|
//Search for the command
|
||||||
for(command cmd : commands)
|
for(command cmd : commands)
|
||||||
@ -756,13 +784,13 @@ class commandList {
|
|||||||
log.log(Level.SEVERE, "Exception while running command", e);
|
log.log(Level.SEVERE, "Exception while running command", e);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
log.log(Level.SEVERE, "The Command Entered Doesn't Exist", e);
|
log.log(Level.SEVERE, "The Command Entered Doesn't Exist", e);
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Something went wrong
|
//Something went wrong
|
||||||
return false;
|
return EXIT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
@ -801,14 +829,14 @@ class commandList {
|
|||||||
//Output: boolean: If the command was called successfully
|
//Output: boolean: If the command was called successfully
|
||||||
//Use: Attempts to call the command
|
//Use: Attempts to call the command
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
boolean call(Player player, String[] arg)
|
int call(Player player, String[] arg)
|
||||||
{
|
{
|
||||||
|
|
||||||
Method m;
|
Method m;
|
||||||
try {
|
try {
|
||||||
m = vminecraftCommands.class.getMethod(function, Player.class, String[].class);
|
m = vminecraftCommands.class.getMethod(function, Player.class, String[].class);
|
||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
return (Boolean) m.invoke(null, player, arg);
|
return (Integer) m.invoke(null, player, arg);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
@ -820,7 +848,7 @@ class commandList {
|
|||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return true;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,7 +895,7 @@ class commandList {
|
|||||||
//Output: boolean: If the command was called successfully
|
//Output: boolean: If the command was called successfully
|
||||||
//Use: Attempts to call the command
|
//Use: Attempts to call the command
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
boolean call(Player player, String[] arg)
|
int call(Player player, String[] arg)
|
||||||
{
|
{
|
||||||
if(args != null) {
|
if(args != null) {
|
||||||
String[] temp = new String[args.length];
|
String[] temp = new String[args.length];
|
||||||
@ -902,12 +930,7 @@ class commandList {
|
|||||||
player.command(reference + " " + etc.combineSplit(0, temp, " "));
|
player.command(reference + " " + etc.combineSplit(0, temp, " "));
|
||||||
} else
|
} else
|
||||||
player.command(reference);
|
player.command(reference);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
/*if(temp != null)
|
|
||||||
etc.getServer().useConsoleCommand(reference + " " + etc.combineSplit(0, temp, " "), player);
|
|
||||||
else
|
|
||||||
etc.getServer().useConsoleCommand(reference, player);*/
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,17 +54,18 @@ public class vminecraftListener extends PluginListener {
|
|||||||
//=====================================================================
|
//=====================================================================
|
||||||
public boolean onCommand(Player player, String[] split) {
|
public boolean onCommand(Player player, String[] split) {
|
||||||
|
|
||||||
//Explot fix on /modify
|
|
||||||
if(split[0].equals("/modify") && split[2].equals("commands")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Copy the arguments into their own array.
|
//Copy the arguments into their own array.
|
||||||
String[] args = new String[split.length - 1];
|
String[] args = new String[split.length - 1];
|
||||||
System.arraycopy(split, 1, args, 0, args.length);
|
System.arraycopy(split, 1, args, 0, args.length);
|
||||||
|
|
||||||
//Return the results of the command
|
//Return the results of the command
|
||||||
return vminecraftCommands.cl.call(split[0], player, args);
|
int exitCode = vminecraftCommands.cl.call(split[0], player, args);
|
||||||
|
if(exitCode == 0)
|
||||||
|
return false;
|
||||||
|
else if(exitCode == 1)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import java.io.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.Random;
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
//Class: vminecraftSettings
|
//Class: vminecraftSettings
|
||||||
//Use: Controls the settings for vminecraft
|
//Use: Controls the settings for vminecraft
|
||||||
|
Loading…
Reference in New Issue
Block a user