diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index d0c4309..4f61eed 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -24,6 +24,7 @@ import java.text.*; import me.kaZep.Commands.JobsDataInfo; import me.kaZep.Commands.JobsDataInfo.Job; import me.kaZep.Commands.commandBankEconomy; +import net.jmhertlein.mctowns.MCTowns; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; @@ -67,6 +68,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.ShapedRecipe; +import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.ItemMeta; @@ -84,6 +86,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitScheduler; +import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; import org.bukkit.enchantments.Enchantment; @@ -223,6 +226,10 @@ public class Main extends JavaPlugin cleaned=false; + if (Bukkit.getPluginManager().isPluginEnabled("MCTowns")) { + Bukkit.getLogger().info("MCTowns loaded."); + } + PluginDescriptionFile pdf = getDescription(); System.out.println("[" + getDescription().getName() + "] Status: Activated (mb: kaZep)"); System.out.println("[" + getDescription().getName() + "] PayDay: " + getConfig().getBoolean("payday.enabled")); @@ -577,11 +584,11 @@ public class Main extends JavaPlugin Color.fromRGB(133, 184, 133), Color.fromRGB(133, 184, 159), Color.fromRGB(159, 184, 133)), - "Thin and light armor made for" + + "Thin and light armor made for\n" + "nimble and precise movement.", - "When getting hit, you will gain" + + "When getting hit, you will gain\n" + "40% movement speed.", - "Every 20% of bonus movement speed" + + "Every 20% of bonus movement speed\n" + "gives you 10% block chance.", "When jumping, you cannot be hit."); ItemSetList.addSet(set); @@ -1064,6 +1071,7 @@ public class Main extends JavaPlugin public void onDisable() { + saveAccountsConfig(); getConfig().set("server-tick-time", Long.valueOf(SERVER_TICK_TIME)); saveConfig(); saveAccountsConfig(); @@ -1078,31 +1086,31 @@ public void onDisable() //Get list of all players on the server. OfflinePlayer playerlist[] = Bukkit.getOfflinePlayers(); for (int i=0;i=20) { - if (getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[0]) { + if (getAccountsConfig().contains(playerlist[i].getName().toLowerCase())) { + if (getAccountsConfig().contains(playerlist[i].getName().toLowerCase()+".spleefrating") && getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleefwins")+getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleeflosses")>=20) { + if (getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating")>rating[0]) { //This beats the top record, move everything down. name[2]=name[1];rating[2]=rating[1];wins[2]=wins[1];losses[2]=losses[1]; name[1]=name[0];rating[1]=rating[0];wins[1]=wins[0];losses[1]=losses[0]; - name[0]=playerlist[i].getName(); - rating[0]=(int)getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); - wins[0]=getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); - losses[0]=getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); + name[0]=playerlist[i].getName().toLowerCase(); + rating[0]=(int)getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating"); + wins[0]=getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleefwins"); + losses[0]=getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleeflosses"); } else - if (getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[1]) { + if (getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating")>rating[1]) { //This beats the 2nd record, move everything down. name[2]=name[1];rating[2]=rating[1];wins[2]=wins[1];losses[2]=losses[1]; - name[1]=playerlist[i].getName(); - rating[1]=(int)getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); - wins[1]=getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); - losses[1]=getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); + name[1]=playerlist[i].getName().toLowerCase(); + rating[1]=(int)getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating"); + wins[1]=getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleefwins"); + losses[1]=getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleeflosses"); } else - if (getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[2]) { + if (getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating")>rating[2]) { //This beats the 3rd record, move everything down. - name[2]=playerlist[i].getName(); - rating[2]=(int)getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); - wins[2]=getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); - losses[2]=getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); + name[2]=playerlist[i].getName().toLowerCase(); + rating[2]=(int)getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating"); + wins[2]=getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleefwins"); + losses[2]=getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleeflosses"); } } } @@ -1312,7 +1320,7 @@ public void runTick() { Player p = Bukkit.getOnlinePlayers()[zx]; //p.sendMessage("That's item slot #"+p.getInventory().getHeldItemSlot()); /* - if (p.getName().compareTo("sigonasr2")==0) { + if (p.getName().toLowerCase().compareTo("sigonasr2")==0) { //Packet61WorldEvent packet = new Packet61WorldEvent(2004, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 0, false); //((CraftPlayer)t).getHandle().netServerHandler.sendPacket(packet); @@ -1424,16 +1432,14 @@ public void runTick() { } } if (nearbylist2.size()<5) { - if (Math.random()<=0.2d) { - int l=0; - while (l<5) { - //CreatureSpawner spawner = (CreatureSpawner)Bukkit.getWorld("world").getBlockAt(p.getLocation().getBlockX()+i,p.getLocation().getBlockY()+k,p.getLocation().getBlockZ()+j).getState(); - Location testloc = new Location(Bukkit.getWorld("world"),spawner.getLocation().getX()+Math.random()*2-Math.random()*2,spawner.getLocation().getY()+Math.random()*5,spawner.getLocation().getZ()+Math.random()*2-Math.random()*2); - if (p.getNearbyEntities(15, 15, 5).size()<50 && Bukkit.getWorld("world").getBlockAt(testloc).getType()==Material.AIR || Bukkit.getWorld("world").getBlockAt(testloc).getType()==Material.WEB) { - Bukkit.getWorld("world").spawnCreature(testloc,spawner.getCreatureType()); - } - l++; + int l=0; + while (l<5) { + //CreatureSpawner spawner = (CreatureSpawner)Bukkit.getWorld("world").getBlockAt(p.getLocation().getBlockX()+i,p.getLocation().getBlockY()+k,p.getLocation().getBlockZ()+j).getState(); + Location testloc = new Location(Bukkit.getWorld("world"),spawner.getLocation().getX()+Math.random()*2-Math.random()*2,spawner.getLocation().getY()+Math.random()*5,spawner.getLocation().getZ()+Math.random()*2-Math.random()*2); + if (p.getNearbyEntities(15, 15, 5).size()<50 && Bukkit.getWorld("world").getBlockAt(testloc).getType()==Material.AIR || Bukkit.getWorld("world").getBlockAt(testloc).getType()==Material.WEB) { + Bukkit.getWorld("world").spawnCreature(testloc,spawner.getCreatureType()); } + l++; } } } @@ -2089,7 +2095,7 @@ public void runTick() { } } if (Main.SERVER_TICK_TIME%600==0) { - saveAccountsConfig(); + saveAccountsConfig(); //Save account data once every 30 seconds. if (turnedon==false && Bukkit.getWorld("world").getTime()>13000) { //Bukkit.getPlayer("sigonasr2").sendMessage("It's night now..."); turnedon=true; @@ -2123,7 +2129,7 @@ public void runTick() { if (getConfig().getBoolean("spleef4insession")) { //Check to see if we fall off. if ((p.getLocation().getX()<1585 || p.getLocation().getX()>1600 || p.getLocation().getZ()<24 || p.getLocation().getZ()>39 || p.getLocation().getY()<86.5d) && ( - (p.getName().compareTo(getConfig().getString("spleefrequesta4player"))==0 || p.getName().compareTo(getConfig().getString("spleefrequestb4player"))==0 + (p.getName().toLowerCase().compareTo(getConfig().getString("spleefrequesta4player"))==0 || p.getName().compareTo(getConfig().getString("spleefrequestb4player"))==0 || p.getName().compareTo(getConfig().getString("spleefrequestc4player"))==0 || p.getName().compareTo(getConfig().getString("spleefrequestd4player"))==0))) { //You lose. //See if we're the winner. @@ -2134,7 +2140,7 @@ public void runTick() { if (getConfig().getString("spleefrequesta4player").compareTo("none")==0) { countdead++; } else { - if (getConfig().getString("spleefrequesta4player").compareTo(p.getName())==0) { + if (getConfig().getString("spleefrequesta4player").compareTo(p.getName().toLowerCase())==0) { losingplayer=Bukkit.getPlayer(getConfig().getString("spleefrequesta4player")); } else { winningplayer=Bukkit.getPlayer(getConfig().getString("spleefrequesta4player")); @@ -2143,7 +2149,7 @@ public void runTick() { if (getConfig().getString("spleefrequestb4player").compareTo("none")==0) { countdead++; } else { - if (getConfig().getString("spleefrequestb4player").compareTo(p.getName())==0) { + if (getConfig().getString("spleefrequestb4player").compareTo(p.getName().toLowerCase())==0) { losingplayer=Bukkit.getPlayer(getConfig().getString("spleefrequestb4player")); } else { winningplayer=Bukkit.getPlayer(getConfig().getString("spleefrequestb4player")); @@ -2152,7 +2158,7 @@ public void runTick() { if (getConfig().getString("spleefrequestc4player").compareTo("none")==0) { countdead++; } else { - if (getConfig().getString("spleefrequestc4player").compareTo(p.getName())==0) { + if (getConfig().getString("spleefrequestc4player").compareTo(p.getName().toLowerCase())==0) { losingplayer=Bukkit.getPlayer(getConfig().getString("spleefrequestc4player")); } else { winningplayer=Bukkit.getPlayer(getConfig().getString("spleefrequestc4player")); @@ -2161,7 +2167,7 @@ public void runTick() { if (getConfig().getString("spleefrequestd4player").compareTo("none")==0) { countdead++; } else { - if (getConfig().getString("spleefrequestd4player").compareTo(p.getName())==0) { + if (getConfig().getString("spleefrequestd4player").compareTo(p.getName().toLowerCase())==0) { losingplayer=Bukkit.getPlayer(getConfig().getString("spleefrequestd4player")); } else { winningplayer=Bukkit.getPlayer(getConfig().getString("spleefrequestd4player")); @@ -2200,7 +2206,7 @@ public void runTick() { p.getInventory().clear(); p.getInventory().clear(p.getInventory().getHeldItemSlot()); //Give inventories back. - if (getConfig().getString("spleefrequesta4player").compareTo(p.getName())==0) { + if (getConfig().getString("spleefrequesta4player").compareTo(p.getName().toLowerCase())==0) { for (int i=0;i78.0d && p.getLocation().getZ()>53.0d && p.getLocation().getZ()<64.0d && p.getLocation().getX()<1627.0d && p.getLocation().getX()>1616.0d) { Location newloc = p.getLocation(); newloc.setX(1622.5d); @@ -2625,7 +2631,7 @@ public void runTick() { } public String healthbar(double curHP,double maxHP) { - //笆�笆� + //隨�ソス隨�ソス int bits=(int)(Math.ceil(curHP/maxHP*10)); String bar=" "; if (bits>6) { @@ -2647,7 +2653,7 @@ public String healthbar(double curHP,double maxHP) { } public String healthbar(double curHP,double maxHP,int hunger) { - //笆�笆� + //隨�ソス隨�ソス int bits=(int)(Math.ceil(curHP/maxHP*10)); String bar=" "; if (hunger>=17) { @@ -2705,7 +2711,7 @@ public void checkJukeboxes() { Player p = Bukkit.getPlayer(explorers.get(i).name); if (explorers.get(i).event==1 && Bukkit.getPlayer(explorers.get(i).name)!=null && !Bukkit.getPlayer(explorers.get(i).name).isDead()) { if (getJobLv("Explorer", p)>=10) { - PersistentExplorerList eve = new PersistentExplorerList(p.getName()); + PersistentExplorerList eve = new PersistentExplorerList(p.getName().toLowerCase()); eve.event=1; eve.data=p.getExp(); eve.data2=p.getLevel(); @@ -2713,12 +2719,12 @@ public void checkJukeboxes() { explorers.add(eve); } } - if (explorers.get(i).event==1 && explorers.get(i).name.compareTo(p.getName())==0) { + if (explorers.get(i).event==1 && explorers.get(i).name.compareTo(p.getName().toLowerCase())==0) { exppoint=i; //p.setTotalExperience(p.getTotalExperience()+explorers.get(j).data); //p.sendMessage("Your experience: "+explorers.get(i).data+"/"+p.getTotalExperience()); } else - if (explorers.get(i).event==2 && explorers.get(i).name.compareTo(p.getName())==0) { + if (explorers.get(i).event==2 && explorers.get(i).name.compareTo(p.getName().toLowerCase())==0) { deadpoint=i; } if (exppoint!=-1 && deadpoint!=-1) { @@ -2965,7 +2971,13 @@ public void checkJukeboxes() { } } } - list[i].getScoreboard().getTeam(list[i].getName()).setSuffix(healthbar(list[i].getHealth(),list[i].getMaxHealth(),list[i].getFoodLevel())); + list[i].getScoreboard().getTeam(list[i].getName().toLowerCase()).setSuffix(healthbar(list[i].getHealth(),list[i].getMaxHealth(),list[i].getFoodLevel())); + + /* Team t = list[i].getScoreboard().getTeam(list[i].getName()); + double hp = list[i].getHealth(); + double maxhp = list[i].getMaxHealth(); + int food = list[i].getFoodLevel(); + t.setSuffix(healthbar(hp, maxhp, food)); */ } LOGGING_UPDATE_COUNTS++; //3 for (int i=0;i"); DecimalFormat df = new DecimalFormat("#0.00"); allOnlineP.sendMessage(ChatColor.GOLD+"The money interest has been delivered to all players. ("+df.format((double)(Main.this.getConfig().getDouble("payday.amount")*100))+"% interest rate)"); - allOnlineP.sendMessage(ChatColor.GOLD+"Your Balance: $"+df.format((getAccountsConfig().getDouble(allOnlineP.getName() + ".money")))+" -> $"+df.format(((Main.this.getConfig().getDouble("payday.amount")*(getAccountsConfig().getDouble(allOnlineP.getName() + ".money"))+getAccountsConfig().getDouble(allOnlineP.getName() + ".money"))))); + allOnlineP.sendMessage(ChatColor.GOLD+"Your Balance: $"+df.format((getAccountsConfig().getDouble(allOnlineP.getName().toLowerCase() + ".money")))+" -> $"+df.format(((Main.this.getConfig().getDouble("payday.amount")*(getAccountsConfig().getDouble(allOnlineP.getName().toLowerCase() + ".money"))+getAccountsConfig().getDouble(allOnlineP.getName().toLowerCase() + ".money"))))); allOnlineP.sendMessage(ChatColor.DARK_GREEN+"<==========================>"); - getAccountsConfig().set(allOnlineP.getName() + ".money", ((Main.this.getConfig().getDouble("payday.amount")*(getAccountsConfig().getDouble(allOnlineP.getName() + ".money"))+getAccountsConfig().getDouble(allOnlineP.getName() + ".money")))); - //Main.economy.depositPlayer(allOnlineP.getName(), (Main.this.getConfig().getDouble("payday.amount")*Main.economy.bankBalance(allOnlineP.getName()).balance)); + getAccountsConfig().set(allOnlineP.getName().toLowerCase() + ".money", ((Main.this.getConfig().getDouble("payday.amount")*(getAccountsConfig().getDouble(allOnlineP.getName().toLowerCase() + ".money"))+getAccountsConfig().getDouble(allOnlineP.getName().toLowerCase() + ".money")))); + //Main.economy.depositPlayer(allOnlineP.getName().toLowerCase(), (Main.this.getConfig().getDouble("payday.amount")*Main.economy.bankBalance(allOnlineP.getName().toLowerCase()).balance)); } for (OfflinePlayer allOnlineP : Bukkit.getOfflinePlayers()) { if (!allOnlineP.isOnline()) { - getAccountsConfig().set(allOnlineP.getName() + ".money", ((Main.this.getConfig().getDouble("payday.amount")*(getAccountsConfig().getDouble(allOnlineP.getName() + ".money"))+getAccountsConfig().getDouble(allOnlineP.getName() + ".money")))); + getAccountsConfig().set(allOnlineP.getName().toLowerCase() + ".money", ((Main.this.getConfig().getDouble("payday.amount")*(getAccountsConfig().getDouble(allOnlineP.getName().toLowerCase() + ".money"))+getAccountsConfig().getDouble(allOnlineP.getName().toLowerCase() + ".money")))); } - //Main.economy.depositPlayer(allOnlineP.getName(), (Main.this.getConfig().getDouble("payday.amount")*Main.economy.bankBalance(allOnlineP.getName()).balance)); + //Main.economy.depositPlayer(allOnlineP.getName().toLowerCase(), (Main.this.getConfig().getDouble("payday.amount")*Main.economy.bankBalance(allOnlineP.getName().toLowerCase()).balance)); } //saveAccountsConfig() //Commented out; List expired_uuids = new ArrayList(); @@ -3668,6 +3680,13 @@ public void payDay(int time) p.sendMessage(ChatColor.GOLD+"Sorry, there are already "+getConfig().getInt("jobs.MAX_JOBS")+" people in this job!"); return false; } + if (getConfig().getInt("jobs."+ValidJobs[matchedjob])==0) { + //Simply set the string. + getConfig().set("jobs."+ValidJobs[matchedjob]+"_members",String.valueOf(p.getName().toLowerCase())); + } else { + //Append to list. + getConfig().set("jobs."+ValidJobs[matchedjob]+"_members",String.valueOf(getConfig().getString("jobs."+ValidJobs[matchedjob]+"_members")+", "+p.getName().toLowerCase())); + } if (getConfig().getInt("jobs."+ValidJobs[matchedjob])==0) { //Simply set the string. getConfig().set("jobs."+ValidJobs[matchedjob]+"_members",String.valueOf(p.getName().toLowerCase())); @@ -3691,7 +3710,7 @@ public void payDay(int time) } } if (ValidJobs[matchedjob].compareTo("Explorer")==0) { - explorerlist.add(new ExplorerData(p.getName(), p.getLocation().getX(), p.getLocation().getZ())); + explorerlist.add(new ExplorerData(p.getName().toLowerCase(), p.getLocation().getX(), p.getLocation().getZ())); } if (ValidJobs[matchedjob].compareTo("Support")==0) { supportplayers.add(new SupportPlayer(p)); @@ -3705,7 +3724,7 @@ public void payDay(int time) getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(openslot+1)+"exp", Double.valueOf(0)); //saveAccountsConfig() //Commented out; Bukkit.getLogger().info("Set job data."); - Bukkit.broadcastMessage(p.getName()+" has joined the "+JobColors[matchedjob]+ValidJobs[matchedjob]+ChatColor.WHITE+" job!"); + Bukkit.broadcastMessage(p.getName().toLowerCase()+" has joined the "+JobColors[matchedjob]+ValidJobs[matchedjob]+ChatColor.WHITE+" job!"); p.sendMessage("You can check out your job progress anytime with "+ChatColor.GOLD+"/jobs stats"+ChatColor.WHITE+"."); return true; } @@ -3715,11 +3734,13 @@ public void payDay(int time) } public String[] getJobs(String p) { + p=p.toLowerCase(); String[] string= {getAccountsConfig().getString(p.toLowerCase()+".jobs.job1"),getAccountsConfig().getString(p.toLowerCase()+".jobs.job2"),getAccountsConfig().getString(p.toLowerCase()+".jobs.job3")}; return string; } public boolean PlayerinJob(String p,String job) { + p=p.toLowerCase(); String[] jobs = getJobs(p); for (int i=0;i chestlore = new ArrayList(); + double rand = 1; // Randomly generated number determined by fair dice roll. + + if (tier == -1) { + rand = Math.random(); + // No argument, randomize + } + if (tier == 0) { + // Invalid chest, don't return anything + Bukkit.getLogger().warning("Invalid loot chest detected! This should never happen."); + return null; + } + + if (rand < 0.005 || tier == 2) { + // Generate a mythic chest + chest_name.setDisplayName(ChatColor.LIGHT_PURPLE+"Mythic Chest"); + + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+""); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"You feel powerful magic"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"emanating from within;"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"it must contain epic"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"equipment!"); + chest_name.setLore(chestlore); + + chest.setItemMeta(chest_name); + } else if (rand < 0.02 || tier == 3) { + // Generate a loaded goods chest + chest_name.setDisplayName(ChatColor.AQUA+"Heavy Chest"); + + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+""); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"It is very heavy; there"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"may be lots of loot within!"); + chest_name.setLore(chestlore); + + chest.setItemMeta(chest_name); + } else if (rand < 0.1 || tier == 4) { + // Generate a double chest + chest_name.setDisplayName(ChatColor.YELLOW+"Closed Chest"); + + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+""); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"You can feel a variety of"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"items rattling around inside."); + chest_name.setLore(chestlore); + + chest.setItemMeta(chest_name); + } else { + chest_name.setDisplayName(ChatColor.YELLOW+"Closed Chest"); + + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+""); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"Something is rattling"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"around inside; it may"); + chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"contain valuables!"); + chest_name.setLore(chestlore); + + chest.setItemMeta(chest_name); + } + + return chest; + } + public PlayerListener.Cube get_ItemCubeType(ItemStack item_cube) { if (item_cube.hasItemMeta() && item_cube.getItemMeta().hasLore()) { //Check to see if the Lore contains anything. diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java b/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java index 7f9e64d..e8729d5 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java @@ -266,7 +266,7 @@ public class PlayerBuffData { } money_gained=0; } - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); } } } diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index ddcb9d9..06494d6 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -20,6 +20,7 @@ import net.milkbowl.vault.economy.EconomyResponse; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; @@ -241,31 +242,31 @@ implements Listener //Get list of all players on the server. OfflinePlayer playerlist[] = Bukkit.getOfflinePlayers(); for (int i=0;i=20) { - if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[0]) { + if (this.plugin.getAccountsConfig().contains(playerlist[i].getName().toLowerCase())) { + if (this.plugin.getAccountsConfig().contains(playerlist[i].getName().toLowerCase()+".spleefrating") && this.plugin.getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleefwins")+this.plugin.getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleeflosses")>=20) { + if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating")>rating[0]) { //This beats the top record, move everything down. name[2]=name[1];rating[2]=rating[1];wins[2]=wins[1];losses[2]=losses[1]; name[1]=name[0];rating[1]=rating[0];wins[1]=wins[0];losses[1]=losses[0]; name[0]=playerlist[i].getName(); - rating[0]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); - wins[0]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); - losses[0]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); + rating[0]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating"); + wins[0]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleefwins"); + losses[0]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleeflosses"); } else - if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[1]) { + if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating")>rating[1]) { //This beats the 2nd record, move everything down. name[2]=name[1];rating[2]=rating[1];wins[2]=wins[1];losses[2]=losses[1]; name[1]=playerlist[i].getName(); - rating[1]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); - wins[1]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); - losses[1]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); + rating[1]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating"); + wins[1]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleefwins"); + losses[1]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleeflosses"); } else - if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating")>rating[2]) { + if (this.plugin.getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating")>rating[2]) { //This beats the 3rd record, move everything down. name[2]=playerlist[i].getName(); - rating[2]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName()+".spleefrating"); - wins[2]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleefwins"); - losses[2]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName()+".spleeflosses"); + rating[2]=(int)this.plugin.getAccountsConfig().getDouble(playerlist[i].getName().toLowerCase()+".spleefrating"); + wins[2]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleefwins"); + losses[2]=this.plugin.getAccountsConfig().getInt(playerlist[i].getName().toLowerCase()+".spleeflosses"); } } } @@ -322,7 +323,7 @@ implements Listener if (this.plugin.getAccountsConfig().getBoolean("halloween-enabled")) { e.setAmount(e.getAmount()*2); } - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify3")) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify3")) { p.sendMessage(ChatColor.DARK_GREEN+""+ChatColor.ITALIC+"Gained "+e.getAmount()+" exp."); } } @@ -964,7 +965,7 @@ implements Listener this.plugin.animallist.add(new EntityInteractData(e.getRightClicked().getUniqueId(), p.getName())); } else { //Modify the owner. - this.plugin.animallist.get(slot).setOwner(p.getName()); + this.plugin.animallist.get(slot).setOwner(p.getName().toLowerCase()); } if (p.getItemInHand().getType()==Material.WHEAT) { if (e.getRightClicked().getType()==EntityType.COW) { @@ -1411,11 +1412,11 @@ implements Listener } else { Bukkit.getWorld("world").setDifficulty(Difficulty.HARD); } - if (p.getScoreboard().getTeam(p.getName())!=null) { - tempteam=p.getScoreboard().getTeam(p.getName()); + if (p.getScoreboard().getTeam(p.getName().toLowerCase())!=null) { + tempteam=p.getScoreboard().getTeam(p.getName().toLowerCase()); tempteam.unregister(); } - tempteam=p.getScoreboard().registerNewTeam(p.getName()); + tempteam=p.getScoreboard().registerNewTeam(p.getName().toLowerCase()); if (p.hasPermission("group.moderator")) { tempteam.setPrefix(ChatColor.GREEN+""); } @@ -1443,7 +1444,7 @@ implements Listener p.getInventory().getArmorContents()[i].setItemMeta(meta); } } - /*if (p.getName().equalsIgnoreCase("AaMay")) { + /*if (p.getName().toLowerCase().equalsIgnoreCase("AaMay")) { p.removePotionEffect(PotionEffectType.SPEED); } */ @@ -1511,7 +1512,7 @@ implements Listener } String name = players.next().getName(); playerslist += name; - if (name.compareToIgnoreCase(p.getName())==0) { + if (name.compareToIgnoreCase(p.getName().toLowerCase())==0) { playerwhitelisted=true; } } @@ -1539,55 +1540,55 @@ implements Listener */ //System.out.println("Whitelisted Players: "+playerslist); //System.out.println("Maximum Air: "+p.getMaximumAir()); - if (!this.plugin.getAccountsConfig().contains(p.getName())) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase())) { //This is a brand new player. - Main.economy.withdrawPlayer(p.getName(), Main.economy.getBalance(p.getName())); - Main.economy.depositPlayer(p.getName(), 70); - this.plugin.getAccountsConfig().set(p.getName() + ".status", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".money", Double.valueOf(this.plugin.getConfig().getDouble("start-balance"))); - this.plugin.getAccountsConfig().set(p.getName() + ".revived", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".spleefrating", Double.valueOf(1000.0d)); - this.plugin.getAccountsConfig().set(p.getName() + ".spleefwins", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".spleeflosses", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job1", String.valueOf("None")); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job1lv", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job1exp", Double.valueOf(0.0d)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job2", String.valueOf("None")); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job2lv", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job2exp", Double.valueOf(0.0d)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job3", String.valueOf("None")); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job3lv", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.job3exp", Double.valueOf(0.0d)); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.ultimate", String.valueOf("None")); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.ultimatesealed", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat1", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat2", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat3", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat4", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat5", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat6", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat7", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat8", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat9", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat10", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify1", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify2", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify3", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify4", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify5", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify6", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest1", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest2", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest3", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest4", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest5", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest6", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest7", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest8", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest9", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest10", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName()+".bonus.witherskeleton", Integer.valueOf(0)); - this.plugin.saveAccountsConfig(); + Main.economy.withdrawPlayer(p.getName().toLowerCase(), Main.economy.getBalance(p.getName().toLowerCase())); + Main.economy.depositPlayer(p.getName().toLowerCase(), 70); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".status", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".money", Double.valueOf(this.plugin.getConfig().getDouble("start-balance"))); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".revived", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".spleefrating", Double.valueOf(1000.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".spleefwins", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".spleeflosses", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1", String.valueOf("None")); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1lv", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2", String.valueOf("None")); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2lv", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3", String.valueOf("None")); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3lv", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimate", String.valueOf("None")); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimatesealed", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat1", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat2", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat3", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat4", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat5", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat6", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat7", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat8", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat9", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat10", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify1", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify2", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify3", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify4", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify5", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify6", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest1", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest2", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest3", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest4", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest5", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest6", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest7", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest8", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest9", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest10", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".bonus.witherskeleton", Integer.valueOf(0)); + //this.plugin.saveAccountsConfig(); System.out.println("[BankEconomy] Bank account created for " + p.getName() + "."); if (playerwhitelisted) { Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE+"New player "+ChatColor.ITALIC+ChatColor.GOLD+p.getName()+ChatColor.RESET+ChatColor.LIGHT_PURPLE+" has joined the game."); @@ -1606,35 +1607,35 @@ implements Listener DecimalFormat df = new DecimalFormat("#0.00"); p.sendMessage(ChatColor.DARK_AQUA+"For a list of all changes made to this server, visit: http://z-gamers.net/changelog.html"); p.sendMessage("----------------------------"); - p.sendMessage(ChatColor.YELLOW+"Current Money Balance: $ "+df.format(Main.economy.bankBalance(p.getName()).balance)+", Bank Balance: $"+df.format(this.plugin.getAccountsConfig().getDouble(p.getName()+".money"))); + p.sendMessage(ChatColor.YELLOW+"Current Money Balance: $ "+df.format(Main.economy.bankBalance(p.getName().toLowerCase()).balance)+", Bank Balance: $"+df.format(this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase()+".money"))); //Update account information for the stat point update. - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".bonus.witherskeleton")) { - this.plugin.getAccountsConfig().set(p.getName()+".bonus.witherskeleton", Integer.valueOf(0)); - this.plugin.saveAccountsConfig(); - } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".stats.stat1")) { - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat1", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat2", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat3", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat4", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat5", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat6", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat7", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat8", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat9", Integer.valueOf(0)); - this.plugin.getAccountsConfig().set(p.getName() + ".stats.stat10", Integer.valueOf(0)); - this.plugin.saveAccountsConfig(); + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".bonus.witherskeleton")) { + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".bonus.witherskeleton", Integer.valueOf(0)); + //this.plugin.saveAccountsConfig(); + } + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".stats.stat1")) { + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat1", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat2", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat3", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat4", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat5", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat6", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat7", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat8", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat9", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat10", Integer.valueOf(0)); + //this.plugin.saveAccountsConfig(); System.out.println("Updated " + p.getName() + "'s data with stat point update."); } //Update account information for notification settings. - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".settings.notify1")) { - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify1", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify2", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify3", Boolean.valueOf(true)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify4", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify5", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".settings.notify6", Boolean.valueOf(false)); - this.plugin.saveAccountsConfig(); + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".settings.notify1")) { + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify1", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify2", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify3", Boolean.valueOf(true)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify4", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify5", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify6", Boolean.valueOf(false)); + //this.plugin.saveAccountsConfig(); System.out.println("Updated " + p.getName() + "'s data with nofitications update."); } if (this.plugin.getConfig().getBoolean("halloween-enabled")) { @@ -1648,9 +1649,9 @@ implements Listener } } if (!full) { - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".join.halloween_book")) { - this.plugin.getAccountsConfig().set(p.getName() + ".join.halloween_book", Boolean.valueOf(true)); - this.plugin.saveAccountsConfig(); + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_book")) { + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".join.halloween_book", Boolean.valueOf(true)); + //this.plugin.saveAccountsConfig(); System.out.println("Updated " + p.getName() + "'s data with a Halloween Book."); ItemStack book = new ItemStack(Material.WRITTEN_BOOK); BookMeta bookdata = (BookMeta)book.getItemMeta(); @@ -1666,9 +1667,9 @@ implements Listener book.setItemMeta(bookdata); p.getInventory().addItem(book); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".join.halloween_vote_signs")) { - this.plugin.getAccountsConfig().set(p.getName() + ".join.halloween_vote_signs", Boolean.valueOf(true)); - this.plugin.saveAccountsConfig(); + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_vote_signs")) { + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".join.halloween_vote_signs", Boolean.valueOf(true)); + //this.plugin.saveAccountsConfig(); ItemStack sign = new ItemStack(Material.SIGN,2); ItemMeta meta = sign.getItemMeta(); meta.setDisplayName(ChatColor.BLUE+p.getName()); @@ -1677,31 +1678,31 @@ implements Listener p.sendMessage("You have received 2 vote signs. Go vote at the Pumpkin Patch for the best pumpkin! (Note that voting for yourself does not count. Please vote the best of the others' pumpkins.)"); } } else { - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".join.halloween_vote_signs")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_vote_signs")) { p.sendMessage("You do not have enough room in your inventory to receive Pumpkin vote signs. Clear some of your inventory and then rejoin."); } } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".halloween.chest1")) { - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest1", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest2", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest3", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest4", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest5", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest6", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest7", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest8", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest9", Boolean.valueOf(false)); - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.chest10", Boolean.valueOf(false)); - this.plugin.saveAccountsConfig(); + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".halloween.chest1")) { + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest1", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest2", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest3", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest4", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest5", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest6", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest7", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest8", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest9", Boolean.valueOf(false)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest10", Boolean.valueOf(false)); + //this.plugin.saveAccountsConfig(); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".jobs.ultimate")) { - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.ultimate", String.valueOf("None")); - this.plugin.getAccountsConfig().set(p.getName() + ".jobs.ultimatesealed", Boolean.valueOf(false)); - this.plugin.saveAccountsConfig(); + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".jobs.ultimate")) { + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimate", String.valueOf("None")); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimatesealed", Boolean.valueOf(false)); + //this.plugin.saveAccountsConfig(); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".halloween.wand")) { - this.plugin.getAccountsConfig().set(p.getName() + ".halloween.wand", Long.valueOf(Main.SERVER_TICK_TIME)); - this.plugin.saveAccountsConfig(); + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".halloween.wand")) { + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.wand", Long.valueOf(Main.SERVER_TICK_TIME)); + //this.plugin.saveAccountsConfig(); } } //Check if this player has unallocated stat points. @@ -1711,8 +1712,8 @@ implements Listener p.sendMessage(ChatColor.GOLD+""); } //Set Stat Point specific stuff here. - if (this.plugin.getAccountsConfig().getInt(p.getName() + ".stats.stat10")>0) { - p.setMaximumAir(300+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName() + ".stats.stat10"))*20); + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase() + ".stats.stat10")>0) { + p.setMaximumAir(300+this.plugin.getStatBonus(9, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase() + ".stats.stat10"))*20); } if (p.getLocation().getY()>78.0d && p.getLocation().getZ()>53.0d && p.getLocation().getZ()<64.0d && p.getLocation().getX()<1627.0d && p.getLocation().getX()>1616.0d) { //In a spleef zone. Kick this player out. @@ -1726,7 +1727,7 @@ implements Listener } boolean found=false; for (int i=0;i20*levelsmult) { if (totallvs<40*levelsmult) { + //Can't have baby zombies at this level. + if (e.getEntity().getType()==EntityType.ZOMBIE) { + Zombie z = (Zombie)e.getEntity(); + if (z.isBaby()) { + z.setBaby(false); + } + } //Sometimes wear leather armor. Only for Skeletons and Zombies. if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { LivingEntity l = (LivingEntity) e.getEntity(); @@ -2463,6 +2471,13 @@ implements Listener } } else if (totallvs<60*levelsmult) { + //Can't have baby zombies at this level. + if (e.getEntity().getType()==EntityType.ZOMBIE) { + Zombie z = (Zombie)e.getEntity(); + if (z.isBaby()) { + z.setBaby(false); + } + } //Wear leather armor a bit more often. Sometimes a chain piece here or there. Include a Wooden sword usually. if (e.getEntity().getType()==EntityType.SKELETON || e.getEntity().getType()==EntityType.ZOMBIE) { LivingEntity l = (LivingEntity) e.getEntity(); @@ -3036,6 +3051,15 @@ implements Listener } } } + + if (e.getEntity() instanceof Zombie) { + Zombie z = (Zombie)e.getEntity(); + if (z.isBaby() && z.getCustomName()!=null && !z.getCustomName().contains("Ninja")) { + //Can't have weird special baby zombies. + z.setBaby(false); + } + } + if (e.getEntity().getType()==EntityType.EXPERIENCE_ORB) { Bukkit.getWorld("world").spawnEntity(e.getEntity().getLocation(),e.getEntity().getType()); } @@ -4068,10 +4092,10 @@ implements Listener if ((e.getBlock().getX()==1585 && e.getBlock().getZ()>=24 && e.getBlock().getZ()<=39) || (e.getBlock().getX()==1600 && e.getBlock().getZ()>=24 && e.getBlock().getZ()<=39) || (e.getBlock().getZ()==24 && e.getBlock().getX()>=1585 && e.getBlock().getX()<=1600) || (e.getBlock().getZ()==39 && e.getBlock().getX()>=1585 && e.getBlock().getX()<=1600)) { e.setCancelled(true); } - if (this.plugin.getConfig().getBoolean("spleefinsession")==true && (this.plugin.getConfig().getString("spleefrequestaplayer").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestbplayer").compareTo(p.getName())==0)) { + if (this.plugin.getConfig().getBoolean("spleefinsession")==true && (this.plugin.getConfig().getString("spleefrequestaplayer").compareTo(p.getName().toLowerCase())==0 || this.plugin.getConfig().getString("spleefrequestbplayer").compareTo(p.getName().toLowerCase())==0)) { this.plugin.spleef_last_broken_block=p.getPlayerTime(); } - if (this.plugin.getConfig().getBoolean("spleef4insession")==true && (this.plugin.getConfig().getString("spleefrequesta4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestb4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestc4player").compareTo(p.getName())==0 || this.plugin.getConfig().getString("spleefrequestd4player").compareTo(p.getName())==0)) { + if (this.plugin.getConfig().getBoolean("spleef4insession")==true && (this.plugin.getConfig().getString("spleefrequesta4player").compareTo(p.getName().toLowerCase())==0 || this.plugin.getConfig().getString("spleefrequestb4player").compareTo(p.getName().toLowerCase())==0 || this.plugin.getConfig().getString("spleefrequestc4player").compareTo(p.getName().toLowerCase())==0 || this.plugin.getConfig().getString("spleefrequestd4player").compareTo(p.getName().toLowerCase())==0)) { this.plugin.spleef4_last_broken_block=p.getPlayerTime(); } if (p.getItemInHand()!=null && p.getItemInHand().getItemMeta()!=null && p.getItemInHand().getItemMeta().hasDisplayName()==true && p.getItemInHand().getItemMeta().getDisplayName().compareTo("Spleef Wooden Shovel")==0) { @@ -4159,12 +4183,12 @@ implements Listener Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { @Override public void run() { - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); } },5); if (e.getItem().getType()==Material.MILK_BUCKET) { for (int i=0;i effects = e.getPotion().getEffects().iterator(); try { Collection effects = e.getPotion().getEffects(); @@ -4239,7 +4263,7 @@ implements Listener if (nextpotioneffect.getType().getName().compareTo("SPEED")==0) { this.plugin.gainMoneyExp(shooter,"Support",0.15,6); for (int i=0;ip.getMaxHealth()) { @@ -4291,7 +4315,7 @@ implements Listener if (nextpotioneffect.getType().getName().compareTo("SPEED")==0) { this.plugin.gainMoneyExp(shooter,"Support",0.15,6); for (int i=0;i chestlore = new ArrayList(); - chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!"); - chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+""); - chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"It feels heavy; there"); - chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"might be items inside."); - chest_name.setLore(chestlore); - - chest.setItemMeta(chest_name); - - f.getWorld().dropItemNaturally(f.getLocation(), chest); + f.getWorld().dropItemNaturally(f.getLocation(), this.plugin.generate_LootChest()); + } + if (f instanceof Zombie) { + Zombie z = (Zombie)f; + if (z.isBaby()) { + //Randomly drop a loot chest sometimes. (4.5% of the time.) + if (Math.random() <= 0.045) { + z.getWorld().dropItemNaturally(z.getLocation(), this.plugin.generate_LootChest()); + } + } } //if (Math.random()<=0.005) { /* @@ -6684,7 +6859,7 @@ implements Listener this.plugin.gainMoneyExp(p,"Hunter",275.00,7800); } } - if (this.plugin.getAccountsConfig().getBoolean(p.getName()+".settings.notify3")) { + if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify3")) { p.sendMessage(ChatColor.DARK_GREEN+""+ChatColor.ITALIC+"Gained "+e.getDroppedExp()+" exp."); } if (this.plugin.getConfig().getBoolean("halloween-enabled") && p.getWorld().getName().equalsIgnoreCase("world") && (e.getEntity() instanceof Sheep)) { @@ -6723,11 +6898,11 @@ implements Listener Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { @Override public void run() { - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); } },5); - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9")>0) { - if (Math.random()<=this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat9"))/100.0d) { + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9")>0) { + if (Math.random()<=this.plugin.getStatBonus(8, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat9"))/100.0d) { e.setFoodLevel(e.getFoodLevel()+1); } } @@ -6824,6 +6999,10 @@ implements Listener @EventHandler public void onFishCatch(PlayerFishEvent e) { if (e.getState()==State.CAUGHT_FISH) { + if (this.plugin.getConfig().getBoolean("thanksgiving-enabled") && Math.random() < 0.10) { + // 5% chance of fishing up a loot chest + e.getPlayer().getWorld().dropItemNaturally(e.getPlayer().getLocation(), this.plugin.generate_LootChest()); + } Player p = e.getPlayer(); if (this.plugin.PlayerinJob(p, "Fisherman")) { this.plugin.gainMoneyExp(p,"Fisherman",0.175,3); @@ -7053,26 +7232,26 @@ implements Listener } // 笆�笆�(Player)e.getPlayer()).sendMessage(((Player)e.getPlayer()).getScoreboard().getPlayerTeam((OfflinePlayer)e.getPlayer()).getName()); Player p = (Player)e.getPlayer(); - p.getScoreboard().getTeam(p.getName()).setPrefix(ChatColor.DARK_GRAY+""); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(ChatColor.DARK_GRAY+""); if (p.hasPermission("group.moderator")) { - p.getScoreboard().getTeam(p.getName()).setPrefix(ChatColor.DARK_GREEN+""); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(ChatColor.DARK_GREEN+""); } if (p.hasPermission("group.administrators")) { - p.getScoreboard().getTeam(p.getName()).setPrefix(ChatColor.DARK_PURPLE+""); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(ChatColor.DARK_PURPLE+""); } if (this.plugin.getConfig().getBoolean("halloween-enabled")) { for (int m=0;m0) { - p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, (this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat6"))/3)*20, 0)); + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6")>0) { + p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, (this.plugin.getStatBonus(5, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat6"))/3)*20, 0)); } } } @@ -7414,7 +7593,7 @@ implements Listener public void onRegainHealth(EntityRegainHealthEvent e) { if (e.getEntity().getType()==EntityType.PLAYER) { final Player p = (Player)e.getEntity(); - p.getScoreboard().getTeam(p.getName()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); boolean regen_high=false; int duration=0; if (e.getRegainReason()==RegainReason.MAGIC_REGEN) { @@ -7449,8 +7628,8 @@ implements Listener }, 1L); } } - if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")>0) { - e.setAmount(e.getAmount()+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat1")/6)); + if (this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")>0) { + e.setAmount(e.getAmount()+this.plugin.getStatBonus(0, this.plugin.getAccountsConfig().getInt(p.getName().toLowerCase()+".stats.stat1")/6)); } } } @@ -7729,12 +7908,12 @@ implements Listener //Check to see if our "fatal s urvivor" effect is available. boolean survivor=false; for (int i=0;i 1) { e.getItemInHand().setAmount(e.getItemInHand().getAmount() - 1); } else { e.getPlayer().setItemInHand(null); } - e.getPlayer().getWorld().dropItemNaturally(e.getBlockPlaced().getLocation(), getGoodie()); + // e.getPlayer().getWorld().dropItemNaturally(e.getBlockPlaced().getLocation(), getGoodie()); + p.sendMessage(ChatColor.GREEN+"You open the chest and find treasure inside!"); p.playSound(p.getLocation(), Sound.ORB_PICKUP, 10, 1); p.updateInventory(); @@ -9488,12 +9671,12 @@ implements Listener public void onInventoryCloseEvent(InventoryCloseEvent e) { Player p = (Player)e.getPlayer(); //Bukkit.getLogger().info("GEt close inventory event."); - p.getScoreboard().getTeam(p.getName()).setPrefix(ChatColor.WHITE+""); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(ChatColor.WHITE+""); if (p.hasPermission("group.moderator")) { - p.getScoreboard().getTeam(p.getName()).setPrefix(ChatColor.GREEN+""); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(ChatColor.GREEN+""); } if (p.hasPermission("group.administrators")) { - p.getScoreboard().getTeam(p.getName()).setPrefix(ChatColor.LIGHT_PURPLE+""); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(ChatColor.LIGHT_PURPLE+""); } if (e.getInventory().getName().contains("Item Cube")) { int identifier=-1; @@ -9514,13 +9697,13 @@ implements Listener if (e.getInventory().getTitle().equalsIgnoreCase("Notification Options")) { //We have to save the notification settings for this player. FileConfiguration savefile = this.plugin.getAccountsConfig(); - savefile.set(p.getName()+".settings.notify1", Boolean.valueOf(e.getInventory().getItem(2).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify2", Boolean.valueOf(e.getInventory().getItem(6).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify3", Boolean.valueOf(e.getInventory().getItem(11).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify4", Boolean.valueOf(e.getInventory().getItem(15).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify5", Boolean.valueOf(e.getInventory().getItem(20).getType()==Material.REDSTONE_TORCH_ON)); - savefile.set(p.getName()+".settings.notify6", Boolean.valueOf(e.getInventory().getItem(24).getType()==Material.REDSTONE_TORCH_ON)); - this.plugin.saveAccountsConfig(); + savefile.set(p.getName().toLowerCase()+".settings.notify1", Boolean.valueOf(e.getInventory().getItem(2).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify2", Boolean.valueOf(e.getInventory().getItem(6).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify3", Boolean.valueOf(e.getInventory().getItem(11).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify4", Boolean.valueOf(e.getInventory().getItem(15).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify5", Boolean.valueOf(e.getInventory().getItem(20).getType()==Material.REDSTONE_TORCH_ON)); + savefile.set(p.getName().toLowerCase()+".settings.notify6", Boolean.valueOf(e.getInventory().getItem(24).getType()==Material.REDSTONE_TORCH_ON)); + //this.plugin.saveAccountsConfig(); } if (e.getInventory().getTitle().equalsIgnoreCase("Repair and Enchant")) { // We have to return the items the player placed inside the anvil @@ -10750,7 +10933,7 @@ implements Listener } if (this.plugin.getJobLv("Cook", p)>=10 && crafteditem==true) { //This is an ugly fix for the problem...But it works somehow. - //Player newp = Bukkit.getPlayer(p.getName()); + //Player newp = Bukkit.getPlayer(p.getName().toLowerCase()); p.getInventory().addItem(new ItemStack(item.getType(),amount,item.getDurability(),item.getData().getData())); } } @@ -11779,7 +11962,7 @@ implements Listener if (this.plugin.getConfig().getBoolean("spleef4insession")) { //Check to see if we fall off. if ((p.getLocation().getX()<1585 || p.getLocation().getX()>1600 || p.getLocation().getZ()<24 || p.getLocation().getZ()>39 || p.getLocation().getY()<86.5d) && ( - (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequesta4player"))==0 || p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestb4player"))==0 + (p.getName().toLowerCase().compareTo(this.plugin.getConfig().getString("spleefrequesta4player"))==0 || p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestb4player"))==0 || p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestc4player"))==0 || p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestd4player"))==0))) { //You lose. //See if we're the winner. @@ -11790,7 +11973,7 @@ implements Listener if (this.plugin.getConfig().getString("spleefrequesta4player").compareTo("none")==0) { countdead++; } else { - if (this.plugin.getConfig().getString("spleefrequesta4player").compareTo(p.getName())==0) { + if (this.plugin.getConfig().getString("spleefrequesta4player").compareTo(p.getName().toLowerCase())==0) { losingplayer=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequesta4player")); } else { winningplayer=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequesta4player")); @@ -11799,7 +11982,7 @@ implements Listener if (this.plugin.getConfig().getString("spleefrequestb4player").compareTo("none")==0) { countdead++; } else { - if (this.plugin.getConfig().getString("spleefrequestb4player").compareTo(p.getName())==0) { + if (this.plugin.getConfig().getString("spleefrequestb4player").compareTo(p.getName().toLowerCase())==0) { losingplayer=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestb4player")); } else { winningplayer=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestb4player")); @@ -11808,7 +11991,7 @@ implements Listener if (this.plugin.getConfig().getString("spleefrequestc4player").compareTo("none")==0) { countdead++; } else { - if (this.plugin.getConfig().getString("spleefrequestc4player").compareTo(p.getName())==0) { + if (this.plugin.getConfig().getString("spleefrequestc4player").compareTo(p.getName().toLowerCase())==0) { losingplayer=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestc4player")); } else { winningplayer=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestc4player")); @@ -11817,7 +12000,7 @@ implements Listener if (this.plugin.getConfig().getString("spleefrequestd4player").compareTo("none")==0) { countdead++; } else { - if (this.plugin.getConfig().getString("spleefrequestd4player").compareTo(p.getName())==0) { + if (this.plugin.getConfig().getString("spleefrequestd4player").compareTo(p.getName().toLowerCase())==0) { losingplayer=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestd4player")); } else { winningplayer=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestd4player")); @@ -11841,7 +12024,7 @@ implements Listener p.getInventory().clear(); p.getInventory().clear(p.getInventory().getHeldItemSlot()); //Give inventories back. - if (this.plugin.getConfig().getString("spleefrequesta4player").compareTo(p.getName())==0) { + if (this.plugin.getConfig().getString("spleefrequesta4player").compareTo(p.getName().toLowerCase())==0) { for (int i=0;i78.0d && p.getLocation().getZ()>53.0d && p.getLocation().getZ()<64.0d && p.getLocation().getX()<1627.0d && p.getLocation().getX()>1616.0d) { Location newloc = p.getLocation(); newloc.setX(1622.5d); @@ -12181,7 +12364,7 @@ implements Listener p.closeInventory(); } for (int i=0;i=10) { //Check to see if our "fatal s urvivor" effect is available. for (int i=0;i=20) { finalcost*=0.25; @@ -12673,10 +12857,10 @@ implements Listener //Deposit all the money into their account. val = this.plugin.economy.getBalance(e.getPlayer().getName()); this.plugin.economy.withdrawPlayer(e.getPlayer().getName(), val); - double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); - this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(mymoney+val)); - this.plugin.saveAccountsConfig(); - e.getPlayer().sendMessage(ChatColor.GREEN+"Deposited $" + df.format(val) + " into your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); + double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money"); + this.plugin.getAccountsConfig().set(e.getPlayer().getName().toLowerCase() + ".money", Double.valueOf(mymoney+val)); + //this.plugin.saveAccountsConfig(); + e.getPlayer().sendMessage(ChatColor.GREEN+"Deposited $" + df.format(val) + " into your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money"))); this.plugin.last_bank_deposit_use_time=0; } else { try { @@ -12686,10 +12870,10 @@ implements Listener //Deposit the money into their account. //this.plugin.economy.bankDeposit(e.getPlayer().getName(), val); this.plugin.economy.withdrawPlayer(e.getPlayer().getName(), val); - double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); - this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(mymoney+val)); - this.plugin.saveAccountsConfig(); - e.getPlayer().sendMessage(ChatColor.GREEN+"Deposited $" + df.format(val) + " into your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); + double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money"); + this.plugin.getAccountsConfig().set(e.getPlayer().getName().toLowerCase() + ".money", Double.valueOf(mymoney+val)); + //this.plugin.saveAccountsConfig(); + e.getPlayer().sendMessage(ChatColor.GREEN+"Deposited $" + df.format(val) + " into your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money"))); this.plugin.last_bank_deposit_use_time=0; } else { e.getPlayer().sendMessage(ChatColor.RED+"You are not holding that much! " + ChatColor.YELLOW +"Enter a value equal to or lower than $" + ChatColor.GREEN+ df.format(this.plugin.economy.getBalance(e.getPlayer().getName())) + "" + ChatColor.GRAY + ChatColor.ITALIC + " (Remember you can also use the word all)"); @@ -12707,27 +12891,27 @@ implements Listener double val=0; if (e.getMessage().equalsIgnoreCase("all")) { //Withdraw all the money in their account. - val = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); - this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(0)); - this.plugin.saveAccountsConfig(); + val = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money"); + this.plugin.getAccountsConfig().set(e.getPlayer().getName().toLowerCase() + ".money", Double.valueOf(0)); + //this.plugin.saveAccountsConfig(); this.plugin.economy.depositPlayer(e.getPlayer().getName(), val); - e.getPlayer().sendMessage(ChatColor.GREEN+"Withdrawed $" + df.format(val) + " from your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); + e.getPlayer().sendMessage(ChatColor.GREEN+"Withdrawed $" + df.format(val) + " from your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money"))); this.plugin.last_bank_withdraw_use_time=0; } else { try { val = Double.parseDouble(e.getMessage()); //Make sure the user is holding at least that much money. - if (this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money")>=val && val>0) { + if (this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money")>=val && val>0) { //Deposit the money into their account. //this.plugin.economy.bankDeposit(e.getPlayer().getName(), val); this.plugin.economy.depositPlayer(e.getPlayer().getName(), val); - double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"); - this.plugin.getAccountsConfig().set(e.getPlayer().getName() + ".money", Double.valueOf(mymoney-val)); - this.plugin.saveAccountsConfig(); - e.getPlayer().sendMessage(ChatColor.GREEN+"Withdrawed $" + df.format(val) + " from your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money"))); + double mymoney = this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money"); + this.plugin.getAccountsConfig().set(e.getPlayer().getName().toLowerCase() + ".money", Double.valueOf(mymoney-val)); + //this.plugin.saveAccountsConfig(); + e.getPlayer().sendMessage(ChatColor.GREEN+"Withdrawed $" + df.format(val) + " from your account. " + ChatColor.YELLOW + "New Bank Balance: $" + ChatColor.AQUA + df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money"))); this.plugin.last_bank_withdraw_use_time=0; } else { - e.getPlayer().sendMessage(ChatColor.RED+"You do not have that much! " + ChatColor.YELLOW +"Enter a value equal to or lower than $" + ChatColor.GREEN+ df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName() + ".money")) + "" + ChatColor.GRAY + ChatColor.ITALIC + " (Remember you can also use the word all)"); + e.getPlayer().sendMessage(ChatColor.RED+"You do not have that much! " + ChatColor.YELLOW +"Enter a value equal to or lower than $" + ChatColor.GREEN+ df.format(this.plugin.getAccountsConfig().getDouble(e.getPlayer().getName().toLowerCase() + ".money")) + "" + ChatColor.GRAY + ChatColor.ITALIC + " (Remember you can also use the word all)"); this.plugin.last_bank_withdraw_use_time=Main.SERVER_TICK_TIME; } } catch (NumberFormatException ex_e) { @@ -13009,7 +13193,7 @@ implements Listener //We have to attempt to insert the item in the Item Cube. Cube cube_type = null; int identifier=-1; - if (item_cube.getItemMeta().getLore()!=null) { + if (item_cube.getItemMeta().getLore()!=null && isItemCube(item_cube)) { //Check to see if the Lore contains anything. for (int i=0;i 1) { p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1); } else { p.setItemInHand(null); } - p.getWorld().dropItemNaturally(p.getLocation(), getGoodie()); + p.sendMessage(ChatColor.GREEN+"You open the chest and find treasure inside!"); p.playSound(p.getLocation(), Sound.ORB_PICKUP, 10, 1); p.updateInventory(); @@ -13582,7 +13770,7 @@ implements Listener }*/ //Bukkit.getWorld("world").createExplosion(p.getLocation().getX(),p.getLocation().getY(),p.getLocation().getZ(),3f,false,true); /* - if (p.getName().compareToIgnoreCase("AaMay")==0) { + if (p.getName().toLowerCase().compareToIgnoreCase("AaMay")==0) { LivingEntity f = (LivingEntity)Bukkit.getWorld("world").spawnEntity(p.getLocation(), EntityType.CREEPER); f.setCustomName(ChatColor.GOLD+"Destructive Creeper II"); f.setCustomNameVisible(true); @@ -13603,8 +13791,8 @@ implements Listener e.getItem().getType()==Material.RECORD_10 || e.getItem().getType()==Material.RECORD_11 || e.getItem().getType()==Material.RECORD_12 || e.getItem().getType()==Material.GOLD_RECORD || e.getItem().getType()==Material.GREEN_RECORD)) { - //if (p.getName().compareTo("sigonasr2")==0) {p.sendMessage("This is a jukebox.");} - //if (p.getName().compareTo("sigonasr2")==0) {p.sendMessage("Item in hand: "+e.getItem().getType().toString());} + //if (p.getName().toLowerCase().compareTo("sigonasr2")==0) {p.sendMessage("This is a jukebox.");} + //if (p.getName().toLowerCase().compareTo("sigonasr2")==0) {p.sendMessage("Item in hand: "+e.getItem().getType().toString());} boolean contains=false; for (int i=0;i400) { - if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400 && (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestbplayer"))!=0 || p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestbtime")>400)) { + if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400 && (p.getName().toLowerCase().compareTo(this.plugin.getConfig().getString("spleefrequestbplayer"))!=0 || p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestbtime")>400)) { Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.YELLOW+"Spleef Player "+p.getName()+" requested a game in slot A. Join within 20 seconds."); this.plugin.getConfig().set("spleefrequestatime", Double.valueOf(p.getPlayerTime())); - this.plugin.getConfig().set("spleefrequestaplayer", String.valueOf(p.getName())); + this.plugin.getConfig().set("spleefrequestaplayer", String.valueOf(p.getName().toLowerCase())); } } else { - if (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestbplayer"))!=0) { + if (p.getName().toLowerCase().compareTo(this.plugin.getConfig().getString("spleefrequestbplayer"))!=0) { //This is a confirmed Spleef game. int playerarating,playerbrating; Player playera,playerb; playera=p; this.plugin.getConfig().set("spleefrequestatime", Double.valueOf(p.getPlayerTime())); - this.plugin.getConfig().set("spleefrequestaplayer", String.valueOf(p.getName())); + this.plugin.getConfig().set("spleefrequestaplayer", String.valueOf(p.getName().toLowerCase())); playerb=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestbplayer")); if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")) { playerarating=(int)this.plugin.getAccountsConfig().getDouble(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")/10; @@ -13883,25 +14071,25 @@ implements Listener } } this.plugin.saveConfig(); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig(); } } else if (sign.getBlock().getX()==1620 && sign.getBlock().getY()==83 && sign.getBlock().getZ()==45) { //Side B Request. //If not requested already. if (!this.plugin.getConfig().getBoolean("spleefinsession")) { if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400) { - if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestbtime")>400 && (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestaplayer"))!=0 || p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400)) { + if (p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestbtime")>400 && (p.getName().toLowerCase().compareTo(this.plugin.getConfig().getString("spleefrequestaplayer"))!=0 || p.getPlayerTime()-this.plugin.getConfig().getDouble("spleefrequestatime")>400)) { Bukkit.broadcastMessage(ChatColor.RED+"[SPLEEF] "+ChatColor.YELLOW+"Spleef Player "+p.getName()+" requested a game in slot B. Join within 20 seconds."); this.plugin.getConfig().set("spleefrequestbtime", Double.valueOf(p.getPlayerTime())); - this.plugin.getConfig().set("spleefrequestbplayer", String.valueOf(p.getName())); + this.plugin.getConfig().set("spleefrequestbplayer", String.valueOf(p.getName().toLowerCase())); } } else { - if (p.getName().compareTo(this.plugin.getConfig().getString("spleefrequestaplayer"))!=0) { + if (p.getName().toLowerCase().compareTo(this.plugin.getConfig().getString("spleefrequestaplayer"))!=0) { //This is a confirmed Spleef game. int playerarating,playerbrating; Player playera,playerb; this.plugin.getConfig().set("spleefrequestbtime", Double.valueOf(p.getPlayerTime())); - this.plugin.getConfig().set("spleefrequestbplayer", String.valueOf(p.getName())); + this.plugin.getConfig().set("spleefrequestbplayer", String.valueOf(p.getName().toLowerCase())); playera=Bukkit.getPlayer(this.plugin.getConfig().getString("spleefrequestaplayer")); playerb=p; if (this.plugin.getAccountsConfig().contains(this.plugin.getConfig().getString("spleefrequestaplayer")+".spleefrating")) { @@ -13954,7 +14142,7 @@ implements Listener } } this.plugin.saveConfig(); - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig(); } } if (stats) { @@ -13963,22 +14151,22 @@ implements Listener /*double value = Double.parseDouble(arg0); double total = actMon + value; if (value <= actHand) { - this.plugin.getAccountsConfig().set(p.getName() + ".money", Double.valueOf(total)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".money", Double.valueOf(total)); this.plugin.saveAccountsConfig(); if (value <= 1) p.sendMessage("�ァ2[BankEconomy]" + ChatColor.AQUA + " You added " + value + " " + currencySG + " to your bank account."); else { p.sendMessage("�ァ2[BankEconomy]" + ChatColor.AQUA + " You added " + value + " " + currencyPL + " to your bank account."); } - Main.economy.withdrawPlayer(p.getName(), value); + Main.economy.withdrawPlayer(p.getName().toLowerCase(), value); } else { p.sendMessage("�ァ2[BankEconomy]" + ChatColor.AQUA + " Sorry, you can't deposit that amount of money."); }*/ //If they were using the withdraw bank before, clear them from it. - if (this.plugin.last_bank_withdraw_user.equalsIgnoreCase(p.getName())) { + if (this.plugin.last_bank_withdraw_user.equalsIgnoreCase(p.getName().toLowerCase())) { this.plugin.last_bank_withdraw_user=""; } - if (this.plugin.last_bank_deposit_use_time+200"+ChatColor.WHITE+" - Teleport to a player for a cost."); } else - if (cmd.getName().equalsIgnoreCase("settings")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("settings")) { Inventory i = Bukkit.createInventory(p, 27, "Notification Options"); int count=-1; ItemStack temp,on,off; @@ -398,12 +404,12 @@ public String convertToItemName(String val) { temp.setItemMeta(temp_meta);i.setItem(count+=3, temp);on.setItemMeta(temp_meta);off.setItemMeta(temp_meta); i.setItem(count+=1, (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify6")?on:off)); p.openInventory(i); } else - if (cmd.getName().equalsIgnoreCase("event")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("event")) { if (p.hasPermission("maintenance-mode-admin")) { p.sendMessage("Events available: halloween, thanksgiving. Use: /event "); } } else - if (cmd.getName().equalsIgnoreCase("maintenance")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("maintenance")) { if (p.hasPermission("maintenance-mode-admin")) { if (this.plugin.getConfig().getBoolean("maintenance-mode")) { this.plugin.getConfig().set("maintenance-mode", Boolean.valueOf(false)); @@ -415,13 +421,13 @@ public String convertToItemName(String val) { this.plugin.saveConfig(); } } else - if (cmd.getName().equalsIgnoreCase("transfer")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("transfer")) { p.sendMessage("Usage: "+ChatColor.RED+"/transfer name money"+ChatColor.WHITE+" - Transfer money to a player."); } else - if (cmd.getName().equalsIgnoreCase("revive")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("revive")) { p.sendMessage("Usage: "+ChatColor.RED+"/revive me "+ChatColor.WHITE+" - Revive to the last location you died at."); } else - if (cmd.getName().equalsIgnoreCase("unenchant")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("unenchant")) { Map map = p.getItemInHand().getEnchantments(); for (Map.Entry entry : map.entrySet()) { p.getItemInHand().removeEnchantment(entry.getKey()); @@ -483,11 +489,11 @@ public String convertToItemName(String val) { } } else - if (cmd.getName().equalsIgnoreCase("ticktime")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("ticktime")) { p.sendMessage("Current Server Time: "+ChatColor.GRAY+""+ChatColor.ITALIC+Main.SERVER_TICK_TIME); } else - if (cmd.getName().equalsIgnoreCase("jobs")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs")) { FileConfiguration config = this.plugin.getConfig(); int MAXJOBS = config.getInt("jobs.MAX_JOBS"); p.sendMessage(ChatColor.GOLD+" Blacksmith ("+config.getInt("jobs.Blacksmith")+"/"+MAXJOBS+")"); @@ -543,7 +549,7 @@ public String convertToItemName(String val) { "- Reloads config and accounts."); } } else - if (cmd.getName().equalsIgnoreCase("event") && args.length==1 && p.hasPermission("maintenance-mode-admin")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("event") && args.length==1 && p.hasPermission("maintenance-mode-admin")) { if (args[0].equalsIgnoreCase("halloween")) { if (this.plugin.getConfig().getBoolean("halloween-enabled")) { this.plugin.getConfig().set("halloween-enabled", Boolean.valueOf(false)); @@ -565,21 +571,7 @@ public String convertToItemName(String val) { this.plugin.saveConfig(); } if (args[0].equalsIgnoreCase("loot")) { - ItemStack chest = new ItemStack(Material.CHEST); - ItemMeta chest_name = chest.getItemMeta(); - chest_name.setDisplayName(ChatColor.YELLOW+"Closed Chest"); - - List chestlore = new ArrayList(); - chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!"); - chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+""); - chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"It feels heavy; there"); - chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"might be items inside."); - chest_name.setLore(chestlore); - - chest.setItemMeta(chest_name); - - p.getWorld().dropItemNaturally(p.getLocation(), chest); - } + p.getWorld().dropItemNaturally(p.getLocation(), this.plugin.generate_LootChest()); } if (args[0].equalsIgnoreCase("thanksgiving")) { if (this.plugin.getConfig().getBoolean("thanksgiving-enabled")) { this.plugin.getConfig().set("thanksgiving-enabled", Boolean.valueOf(false)); @@ -607,7 +599,7 @@ public String convertToItemName(String val) { p.getWorld().dropItemNaturally(p.getLocation(), chest); } } else - if (cmd.getName().equalsIgnoreCase("event") && args.length==2 && p.hasPermission("maintenance-mode-admin")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("event") && args.length==2 && p.hasPermission("maintenance-mode-admin")) { if (args[0].equalsIgnoreCase("head")) { ItemStack m = new ItemStack(Material.SKULL_ITEM, 64, (short)SkullType.PLAYER.ordinal()); SkullMeta skullMeta = (SkullMeta) m.getItemMeta(); @@ -1262,44 +1254,44 @@ public String convertToItemName(String val) { this.plugin.saveConfig(); } } else - if (cmd.getName().equalsIgnoreCase("dungeon") && p.hasPermission("maintenance-mode-admin") && args.length==1) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("dungeon") && p.hasPermission("maintenance-mode-admin") && args.length==1) { //Dungeon x = new Dungeon(new Location(Bukkit.getWorld("world"),-8990,0,-4),new Location(Bukkit.getWorld("world"),50,255,50),Integer.valueOf(args[0])); } else - if (cmd.getName().equalsIgnoreCase("transfer") && args.length==1) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("transfer") && args.length==1) { p.sendMessage("Usage: "+ChatColor.RED+"/transfer name money"+ChatColor.WHITE+" - Transfer money to a player."); } else - if (cmd.getName().equalsIgnoreCase("transfer") && args.length==2) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("transfer") && args.length==2) { double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", "")); Player target = p.getServer().getPlayer(args[0]); if (target == null) { p.sendMessage(this.prefix + " " + this.offlinePlayer); } - else if (target.getName() == p.getName()) { + else if (target.getName().toLowerCase() == p.getName().toLowerCase()) { p.sendMessage(this.prefix + " " + this.cmdTransferSameNick); } else if (amount > playerBankBalance) { p.sendMessage(this.prefix + " " + this.notEnoughMoney); } else if (amount <= playerBankBalance) { double totalWithdraw = playerBankBalance - amount; - double totalDeposit = amount + this.plugin.getAccountsConfig().getInt(target.getName() + ".money"); + double totalDeposit = amount + this.plugin.getAccountsConfig().getInt(target.getName().toLowerCase() + ".money"); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".money", Double.valueOf(totalWithdraw)); this.plugin.getAccountsConfig().set(target.getName() + ".money", Double.valueOf(totalDeposit)); this.plugin.saveAccountsConfig(); if (amount > 1.0D) { - p.sendMessage(this.prefix + " " + this.cmdTransferToPlayer1 + " " + amount + currencyPlural + " " + this.cmdTransferToPlayer2 + " " + target.getName() + "a."); - target.sendMessage(this.prefix + " b" + p.getName() + " " + this.cmdTransferToTarget1 + " " + amount + currencyPlural + "a."); + p.sendMessage(this.prefix + " " + this.cmdTransferToPlayer1 + " " + amount + currencyPlural + " " + this.cmdTransferToPlayer2 + " " + target.getName().toLowerCase() + "a."); + target.sendMessage(this.prefix + " b" + p.getName().toLowerCase() + " " + this.cmdTransferToTarget1 + " " + amount + currencyPlural + "a."); } else if (amount <= 1.0D) { - p.sendMessage(this.prefix + " " + this.cmdTransferToPlayer1 + " " + amount + currencySingular + " " + this.cmdTransferToPlayer2 + " " + target.getName() + "a."); - target.sendMessage(this.prefix + " b" + p.getName() + " " + this.cmdTransferToTarget1 + " " + amount + currencySingular + "a."); + p.sendMessage(this.prefix + " " + this.cmdTransferToPlayer1 + " " + amount + currencySingular + " " + this.cmdTransferToPlayer2 + " " + target.getName().toLowerCase() + "a."); + target.sendMessage(this.prefix + " b" + p.getName().toLowerCase() + " " + this.cmdTransferToTarget1 + " " + amount + currencySingular + "a."); } } } else - if (cmd.getName().equalsIgnoreCase("sp") && args.length==1) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("sp") && args.length==1) { try { int readvalue = Integer.valueOf(args[0]); if (readvalue<=10 && readvalue>=1) { @@ -1403,7 +1395,7 @@ public String convertToItemName(String val) { p.sendMessage(ChatColor.RED+"The inputted slot is not a valid number."); } } - else if (cmd.getName().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("info")) && (p.hasPermission("bankeconomy.info"))) { + else if (cmd.getName().toLowerCase().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("info")) && (p.hasPermission("bankeconomy.info"))) { if (args.length == 1) { if (playerBankBalance <= 1) p.sendMessage(this.prefix + " " + this.cmdInfo + " " + playerBankBalance + currencySingular + "a."); @@ -1413,7 +1405,7 @@ public String convertToItemName(String val) { else p.sendMessage(this.invARG); } - else if (cmd.getName().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("check")) && (p.hasPermission("bankeconomy.check"))) { + else if (cmd.getName().toLowerCase().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("check")) && (p.hasPermission("bankeconomy.check"))) { if (args.length == 1) { p.sendMessage(this.prefix + " " + this.usage + " " + this.cmdCheckARG1); } else if (args.length == 2) { @@ -1422,18 +1414,18 @@ public String convertToItemName(String val) { if (target == null) { p.sendMessage(this.prefix + " " + this.offlinePlayer); } else { - int targetBalance = this.plugin.getAccountsConfig().getInt(target.getName() + ".money"); + int targetBalance = this.plugin.getAccountsConfig().getInt(target.getName().toLowerCase() + ".money"); if (targetBalance <= 1) - p.sendMessage(this.prefix + "a " + target.getName() + this.cmdCheckReponsePlayer + " " + targetBalance + currencySingular); + p.sendMessage(this.prefix + "a " + target.getName().toLowerCase() + this.cmdCheckReponsePlayer + " " + targetBalance + currencySingular); else if (targetBalance > 1) - p.sendMessage(this.prefix + "a " + target.getName() + this.cmdCheckReponsePlayer + " " + targetBalance + currencyPlural); + p.sendMessage(this.prefix + "a " + target.getName().toLowerCase() + this.cmdCheckReponsePlayer + " " + targetBalance + currencyPlural); } } else { p.sendMessage(this.invARG); } - } else if (cmd.getName().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("reset")) && (p.hasPermission("bankeconomy.reset"))) { + } else if (cmd.getName().toLowerCase().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("reset")) && (p.hasPermission("bankeconomy.reset"))) { if (args.length == 1) { p.sendMessage(this.prefix + " " + this.usage + " " + this.cmdResetARG1); } else if (args.length == 2) { @@ -1442,11 +1434,11 @@ public String convertToItemName(String val) { if (target == null) { p.sendMessage(this.prefix + " " + this.offlinePlayer); } else { - this.plugin.getAccountsConfig().set(target.getName() + ".money", Integer.valueOf(0)); - this.plugin.saveAccountsConfig(); + this.plugin.getAccountsConfig().set(target.getName().toLowerCase() + ".money", Integer.valueOf(0)); + //this.plugin.saveAccountsConfig(); - p.sendMessage(this.prefix + " " + this.cmdResetToPlayer1 + " " + target.getName() + this.cmdResetToPlayer2); - target.sendMessage(this.prefix + " a" + p.getName() + " " + this.cmdResetToTarget); + p.sendMessage(this.prefix + " " + this.cmdResetToPlayer1 + " " + target.getName().toLowerCase() + this.cmdResetToPlayer2); + target.sendMessage(this.prefix + " a" + p.getName().toLowerCase() + " " + this.cmdResetToTarget); } } else { p.sendMessage(this.invARG); @@ -1461,7 +1453,7 @@ public String convertToItemName(String val) { } p.sendMessage(this.invARG); } - else if (cmd.getName().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("transfer")) && (p.hasPermission("bankeconomy.transfer"))) { + else if (cmd.getName().toLowerCase().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("transfer")) && (p.hasPermission("bankeconomy.transfer"))) { if (args.length == 1) { p.sendMessage(this.prefix + " " + this.usage + " " + this.cmdTransferARG1); } else if (args.length == 2) { @@ -1473,25 +1465,25 @@ public String convertToItemName(String val) { if (target == null) { p.sendMessage(this.prefix + " " + this.offlinePlayer); } - else if (target.getName() == p.getName()) { + else if (target.getName().toLowerCase() == p.getName().toLowerCase()) { p.sendMessage(this.prefix + " " + this.cmdTransferSameNick); } else if (amount > playerBankBalance) { p.sendMessage(this.prefix + " " + this.notEnoughMoney); } else if (amount <= playerBankBalance) { double totalWithdraw = playerBankBalance - amount; - double totalDeposit = amount + this.plugin.getAccountsConfig().getInt(target.getName() + ".money"); + double totalDeposit = amount + this.plugin.getAccountsConfig().getInt(target.getName().toLowerCase() + ".money"); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".money", Double.valueOf(totalWithdraw)); this.plugin.getAccountsConfig().set(target.getName() + ".money", Double.valueOf(totalDeposit)); this.plugin.saveAccountsConfig(); if (amount > 1.0D) { - p.sendMessage(this.prefix + " " + this.cmdTransferToPlayer1 + " " + amount + currencyPlural + " " + this.cmdTransferToPlayer2 + " " + target.getName() + "a."); - target.sendMessage(this.prefix + " b" + p.getName() + " " + this.cmdTransferToTarget1 + " " + amount + currencyPlural + "a."); + p.sendMessage(this.prefix + " " + this.cmdTransferToPlayer1 + " " + amount + currencyPlural + " " + this.cmdTransferToPlayer2 + " " + target.getName().toLowerCase() + "a."); + target.sendMessage(this.prefix + " b" + p.getName().toLowerCase() + " " + this.cmdTransferToTarget1 + " " + amount + currencyPlural + "a."); } else if (amount <= 1.0D) { - p.sendMessage(this.prefix + " " + this.cmdTransferToPlayer1 + " " + amount + currencySingular + " " + this.cmdTransferToPlayer2 + " " + target.getName() + "a."); - target.sendMessage(this.prefix + " b" + p.getName() + " " + this.cmdTransferToTarget1 + " " + amount + currencySingular + "a."); + p.sendMessage(this.prefix + " " + this.cmdTransferToPlayer1 + " " + amount + currencySingular + " " + this.cmdTransferToPlayer2 + " " + target.getName().toLowerCase() + "a."); + target.sendMessage(this.prefix + " b" + p.getName().toLowerCase() + " " + this.cmdTransferToTarget1 + " " + amount + currencySingular + "a."); } } } @@ -1499,7 +1491,7 @@ public String convertToItemName(String val) { { p.sendMessage(this.invARG); } - } else if (cmd.getName().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("edit")) && (p.hasPermission("bankeconomy.edit"))) { + } else if (cmd.getName().toLowerCase().equalsIgnoreCase("bankeconomy") && (args[0].equalsIgnoreCase("edit")) && (p.hasPermission("bankeconomy.edit"))) { if (args.length == 1) { p.sendMessage(this.prefix + " " + this.usage + " " + this.cmdEditARG1); p.sendMessage(this.prefix + " " + this.cmdEditAvaibleActions); @@ -1516,24 +1508,24 @@ public String convertToItemName(String val) { } else if (args[1].equalsIgnoreCase("status")) { if (amount == 1.0D) { - this.plugin.getAccountsConfig().set(target.getName() + ".status", Boolean.valueOf(true)); - this.plugin.saveAccountsConfig(); + this.plugin.getAccountsConfig().set(target.getName().toLowerCase() + ".status", Boolean.valueOf(true)); + //this.plugin.saveAccountsConfig(); - p.sendMessage(this.prefix + " " + this.cmdEditEnableToPlayer1 + " " + p.getName() + this.cmdEditEnableToPlayer2); + p.sendMessage(this.prefix + " " + this.cmdEditEnableToPlayer1 + " " + p.getName().toLowerCase() + this.cmdEditEnableToPlayer2); } else if (amount == 0.0D) { - this.plugin.getAccountsConfig().set(target.getName() + ".status", Boolean.valueOf(false)); - this.plugin.saveAccountsConfig(); + this.plugin.getAccountsConfig().set(target.getName().toLowerCase() + ".status", Boolean.valueOf(false)); + //this.plugin.saveAccountsConfig(); - p.sendMessage(this.prefix + " " + this.cmdEditDisabledToPlayer1 + " " + p.getName() + this.cmdEditDisabledToPlayer2); + p.sendMessage(this.prefix + " " + this.cmdEditDisabledToPlayer1 + " " + p.getName().toLowerCase() + this.cmdEditDisabledToPlayer2); } } else if (args[1].equalsIgnoreCase("balance")) { - this.plugin.getAccountsConfig().set(target.getName() + ".money", Double.valueOf(amount)); - this.plugin.saveAccountsConfig(); + this.plugin.getAccountsConfig().set(target.getName().toLowerCase() + ".money", Double.valueOf(amount)); + //this.plugin.saveAccountsConfig(); if (amount > 1.0D) - p.sendMessage(this.prefix + " " + this.cmdEditAmountSetPlayer1 + " b" + amount + currencyPlural + " " + this.cmdEditAmountSetPlayer2 + " " + target.getName() + this.cmdEditAmountSetPlayer3); + p.sendMessage(this.prefix + " " + this.cmdEditAmountSetPlayer1 + " b" + amount + currencyPlural + " " + this.cmdEditAmountSetPlayer2 + " " + target.getName().toLowerCase() + this.cmdEditAmountSetPlayer3); else if (amount <= 1.0D) - p.sendMessage(this.prefix + " " + this.cmdEditAmountSetPlayer1 + " b" + amount + currencySingular + " " + this.cmdEditAmountSetPlayer2 + " " + target.getName() + this.cmdEditAmountSetPlayer3); + p.sendMessage(this.prefix + " " + this.cmdEditAmountSetPlayer1 + " b" + amount + currencySingular + " " + this.cmdEditAmountSetPlayer2 + " " + target.getName().toLowerCase() + this.cmdEditAmountSetPlayer3); } else { p.sendMessage(this.prefix + " " + this.cmdEditAvaibleActions); @@ -1543,7 +1535,7 @@ public String convertToItemName(String val) { p.sendMessage(this.invARG); } } - else if (cmd.getName().equalsIgnoreCase("revive") && args[0].equalsIgnoreCase("me")) { + else if (cmd.getName().toLowerCase().equalsIgnoreCase("revive") && args[0].equalsIgnoreCase("me")) { DecimalFormat df = new DecimalFormat("#0.00"); double deathX = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".deathpointX"); double deathY = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".deathpointY"); @@ -1607,17 +1599,17 @@ public String convertToItemName(String val) { p2.setMaximumNoDamageTicks(20); } },100); - Bukkit.broadcastMessage(ChatColor.GREEN+p.getName()+ChatColor.WHITE+" decided to revive."); + Bukkit.broadcastMessage(ChatColor.GREEN+p.getName().toLowerCase()+ChatColor.WHITE+" decided to revive."); } else { p.sendMessage("You cannot revive. You need to have $"+df.format(finalcost)+" to do so."); } } else { p.sendMessage("You haven't died. So you cannot revive."); } - this.plugin.saveAccountsConfig(); + //this.plugin.saveAccountsConfig(); return true; } - else if (cmd.getName().equalsIgnoreCase("revive") && (args[0].equalsIgnoreCase("amount"))) { + else if (cmd.getName().toLowerCase().equalsIgnoreCase("revive") && (args[0].equalsIgnoreCase("amount"))) { DecimalFormat df = new DecimalFormat("#0.00"); double deathX = p.getLocation().getX(); double deathY = p.getLocation().getY(); @@ -1636,7 +1628,7 @@ public String convertToItemName(String val) { p.sendMessage("You need to have $"+df.format(finalcost)+" to revive."); return true; } - else if (cmd.getName().equalsIgnoreCase("tele") && (args[0].equalsIgnoreCase("to"))) { + else if (cmd.getName().toLowerCase().equalsIgnoreCase("tele") && (args[0].equalsIgnoreCase("to"))) { DecimalFormat df = new DecimalFormat("#0.00"); if (p.getPlayerTime()-this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".teletime")<400) { if (args.length==1) { @@ -1645,7 +1637,96 @@ public String convertToItemName(String val) { //Teleport. Player target = p.getServer().getPlayer(args[1]); if (target == null) { - p.sendMessage(this.prefix + " " + this.offlinePlayer); + //It could be a town name. Check + TownManager t = MCTownsPlugin.getPlugin().getTownManager(); + Bukkit.getLogger().info("Town Manager started:"+ t.toString()); + Town teleport_town = null; + Collection towns = t.getTownsCollection(); + for (Town towny : towns) { + if (towny!=null) { + if (towny.getTownName().equalsIgnoreCase(args[1])) { + teleport_town = towny; + break; + } else { + Bukkit.getLogger().info("This was town "+towny.getTownName()); + } + } + } + //Iterate through collection, seeing if we can find the town. + if (teleport_town == null) { + p.sendMessage(this.prefix + " " + this.offlinePlayer); + } else { + boolean is_in_vehicle = false; + Entity vehicle = null; + if (p.isInsideVehicle()) { + is_in_vehicle=true; + vehicle = p.getVehicle(); + } + if (teleport_town.getTownName().equalsIgnoreCase(this.plugin.getAccountsConfig().getString(p.getName().toLowerCase() + ".teleplayer"))) { + //Determine distance of player to other player. + double otherx = teleport_town.getSpawn(Bukkit.getServer()).getX(); + double othery = teleport_town.getSpawn(Bukkit.getServer()).getY(); + double otherz = teleport_town.getSpawn(Bukkit.getServer()).getZ(); + double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase().toLowerCase() + ".money"); + double finalcost = Math.abs(p.getLocation().getX()-otherx)+Math.abs(p.getLocation().getY()-othery)+Math.abs(p.getLocation().getZ()-otherz); + //Bukkit.getLogger().info("finalcost1:"+finalcost); + finalcost *= this.plugin.getConfig().getDouble("teleport-cost-rate"); + //Bukkit.getLogger().info("finalcost2:"+finalcost); + finalcost += finalcost * 15 * ((p.getMaxHealth()-p.getHealth())/p.getMaxHealth()); + //Bukkit.getLogger().info("finalcost3:"+finalcost); + //finalcost += mymoney*this.plugin.getConfig().getDouble("teleport-cost-tax"); + if (mymoney>=finalcost) { + //Allow teleport to occur. + this.plugin.getAccountsConfig().set(p.getName().toLowerCase().toLowerCase() + ".money", mymoney-finalcost); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase().toLowerCase() + ".teletime", Double.valueOf(0.0d)); + //this.plugin.saveAccountsConfig(); + if (this.plugin.PlayerinJob(p, "Support")) { + //Give exp for doing so. + //this.plugin.gainMoneyExp(p,"Support",0,100); + } + p.sendMessage("Teleported to "+ChatColor.GREEN+teleport_town.getTownName()+ChatColor.WHITE+" for $"+ChatColor.YELLOW+df.format(finalcost)+ChatColor.WHITE+". New Account balance: $"+df.format(mymoney-finalcost)); + Bukkit.broadcastMessage(ChatColor.GREEN+p.getName()+ChatColor.WHITE+" teleported to "+ChatColor.YELLOW+teleport_town.getTownName()+"."); + if (is_in_vehicle) { + vehicle.eject(); + p.eject(); + final Player p2 = p; + final Town target2 = teleport_town; + Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { + @Override + public void run() { + p2.teleport(target2.getSpawn(Bukkit.getServer())); + } + },5); + } else { + p.teleport(teleport_town.getSpawn(Bukkit.getServer())); + } + } else { + p.sendMessage("You need $"+ChatColor.YELLOW+df.format(finalcost)+" in the bank to teleport to "+ChatColor.GREEN+teleport_town.getTownName()+ChatColor.WHITE+"!"); + } + } else { + //Setup another town. + //Determine distance of player to new town. + double otherx = teleport_town.getSpawn(Bukkit.getServer()).getX(); + double othery = teleport_town.getSpawn(Bukkit.getServer()).getY(); + double otherz = teleport_town.getSpawn(Bukkit.getServer()).getZ(); + double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase().toLowerCase() + ".money"); + double finalcost = Math.abs(p.getLocation().getX()-otherx)+Math.abs(p.getLocation().getY()-othery)+Math.abs(p.getLocation().getZ()-otherz); + Bukkit.getLogger().info("finalcost1:"+finalcost); + finalcost *= this.plugin.getConfig().getDouble("teleport-cost-rate"); + Bukkit.getLogger().info("finalcost2:"+finalcost); + finalcost += finalcost * 15 * ((p.getMaxHealth()-p.getHealth())/p.getMaxHealth()); + Bukkit.getLogger().info("finalcost3:"+finalcost); + //finalcost += mymoney*this.plugin.getConfig().getDouble("teleport-cost-tax"); + if (mymoney>=finalcost) { + //Allow teleport to occur. + p.sendMessage("Teleporting to "+ChatColor.GREEN+teleport_town.getTownName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". Type the command again to teleport."); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase().toLowerCase() + ".teletime", Double.valueOf(p.getPlayerTime())); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase().toLowerCase() + ".teleplayer", String.valueOf(teleport_town.getTownName())); + } else { + p.sendMessage("Teleporting to "+ChatColor.GREEN+teleport_town.getTownName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". You do not have enough in the bank for that."); + } + } + } } else { boolean is_in_vehicle = false; Entity vehicle = null; @@ -1660,7 +1741,11 @@ public String convertToItemName(String val) { double otherz = target.getLocation().getZ(); double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".money"); double finalcost = Math.abs(p.getLocation().getX()-otherx)+Math.abs(p.getLocation().getY()-othery)+Math.abs(p.getLocation().getZ()-otherz); + //Bukkit.getLogger().info("finalcost1:"+finalcost); finalcost *= this.plugin.getConfig().getDouble("teleport-cost-rate"); + //Bukkit.getLogger().info("finalcost2:"+finalcost); + finalcost += finalcost * 15 * ((p.getMaxHealth()-p.getHealth())/p.getMaxHealth()); + //Bukkit.getLogger().info("finalcost3:"+finalcost); //finalcost += mymoney*this.plugin.getConfig().getDouble("teleport-cost-tax"); if (mymoney>=finalcost) { //Allow teleport to occur. @@ -1706,7 +1791,11 @@ public String convertToItemName(String val) { double otherz = target.getLocation().getZ(); double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".money"); double finalcost = Math.abs(p.getLocation().getX()-otherx)+Math.abs(p.getLocation().getY()-othery)+Math.abs(p.getLocation().getZ()-otherz); + Bukkit.getLogger().info("finalcost1:"+finalcost); finalcost *= this.plugin.getConfig().getDouble("teleport-cost-rate"); + Bukkit.getLogger().info("finalcost2:"+finalcost); + finalcost += finalcost * 15 * ((p.getMaxHealth()-p.getHealth())/p.getMaxHealth()); + Bukkit.getLogger().info("finalcost3:"+finalcost); //finalcost += mymoney*this.plugin.getConfig().getDouble("teleport-cost-tax"); if (mymoney>=finalcost) { //Allow teleport to occur. @@ -1714,7 +1803,7 @@ public String convertToItemName(String val) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".teletime", Double.valueOf(p.getPlayerTime())); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".teleplayer", String.valueOf(target.getName())); } else { - p.sendMessage("Teleporting to "+ChatColor.GREEN+target.getName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". You do not have enough in the bank for that."); + p.sendMessage("Teleporting to "+ChatColor.GREEN+target.getName().toLowerCase()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". You do not have enough in the bank for that."); } } } @@ -1727,7 +1816,47 @@ public String convertToItemName(String val) { //Teleport. Player target = p.getServer().getPlayer(args[1]); if (target == null) { - p.sendMessage(this.prefix + " " + this.offlinePlayer); + //It could be a town name. Check + TownManager t = MCTownsPlugin.getPlugin().getTownManager(); + Bukkit.getLogger().info("Town Manager started:"+ t.toString()); + Town teleport_town = null; + Collection towns = t.getTownsCollection(); + for (Town towny : towns) { + if (towny!=null) { + if (towny.getTownName().equalsIgnoreCase(args[1])) { + teleport_town = towny; + break; + } else { + Bukkit.getLogger().info("This was town "+towny.getTownName()); + } + } + } + if (teleport_town == null) { + p.sendMessage(this.prefix + " " + this.offlinePlayer); + } else { + //We can attempt to teleport to this town's spawn point. Find out the point and how much it costs. + Location spawn_point = teleport_town.getSpawn(Bukkit.getServer()); + //Determine distance of player to town.. + double otherx = spawn_point.getX(); + double othery = spawn_point.getY(); + double otherz = spawn_point.getZ(); + double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase().toLowerCase() + ".money"); + double finalcost = Math.abs(p.getLocation().getX()-otherx)+Math.abs(p.getLocation().getY()-othery)+Math.abs(p.getLocation().getZ()-otherz); + //Bukkit.getLogger().info("finalcost1:"+finalcost); + finalcost *= this.plugin.getConfig().getDouble("teleport-cost-rate"); + //Bukkit.getLogger().info("finalcost2:"+finalcost); + finalcost += finalcost * 15 * ((p.getMaxHealth()-p.getHealth())/p.getMaxHealth()); + //Bukkit.getLogger().info("finalcost3:"+finalcost); + //finalcost += mymoney*this.plugin.getConfig().getDouble("teleport-cost-tax"); + if (mymoney>=finalcost) { + //Allow teleport to occur. + p.sendMessage("Teleporting to "+ChatColor.GREEN+teleport_town.getTownName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". Type the command again to teleport."); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase().toLowerCase() + ".teletime", Double.valueOf(p.getPlayerTime())); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase().toLowerCase() + ".teleplayer", String.valueOf(teleport_town.getTownName().toLowerCase())); + } else { + p.sendMessage("Teleporting to "+ChatColor.GREEN+teleport_town.getTownName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". You do not have enough in the bank for that."); + } + } } else { //Determine distance of player to other player. double otherx = target.getLocation().getX(); @@ -1735,7 +1864,11 @@ public String convertToItemName(String val) { double otherz = target.getLocation().getZ(); double mymoney = this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase() + ".money"); double finalcost = Math.abs(p.getLocation().getX()-otherx)+Math.abs(p.getLocation().getY()-othery)+Math.abs(p.getLocation().getZ()-otherz); + //Bukkit.getLogger().info("finalcost1:"+finalcost); finalcost *= this.plugin.getConfig().getDouble("teleport-cost-rate"); + //Bukkit.getLogger().info("finalcost2:"+finalcost); + finalcost += finalcost * 15 * ((p.getMaxHealth()-p.getHealth())/p.getMaxHealth()); + //Bukkit.getLogger().info("finalcost3:"+finalcost); //finalcost += mymoney*this.plugin.getConfig().getDouble("teleport-cost-tax"); if (mymoney>=finalcost) { //Allow teleport to occur. @@ -1743,31 +1876,34 @@ public String convertToItemName(String val) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".teletime", Double.valueOf(p.getPlayerTime())); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".teleplayer", String.valueOf(target.getName())); } else { - p.sendMessage("Teleporting to "+ChatColor.GREEN+target.getName()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". You do not have enough in the bank for that."); + p.sendMessage("Teleporting to "+ChatColor.GREEN+target.getName().toLowerCase()+ChatColor.WHITE+" costs $"+ChatColor.YELLOW+df.format(finalcost)+". You do not have enough in the bank for that."); } } } } return true; } else - if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("info")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("info")) { p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs info [JobName]"+ChatColor.WHITE+" - Get information about a job."); p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs info [JobName] "+ChatColor.LIGHT_PURPLE+"[lv]"+ChatColor.WHITE+" - Get information about a job at a certain job level."); p.sendMessage(" Type /jobs to see the jobs."); } else - if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("join")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("join")) { p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs join [JobName]"+ChatColor.WHITE+" - Join a job. Type /jobs to see the jobs."); } else if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("members")) { p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs members [JobName]"+ChatColor.WHITE+" - Check all members in a job."); } else - if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("leave")) { + if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("members")) { + p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs members [JobName]"+ChatColor.WHITE+" - Check all members in a job."); + } else + if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("leave")) { p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs leave [JobName]"+ChatColor.WHITE+" - Leave a job. Type /jobs stats to see your jobs."); } else if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("buffs")) { p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs buffs [JobName]"+ChatColor.WHITE+" - Get buffs information about a job. Type /jobs to see the jobs."); } else - if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("ultimate")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("ultimate")) { //Attempt to join the job. this.plugin.setUltimate(p,args[1]); } else @@ -1775,11 +1911,11 @@ public String convertToItemName(String val) { //Attempt to level up the job. this.plugin.levelUpJob(p,args[1]); } else - if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("join")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("join")) { //Attempt to join the job. this.plugin.joinJob(p,args[1]); } else - if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("leave")) { + if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("leave")) { //Attempt to join the job. this.plugin.leaveJob(p,args[1]); } else @@ -1831,7 +1967,67 @@ public String convertToItemName(String val) { p.sendMessage(ChatColor.RED+"Sorry, that is not a valid job!"); } } else - if (cmd.getName().equalsIgnoreCase("jobs") && (args.length == 2 || args.length==3) && args[0].equalsIgnoreCase("info")) { + if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("members")) { + JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Farmer_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job}; + boolean found=false; + String job = ""; + ChatColor job_color = null; + for (int i=0;i sorted_players = new ArrayList(); + for (int i=0;i sorted_list_players = new ArrayList(); + int lowest_slot = -1; + while (sorted_players.size()>0) { + for (int i=0;i0) { //If it's 0, for some reason it didn't read this name right....Skip it. + if (this.plugin.getJobLv(job, sorted_players.get(i))0) { + for (int i=0;i=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); + p.sendMessage("Lv"+mylv+" "+this.plugin.getJobColor(joblist[i])+joblist[i]+ChatColor.WHITE+": "+Math.round(this.plugin.getAccountsConfig().getInt(Bukkit.getPlayer(args[1]).getName().toLowerCase()+".jobs.job"+(i+1)+"exp"))+"xp "+ChatColor.BLUE+(mylv>=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); } else { - p.sendMessage("Lv"+mylv+" "+this.plugin.getJobColor(joblist[i])+joblist[i]+ChatColor.WHITE+": "+Math.round(this.plugin.getAccountsConfig().getInt(Bukkit.getPlayer(args[1]).getName()+".jobs.job"+(i+1)+"exp"))+"/"+Math.round(this.plugin.getJobExp(joblist[i], this.plugin.getAccountsConfig().getInt(Bukkit.getPlayer(args[1]).getName()+".jobs.job"+(i+1)+"lv")))+"xp "+ChatColor.BLUE+(mylv>=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); + p.sendMessage("Lv"+mylv+" "+this.plugin.getJobColor(joblist[i])+joblist[i]+ChatColor.WHITE+": "+Math.round(this.plugin.getAccountsConfig().getInt(Bukkit.getPlayer(args[1]).getName().toLowerCase()+".jobs.job"+(i+1)+"exp"))+"/"+Math.round(this.plugin.getJobExp(joblist[i], this.plugin.getAccountsConfig().getInt(Bukkit.getPlayer(args[1]).getName().toLowerCase()+".jobs.job"+(i+1)+"lv")))+"xp "+ChatColor.BLUE+(mylv>=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); } if (joblist[i].equalsIgnoreCase("Explorer") && this.plugin.getJobLv(joblist[i], Bukkit.getPlayer(args[1]))>=10) { @@ -1974,7 +2170,7 @@ public String convertToItemName(String val) { boolean discovered=false; long timeleft=0; for (int j=0;j=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); + p.sendMessage("Lv"+mylv+" "+this.plugin.getJobColor(joblist[i])+joblist[i]+ChatColor.WHITE+": "+Math.round(this.plugin.getAccountsConfig().getInt(q.getName().toLowerCase()+".jobs.job"+(i+1)+"exp"))+"xp "+ChatColor.BLUE+(mylv>=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); } else { - p.sendMessage("Lv"+mylv+" "+this.plugin.getJobColor(joblist[i])+joblist[i]+ChatColor.WHITE+": "+Math.round(this.plugin.getAccountsConfig().getInt(q.getName()+".jobs.job"+(i+1)+"exp"))+"/"+Math.round(this.plugin.getJobExp(joblist[i], this.plugin.getAccountsConfig().getInt(q.getName()+".jobs.job"+(i+1)+"lv")))+"xp "+ChatColor.BLUE+(mylv>=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); + p.sendMessage("Lv"+mylv+" "+this.plugin.getJobColor(joblist[i])+joblist[i]+ChatColor.WHITE+": "+Math.round(this.plugin.getAccountsConfig().getInt(q.getName().toLowerCase()+".jobs.job"+(i+1)+"exp"))+"/"+Math.round(this.plugin.getJobExp(joblist[i], this.plugin.getAccountsConfig().getInt(q.getName().toLowerCase()+".jobs.job"+(i+1)+"lv")))+"xp "+ChatColor.BLUE+(mylv>=5?"+Lv5 Buff":"")+ChatColor.GREEN+(mylv>=10?" +Lv10 Buff":"")+ChatColor.GOLD+(mylv>=20?" +Lv20 Buff":"")); } } - if (joblist[i].equalsIgnoreCase("Explorer") && this.plugin.getJobLv(joblist[i], q.getName())>=10) { + if (joblist[i].equalsIgnoreCase("Explorer") && this.plugin.getJobLv(joblist[i], q.getName().toLowerCase())>=10) { //Check to see if the buff is on cooldown for this player or not. boolean discovered=false; long timeleft=0; for (int j=0;j