Changed all spilt[0].equalsIgnoreCase to label.equalsIgnoreCase.

Changed all if statement format to if elseif (should save time).
Added isConsole for supporting console in commands.
Rearranged some if statements so that errors are not thrown if console while moving down the if/elseif tree.
Added ability for console to talk to parties and admin chat.
Console still throws errors for commands not yet supporting it.
This commit is contained in:
NuclearW 2011-07-19 21:59:38 -04:00
parent 463c044b5e
commit ca009f3d22

View File

@ -178,8 +178,12 @@ public class mcMMO extends JavaPlugin
} }
public boolean onCommand( CommandSender sender, Command command, String label, String[] args ) { public boolean onCommand( CommandSender sender, Command command, String label, String[] args ) {
Player player = (Player) sender; Player player = null;
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = null;
if(!isConsole(sender)) {
player = (Player) sender;
PP = Users.getProfile(player);
}
String[] split = new String[args.length + 1]; String[] split = new String[args.length + 1];
split[0] = label; split[0] = label;
@ -188,7 +192,7 @@ public class mcMMO extends JavaPlugin
} }
//Check if the command is an MMO related help command //Check if the command is an MMO related help command
if(split[0].equalsIgnoreCase("taming") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillTaming").toLowerCase())){ if(label.equalsIgnoreCase("taming") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillTaming").toLowerCase())){
float skillvalue = (float)PP.getSkillLevel(SkillType.TAMING); float skillvalue = (float)PP.getSkillLevel(SkillType.TAMING);
String percentage = String.valueOf((skillvalue / 1000) * 100); String percentage = String.valueOf((skillvalue / 1000) * 100);
@ -222,7 +226,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] {mcLocale.getString("m.AbilBonusTaming4_0"), mcLocale.getString("m.AbilBonusTaming4_1")})); player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] {mcLocale.getString("m.AbilBonusTaming4_0"), mcLocale.getString("m.AbilBonusTaming4_1")}));
player.sendMessage(mcLocale.getString("m.TamingGoreChance", new Object[] {percentage})); player.sendMessage(mcLocale.getString("m.TamingGoreChance", new Object[] {percentage}));
} }
if(split[0].equalsIgnoreCase("woodcutting") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillWoodCutting").toLowerCase())){ else if(label.equalsIgnoreCase("woodcutting") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillWoodCutting").toLowerCase())){
float skillvalue = (float)PP.getSkillLevel(SkillType.WOODCUTTING); float skillvalue = (float)PP.getSkillLevel(SkillType.WOODCUTTING);
int ticks = 2; int ticks = 2;
int x = PP.getSkillLevel(SkillType.WOODCUTTING); int x = PP.getSkillLevel(SkillType.WOODCUTTING);
@ -247,7 +251,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.WoodCuttingDoubleDropChance", new Object[] {percentage})); player.sendMessage(mcLocale.getString("m.WoodCuttingDoubleDropChance", new Object[] {percentage}));
player.sendMessage(mcLocale.getString("m.WoodCuttingTreeFellerLength", new Object[] {ticks})); player.sendMessage(mcLocale.getString("m.WoodCuttingTreeFellerLength", new Object[] {ticks}));
} }
if(split[0].equalsIgnoreCase("archery") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillArchery").toLowerCase())){ else if(label.equalsIgnoreCase("archery") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillArchery").toLowerCase())){
Integer rank = 0; Integer rank = 0;
if(PP.getSkillLevel(SkillType.ARCHERY) >= 50) if(PP.getSkillLevel(SkillType.ARCHERY) >= 50)
rank++; rank++;
@ -295,7 +299,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.ArcheryIgnitionLength", new Object[] {(ignition / 20)})); player.sendMessage(mcLocale.getString("m.ArcheryIgnitionLength", new Object[] {(ignition / 20)}));
player.sendMessage(mcLocale.getString("m.ArcheryDamagePlus", new Object[] {rank})); player.sendMessage(mcLocale.getString("m.ArcheryDamagePlus", new Object[] {rank}));
} }
if(split[0].equalsIgnoreCase("axes") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillAxes"))){ else if(label.equalsIgnoreCase("axes") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillAxes"))){
String percentage; String percentage;
float skillvalue = (float)PP.getSkillLevel(SkillType.AXES); float skillvalue = (float)PP.getSkillLevel(SkillType.AXES);
if(PP.getSkillLevel(SkillType.AXES) < 750){ if(PP.getSkillLevel(SkillType.AXES) < 750){
@ -327,7 +331,7 @@ public class mcMMO extends JavaPlugin
} }
player.sendMessage(mcLocale.getString("m.AxesSkullLength", new Object[] {ticks})); player.sendMessage(mcLocale.getString("m.AxesSkullLength", new Object[] {ticks}));
} }
if(split[0].equalsIgnoreCase("swords") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillSwords").toLowerCase())){ else if(label.equalsIgnoreCase("swords") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillSwords").toLowerCase())){
int bleedrank = 2; int bleedrank = 2;
String percentage, parrypercentage = null, counterattackpercentage; String percentage, parrypercentage = null, counterattackpercentage;
float skillvalue = (float)PP.getSkillLevel(SkillType.SWORDS); float skillvalue = (float)PP.getSkillLevel(SkillType.SWORDS);
@ -377,7 +381,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.SwordsSSLength", new Object[] {ticks})); player.sendMessage(mcLocale.getString("m.SwordsSSLength", new Object[] {ticks}));
} }
if(split[0].equalsIgnoreCase("acrobatics") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillAcrobatics").toLowerCase())){ else if(label.equalsIgnoreCase("acrobatics") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillAcrobatics").toLowerCase())){
String dodgepercentage; String dodgepercentage;
float skillvalue = (float)PP.getSkillLevel(SkillType.ACROBATICS); float skillvalue = (float)PP.getSkillLevel(SkillType.ACROBATICS);
String percentage = String.valueOf((skillvalue / 1000) * 100); String percentage = String.valueOf((skillvalue / 1000) * 100);
@ -400,7 +404,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.AcrobaticsGracefulRollChance", new Object[] {gracepercentage})); player.sendMessage(mcLocale.getString("m.AcrobaticsGracefulRollChance", new Object[] {gracepercentage}));
player.sendMessage(mcLocale.getString("m.AcrobaticsDodgeChance", new Object[] {dodgepercentage})); player.sendMessage(mcLocale.getString("m.AcrobaticsDodgeChance", new Object[] {dodgepercentage}));
} }
if(split[0].equalsIgnoreCase("mining") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillMining"))){ else if(label.equalsIgnoreCase("mining") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillMining"))){
float skillvalue = (float)PP.getSkillLevel(SkillType.MINING); float skillvalue = (float)PP.getSkillLevel(SkillType.MINING);
String percentage = String.valueOf((skillvalue / 1000) * 100); String percentage = String.valueOf((skillvalue / 1000) * 100);
int ticks = 2; int ticks = 2;
@ -420,7 +424,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.MiningDoubleDropChance", new Object[] {percentage})); player.sendMessage(mcLocale.getString("m.MiningDoubleDropChance", new Object[] {percentage}));
player.sendMessage(mcLocale.getString("m.MiningSuperBreakerLength", new Object[] {ticks})); player.sendMessage(mcLocale.getString("m.MiningSuperBreakerLength", new Object[] {ticks}));
} }
if(split[0].equalsIgnoreCase("repair") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillRepair").toLowerCase())){ else if(label.equalsIgnoreCase("repair") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillRepair").toLowerCase())){
float skillvalue = (float)PP.getSkillXpLevel(SkillType.REPAIR); float skillvalue = (float)PP.getSkillXpLevel(SkillType.REPAIR);
String percentage = String.valueOf((skillvalue / 1000) * 100); String percentage = String.valueOf((skillvalue / 1000) * 100);
String repairmastery = String.valueOf((skillvalue / 500) * 100); String repairmastery = String.valueOf((skillvalue / 500) * 100);
@ -437,7 +441,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.RepairRepairMastery", new Object[] {repairmastery})); player.sendMessage(mcLocale.getString("m.RepairRepairMastery", new Object[] {repairmastery}));
player.sendMessage(mcLocale.getString("m.RepairSuperRepairChance", new Object[] {percentage})); player.sendMessage(mcLocale.getString("m.RepairSuperRepairChance", new Object[] {percentage}));
} }
if(split[0].equalsIgnoreCase("unarmed")){ else if(label.equalsIgnoreCase("unarmed")){
String percentage, arrowpercentage; String percentage, arrowpercentage;
float skillvalue = (float)PP.getSkillLevel(SkillType.UNARMED); float skillvalue = (float)PP.getSkillLevel(SkillType.UNARMED);
@ -484,7 +488,7 @@ public class mcMMO extends JavaPlugin
} }
player.sendMessage(mcLocale.getString("m.UnarmedBerserkLength", new Object[] {ticks})); player.sendMessage(mcLocale.getString("m.UnarmedBerserkLength", new Object[] {ticks}));
} }
if(split[0].equalsIgnoreCase("herbalism") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillHerbalism").toLowerCase())){ else if(label.equalsIgnoreCase("herbalism") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillHerbalism").toLowerCase())){
int rank = 0; int rank = 0;
if(PP.getSkillLevel(SkillType.HERBALISM) >= 50) if(PP.getSkillLevel(SkillType.HERBALISM) >= 50)
rank++; rank++;
@ -538,7 +542,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.HerbalismFoodPlus", new Object[] {rank})); player.sendMessage(mcLocale.getString("m.HerbalismFoodPlus", new Object[] {rank}));
} }
if(split[0].equalsIgnoreCase("excavation") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillExcavation").toLowerCase())) else if(label.equalsIgnoreCase("excavation") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillExcavation").toLowerCase()))
{ {
int ticks = 2; int ticks = 2;
int x = PP.getSkillLevel(SkillType.EXCAVATION); int x = PP.getSkillLevel(SkillType.EXCAVATION);
@ -557,7 +561,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.ExcavationGreenTerraLength", new Object[] {ticks})); player.sendMessage(mcLocale.getString("m.ExcavationGreenTerraLength", new Object[] {ticks}));
} }
if(split[0].equalsIgnoreCase("sorcery") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillSorcery").toLowerCase())) else if(label.equalsIgnoreCase("sorcery") || split[0].toLowerCase().equalsIgnoreCase(mcLocale.getString("m.SkillSorcery").toLowerCase()))
{ {
/* /*
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] {mcLocale.getString("m.SkillExcavation")})); player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] {mcLocale.getString("m.SkillExcavation")}));
@ -570,7 +574,7 @@ public class mcMMO extends JavaPlugin
*/ */
} }
if(LoadProperties.mcmmoEnable && split[0].equalsIgnoreCase(LoadProperties.mcmmo)){ else if(LoadProperties.mcmmoEnable && label.equalsIgnoreCase(LoadProperties.mcmmo)){
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"mMO"+ChatColor.RED+"[]-----"); player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"mMO"+ChatColor.RED+"[]-----");
player.sendMessage(ChatColor.YELLOW+"mcMMO is an RPG server mod for minecraft."); player.sendMessage(ChatColor.YELLOW+"mcMMO is an RPG server mod for minecraft.");
player.sendMessage(ChatColor.YELLOW+"There are many skills added by mcMMO to minecraft."); player.sendMessage(ChatColor.YELLOW+"There are many skills added by mcMMO to minecraft.");
@ -591,7 +595,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(ChatColor.GREEN+"Find out mcMMO commands with "+ChatColor.DARK_AQUA+LoadProperties.mcc); player.sendMessage(ChatColor.GREEN+"Find out mcMMO commands with "+ChatColor.DARK_AQUA+LoadProperties.mcc);
player.sendMessage(ChatColor.GREEN+"You can donate via paypal to"+ChatColor.DARK_RED+" nossr50@gmail.com"); player.sendMessage(ChatColor.GREEN+"You can donate via paypal to"+ChatColor.DARK_RED+" nossr50@gmail.com");
} }
if(LoadProperties.mccEnable && split[0].equalsIgnoreCase(LoadProperties.mcc)){ else if(LoadProperties.mccEnable && label.equalsIgnoreCase(LoadProperties.mcc)){
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.YELLOW+"mcMMO Commands"+ChatColor.RED+"[]---"); player.sendMessage(ChatColor.RED+"---[]"+ChatColor.YELLOW+"mcMMO Commands"+ChatColor.RED+"[]---");
if(mcPermissions.getInstance().party(player)){ if(mcPermissions.getInstance().party(player)){
player.sendMessage(mcLocale.getString("m.mccPartyCommands")); player.sendMessage(mcLocale.getString("m.mccPartyCommands"));
@ -627,7 +631,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("m.mccSkillInfo")); player.sendMessage(mcLocale.getString("m.mccSkillInfo"));
player.sendMessage(LoadProperties.mcmmo+" "+mcLocale.getString("m.mccModDescription")); player.sendMessage(LoadProperties.mcmmo+" "+mcLocale.getString("m.mccModDescription"));
} }
if(LoadProperties.mcabilityEnable && mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase(LoadProperties.mcability)){ else if(LoadProperties.mcabilityEnable && mcPermissions.permissionsEnabled && label.equalsIgnoreCase(LoadProperties.mcability)){
if(PP.getAbilityUse()){ if(PP.getAbilityUse()){
player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff")); player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff"));
PP.toggleAbilityUse(); PP.toggleAbilityUse();
@ -640,7 +644,7 @@ public class mcMMO extends JavaPlugin
/* /*
* FFS -> MySQL * FFS -> MySQL
*/ */
if(player.isOp() && split[0].equalsIgnoreCase("mmoupdate")) else if(label.equalsIgnoreCase("mmoupdate") && player.isOp())
{ {
if(!mcPermissions.getInstance().admin(player)) if(!mcPermissions.getInstance().admin(player))
{ {
@ -660,7 +664,7 @@ public class mcMMO extends JavaPlugin
/* /*
* LEADER BOARD COMMAND * LEADER BOARD COMMAND
*/ */
if(LoadProperties.mctopEnable && split[0].equalsIgnoreCase(LoadProperties.mctop)){ else if(LoadProperties.mctopEnable && label.equalsIgnoreCase(LoadProperties.mctop)){
if(LoadProperties.useMySQL == false){ if(LoadProperties.useMySQL == false){
/* /*
@ -833,7 +837,7 @@ public class mcMMO extends JavaPlugin
} }
} }
if(LoadProperties.mcrefreshEnable && split[0].equalsIgnoreCase(LoadProperties.mcrefresh)){ else if(LoadProperties.mcrefreshEnable && label.equalsIgnoreCase(LoadProperties.mcrefresh)){
if(!mcPermissions.getInstance().mcrefresh(player)){ if(!mcPermissions.getInstance().mcrefresh(player)){
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
@ -890,7 +894,7 @@ public class mcMMO extends JavaPlugin
/* /*
* GODMODE COMMAND * GODMODE COMMAND
*/ */
if(LoadProperties.mcgodEnable && split[0].equalsIgnoreCase(LoadProperties.mcgod)) else if(LoadProperties.mcgodEnable && label.equalsIgnoreCase(LoadProperties.mcgod))
{ {
if(mcPermissions.permissionsEnabled) if(mcPermissions.permissionsEnabled)
{ {
@ -921,7 +925,7 @@ public class mcMMO extends JavaPlugin
} }
} }
} }
if(LoadProperties.clearmyspawnEnable && LoadProperties.enableMySpawn && mcPermissions.getInstance().mySpawn(player) && split[0].equalsIgnoreCase(LoadProperties.clearmyspawn)) else if(LoadProperties.clearmyspawnEnable && LoadProperties.enableMySpawn && label.equalsIgnoreCase(LoadProperties.clearmyspawn) && mcPermissions.getInstance().mySpawn(player))
{ {
double x = this.getServer().getWorlds().get(0).getSpawnLocation().getX(); double x = this.getServer().getWorlds().get(0).getSpawnLocation().getX();
double y = this.getServer().getWorlds().get(0).getSpawnLocation().getY(); double y = this.getServer().getWorlds().get(0).getSpawnLocation().getY();
@ -930,7 +934,7 @@ public class mcMMO extends JavaPlugin
PP.setMySpawn(x, y, z, worldname); PP.setMySpawn(x, y, z, worldname);
player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnCleared")); player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnCleared"));
} }
if(LoadProperties.mmoeditEnable && mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase(""+LoadProperties.mmoedit)) else if(LoadProperties.mmoeditEnable && mcPermissions.permissionsEnabled && label.equalsIgnoreCase(""+LoadProperties.mmoedit))
{ {
if(!mcPermissions.getInstance().mmoedit(player)) if(!mcPermissions.getInstance().mmoedit(player))
@ -968,7 +972,7 @@ public class mcMMO extends JavaPlugin
/* /*
* ADD EXPERIENCE COMMAND * ADD EXPERIENCE COMMAND
*/ */
if(LoadProperties.addxpEnable && mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase(LoadProperties.addxp)){ else if(LoadProperties.addxpEnable && mcPermissions.permissionsEnabled && label.equalsIgnoreCase(LoadProperties.addxp)){
if(!mcPermissions.getInstance().mmoedit(player)){ if(!mcPermissions.getInstance().mmoedit(player)){
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
@ -997,7 +1001,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp"); player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp");
} }
} }
if(LoadProperties.ptpEnable && PP != null && PP.inParty() && split[0].equalsIgnoreCase(LoadProperties.ptp)){ else if(LoadProperties.ptpEnable && label.equalsIgnoreCase(LoadProperties.ptp) && PP != null && PP.inParty()){
if(!mcPermissions.getInstance().partyTeleport(player)){ if(!mcPermissions.getInstance().partyTeleport(player)){
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
@ -1023,7 +1027,7 @@ public class mcMMO extends JavaPlugin
/* /*
* WHOIS COMMAND * WHOIS COMMAND
*/ */
if(LoadProperties.whoisEnable && (player.isOp() || mcPermissions.getInstance().whois(player)) && split[0].equalsIgnoreCase(LoadProperties.whois)){ else if(LoadProperties.whoisEnable && label.equalsIgnoreCase(LoadProperties.whois) && (player.isOp() || mcPermissions.getInstance().whois(player))){
if(split.length < 2){ if(split.length < 2){
player.sendMessage(ChatColor.RED + "Proper usage is /"+LoadProperties.whois+" <playername>"); player.sendMessage(ChatColor.RED + "Proper usage is /"+LoadProperties.whois+" <playername>");
return true; return true;
@ -1086,7 +1090,7 @@ public class mcMMO extends JavaPlugin
/* /*
* STATS COMMAND * STATS COMMAND
*/ */
if(LoadProperties.statsEnable && split[0].equalsIgnoreCase(LoadProperties.stats)){ else if(LoadProperties.statsEnable && label.equalsIgnoreCase(LoadProperties.stats)){
player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats")); player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats"));
@ -1132,7 +1136,7 @@ public class mcMMO extends JavaPlugin
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel")+ChatColor.GREEN+(m.getPowerLevel(player))); player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel")+ChatColor.GREEN+(m.getPowerLevel(player)));
} }
//Invite Command //Invite Command
if(LoadProperties.inviteEnable && mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase(LoadProperties.invite)){ else if(LoadProperties.inviteEnable && label.equalsIgnoreCase(LoadProperties.invite) && mcPermissions.getInstance().party(player)){
if(!PP.inParty()) if(!PP.inParty())
{ {
@ -1159,7 +1163,7 @@ public class mcMMO extends JavaPlugin
} }
} }
//Accept invite //Accept invite
if(LoadProperties.acceptEnable && mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase(LoadProperties.accept)){ else if(LoadProperties.acceptEnable && label.equalsIgnoreCase(LoadProperties.accept) && mcPermissions.getInstance().party(player)){
if(PP.hasPartyInvite()){ if(PP.hasPartyInvite()){
if(PP.inParty()){ if(PP.inParty()){
Party.getInstance().informPartyMembersQuit(player, getPlayersOnline()); Party.getInstance().informPartyMembersQuit(player, getPlayersOnline());
@ -1172,7 +1176,7 @@ public class mcMMO extends JavaPlugin
} }
} }
//Party command //Party command
if(LoadProperties.partyEnable && split[0].equalsIgnoreCase(LoadProperties.party)){ else if(LoadProperties.partyEnable && label.equalsIgnoreCase(LoadProperties.party)){
if(!mcPermissions.getInstance().party(player)){ if(!mcPermissions.getInstance().party(player)){
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;
@ -1213,7 +1217,33 @@ public class mcMMO extends JavaPlugin
Party.getInstance().informPartyMembers(player, getPlayersOnline()); Party.getInstance().informPartyMembers(player, getPlayersOnline());
} }
} }
if(LoadProperties.partyEnable && split[0].equalsIgnoreCase("p")){ else if(LoadProperties.partyEnable && label.equalsIgnoreCase("p")){
// Console message?
if(isConsole(sender)) {
if(args.length < 2) return true;
String pMessage = args[1];
for (int i = 2; i <= args.length - 1; i++) {
pMessage = pMessage + " " + args[i];
}
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE
+ "*Console*" + ChatColor.GREEN + ") ";
log.log(Level.INFO,
"[P](" + args[0] + ")" + "<*Console*> "
+ pMessage);
for(Player herp : getServer().getOnlinePlayers()) {
if(Users.getProfile(herp).inParty()) {
log.info(Users.getProfile(herp).getParty());
if(Users.getProfile(herp).getParty().equalsIgnoreCase(args[0])) {
herp.sendMessage(pPrefix + pMessage);
}
}
}
return true;
}
if(!mcPermissions.getInstance().party(player)){ if(!mcPermissions.getInstance().party(player)){
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
@ -1258,7 +1288,29 @@ public class mcMMO extends JavaPlugin
} }
} }
if(split[0].equalsIgnoreCase("a") && (player.isOp() || mcPermissions.getInstance().adminChat(player))){ else if(label.equalsIgnoreCase("a")){
// Console message?
if(isConsole(sender) && args.length >= 1) {
String aMessage = args[0];
for (int i = 1; i <= args.length - 1; i++) {
aMessage = aMessage + " " + args[i];
}
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE
+ "*Console*" + ChatColor.AQUA + "} ";
log.log(Level.INFO, "[A]<*Console*> "
+ aMessage);
for (Player herp : getServer().getOnlinePlayers()) {
if ((herp.isOp() || mcPermissions.getInstance().adminChat(
herp)))
herp.sendMessage(aPrefix + aMessage);
}
return true;
}
if(!mcPermissions.getInstance().adminChat(player) && !player.isOp()){ if(!mcPermissions.getInstance().adminChat(player) && !player.isOp()){
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;
@ -1274,7 +1326,7 @@ public class mcMMO extends JavaPlugin
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE
+ player.getName() + ChatColor.AQUA + "} "; + player.getName() + ChatColor.AQUA + "} ";
log.log(Level.INFO, "[A]" + "<" + player.getName() + "> " log.log(Level.INFO, "[A]<" + player.getName() + "> "
+ aMessage); + aMessage);
for (Player herp : getServer().getOnlinePlayers()) { for (Player herp : getServer().getOnlinePlayers()) {
if ((herp.isOp() || mcPermissions.getInstance().adminChat( if ((herp.isOp() || mcPermissions.getInstance().adminChat(
@ -1302,7 +1354,7 @@ public class mcMMO extends JavaPlugin
/* /*
* MYSPAWN * MYSPAWN
*/ */
if(LoadProperties.myspawnEnable && LoadProperties.enableMySpawn && split[0].equalsIgnoreCase(LoadProperties.myspawn)){ else if(LoadProperties.myspawnEnable && LoadProperties.enableMySpawn && label.equalsIgnoreCase(LoadProperties.myspawn)){
if(!mcPermissions.getInstance().mySpawn(player)){ if(!mcPermissions.getInstance().mySpawn(player)){
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;
@ -1344,6 +1396,10 @@ public class mcMMO extends JavaPlugin
return false; return false;
} }
public boolean isConsole(CommandSender sender) {
return !(sender instanceof Player);
}
public Player getPlayer(String playerName){ public Player getPlayer(String playerName){
for(Player herp : getPlayersOnline()){ for(Player herp : getPlayersOnline()){
if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){ if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){