diff --git a/mcMMO/Changelog.txt b/mcMMO/Changelog.txt index b1b50509b..5f47baefb 100644 --- a/mcMMO/Changelog.txt +++ b/mcMMO/Changelog.txt @@ -1,5 +1,10 @@ Changelog: #Versions without changelogs probably had very small misc fixes, like tweaks to the source code# +Version 1.0 +Taming Skill +Leaderboards +Players won't hand out XP if they died within the last 5 seconds + Version 0.9.29 Fixes critical bug involving water turning anything into clay diff --git a/mcMMO/com/gmail/nossr50/PlayerStat.java b/mcMMO/com/gmail/nossr50/PlayerStat.java new file mode 100644 index 000000000..9abd1d961 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/PlayerStat.java @@ -0,0 +1,6 @@ +package com.gmail.nossr50; + +public class PlayerStat { + public String name; + public int statVal = 0; +} diff --git a/mcMMO/com/gmail/nossr50/Tree.java b/mcMMO/com/gmail/nossr50/Tree.java index 6cfe8324a..378d79010 100644 --- a/mcMMO/com/gmail/nossr50/Tree.java +++ b/mcMMO/com/gmail/nossr50/Tree.java @@ -6,21 +6,22 @@ import org.bukkit.entity.Player; public class Tree { - TreeNode root; + TreeNode root = null; public Tree(){} - public void add(Player p, int in ) + public void add(String p, int in) { - if(root == null) - root = new TreeNode(p, in); - else - root.add(p,in); + if(root == null) + root = new TreeNode(p, in); + else + root.add(p,in); } - public Player[] inOrder() + public PlayerStat[] inOrder() { - return (Player[]) root.inOrder(new ArrayList()).toArray(); + ArrayList order = root.inOrder(new ArrayList()); + return order.toArray(new PlayerStat[order.size()]); } } diff --git a/mcMMO/com/gmail/nossr50/TreeNode.java b/mcMMO/com/gmail/nossr50/TreeNode.java index 71f9cf882..417215183 100644 --- a/mcMMO/com/gmail/nossr50/TreeNode.java +++ b/mcMMO/com/gmail/nossr50/TreeNode.java @@ -7,20 +7,19 @@ import org.bukkit.entity.Player; public class TreeNode { TreeNode left = null , right = null; - Player player; - int stat; + PlayerStat ps = new PlayerStat(); - public TreeNode(Player p, int in) {stat = in; player = p;} + public TreeNode(String p, int in) {ps.statVal = in; ps.name = p;} - public void add (Player p, int in) { - if (in <= stat) + public void add (String p, int in) { + if (in >= ps.statVal) { if (left == null) left = new TreeNode(p,in); else left.add(p, in); } - else if(in > stat) + else if(in < ps.statVal) { if (right == null) right = new TreeNode(p,in); @@ -29,12 +28,12 @@ public class TreeNode { } } - public ArrayList inOrder(ArrayList a) + public ArrayList inOrder(ArrayList a) { if(left != null) a = left.inOrder(a); - a.add(player); + a.add(ps); if(right != null) a = right.inOrder(a); diff --git a/mcMMO/com/gmail/nossr50/mcAcrobatics.java b/mcMMO/com/gmail/nossr50/mcAcrobatics.java index c2f04d211..42f9574f2 100644 --- a/mcMMO/com/gmail/nossr50/mcAcrobatics.java +++ b/mcMMO/com/gmail/nossr50/mcAcrobatics.java @@ -35,7 +35,7 @@ public class mcAcrobatics { if(player.getHealth() - newDamage >= 1){ if(!event.isCancelled()) PP.addAcrobaticsXP((event.getDamage() * 8) * mcLoadProperties.xpGainMultiplier); - mcSkills.getInstance().XpCheck(player); + mcSkills.XpCheck(player); event.setDamage(newDamage); if(event.getDamage() <= 0) event.setCancelled(true); @@ -48,7 +48,7 @@ public class mcAcrobatics { } else if (!event.isCancelled()){ if(player.getHealth() - event.getDamage() >= 1){ PP.addAcrobaticsXP((event.getDamage() * 12) * mcLoadProperties.xpGainMultiplier); - mcSkills.getInstance().XpCheck(player); + mcSkills.XpCheck(player); } } } diff --git a/mcMMO/com/gmail/nossr50/mcBlockListener.java b/mcMMO/com/gmail/nossr50/mcBlockListener.java index 400bc66ad..afdb4eafb 100644 --- a/mcMMO/com/gmail/nossr50/mcBlockListener.java +++ b/mcMMO/com/gmail/nossr50/mcBlockListener.java @@ -31,7 +31,7 @@ public class mcBlockListener extends BlockListener { else { block = event.getBlock(); } - if(player != null && mcm.getInstance().shouldBeWatched(block)){ + if(player != null && mcm.shouldBeWatched(block)){ if(block.getTypeId() != 17) block.setData((byte) 5); //Change the byte if(block.getTypeId() == 17) @@ -53,18 +53,18 @@ public class mcBlockListener extends BlockListener { /* * Check if the Timer is doing its job */ - mcSkills.getInstance().monitorSkills(player); + mcSkills.monitorSkills(player); /* * HERBALISM */ if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalismAbility(player) && block.getTypeId() == 59 && block.getData() == (byte) 0x07){ - mcHerbalism.getInstance().greenTerraCheck(player, block, plugin); + mcHerbalism.greenTerraCheck(player, block, plugin); } //Wheat && Triple drops - if(PP.getGreenTerraMode() && mcHerbalism.getInstance().canBeGreenTerra(block)){ - mcHerbalism.getInstance().herbalismProcCheck(block, player, event); - mcHerbalism.getInstance().greenTerraWheat(player, block, event); + if(PP.getGreenTerraMode() && mcHerbalism.canBeGreenTerra(block)){ + mcHerbalism.herbalismProcCheck(block, player, event); + mcHerbalism.greenTerraWheat(player, block, event); } @@ -73,10 +73,10 @@ public class mcBlockListener extends BlockListener { */ if(mcPermissions.getInstance().mining(player)){ if(mcLoadProperties.miningrequirespickaxe){ - if(mcm.getInstance().isMiningPick(inhand)) - mcMining.getInstance().miningBlockCheck(player, block); + if(mcm.isMiningPick(inhand)) + mcMining.miningBlockCheck(player, block); } else { - mcMining.getInstance().miningBlockCheck(player, block); + mcMining.miningBlockCheck(player, block); } } /* @@ -85,19 +85,19 @@ public class mcBlockListener extends BlockListener { if(player != null && block.getTypeId() == 17 && mcPermissions.getInstance().woodcutting(player)){ if(mcLoadProperties.woodcuttingrequiresaxe){ - if(mcm.getInstance().isAxes(inhand)){ + if(mcm.isAxes(inhand)){ if(!mcConfig.getInstance().isBlockWatched(block)){ - mcWoodCutting.getInstance().woodCuttingProcCheck(player, block); + mcWoodCutting.woodCuttingProcCheck(player, block); PP.addWoodcuttingXP(7 * mcLoadProperties.xpGainMultiplier); } } } else { if(block.getData() != 5){ - mcWoodCutting.getInstance().woodCuttingProcCheck(player, block); + mcWoodCutting.woodCuttingProcCheck(player, block); PP.addWoodcuttingXP(7 * mcLoadProperties.xpGainMultiplier); } } - mcSkills.getInstance().XpCheck(player); + mcSkills.XpCheck(player); /* * IF PLAYER IS USING TREEFELLER @@ -105,9 +105,9 @@ public class mcBlockListener extends BlockListener { if(mcPermissions.getInstance().woodCuttingAbility(player) && PP.getTreeFellerMode() && block.getTypeId() == 17 - && mcm.getInstance().blockBreakSimulate(block, player, plugin)){ + && mcm.blockBreakSimulate(block, player, plugin)){ - mcWoodCutting.getInstance().treeFeller(block, player); + mcWoodCutting.treeFeller(block, player); for(Block blockx : mcConfig.getInstance().getTreeFeller()){ if(blockx != null){ Material mat = Material.getMaterial(block.getTypeId()); @@ -119,7 +119,7 @@ public class mcBlockListener extends BlockListener { blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item); //XP WOODCUTTING if(!mcConfig.getInstance().isBlockWatched(block)){ - mcWoodCutting.getInstance().woodCuttingProcCheck(player, blockx); + mcWoodCutting.woodCuttingProcCheck(player, blockx); PP.addWoodcuttingXP(7); } } @@ -133,7 +133,7 @@ public class mcBlockListener extends BlockListener { } } if(mcLoadProperties.toolsLoseDurabilityFromAbilities) - mcm.getInstance().damageTool(player, (short) mcLoadProperties.abilityDurabilityLoss); + mcm.damageTool(player, (short) mcLoadProperties.abilityDurabilityLoss); mcConfig.getInstance().clearTreeFeller(); } } @@ -141,15 +141,15 @@ public class mcBlockListener extends BlockListener { * EXCAVATION */ if(mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 5) - mcExcavation.getInstance().excavationProcCheck(block, player); + mcExcavation.excavationProcCheck(block, player); /* * HERBALISM */ - if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalism(player) && mcHerbalism.getInstance().canBeGreenTerra(block)){ - mcHerbalism.getInstance().greenTerraCheck(player, block, plugin); + if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalism(player) && mcHerbalism.canBeGreenTerra(block)){ + mcHerbalism.greenTerraCheck(player, block, plugin); } if(mcPermissions.getInstance().herbalism(player) && block.getData() != (byte) 5) - mcHerbalism.getInstance().herbalismProcCheck(block, player, event); + mcHerbalism.herbalismProcCheck(block, player, event); //Change the byte back when broken if(block.getData() == 5) @@ -165,41 +165,41 @@ public class mcBlockListener extends BlockListener { /* * Check if the Timer is doing its job */ - mcSkills.getInstance().monitorSkills(player); + mcSkills.monitorSkills(player); /* * ABILITY PREPARATION CHECKS */ - if(PP.getHoePreparationMode() && mcHerbalism.getInstance().canBeGreenTerra(block)) - mcHerbalism.getInstance().greenTerraCheck(player, block, plugin); + if(PP.getHoePreparationMode() && mcHerbalism.canBeGreenTerra(block)) + mcHerbalism.greenTerraCheck(player, block, plugin); if(PP.getAxePreparationMode() && block.getTypeId() == 17) - mcWoodCutting.getInstance().treeFellerCheck(player, block, plugin); + mcWoodCutting.treeFellerCheck(player, block, plugin); if(PP.getPickaxePreparationMode()) - mcMining.getInstance().superBreakerCheck(player, block, plugin); - if(PP.getShovelPreparationMode() && mcExcavation.getInstance().canBeGigaDrillBroken(block)) - mcExcavation.getInstance().gigaDrillBreakerActivationCheck(player, block, plugin); - if(PP.getFistsPreparationMode() && mcExcavation.getInstance().canBeGigaDrillBroken(block)) - mcSkills.getInstance().berserkActivationCheck(player, plugin); + mcMining.superBreakerCheck(player, block, plugin); + if(PP.getShovelPreparationMode() && mcExcavation.canBeGigaDrillBroken(block)) + mcExcavation.gigaDrillBreakerActivationCheck(player, block, plugin); + if(PP.getFistsPreparationMode() && mcExcavation.canBeGigaDrillBroken(block)) + mcSkills.berserkActivationCheck(player, plugin); /* * GREEN TERRA STUFF */ if(PP.getGreenTerraMode() && mcPermissions.getInstance().herbalismAbility(player) && PP.getGreenTerraMode()){ - mcHerbalism.getInstance().greenTerra(player, block); + mcHerbalism.greenTerra(player, block); } /* * GIGA DRILL BREAKER CHECKS */ if(PP.getGigaDrillBreakerMode() - && mcm.getInstance().blockBreakSimulate(block, player, plugin) - && mcExcavation.getInstance().canBeGigaDrillBroken(block) - && mcm.getInstance().isShovel(inhand)){ + && mcm.blockBreakSimulate(block, player, plugin) + && mcExcavation.canBeGigaDrillBroken(block) + && mcm.isShovel(inhand)){ - if(mcm.getInstance().getTier(player) >= 2) - mcExcavation.getInstance().excavationProcCheck(block, player); - if(mcm.getInstance().getTier(player) >= 3) - mcExcavation.getInstance().excavationProcCheck(block, player); - if(mcm.getInstance().getTier(player) >= 4) - mcExcavation.getInstance().excavationProcCheck(block, player); + if(mcm.getTier(player) >= 2) + mcExcavation.excavationProcCheck(block, player); + if(mcm.getTier(player) >= 3) + mcExcavation.excavationProcCheck(block, player); + if(mcm.getTier(player) >= 4) + mcExcavation.excavationProcCheck(block, player); Material mat = Material.getMaterial(block.getTypeId()); if(block.getTypeId() == 2) mat = Material.DIRT; @@ -207,16 +207,16 @@ public class mcBlockListener extends BlockListener { ItemStack item = new ItemStack(mat, 1, (byte)0, type); block.setType(Material.AIR); if(mcLoadProperties.toolsLoseDurabilityFromAbilities) - mcm.getInstance().damageTool(player, (short) mcLoadProperties.abilityDurabilityLoss); + mcm.damageTool(player, (short) mcLoadProperties.abilityDurabilityLoss); block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item); } /* * BERSERK MODE CHECKS */ if(PP.getBerserkMode() - && mcm.getInstance().blockBreakSimulate(block, player, plugin) + && mcm.blockBreakSimulate(block, player, plugin) && player.getItemInHand().getTypeId() == 0 - && mcExcavation.getInstance().canBeGigaDrillBroken(block)){ + && mcExcavation.canBeGigaDrillBroken(block)){ Material mat = Material.getMaterial(block.getTypeId()); if(block.getTypeId() == 2) mat = Material.DIRT; @@ -230,14 +230,14 @@ public class mcBlockListener extends BlockListener { * SUPER BREAKER CHECKS */ if(PP.getSuperBreakerMode() - && mcMining.getInstance().canBeSuperBroken(block) - && mcm.getInstance().blockBreakSimulate(block, player, plugin)){ + && mcMining.canBeSuperBroken(block) + && mcm.blockBreakSimulate(block, player, plugin)){ if(mcLoadProperties.miningrequirespickaxe){ - if(mcm.getInstance().isMiningPick(inhand)) - mcMining.getInstance().SuperBreakerBlockCheck(player, block); + if(mcm.isMiningPick(inhand)) + mcMining.SuperBreakerBlockCheck(player, block); } else { - mcMining.getInstance().SuperBreakerBlockCheck(player, block); + mcMining.SuperBreakerBlockCheck(player, block); } } diff --git a/mcMMO/com/gmail/nossr50/mcCombat.java b/mcMMO/com/gmail/nossr50/mcCombat.java index afe635353..a0ce9dc5d 100644 --- a/mcMMO/com/gmail/nossr50/mcCombat.java +++ b/mcMMO/com/gmail/nossr50/mcCombat.java @@ -26,14 +26,7 @@ public class mcCombat { public mcCombat(mcMMO instance) { plugin = instance; } - private static volatile mcCombat instance; - public static mcCombat getInstance() { - if (instance == null) { - instance = new mcCombat(plugin); - } - return instance; - } - public void playerVersusPlayerChecks(Entity x, Player attacker, EntityDamageByEntityEvent event){ + public static void playerVersusPlayerChecks(Entity x, Player attacker, EntityDamageByEntityEvent event){ if(x instanceof Player){ if(mcLoadProperties.pvp == false){ event.setCancelled(true); @@ -92,37 +85,39 @@ public class mcCombat { if(attacker != null && defender != null && mcLoadProperties.pvpxp){ if(PPd.inParty() && PPa.inParty() && mcParty.getInstance().inSameParty(attacker, defender)) return; - if(mcm.getInstance().isAxes(attacker.getItemInHand())) - PPa.addAxesXP((event.getDamage() * 3) * mcLoadProperties.pvpxprewardmodifier); - if(mcm.getInstance().isSwords(attacker.getItemInHand())) - PPa.addSwordsXP((event.getDamage() * 3) * mcLoadProperties.pvpxprewardmodifier); - if(attacker.getItemInHand().getTypeId() == 0) - PPa.addUnarmedXP((event.getDamage() * 3) * mcLoadProperties.pvpxprewardmodifier); + if(System.currentTimeMillis() >= PPd.getRespawnATS() + 5000 && defender.getHealth() >= 1){ + if(mcm.isAxes(attacker.getItemInHand())) + PPa.addAxesXP((event.getDamage() * 3) * mcLoadProperties.pvpxprewardmodifier); + if(mcm.isSwords(attacker.getItemInHand())) + PPa.addSwordsXP((event.getDamage() * 3) * mcLoadProperties.pvpxprewardmodifier); + if(attacker.getItemInHand().getTypeId() == 0) + PPa.addUnarmedXP((event.getDamage() * 3) * mcLoadProperties.pvpxprewardmodifier); + } } /* * CHECK FOR LEVEL UPS */ - mcSkills.getInstance().XpCheck(attacker); + mcSkills.XpCheck(attacker); } } - public void playerVersusSquidChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ + public static void playerVersusSquidChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); if(x instanceof Squid){ if(!mcConfig.getInstance().isBleedTracked(x)){ bleedCheck(attacker, x); } Squid defender = (Squid)event.getEntity(); - if(mcm.getInstance().isSwords(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().swords(attacker)){ + if(mcm.isSwords(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().swords(attacker)){ PPa.addSwordsXP(10 * mcLoadProperties.xpGainMultiplier); } - mcSkills.getInstance().XpCheck(attacker); - if(mcm.getInstance().isAxes(attacker.getItemInHand()) + mcSkills.XpCheck(attacker); + if(mcm.isAxes(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().axes(attacker)){ PPa.addAxesXP(10 * mcLoadProperties.xpGainMultiplier); - mcSkills.getInstance().XpCheck(attacker); + mcSkills.XpCheck(attacker); } - if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(mcm.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ if(PPa.getAxesInt() >= 500){ event.setDamage(calculateDamage(event, 4)); } @@ -145,19 +140,19 @@ public class mcCombat { //XP if(defender.getHealth() != 0){ PPa.addUnarmedXP(10 * mcLoadProperties.xpGainMultiplier); - mcSkills.getInstance().XpCheck(attacker); + mcSkills.XpCheck(attacker); } } } } - public void playerVersusAnimalsChecks(Entity x, Player attacker, EntityDamageByEntityEvent event, int type){ + public static void playerVersusAnimalsChecks(Entity x, Player attacker, EntityDamageByEntityEvent event, int type){ PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); if(x instanceof Animals){ if(!mcConfig.getInstance().isBleedTracked(x)){ bleedCheck(attacker, x); } Animals defender = (Animals)event.getEntity(); - if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(mcm.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ if(defender.getHealth() <= 0) return; if(PPa.getAxesInt() >= 500){ @@ -175,7 +170,7 @@ public class mcCombat { } } } - public void playerVersusMonsterChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ + public static void playerVersusMonsterChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); if(x instanceof Monster){ /* @@ -186,7 +181,7 @@ public class mcCombat { bleedCheck(attacker, x); } Monster defender = (Monster)event.getEntity(); - if(mcm.getInstance().isSwords(attacker.getItemInHand()) + if(mcm.isSwords(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().swords(attacker)){ if(!mcConfig.getInstance().isMobSpawnTracked(x)){ @@ -201,9 +196,9 @@ public class mcCombat { if(x instanceof PigZombie) PPa.addSwordsXP((event.getDamage() * 3) * mcLoadProperties.xpGainMultiplier); } - mcSkills.getInstance().XpCheck(attacker); + mcSkills.XpCheck(attacker); } - if(mcm.getInstance().isAxes(attacker.getItemInHand()) + if(mcm.isAxes(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().axes(attacker)){ if(!mcConfig.getInstance().isMobSpawnTracked(x)){ @@ -218,12 +213,12 @@ public class mcCombat { if(x instanceof PigZombie) PPa.addAxesXP((event.getDamage() * 3) * mcLoadProperties.xpGainMultiplier); } - mcSkills.getInstance().XpCheck(attacker); + mcSkills.XpCheck(attacker); } /* * AXE DAMAGE SCALING && LOOT CHECKS */ - if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(mcm.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ if(PPa.getAxesInt() >= 500){ event.setDamage(calculateDamage(event, 4)); } @@ -253,11 +248,11 @@ public class mcCombat { if(x instanceof PigZombie) PPa.addUnarmedXP((event.getDamage() * 3) * mcLoadProperties.xpGainMultiplier); } - mcSkills.getInstance().XpCheck(attacker); + mcSkills.XpCheck(attacker); } } } - public void archeryCheck(EntityDamageByProjectileEvent event){ + public static void archeryCheck(EntityDamageByProjectileEvent event){ Entity y = event.getDamager(); Entity x = event.getEntity(); if(event.getProjectile().toString().equals("CraftArrow") && x instanceof Player){ @@ -450,10 +445,10 @@ public class mcCombat { event.setDamage(calculateDamage(event, 5)); } } - mcSkills.getInstance().XpCheck(attacker); + mcSkills.XpCheck(attacker); } } - public boolean simulateUnarmedProc(Player player){ + public static boolean simulateUnarmedProc(Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(PP.getUnarmedInt() >= 1000){ if(Math.random() * 4000 <= 1000){ @@ -466,9 +461,9 @@ public class mcCombat { } return false; } - public void bleedCheck(Player attacker, Entity x){ + public static void bleedCheck(Player attacker, Entity x){ PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); - if(mcPermissions.getInstance().swords(attacker) && mcm.getInstance().isSwords(attacker.getItemInHand())){ + if(mcPermissions.getInstance().swords(attacker) && mcm.isSwords(attacker.getItemInHand())){ if(PPa.getSwordsInt() >= 750){ if(Math.random() * 1000 >= 750){ if(!(x instanceof Player)) @@ -490,10 +485,10 @@ public class mcCombat { } } } - public int calculateDamage(EntityDamageEvent event, int dmg){ + public static int calculateDamage(EntityDamageEvent event, int dmg){ return event.getDamage() + dmg; } - public void dealDamage(Entity target, int dmg){ + public static void dealDamage(Entity target, int dmg){ if(target instanceof Player){ ((Player) target).damage(dmg); } @@ -504,11 +499,11 @@ public class mcCombat { ((Monster) target).damage(dmg); } } - public void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event, Entity x){ + public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event, Entity x){ int targets = 0; - targets = mcm.getInstance().getTier(attacker); + targets = mcm.getTier(attacker); for(Entity derp : x.getWorld().getEntities()){ - if(mcm.getInstance().getDistance(x.getLocation(), derp.getLocation()) < 5){ + if(mcm.getDistance(x.getLocation(), derp.getLocation()) < 5){ if(derp instanceof Player){ Player target = (Player)derp; if(mcParty.getInstance().inSameParty(attacker, target)) @@ -535,11 +530,11 @@ public class mcCombat { } } } - public void applySerratedStrikes(Player attacker, EntityDamageByEntityEvent event, Entity x){ + public static void applySerratedStrikes(Player attacker, EntityDamageByEntityEvent event, Entity x){ int targets = 0; - targets = mcm.getInstance().getTier(attacker); + targets = mcm.getTier(attacker); for(Entity derp : x.getWorld().getEntities()){ - if(mcm.getInstance().getDistance(x.getLocation(), derp.getLocation()) < 5){ + if(mcm.getDistance(x.getLocation(), derp.getLocation()) < 5){ if(derp instanceof Player){ Player target = (Player)derp; if(mcParty.getInstance().inSameParty(attacker, target)) @@ -569,12 +564,12 @@ public class mcCombat { targets--; } } - //attacker.sendMessage(ChatColor.GREEN+"**SERRATED STRIKES HIT "+(mcm.getInstance().getTier(attacker)-targets)+" FOES**"); + //attacker.sendMessage(ChatColor.GREEN+"**SERRATED STRIKES HIT "+(mcm.getTier(attacker)-targets)+" FOES**"); } } - public void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Entity x){ + public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Entity x){ PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); - if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(mcm.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ if(PPa.getAxesInt() >= 750){ if(Math.random() * 1000 <= 750){ if(x instanceof Player){ @@ -602,9 +597,9 @@ public class mcCombat { } } } - public void parryCheck(Player defender, EntityDamageByEntityEvent event, Entity y){ + public static void parryCheck(Player defender, EntityDamageByEntityEvent event, Entity y){ PlayerProfile PPd = mcUsers.getProfile(defender.getName()); - if(defender != null && mcm.getInstance().isSwords(defender.getItemInHand()) + if(defender != null && mcm.isSwords(defender.getItemInHand()) && mcPermissions.getInstance().swords(defender)){ if(PPd.getSwordsInt() >= 900){ if(Math.random() * 3000 <= 900){ @@ -629,7 +624,7 @@ public class mcCombat { } } } - public void bleedSimulate(){ + public static void bleedSimulate(){ //Add items from Que list to BleedTrack list for(Entity x : mcConfig.getInstance().getBleedQue()){ @@ -652,7 +647,7 @@ public class mcCombat { continue; } - if(mcm.getInstance().getHealth(x) <= 0){ + if(mcm.getHealth(x) <= 0){ continue; } diff --git a/mcMMO/com/gmail/nossr50/mcConfig.java b/mcMMO/com/gmail/nossr50/mcConfig.java index a64cdecc0..2cd446eb5 100644 --- a/mcMMO/com/gmail/nossr50/mcConfig.java +++ b/mcMMO/com/gmail/nossr50/mcConfig.java @@ -148,7 +148,7 @@ public class mcConfig { instance = new mcConfig(); } return instance; - } + } public void toggleAdminChat(String playerName){ if(isAdminToggled(playerName)){ removeAdminToggled(playerName); diff --git a/mcMMO/com/gmail/nossr50/mcEntityListener.java b/mcMMO/com/gmail/nossr50/mcEntityListener.java index b423c2628..674d2fd2d 100644 --- a/mcMMO/com/gmail/nossr50/mcEntityListener.java +++ b/mcMMO/com/gmail/nossr50/mcEntityListener.java @@ -36,7 +36,7 @@ public class mcEntityListener extends EntityListener { public void onCreatureSpawn(CreatureSpawnEvent event) { Location loc = event.getLocation(); Entity spawnee = event.getEntity(); - if(mcm.getInstance().isBlockAround(loc, 5, 52)){ + if(mcm.isBlockAround(loc, 5, 52)){ mcConfig.getInstance().addMobSpawnTrack(spawnee); } } @@ -90,7 +90,7 @@ public class mcEntityListener extends EntityListener { /* * PARRYING CHECK, CHECK TO SEE IF ITS A SUCCESSFUL PARRY OR NOT */ - mcCombat.getInstance().parryCheck(defender, eventb, f); + mcCombat.parryCheck(defender, eventb, f); } /* @@ -98,7 +98,7 @@ public class mcEntityListener extends EntityListener { */ if(!event.isCancelled() && event instanceof EntityDamageByProjectileEvent && event.getDamage() >= 1){ EntityDamageByProjectileEvent c = (EntityDamageByProjectileEvent)event; - mcCombat.getInstance().archeryCheck(c); + mcCombat.archeryCheck(c); } /* @@ -117,18 +117,18 @@ public class mcEntityListener extends EntityListener { /* * Check if the Timer is doing its job */ - mcSkills.getInstance().monitorSkills(attacker); + mcSkills.monitorSkills(attacker); PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); /* * ACTIVATE ABILITIES */ if(PPa.getAxePreparationMode()) - mcSkills.getInstance().skullSplitterCheck(attacker, plugin); + mcSkills.skullSplitterCheck(attacker, plugin); if(PPa.getSwordsPreparationMode()) - mcSkills.getInstance().serratedStrikesActivationCheck(attacker, plugin); + mcSkills.serratedStrikesActivationCheck(attacker, plugin); if(PPa.getFistsPreparationMode()) - mcSkills.getInstance().berserkActivationCheck(attacker, plugin); + mcSkills.berserkActivationCheck(attacker, plugin); /* * BERSERK DAMAGE MODIFIER */ @@ -137,29 +137,29 @@ public class mcEntityListener extends EntityListener { /* * Player versus Monster checks, this handles all skill damage modifiers and any procs. */ - mcCombat.getInstance().playerVersusMonsterChecks(eventb, attacker, e, typeid); + mcCombat.playerVersusMonsterChecks(eventb, attacker, e, typeid); /* * Player versus Squid checks, this handles all skill damage modifiers and any procs. */ - mcCombat.getInstance().playerVersusSquidChecks(eventb, attacker, e, typeid); + mcCombat.playerVersusSquidChecks(eventb, attacker, e, typeid); /* * Player versus Player checks, these checks make sure players are not in the same party, etc. They also check for any procs from skills and handle damage modifiers. */ - if(mcm.getInstance().isPvpEnabled()) - mcCombat.getInstance().playerVersusPlayerChecks(e, attacker, eventb); + if(mcm.isPvpEnabled()) + mcCombat.playerVersusPlayerChecks(e, attacker, eventb); /* * Player versus Animals checks, these checks handle any skill modifiers or procs */ - mcCombat.getInstance().playerVersusAnimalsChecks(e, attacker, eventb, typeid); + mcCombat.playerVersusAnimalsChecks(e, attacker, eventb, typeid); /* * This will do AOE damage from the axes ability */ - if(!event.isCancelled() && PPa.getSkullSplitterMode() && mcm.getInstance().isAxes(attacker.getItemInHand())){ - mcCombat.getInstance().applyAoeDamage(attacker, eventb, x); + if(!event.isCancelled() && PPa.getSkullSplitterMode() && mcm.isAxes(attacker.getItemInHand())){ + mcCombat.applyAoeDamage(attacker, eventb, x); } - if(!event.isCancelled() && PPa.getSerratedStrikesMode() && mcm.getInstance().isSwords(attacker.getItemInHand())){ - mcCombat.getInstance().applySerratedStrikes(attacker, eventb, x); + if(!event.isCancelled() && PPa.getSerratedStrikesMode() && mcm.isSwords(attacker.getItemInHand())){ + mcCombat.applySerratedStrikes(attacker, eventb, x); } } /* @@ -179,7 +179,7 @@ public class mcEntityListener extends EntityListener { * COUNTER ATTACK STUFF */ if(mcPermissions.getInstance().swords(defender) - && mcm.getInstance().isSwords(defender.getItemInHand())){ + && mcm.isSwords(defender.getItemInHand())){ boolean isArrow = false; if (event instanceof EntityDamageByProjectileEvent) { final EntityDamageByProjectileEvent realEvent = @@ -190,13 +190,13 @@ public class mcEntityListener extends EntityListener { //defender.sendMessage("isArrow ="+isArrow); if(PPd.getSwordsInt() >= 600){ if(Math.random() * 2000 <= 600){ - mcCombat.getInstance().dealDamage(f, event.getDamage() / 2); + mcCombat.dealDamage(f, event.getDamage() / 2); defender.sendMessage(ChatColor.GREEN+"**COUNTER-ATTACKED**"); if(f instanceof Player) ((Player) f).sendMessage(ChatColor.DARK_RED+"Hit with counterattack!"); } } else if (Math.random() * 2000 <= PPd.getSwordsInt()){ - mcCombat.getInstance().dealDamage(f, event.getDamage() / 2); + mcCombat.dealDamage(f, event.getDamage() / 2); defender.sendMessage(ChatColor.GREEN+"**COUNTER-ATTACKED**"); if(f instanceof Player) ((Player) f).sendMessage(ChatColor.DARK_RED+"Hit with counterattack!"); @@ -210,8 +210,10 @@ public class mcEntityListener extends EntityListener { if(PPd.getAcrobaticsInt() <= 800){ if(Math.random() * 4000 <= PPd.getAcrobaticsInt()){ defender.sendMessage(ChatColor.GREEN+"**DODGE**"); - PPd.addAcrobaticsXP(event.getDamage() * 12); - mcSkills.getInstance().XpCheck(defender); + if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){ + PPd.addAcrobaticsXP(event.getDamage() * 12); + mcSkills.XpCheck(defender); + } event.setDamage(event.getDamage() / 2); //Needs to do minimal damage if(event.getDamage() <= 0) @@ -219,8 +221,10 @@ public class mcEntityListener extends EntityListener { } } else if(Math.random() * 4000 <= 800) { defender.sendMessage(ChatColor.GREEN+"**DODGE**"); - PPd.addAcrobaticsXP(event.getDamage() * 12); - mcSkills.getInstance().XpCheck(defender); + if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){ + PPd.addAcrobaticsXP(event.getDamage() * 12); + mcSkills.XpCheck(defender); + } event.setDamage(event.getDamage() / 2); //Needs to do minimal damage if(event.getDamage() <= 0) @@ -233,7 +237,7 @@ public class mcEntityListener extends EntityListener { */ if(f instanceof Wolf){ Wolf theWolf = (Wolf)f; - if(mcTaming.getInstance().hasOwner(theWolf, plugin)){ + if(mcTaming.hasOwner(theWolf, plugin) && mcTaming.getInstance().getOwner(theWolf, plugin) != null){ Player wolfMaster = mcTaming.getInstance().getOwner(theWolf, plugin); if(!event.isCancelled()){ mcUsers.getProfile(wolfMaster.getName()).addXpToSkill(event.getDamage(), "Taming"); @@ -262,7 +266,7 @@ public class mcEntityListener extends EntityListener { if(mcConfig.getInstance().isBleedTracked(x)) mcConfig.getInstance().addToBleedRemovalQue(x); - mcSkills.getInstance().arrowRetrievalCheck(x); + mcSkills.arrowRetrievalCheck(x); if(mcConfig.getInstance().isMobSpawnTracked(x)){ mcConfig.getInstance().removeMobSpawnTrack(x); } diff --git a/mcMMO/com/gmail/nossr50/mcExcavation.java b/mcMMO/com/gmail/nossr50/mcExcavation.java index bc80c62eb..91d95a61c 100644 --- a/mcMMO/com/gmail/nossr50/mcExcavation.java +++ b/mcMMO/com/gmail/nossr50/mcExcavation.java @@ -16,18 +16,11 @@ public class mcExcavation { public mcExcavation(mcMMO instance) { plugin = instance; } - private static volatile mcExcavation instance; - public static mcExcavation getInstance() { - if (instance == null) { - instance = new mcExcavation(plugin); - } - return instance; - } - public void gigaDrillBreakerActivationCheck(Player player, Block block, Plugin pluginx){ + public static void gigaDrillBreakerActivationCheck(Player player, Block block, Plugin pluginx){ PlayerProfile PP = mcUsers.getProfile(player.getName()); - if(mcm.getInstance().isShovel(player.getItemInHand())){ + if(mcm.isShovel(player.getItemInHand())){ if(block != null){ - if(!mcm.getInstance().abilityBlockCheck(block)) + if(!mcm.abilityBlockCheck(block)) return; } if(PP.getShovelPreparationMode()){ @@ -43,7 +36,7 @@ public class mcExcavation { if(!PP.getGigaDrillBreakerMode() && PP.getGigaDrillBreakerCooldown() == 0){ player.sendMessage(ChatColor.GREEN+"**GIGA DRILL BREAKER ACTIVATED**"); for(Player y : pluginx.getServer().getOnlinePlayers()){ - if(y != null && y != player && mcm.getInstance().getDistance(player.getLocation(), y.getLocation()) < 10) + if(y != null && y != player && mcm.getDistance(player.getLocation(), y.getLocation()) < 10) y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Giga Drill Breaker!"); } PP.setGigaDrillBreakerTicks(ticks * 1000); @@ -53,7 +46,7 @@ public class mcExcavation { } } - public boolean canBeGigaDrillBroken(Block block){ + public static boolean canBeGigaDrillBroken(Block block){ int i = block.getTypeId(); if(i == 2||i == 3||i == 12||i == 13){ return true; @@ -61,7 +54,7 @@ public class mcExcavation { return false; } } - public void excavationProcCheck(Block block, Player player){ + public static void excavationProcCheck(Block block, Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); int type = block.getTypeId(); Location loc = block.getLocation(); @@ -205,6 +198,6 @@ public class mcExcavation { } } } - mcSkills.getInstance().XpCheck(player); + mcSkills.XpCheck(player); } } diff --git a/mcMMO/com/gmail/nossr50/mcHerbalism.java b/mcMMO/com/gmail/nossr50/mcHerbalism.java index a74bd60cc..8c460dcb9 100644 --- a/mcMMO/com/gmail/nossr50/mcHerbalism.java +++ b/mcMMO/com/gmail/nossr50/mcHerbalism.java @@ -18,14 +18,8 @@ public class mcHerbalism { public mcHerbalism(mcMMO instance) { plugin = instance; } - private static volatile mcHerbalism instance; - public static mcHerbalism getInstance() { - if (instance == null) { - instance = new mcHerbalism(plugin); - } - return instance; - } - public void greenTerraWheat(Player player, Block block, BlockBreakEvent event){ + + public static void greenTerraWheat(Player player, Block block, BlockBreakEvent event){ if(block.getType() == Material.WHEAT && block.getData() == (byte) 0x07){ event.setCancelled(true); PlayerProfile PP = mcUsers.getProfile(player.getName()); @@ -39,7 +33,7 @@ public class mcHerbalism { block.setData((byte) 0x03); } } - public void greenTerra(Player player, Block block){ + public static void greenTerra(Player player, Block block){ if(block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT){ if(!hasSeeds(player)) player.sendMessage("You need more seeds to spread Green Terra"); @@ -52,7 +46,7 @@ public class mcHerbalism { } } } - public Boolean canBeGreenTerra(Block block){ + public static Boolean canBeGreenTerra(Block block){ int t = block.getTypeId(); if(t == 4 || t == 3 || t == 59 || t == 81 || t == 83 || t == 91 || t == 86 || t == 39 || t == 46 || t == 37 || t == 38){ return true; @@ -60,7 +54,7 @@ public class mcHerbalism { return false; } } - public boolean hasSeeds(Player player){ + public static boolean hasSeeds(Player player){ ItemStack[] inventory = player.getInventory().getContents(); for(ItemStack x : inventory){ if(x != null && x.getTypeId() == 295){ @@ -69,7 +63,7 @@ public class mcHerbalism { } return false; } - public void removeSeeds(Player player){ + public static void removeSeeds(Player player){ ItemStack[] inventory = player.getInventory().getContents(); for(ItemStack x : inventory){ if(x != null && x.getTypeId() == 295){ @@ -85,11 +79,11 @@ public class mcHerbalism { } } } - public void greenTerraCheck(Player player, Block block, Plugin pluginx){ + public static void greenTerraCheck(Player player, Block block, Plugin pluginx){ PlayerProfile PP = mcUsers.getProfile(player.getName()); - if(mcm.getInstance().isHoe(player.getItemInHand())){ + if(mcm.isHoe(player.getItemInHand())){ if(block != null){ - if(!mcm.getInstance().abilityBlockCheck(block)) + if(!mcm.abilityBlockCheck(block)) return; } if(PP.getHoePreparationMode()){ @@ -102,10 +96,10 @@ public class mcHerbalism { ticks++; } - if(!PP.getGreenTerraMode() && mcSkills.getInstance().cooldownOver(player, PP.getGreenTerraDeactivatedTimeStamp(), mcLoadProperties.greenTerraCooldown)){ + if(!PP.getGreenTerraMode() && mcSkills.cooldownOver(player, PP.getGreenTerraDeactivatedTimeStamp(), mcLoadProperties.greenTerraCooldown)){ player.sendMessage(ChatColor.GREEN+"**GREEN TERRA ACTIVATED**"); for(Player y : pluginx.getServer().getOnlinePlayers()){ - if(y != null && y != player && mcm.getInstance().getDistance(player.getLocation(), y.getLocation()) < 10) + if(y != null && y != player && mcm.getDistance(player.getLocation(), y.getLocation()) < 10) y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Green Terra!"); } PP.setGreenTerraTicks(ticks * 1000); @@ -115,7 +109,7 @@ public class mcHerbalism { } } - public void herbalismProcCheck(Block block, Player player, BlockBreakEvent event){ + public static void herbalismProcCheck(Block block, Player player, BlockBreakEvent event){ PlayerProfile PP = mcUsers.getProfile(player.getName()); int type = block.getTypeId(); Location loc = block.getLocation(); @@ -218,9 +212,9 @@ public class mcHerbalism { PP.addHerbalismXP(10 * mcLoadProperties.xpGainMultiplier); } } - mcSkills.getInstance().XpCheck(player); + mcSkills.XpCheck(player); } - public void breadCheck(Player player, ItemStack is){ + public static void breadCheck(Player player, ItemStack is){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(is.getTypeId() == 297){ if(PP.getHerbalismInt() >= 50 && PP.getHerbalismInt() < 150){ @@ -242,7 +236,7 @@ public class mcHerbalism { } } } - public void stewCheck(Player player, ItemStack is){ + public static void stewCheck(Player player, ItemStack is){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(is.getTypeId() == 282){ if(PP.getHerbalismInt() >= 50 && PP.getHerbalismInt() < 150){ diff --git a/mcMMO/com/gmail/nossr50/mcItem.java b/mcMMO/com/gmail/nossr50/mcItem.java index 7a1327361..859310749 100644 --- a/mcMMO/com/gmail/nossr50/mcItem.java +++ b/mcMMO/com/gmail/nossr50/mcItem.java @@ -12,29 +12,19 @@ import com.gmail.nossr50.PlayerList.PlayerProfile; public class mcItem { - private static mcMMO plugin; - public mcItem(mcMMO instance) { - plugin = instance; - } - private static volatile mcItem instance; - public static mcItem getInstance() { - if (instance == null) { - instance = new mcItem(plugin); - } - return instance; - } - public void itemChecks(Player player, Plugin pluginx){ + + public static void itemChecks(Player player, Plugin plugin){ ItemStack inhand = player.getItemInHand(); if(inhand.getTypeId() == 288){ - chimaerawing(player, pluginx); + chimaerawing(player, plugin); } } - public void chimaerawing(Player player, Plugin pluginx){ + public static void chimaerawing(Player player, Plugin plugin){ PlayerProfile PP = mcUsers.getProfile(player.getName()); ItemStack is = player.getItemInHand(); Block block = player.getLocation().getBlock(); if(mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == 288){ - if(mcSkills.getInstance().cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= mcLoadProperties.feathersConsumedByChimaeraWing){ + if(mcSkills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= mcLoadProperties.feathersConsumedByChimaeraWing){ Block derp = player.getLocation().getBlock(); int y = derp.getY(); ItemStack[] inventory = player.getInventory().getContents(); @@ -66,8 +56,8 @@ public class mcItem { } if(PP.getMySpawn(player) != null){ Location mySpawn = PP.getMySpawn(player); - if(mySpawn != null && pluginx.getServer().getWorld(PP.getMySpawnWorld(pluginx)) != null) - mySpawn.setWorld(pluginx.getServer().getWorld(PP.getMySpawnWorld(pluginx))); + if(mySpawn != null && plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)) != null) + mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin))); if(mySpawn != null){ player.teleportTo(mySpawn);//Do it twice to prevent weird stuff player.teleportTo(mySpawn); @@ -76,9 +66,9 @@ public class mcItem { player.teleportTo(player.getWorld().getSpawnLocation()); } player.sendMessage("**CHIMAERA WING**"); - } else if (!mcSkills.getInstance().cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= 10) { + } else if (!mcSkills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= 10) { player.sendMessage("You were injured recently and must wait to use this." - +ChatColor.YELLOW+" ("+mcSkills.getInstance().calculateTimeLeft(player, PP.getRecentlyHurt(), 60)+"s)"); + +ChatColor.YELLOW+" ("+mcSkills.calculateTimeLeft(player, PP.getRecentlyHurt(), 60)+"s)"); } else if (is.getTypeId() == 288 && is.getAmount() <= 9){ player.sendMessage("You need more of that to use it"); } diff --git a/mcMMO/com/gmail/nossr50/mcLeaderboard.java b/mcMMO/com/gmail/nossr50/mcLeaderboard.java new file mode 100644 index 000000000..5e4fc3869 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcLeaderboard.java @@ -0,0 +1,237 @@ +package com.gmail.nossr50; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class mcLeaderboard { + static String location = "plugins/mcMMO/mcmmo.users"; + protected static final Logger log = Logger.getLogger("Minecraft"); + + /* + * Read from the file + */ + public static void makeLeaderboards(){ + //Make Trees + Tree Mining = new Tree(); + Tree WoodCutting = new Tree(); + Tree Herbalism = new Tree(); + Tree Excavation = new Tree(); + Tree Acrobatics = new Tree(); + Tree Repair = new Tree(); + Tree Swords = new Tree(); + Tree Axes = new Tree(); + Tree Archery = new Tree(); + Tree Unarmed = new Tree(); + Tree Taming = new Tree(); + Tree PowerLevel = new Tree(); + + //Add Data To Trees + try { + //Open the user file + FileReader file = new FileReader(location); + BufferedReader in = new BufferedReader(file); + String line = ""; + while((line = in.readLine()) != null) + { + String[] character = line.split(":"); + String p = character[0]; + + + int Plvl = 0; + + if(character.length > 1 && isInt(character[1])) + { + Mining.add(p, Integer.valueOf(character[1])); + Plvl += Integer.valueOf(character[1]); + } + if(character.length > 5 && isInt(character[5])){ + WoodCutting.add(p, Integer.valueOf(character[5])); + Plvl += Integer.valueOf(character[5]); + } + if(character.length > 7 && isInt(character[7])){ + Repair.add(p, Integer.valueOf(character[7])); + Plvl += Integer.valueOf(character[7]); + } + if(character.length > 8 && isInt(character[8])){ + Unarmed.add(p, Integer.valueOf(character[8])); + Plvl += Integer.valueOf(character[8]); + } + if(character.length > 9 && isInt(character[9])){ + Herbalism.add(p, Integer.valueOf(character[9])); + Plvl += Integer.valueOf(character[9]); + } + if(character.length > 10 && isInt(character[10])){ + Excavation.add(p, Integer.valueOf(character[10])); + Plvl += Integer.valueOf(character[10]); + } + if(character.length > 11 && isInt(character[11])){ + Archery.add(p, Integer.valueOf(character[11])); + Plvl += Integer.valueOf(character[11]); + } + if(character.length > 12 && isInt(character[12])){ + Swords.add(p, Integer.valueOf(character[12])); + Plvl += Integer.valueOf(character[12]); + } + if(character.length > 13 && isInt(character[13])){ + Axes.add(p, Integer.valueOf(character[13])); + Plvl += Integer.valueOf(character[13]); + } + if(character.length > 14 && isInt(character[14])){ + Acrobatics.add(p, Integer.valueOf(character[14])); + Plvl += Integer.valueOf(character[14]); + } + if(character.length > 24 && isInt(character[24])){ + Taming.add(p, Integer.valueOf(character[24])); + Plvl += Integer.valueOf(character[24]); + } + + PowerLevel.add(p, Plvl); + } + in.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while reading " + + location + " (Are you sure you formatted it correctly?)", e); + } + //Write the leader board files + leaderWrite(Mining.inOrder(), "mining"); + leaderWrite(WoodCutting.inOrder(), "woodcutting"); + leaderWrite(Repair.inOrder(), "repair"); + leaderWrite(Unarmed.inOrder(), "unarmed"); + leaderWrite(Herbalism.inOrder(), "herbalism"); + leaderWrite(Excavation.inOrder(), "excavation"); + leaderWrite(Archery.inOrder(), "archery"); + leaderWrite(Swords.inOrder(), "swords"); + leaderWrite(Axes.inOrder(), "axes"); + leaderWrite(Acrobatics.inOrder(), "acrobatics"); + leaderWrite(Taming.inOrder(), "taming"); + leaderWrite(PowerLevel.inOrder(), "powerlevel"); + } + public static void leaderWrite(PlayerStat[] ps, String statName) + { + String theLocation = "plugins/mcMMO/" + statName + ".mcmmo"; + //CHECK IF THE FILE EXISTS + File theDir = new File(theLocation); + if(!theDir.exists()){ + //properties = new PropertiesFile(location); + FileWriter writer = null; + try { + writer = new FileWriter(theLocation); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while creating " + theLocation, e); + } finally { + try { + if (writer != null) { + writer.close(); + } + } catch (IOException e) { + log.log(Level.SEVERE, "Exception while closing writer for " + theLocation, e); + } + } + } else { + try { + FileReader file = new FileReader(theLocation); + + //HERP + BufferedReader in = new BufferedReader(file); + StringBuilder writer = new StringBuilder(); + String line = ""; + for(PlayerStat p : ps) + { + writer.append(p.name + ":" + p.statVal); + writer.append("\r\n"); + } + in.close(); + //Write the new file + FileWriter out = new FileWriter(theLocation); + out.write(writer.toString()); + out.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)", e); + } + } + //Create/open the file + //Loop through backward writing each player + //Close the file + } + + public static String[] retrieveInfo(String statName, int pagenumber){ + String theLocation = "plugins/mcMMO/" + statName + ".mcmmo"; + try { + FileReader file = new FileReader(theLocation); + BufferedReader in = new BufferedReader(file); + + int destination = (pagenumber - 1) * 10; //How many lines to skip through + int x = 0; //how many lines we've gone through + int y = 0; //going through the lines + String line = ""; + String[] info = new String[10]; //what to return + while((line = in.readLine()) != null && y < 10) + { + x++; + if(x >= destination && y < 10){ + info[y] = line.toString(); + y++; + } + } + in.close(); + return info; + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while reading " + + theLocation + " (Are you sure you formatted it correctly?)", e); + } + return null; //Shouldn't get here + } + public static void updateLeaderboard(PlayerStat ps, String statName){ + String theLocation = "plugins/mcMMO/" + statName + ".mcmmo"; + try { + //Open the file + FileReader file = new FileReader(theLocation); + BufferedReader in = new BufferedReader(file); + StringBuilder writer = new StringBuilder(); + String line = ""; + Boolean inserted = false; + //While not at the end of the file + while((line = in.readLine()) != null) + { + //Insert the player into the line before it finds a smaller one + if(Integer.valueOf(line.split(":")[1]) < ps.statVal && !inserted) + { + writer.append(ps.name + ":" + ps.statVal).append("\r\n"); + inserted = true; + } + //Write anything that isn't the player already in the file so we remove the duplicate + if(!line.split(":")[0].equalsIgnoreCase(ps.name)) + { + writer.append(line).append("\r\n"); + } + } + + if(!inserted) + { + writer.append(ps.name + ":" + ps.statVal).append("\r\n"); + } + + in.close(); + //Write the new file + FileWriter out = new FileWriter(theLocation); + out.write(writer.toString()); + out.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)", e); + } + } + public static boolean isInt(String string){ + try { + int x = Integer.parseInt(string); + } + catch(NumberFormatException nFE) { + return false; + } + return true; + } +} diff --git a/mcMMO/com/gmail/nossr50/mcLoadProperties.java b/mcMMO/com/gmail/nossr50/mcLoadProperties.java index 16ff92be2..51e23b187 100644 --- a/mcMMO/com/gmail/nossr50/mcLoadProperties.java +++ b/mcMMO/com/gmail/nossr50/mcLoadProperties.java @@ -2,7 +2,7 @@ package com.gmail.nossr50; public class mcLoadProperties { public static Boolean cocoabeans, archeryFireRateLimit, mushrooms, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, woodcuttingrequiresaxe, pvp, eggs, apples, myspawnclearsinventory, cake, music, diamond, glowstone, slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages; - public static String addxp, mcability, mcmmo, mcc, mcrefresh, mcitem, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn; + public static String mctop, addxp, mcability, mcmmo, mcc, mcrefresh, mcitem, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn; public static int xpGainMultiplier, superBreakerCooldown, greenTerraCooldown, gigaDrillBreakerCooldown, treeFellerCooldown, berserkCooldown, serratedStrikeCooldown, skullSplitterCooldown, abilityDurabilityLoss, feathersConsumedByChimaeraWing, pvpxprewardmodifier, repairdiamondlevel, globalxpmodifier, tamingxpmodifier, miningxpmodifier, repairxpmodifier, woodcuttingxpmodifier, unarmedxpmodifier, herbalismxpmodifier, excavationxpmodifier, archeryxpmodifier, swordsxpmodifier, axesxpmodifier, acrobaticsxpmodifier; public static void loadMain(){ @@ -77,6 +77,7 @@ public class mcLoadProperties { /* * CUSTOM COMMANDS */ + mctop = properties.getString("/mctop", "mctop"); addxp = properties.getString("/addxp", "addxp"); mcability = properties.getString("/mcability", "mcability"); mcrefresh = properties.getString("/mcrefresh", "mcrefresh"); diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index 5da6fc10c..f2b836a10 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -84,6 +84,7 @@ public class mcMMO extends JavaPlugin { PluginDescriptionFile pdfFile = this.getDescription(); mcPermissions.initialize(getServer()); + mcLeaderboard.makeLeaderboards(); //Make the leaderboards System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); } public void setupPermissions() { @@ -118,7 +119,7 @@ public class mcMMO extends JavaPlugin { public void addXp(Player player, String skillname, Integer newvalue){ PlayerProfile PP = mcUsers.getProfile(player.getName()); PP.addXpToSkill(newvalue, skillname); - mcSkills.getInstance().XpCheck(player); + mcSkills.XpCheck(player); } public void modifySkill(Player player, String skillname, Integer newvalue){ PlayerProfile PP = mcUsers.getProfile(player.getName()); diff --git a/mcMMO/com/gmail/nossr50/mcMining.java b/mcMMO/com/gmail/nossr50/mcMining.java index ff5fcaff1..93a627f12 100644 --- a/mcMMO/com/gmail/nossr50/mcMining.java +++ b/mcMMO/com/gmail/nossr50/mcMining.java @@ -16,19 +16,12 @@ public class mcMining { public mcMining(mcMMO instance) { plugin = instance; } - private static volatile mcMining instance; - public static mcMining getInstance() { - if (instance == null) { - instance = new mcMining(plugin); - } - return instance; - } - public void superBreakerCheck(Player player, Block block, Plugin pluginx){ + public static void superBreakerCheck(Player player, Block block, Plugin pluginx){ PlayerProfile PP = mcUsers.getProfile(player.getName()); - if(mcm.getInstance().isMiningPick(player.getItemInHand())){ + if(mcm.isMiningPick(player.getItemInHand())){ if(block != null){ - if(!mcm.getInstance().abilityBlockCheck(block)) + if(!mcm.abilityBlockCheck(block)) return; } if(PP.getPickaxePreparationMode()){ @@ -41,10 +34,10 @@ public class mcMining { ticks++; } - if(!PP.getSuperBreakerMode() && mcSkills.getInstance().cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), mcLoadProperties.superBreakerCooldown)){ + if(!PP.getSuperBreakerMode() && mcSkills.cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), mcLoadProperties.superBreakerCooldown)){ player.sendMessage(ChatColor.GREEN+"**SUPER BREAKER ACTIVATED**"); for(Player y : pluginx.getServer().getOnlinePlayers()){ - if(y != null && y != player && mcm.getInstance().getDistance(player.getLocation(), y.getLocation()) < 10) + if(y != null && y != player && mcm.getDistance(player.getLocation(), y.getLocation()) < 10) y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Super Breaker!"); } PP.setSuperBreakerTicks(ticks * 1000); @@ -54,7 +47,7 @@ public class mcMining { } } - public void blockProcSimulate(Block block){ + public static void blockProcSimulate(Block block){ Location loc = block.getLocation(); Material mat = Material.getMaterial(block.getTypeId()); byte damage = 0; @@ -100,7 +93,7 @@ public class mcMining { loc.getWorld().dropItemNaturally(loc, item); } } - public void blockProcCheck(Block block, Player player){ + public static void blockProcCheck(Block block, Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(player != null){ if(Math.random() * 1000 <= PP.getMiningInt()){ @@ -109,7 +102,7 @@ public class mcMining { } } } - public void miningBlockCheck(Player player, Block block){ + public static void miningBlockCheck(Player player, Block block){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(mcConfig.getInstance().isBlockWatched(block) || block.getData() == (byte) 5) return; @@ -164,12 +157,12 @@ public class mcMining { blockProcCheck(block, player); } PP.addMiningXP(xp * mcLoadProperties.xpGainMultiplier); - mcSkills.getInstance().XpCheck(player); + mcSkills.XpCheck(player); } /* * Handling SuperBreaker stuff */ - public Boolean canBeSuperBroken(Block block){ + public static Boolean canBeSuperBroken(Block block){ int t = block.getTypeId(); if(t == 49 || t == 87 || t == 89 || t == 73 || t == 74 || t == 56 || t == 21 || t == 1 || t == 16 || t == 14 || t == 15){ return true; @@ -177,10 +170,10 @@ public class mcMining { return false; } } - public void SuperBreakerBlockCheck(Player player, Block block){ + public static void SuperBreakerBlockCheck(Player player, Block block){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(mcLoadProperties.toolsLoseDurabilityFromAbilities) - mcm.getInstance().damageTool(player, (short) mcLoadProperties.abilityDurabilityLoss); + mcm.damageTool(player, (short) mcLoadProperties.abilityDurabilityLoss); Location loc = block.getLocation(); Material mat = Material.getMaterial(block.getTypeId()); int xp = 0; @@ -238,7 +231,7 @@ public class mcMining { block.setType(Material.AIR); } //GOLD - if(block.getTypeId() == 14 && mcm.getInstance().getTier(player) >= 3){ + if(block.getTypeId() == 14 && mcm.getTier(player) >= 3){ if(!mcConfig.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){ xp += 35; blockProcCheck(block, player); @@ -249,9 +242,9 @@ public class mcMining { block.setType(Material.AIR); } //OBSIDIAN - if(block.getTypeId() == 49 && mcm.getInstance().getTier(player) >= 4){ + if(block.getTypeId() == 49 && mcm.getTier(player) >= 4){ if(mcLoadProperties.toolsLoseDurabilityFromAbilities) - mcm.getInstance().damageTool(player, (short) 104); + mcm.damageTool(player, (short) 104); if(!mcConfig.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){ xp += 15; blockProcCheck(block, player); @@ -263,7 +256,7 @@ public class mcMining { block.setType(Material.AIR); } //DIAMOND - if(block.getTypeId() == 56 && mcm.getInstance().getTier(player) >= 3){ + if(block.getTypeId() == 56 && mcm.getTier(player) >= 3){ if(!mcConfig.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){ xp += 75; blockProcCheck(block, player); @@ -275,7 +268,7 @@ public class mcMining { block.setType(Material.AIR); } //IRON - if(block.getTypeId() == 15 && mcm.getInstance().getTier(player) >= 2){ + if(block.getTypeId() == 15 && mcm.getTier(player) >= 2){ if(!mcConfig.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){ xp += 25; blockProcCheck(block, player); @@ -286,7 +279,7 @@ public class mcMining { block.setType(Material.AIR); } //REDSTONE - if((block.getTypeId() == 73 || block.getTypeId() == 74) && mcm.getInstance().getTier(player) >= 4){ + if((block.getTypeId() == 73 || block.getTypeId() == 74) && mcm.getTier(player) >= 4){ if(!mcConfig.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){ xp += 15; blockProcCheck(block, player); @@ -303,7 +296,7 @@ public class mcMining { block.setType(Material.AIR); } //LAPUS - if(block.getTypeId() == 21 && mcm.getInstance().getTier(player) >= 3){ + if(block.getTypeId() == 21 && mcm.getTier(player) >= 3){ if(!mcConfig.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){ xp += 40; blockProcCheck(block, player); @@ -319,6 +312,6 @@ public class mcMining { } if(block.getData() != (byte) 5) PP.addMiningXP(xp * mcLoadProperties.xpGainMultiplier); - mcSkills.getInstance().XpCheck(player); + mcSkills.XpCheck(player); } } diff --git a/mcMMO/com/gmail/nossr50/mcPermissions.java b/mcMMO/com/gmail/nossr50/mcPermissions.java index c40311e77..5da3fb329 100644 --- a/mcMMO/com/gmail/nossr50/mcPermissions.java +++ b/mcMMO/com/gmail/nossr50/mcPermissions.java @@ -27,7 +27,7 @@ public class mcPermissions { } } - private boolean permission(Player player, String string) { + private static boolean permission(Player player, String string) { return permissionsPlugin.Security.permission(player, string); } public boolean mcrefresh(Player player) { @@ -204,7 +204,7 @@ public class mcPermissions { return true; } } - public boolean repair(Player player) { + public static boolean repair(Player player) { if (permissionsEnabled) { return permission(player, "mcmmo.skills.repair"); } else { diff --git a/mcMMO/com/gmail/nossr50/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/mcPlayerListener.java index 462cff052..a0b5ce6a7 100644 --- a/mcMMO/com/gmail/nossr50/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/mcPlayerListener.java @@ -29,10 +29,12 @@ public class mcPlayerListener extends PlayerListener { public mcPlayerListener(mcMMO instance) { plugin = instance; } + public void onPlayerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); PlayerProfile PP = mcUsers.getProfile(player.getName()); if(player != null){ + PP.setRespawnATS(System.currentTimeMillis()); Location mySpawn = PP.getMySpawn(player); if(mySpawn != null && plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)) != null) mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin))); @@ -80,8 +82,8 @@ public class mcPlayerListener extends PlayerListener { if(player.getItemInHand().getTypeId() == 261 && mcLoadProperties.archeryFireRateLimit){ if(System.currentTimeMillis() < PP.getArcheryShotATS() + 1000){ /* - if(mcm.getInstance().hasArrows(player)) - mcm.getInstance().addArrows(player); + if(mcm.hasArrows(player)) + mcm.addArrows(player); */ player.updateInventory(); event.setCancelled(true); @@ -104,22 +106,22 @@ public class mcPlayerListener extends PlayerListener { } } if(block != null && player != null && mcPermissions.getInstance().repair(player) && event.getClickedBlock().getTypeId() == 42){ - mcRepair.getInstance().repairCheck(player, is, event.getClickedBlock()); + mcRepair.repairCheck(player, is, event.getClickedBlock()); } - if(mcm.getInstance().abilityBlockCheck(block)) + if(mcm.abilityBlockCheck(block)) { - if(block != null && mcm.getInstance().isHoe(player.getItemInHand()) && block.getTypeId() != 3 && block.getTypeId() != 2 && block.getTypeId() != 60){ - mcSkills.getInstance().hoeReadinessCheck(player); + if(block != null && mcm.isHoe(player.getItemInHand()) && block.getTypeId() != 3 && block.getTypeId() != 2 && block.getTypeId() != 60){ + mcSkills.hoeReadinessCheck(player); } - mcSkills.getInstance().abilityActivationCheck(player); + mcSkills.abilityActivationCheck(player); } //GREEN THUMB if(block != null && (block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT) && player.getItemInHand().getType() == Material.SEEDS){ boolean pass = false; - if(mcHerbalism.getInstance().hasSeeds(player)){ - mcHerbalism.getInstance().removeSeeds(player); + if(mcHerbalism.hasSeeds(player)){ + mcHerbalism.removeSeeds(player); if(block.getType() == Material.COBBLESTONE && Math.random() * 1500 <= PP.getHerbalismInt()){ player.sendMessage(ChatColor.GREEN+"**GREEN THUMB**"); block.setType(Material.MOSSY_COBBLESTONE); @@ -137,25 +139,25 @@ public class mcPlayerListener extends PlayerListener { } } if(action == Action.RIGHT_CLICK_AIR){ - mcSkills.getInstance().hoeReadinessCheck(player); - mcSkills.getInstance().abilityActivationCheck(player); + mcSkills.hoeReadinessCheck(player); + mcSkills.abilityActivationCheck(player); /* * HERBALISM MODIFIERS */ if(mcPermissions.getInstance().herbalism(player)){ - mcHerbalism.getInstance().breadCheck(player, player.getItemInHand()); - mcHerbalism.getInstance().stewCheck(player, player.getItemInHand()); + mcHerbalism.breadCheck(player, player.getItemInHand()); + mcHerbalism.stewCheck(player, player.getItemInHand()); } } /* * ITEM CHECKS */ if(action == Action.RIGHT_CLICK_AIR) - mcItem.getInstance().itemChecks(player, plugin); + mcItem.itemChecks(player, plugin); if(action == Action.RIGHT_CLICK_BLOCK){ - if(mcm.getInstance().abilityBlockCheck(event.getClickedBlock())) - mcItem.getInstance().itemChecks(player, plugin); + if(mcm.abilityBlockCheck(event.getClickedBlock())) + mcItem.itemChecks(player, plugin); } } public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { @@ -164,7 +166,7 @@ public class mcPlayerListener extends PlayerListener { String[] split = event.getMessage().split(" "); String playerName = player.getName(); //Check if the command is an mcMMO related help command - mcm.getInstance().mcmmoHelpCheck(split, player, event); + mcm.mcmmoHelpCheck(split, player, event); if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.mcability)){ event.setCancelled(true); if(PP.getAbilityUse()){ @@ -175,6 +177,102 @@ public class mcPlayerListener extends PlayerListener { PP.toggleAbilityUse(); } } + /* + * LEADER BOARD COMMAND + */ + + if(split[0].equalsIgnoreCase("/"+mcLoadProperties.mctop)){ + event.setCancelled(true); + //Format: /mctop + + /* + * POWER LEVEL INFO RETRIEVAL + */ + if(split.length == 1){ + int p = 1; + String[] info = mcLeaderboard.retrieveInfo("powerlevel", p); + player.sendMessage(ChatColor.YELLOW+"--mcMMO"+ChatColor.BLUE+" Power Level "+ChatColor.YELLOW+"Leaderboard--"); + int n = 1 * p; //Position + for(String x : info){ + if(x != null){ + String digit = String.valueOf(n); + if(n < 10) + digit ="0"+String.valueOf(n); + String[] splitx = x.split(":"); + //Format: 1. Playername - skill value + player.sendMessage(digit+". "+ChatColor.GREEN+splitx[1]+" - "+ChatColor.WHITE+splitx[0]); + n++; + } + } + } + if(split.length >= 2 && mcLeaderboard.isInt(split[1])){ + int p = 1; + //Grab page value if specified + if(split.length >= 2){ + if(mcLeaderboard.isInt(split[1])){ + p = Integer.valueOf(split[1]); + } + } + int pt = p; + if(p > 1){ + pt -= 1; + pt += (pt * 10); + pt = 10; + } + String[] info = mcLeaderboard.retrieveInfo("powerlevel", p); + player.sendMessage("--mcMMO Power Level Leaderboard--"); + int n = 1 * pt; //Position + for(String x : info){ + if(x != null){ + String digit = String.valueOf(n); + if(n < 10) + digit ="0"+String.valueOf(n); + String[] splitx = x.split(":"); + //Format: 1. Playername - skill value + player.sendMessage(digit+". "+ChatColor.GREEN+splitx[1]+" - "+ChatColor.WHITE+splitx[0]); + n++; + } + } + } + /* + * SKILL SPECIFIED INFO RETRIEVAL + */ + if(split.length >= 2 && mcSkills.isSkill(split[1])){ + int p = 1; + //Grab page value if specified + if(split.length >= 3){ + if(mcLeaderboard.isInt(split[2])){ + p = Integer.valueOf(split[2]); + } + } + int pt = p; + if(p > 1){ + pt -= 1; + pt += (pt * 10); + pt = 10; + } + String firstLetter = split[1].substring(0,1); // Get first letter + String remainder = split[1].substring(1); // Get remainder of word. + String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase(); + + String[] info = mcLeaderboard.retrieveInfo(split[1].toLowerCase(), p); + player.sendMessage(ChatColor.YELLOW+"--mcMMO "+ChatColor.BLUE+capitalized+ChatColor.YELLOW+" Leaderboard--"); + int n = 1 * pt; //Position + for(String x : info){ + if(x != null){ + String digit = String.valueOf(n); + if(n < 10) + digit ="0"+String.valueOf(n); + String[] splitx = x.split(":"); + //Format: 1. Playername - skill value + player.sendMessage(digit+". "+ChatColor.GREEN+splitx[1]+" - "+ChatColor.WHITE+splitx[0]); + n++; + } + } + } + } + + /* if(split[0].equalsIgnoreCase("/mutechat")){ event.setCancelled(true); @@ -278,14 +376,14 @@ public class mcPlayerListener extends PlayerListener { return; } if(split.length == 4){ - if(isPlayer(split[1]) && mcm.getInstance().isInt(split[3]) && mcSkills.getInstance().isSkill(split[2])){ + if(isPlayer(split[1]) && mcm.isInt(split[3]) && mcSkills.isSkill(split[2])){ int newvalue = Integer.valueOf(split[3]); mcUsers.getProfile(getPlayer(split[1]).getName()).modifyskill(newvalue, split[2]); player.sendMessage(ChatColor.RED+split[2]+" has been modified."); } } else if(split.length == 3){ - if(mcm.getInstance().isInt(split[2]) && mcSkills.getInstance().isSkill(split[1])){ + if(mcm.isInt(split[2]) && mcSkills.isSkill(split[1])){ int newvalue = Integer.valueOf(split[2]); PP.modifyskill(newvalue, split[1]); player.sendMessage(ChatColor.RED+split[1]+" has been modified."); @@ -308,7 +406,7 @@ public class mcPlayerListener extends PlayerListener { return; } if(split.length == 4){ - if(isPlayer(split[1]) && mcm.getInstance().isInt(split[3]) && mcSkills.getInstance().isSkill(split[2])){ + if(isPlayer(split[1]) && mcm.isInt(split[3]) && mcSkills.isSkill(split[2])){ int newvalue = Integer.valueOf(split[3]); mcUsers.getProfile(getPlayer(split[1]).getName()).addXpToSkill(newvalue, split[2]); getPlayer(split[1]).sendMessage(ChatColor.GREEN+"Experience granted!"); @@ -316,7 +414,7 @@ public class mcPlayerListener extends PlayerListener { } } else if(split.length == 3){ - if(mcm.getInstance().isInt(split[2]) && mcSkills.getInstance().isSkill(split[1])){ + if(mcm.isInt(split[2]) && mcSkills.isSkill(split[1])){ int newvalue = Integer.valueOf(split[2]); PP.addXpToSkill(newvalue, split[1]); player.sendMessage(ChatColor.RED+split[1]+" has been modified."); @@ -417,7 +515,7 @@ public class mcPlayerListener extends PlayerListener { player.sendMessage(ChatColor.YELLOW + "Acrobatics Skill: " + ChatColor.GREEN + PPt.getAcrobatics()+ChatColor.DARK_AQUA + " XP("+PPt.getAcrobaticsXP() +"/"+PPt.getXpToLevel("acrobatics")+")"); - player.sendMessage(ChatColor.DARK_RED+"POWER LEVEL: "+ChatColor.GREEN+(mcm.getInstance().getPowerLevel(target))); + player.sendMessage(ChatColor.DARK_RED+"POWER LEVEL: "+ChatColor.GREEN+(mcm.getPowerLevel(target))); player.sendMessage(ChatColor.GREEN+"~~COORDINATES~~"); player.sendMessage("X: "+x); player.sendMessage("Y: "+y); @@ -477,7 +575,7 @@ public class mcPlayerListener extends PlayerListener { player.sendMessage(ChatColor.YELLOW + "Acrobatics Skill: " + ChatColor.GREEN + PP.getAcrobatics()+ChatColor.DARK_AQUA + " XP("+PP.getAcrobaticsXP() +"/"+PP.getXpToLevel("acrobatics")+")"); - player.sendMessage(ChatColor.DARK_RED+"POWER LEVEL: "+ChatColor.GREEN+(mcm.getInstance().getPowerLevel(player))); + player.sendMessage(ChatColor.DARK_RED+"POWER LEVEL: "+ChatColor.GREEN+(mcm.getPowerLevel(player))); } //Invite Command if(mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.invite)){ diff --git a/mcMMO/com/gmail/nossr50/mcRepair.java b/mcMMO/com/gmail/nossr50/mcRepair.java index 71911aadb..e630486ac 100644 --- a/mcMMO/com/gmail/nossr50/mcRepair.java +++ b/mcMMO/com/gmail/nossr50/mcRepair.java @@ -14,19 +14,14 @@ public class mcRepair { plugin = instance; } private static volatile mcRepair instance; - public static mcRepair getInstance() { - if (instance == null) { - instance = new mcRepair(plugin); - } - return instance; - } - public void repairCheck(Player player, ItemStack is, Block block){ + + public static void repairCheck(Player player, ItemStack is, Block block){ PlayerProfile PP = mcUsers.getProfile(player.getName()); short durabilityBefore = player.getItemInHand().getDurability(); short durabilityAfter = 0; short dif = 0; if(block != null - && mcPermissions.getInstance().repair(player)){ + && mcPermissions.repair(player)){ if(player.getItemInHand().getDurability() > 0 && player.getItemInHand().getAmount() < 2){ /* * ARMOR @@ -80,11 +75,11 @@ public class mcRepair { player.getItemInHand().setDurability(getToolRepairAmount(is, player)); durabilityAfter = player.getItemInHand().getDurability(); dif = (short) (durabilityBefore - durabilityAfter); - if(mcm.getInstance().isShovel(is)) + if(mcm.isShovel(is)) dif = (short) (dif / 3); - if(mcm.getInstance().isSwords(is)) + if(mcm.isSwords(is)) dif = (short) (dif / 2); - if(mcm.getInstance().isHoe(is)) + if(mcm.isHoe(is)) dif = (short) (dif / 2); PP.addRepairXP(dif * mcLoadProperties.xpGainMultiplier); } else if (isDiamondTools(is) && hasDiamond(player) && PP.getRepairInt() >= mcLoadProperties.repairdiamondlevel){ //Check if its diamond and the player has diamonds @@ -95,11 +90,11 @@ public class mcRepair { removeDiamond(player); durabilityAfter = player.getItemInHand().getDurability(); dif = (short) (durabilityBefore - durabilityAfter); - if(mcm.getInstance().isShovel(is)) + if(mcm.isShovel(is)) dif = (short) (dif / 3); - if(mcm.getInstance().isSwords(is)) + if(mcm.isSwords(is)) dif = (short) (dif / 2); - if(mcm.getInstance().isHoe(is)) + if(mcm.isHoe(is)) dif = (short) (dif / 2); PP.addRepairXP(dif * mcLoadProperties.xpGainMultiplier); } else if(isGoldTools(is) && hasGold(player)){ @@ -108,11 +103,11 @@ public class mcRepair { durabilityAfter = player.getItemInHand().getDurability(); dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron - if(mcm.getInstance().isShovel(is)) + if(mcm.isShovel(is)) dif = (short) (dif / 3); - if(mcm.getInstance().isSwords(is)) + if(mcm.isSwords(is)) dif = (short) (dif / 2); - if(mcm.getInstance().isHoe(is)) + if(mcm.isHoe(is)) dif = (short) (dif / 2); PP.addRepairXP(dif * mcLoadProperties.xpGainMultiplier); } else { @@ -127,10 +122,10 @@ public class mcRepair { /* * GIVE SKILL IF THERE IS ENOUGH XP */ - mcSkills.getInstance().XpCheck(player); + mcSkills.XpCheck(player); } } - public boolean isArmor(ItemStack is){ + public static boolean isArmor(ItemStack is){ if(is.getTypeId() == 306 || is.getTypeId() == 307 ||is.getTypeId() == 308 ||is.getTypeId() == 309 || is.getTypeId() == 310 ||is.getTypeId() == 311 ||is.getTypeId() == 312 ||is.getTypeId() == 313 || is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317){ @@ -139,14 +134,14 @@ public class mcRepair { return false; } } - public boolean isGoldArmor(ItemStack is){ + public static boolean isGoldArmor(ItemStack is){ if(is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317){ return true; } else { return false; } } - public boolean isIronArmor(ItemStack is){ + public static boolean isIronArmor(ItemStack is){ if(is.getTypeId() == 306 || is.getTypeId() == 307 || is.getTypeId() == 308 || is.getTypeId() == 309) { return true; @@ -154,7 +149,7 @@ public class mcRepair { return false; } } - public boolean isDiamondArmor(ItemStack is){ + public static boolean isDiamondArmor(ItemStack is){ if(is.getTypeId() == 310 || is.getTypeId() == 311 || is.getTypeId() == 312 || is.getTypeId() == 313) { return true; @@ -162,7 +157,7 @@ public class mcRepair { return false; } } - public boolean isTools(ItemStack is){ + public static boolean isTools(ItemStack is){ if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 || //IRON is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293 || //DIAMOND is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284) //GOLD @@ -172,14 +167,14 @@ public class mcRepair { return false; } } - public boolean isGoldTools(ItemStack is){ + public static boolean isGoldTools(ItemStack is){ if(is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294){ return true; } else { return false; } } - public boolean isIronTools(ItemStack is){ + public static boolean isIronTools(ItemStack is){ if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292) { return true; @@ -188,7 +183,7 @@ public class mcRepair { } } - public boolean isDiamondTools(ItemStack is){ + public static boolean isDiamondTools(ItemStack is){ if(is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293) { return true; @@ -196,7 +191,7 @@ public class mcRepair { return false; } } - public void removeIron(Player player){ + public static void removeIron(Player player){ ItemStack[] inventory = player.getInventory().getContents(); for(ItemStack x : inventory){ if(x != null && x.getTypeId() == 265){ @@ -212,7 +207,7 @@ public class mcRepair { } } } - public void removeGold(Player player){ + public static void removeGold(Player player){ ItemStack[] inventory = player.getInventory().getContents(); for(ItemStack x : inventory){ if(x != null && x.getTypeId() == 266){ @@ -228,7 +223,7 @@ public class mcRepair { } } } - public void removeDiamond(Player player){ + public static void removeDiamond(Player player){ ItemStack[] inventory = player.getInventory().getContents(); for(ItemStack x : inventory){ if(x != null && x.getTypeId() == 264){ @@ -244,7 +239,7 @@ public class mcRepair { } } } - public boolean hasGold(Player player){ + public static boolean hasGold(Player player){ ItemStack[] inventory = player.getInventory().getContents(); for(ItemStack x : inventory){ if(x != null && x.getTypeId() == 266){ @@ -253,7 +248,7 @@ public class mcRepair { } return false; } - public boolean hasDiamond(Player player){ + public static boolean hasDiamond(Player player){ ItemStack[] inventory = player.getInventory().getContents(); for(ItemStack x : inventory){ if(x != null && x.getTypeId() == 264){ @@ -262,7 +257,7 @@ public class mcRepair { } return false; } - public boolean hasIron(Player player){ + public static boolean hasIron(Player player){ ItemStack[] inventory = player.getInventory().getContents(); for(ItemStack x : inventory){ if(x != null && x.getTypeId() == 265){ @@ -271,7 +266,7 @@ public class mcRepair { } return false; } - public short repairCalculate(Player player, short durability, short ramt){ + public static short repairCalculate(Player player, short durability, short ramt){ PlayerProfile PP = mcUsers.getProfile(player.getName()); float bonus = (PP.getRepairInt() / 500); bonus = (ramt * bonus); @@ -285,7 +280,7 @@ public class mcRepair { } return durability; } - public short getToolRepairAmount(ItemStack is, Player player){ + public static short getToolRepairAmount(ItemStack is, Player player){ short durability = is.getDurability(); short ramt = 0; switch(is.getTypeId()) @@ -354,7 +349,7 @@ public class mcRepair { return repairCalculate(player, durability, ramt); } //This determines how much we repair - public short getArmorRepairAmount(ItemStack is, Player player){ + public static short getArmorRepairAmount(ItemStack is, Player player){ short durability = is.getDurability(); short ramt = 0; switch(is.getTypeId()) @@ -400,7 +395,7 @@ public class mcRepair { durability = 0; return repairCalculate(player, durability, ramt); } - public void needMoreVespeneGas(ItemStack is, Player player){ + public static void needMoreVespeneGas(ItemStack is, Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getRepairInt() < mcLoadProperties.repairdiamondlevel){ player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond"); @@ -421,7 +416,7 @@ public class mcRepair { } else if (is.getAmount() > 1) player.sendMessage(ChatColor.DARK_RED+"You can't repair stacked items"); } - public boolean checkPlayerProcRepair(Player player){ + public static boolean checkPlayerProcRepair(Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(player != null){ if(Math.random() * 1000 <= PP.getRepairInt()){ diff --git a/mcMMO/com/gmail/nossr50/mcSkills.java b/mcMMO/com/gmail/nossr50/mcSkills.java index 687ac5155..5b0ddd173 100644 --- a/mcMMO/com/gmail/nossr50/mcSkills.java +++ b/mcMMO/com/gmail/nossr50/mcSkills.java @@ -16,13 +16,8 @@ public class mcSkills { plugin = instance; } private static volatile mcSkills instance; - public static mcSkills getInstance() { - if (instance == null) { - instance = new mcSkills(plugin); - } - return instance; - } - public boolean cooldownOver(Player player, long oldTime, int cooldown){ + + public static boolean cooldownOver(Player player, long oldTime, int cooldown){ long currentTime = System.currentTimeMillis(); if(currentTime - oldTime >= (cooldown * 1000)){ return true; @@ -46,7 +41,7 @@ public class mcSkills { } } } - public int calculateTimeLeft(Player player, long deactivatedTimeStamp, int cooldown){ + public static int calculateTimeLeft(Player player, long deactivatedTimeStamp, int cooldown){ long currentTime = System.currentTimeMillis(); int x = 0; while(currentTime < deactivatedTimeStamp + (cooldown * 1000)){ @@ -55,7 +50,7 @@ public class mcSkills { } return x; } - public void watchCooldowns(Player player){ + public static void watchCooldowns(Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(!PP.getGreenTerraInformed() && System.currentTimeMillis() - PP.getGreenTerraDeactivatedTimeStamp() >= (mcLoadProperties.greenTerraCooldown * 1000)){ PP.setGreenTerraInformed(true); @@ -86,9 +81,9 @@ public class mcSkills { player.sendMessage(ChatColor.GREEN+"Your "+ChatColor.YELLOW+"Giga Drill Breaker "+ChatColor.GREEN+"ability is refreshed!"); } } - public void hoeReadinessCheck(Player player){ + public static void hoeReadinessCheck(Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); - if(mcPermissions.getInstance().herbalismAbility(player) && mcm.getInstance().isHoe(player.getItemInHand()) && !PP.getHoePreparationMode()){ + if(mcPermissions.getInstance().herbalismAbility(player) && mcm.isHoe(player.getItemInHand()) && !PP.getHoePreparationMode()){ if(!PP.getGreenTerraMode() && !cooldownOver(player, PP.getGreenTerraDeactivatedTimeStamp(), mcLoadProperties.greenTerraCooldown)){ player.sendMessage(ChatColor.RED+"You are too tired to use that ability again." +ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getGreenTerraDeactivatedTimeStamp(), mcLoadProperties.greenTerraCooldown)+"s)"); @@ -99,11 +94,11 @@ public class mcSkills { PP.setHoePreparationMode(true); } } - public void abilityActivationCheck(Player player){ + public static void abilityActivationCheck(Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(!PP.getAbilityUse()) return; - if(mcPermissions.getInstance().miningAbility(player) && mcm.getInstance().isMiningPick(player.getItemInHand()) && !PP.getPickaxePreparationMode()){ + if(mcPermissions.getInstance().miningAbility(player) && mcm.isMiningPick(player.getItemInHand()) && !PP.getPickaxePreparationMode()){ if(!PP.getSuperBreakerMode() && !cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), mcLoadProperties.superBreakerCooldown)){ player.sendMessage(ChatColor.RED+"You are too tired to use that ability again." +ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getSuperBreakerDeactivatedTimeStamp(), mcLoadProperties.superBreakerCooldown)+"s)"); @@ -113,7 +108,7 @@ public class mcSkills { PP.setPickaxePreparationATS(System.currentTimeMillis()); PP.setPickaxePreparationMode(true); } - if(mcPermissions.getInstance().excavationAbility(player) && mcm.getInstance().isShovel(player.getItemInHand()) && !PP.getShovelPreparationMode()){ + if(mcPermissions.getInstance().excavationAbility(player) && mcm.isShovel(player.getItemInHand()) && !PP.getShovelPreparationMode()){ if(!PP.getGigaDrillBreakerMode() && !cooldownOver(player, PP.getGigaDrillBreakerDeactivatedTimeStamp(), mcLoadProperties.gigaDrillBreakerCooldown)){ player.sendMessage(ChatColor.RED+"You are too tired to use that ability again." +ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getGigaDrillBreakerDeactivatedTimeStamp(), mcLoadProperties.gigaDrillBreakerCooldown)+"s)"); @@ -123,7 +118,7 @@ public class mcSkills { PP.setShovelPreparationATS(System.currentTimeMillis()); PP.setShovelPreparationMode(true); } - if(mcPermissions.getInstance().swordsAbility(player) && mcm.getInstance().isSwords(player.getItemInHand()) && !PP.getSwordsPreparationMode()){ + if(mcPermissions.getInstance().swordsAbility(player) && mcm.isSwords(player.getItemInHand()) && !PP.getSwordsPreparationMode()){ if(!PP.getSerratedStrikesMode() && !cooldownOver(player, PP.getSerratedStrikesDeactivatedTimeStamp(), mcLoadProperties.serratedStrikeCooldown)){ player.sendMessage(ChatColor.RED+"You are too tired to use that ability again." +ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getSerratedStrikesDeactivatedTimeStamp(), mcLoadProperties.serratedStrikeCooldown)+"s)"); @@ -144,16 +139,16 @@ public class mcSkills { PP.setFistsPreparationMode(true); } if((mcPermissions.getInstance().axes(player) || mcPermissions.getInstance().woodcutting(player)) && !PP.getAxePreparationMode()){ - if(mcm.getInstance().isAxes(player.getItemInHand())){ + if(mcm.isAxes(player.getItemInHand())){ player.sendMessage(ChatColor.GREEN+"**YOU READY YOUR AXE**"); PP.setAxePreparationATS(System.currentTimeMillis()); PP.setAxePreparationMode(true); } } } - public void serratedStrikesActivationCheck(Player player, Plugin pluginx){ + public static void serratedStrikesActivationCheck(Player player, Plugin pluginx){ PlayerProfile PP = mcUsers.getProfile(player.getName()); - if(mcm.getInstance().isSwords(player.getItemInHand())){ + if(mcm.isSwords(player.getItemInHand())){ if(PP.getSwordsPreparationMode()){ PP.setSwordsPreparationMode(false); } @@ -167,7 +162,7 @@ public class mcSkills { if(!PP.getSerratedStrikesMode() && PP.getSerratedStrikesCooldown() == 0){ player.sendMessage(ChatColor.GREEN+"**SERRATED STRIKES ACTIVATED**"); for(Player y : pluginx.getServer().getOnlinePlayers()){ - if(y != null && y != player && mcm.getInstance().getDistance(player.getLocation(), y.getLocation()) < 10) + if(y != null && y != player && mcm.getDistance(player.getLocation(), y.getLocation()) < 10) y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Serrated Strikes!"); } PP.setSerratedStrikesTicks((ticks * 2) * 1000); @@ -177,7 +172,7 @@ public class mcSkills { } } - public void berserkActivationCheck(Player player, Plugin pluginx){ + public static void berserkActivationCheck(Player player, Plugin pluginx){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(player.getItemInHand().getTypeId() == 0){ if(PP.getFistsPreparationMode()){ @@ -193,7 +188,7 @@ public class mcSkills { if(!PP.getBerserkMode() && cooldownOver(player, PP.getBerserkDeactivatedTimeStamp(), mcLoadProperties.berserkCooldown)){ player.sendMessage(ChatColor.GREEN+"**BERSERK ACTIVATED**"); for(Player y : pluginx.getServer().getOnlinePlayers()){ - if(y != null && y != player && mcm.getInstance().getDistance(player.getLocation(), y.getLocation()) < 10) + if(y != null && y != player && mcm.getDistance(player.getLocation(), y.getLocation()) < 10) y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Berserk!"); } PP.setBerserkTicks(ticks * 1000); @@ -202,9 +197,9 @@ public class mcSkills { } } } - public void skullSplitterCheck(Player player, Plugin pluginx){ + public static void skullSplitterCheck(Player player, Plugin pluginx){ PlayerProfile PP = mcUsers.getProfile(player.getName()); - if(mcm.getInstance().isAxes(player.getItemInHand()) && mcPermissions.getInstance().axesAbility(player)){ + if(mcm.isAxes(player.getItemInHand()) && mcPermissions.getInstance().axesAbility(player)){ /* * CHECK FOR AXE PREP MODE */ @@ -221,7 +216,7 @@ public class mcSkills { if(!PP.getSkullSplitterMode() && cooldownOver(player, PP.getSkullSplitterDeactivatedTimeStamp(), mcLoadProperties.skullSplitterCooldown)){ player.sendMessage(ChatColor.GREEN+"**SKULL SPLITTER ACTIVATED**"); for(Player y : pluginx.getServer().getOnlinePlayers()){ - if(y != null && y != player && mcm.getInstance().getDistance(player.getLocation(), y.getLocation()) < 10) + if(y != null && y != player && mcm.getDistance(player.getLocation(), y.getLocation()) < 10) y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Skull Splitter!"); } PP.setSkullSplitterTicks(ticks * 1000); @@ -234,7 +229,7 @@ public class mcSkills { } } } - public void monitorSkills(Player player){ + public static void monitorSkills(Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(PP == null) mcUsers.addUser(player); @@ -340,7 +335,7 @@ public class mcSkills { } } } - public void XpCheck(Player player){ + public static void XpCheck(Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); /* * TAMING @@ -352,6 +347,13 @@ public class mcSkills { PP.removeTamingXP(PP.getXpToLevel("taming")); PP.skillUpTaming(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getTamingInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "taming"); if(player != null && PP.getTaming() != null) player.sendMessage(ChatColor.YELLOW+"Taming skill increased by "+skillups+"."+" Total ("+PP.getTaming()+")"); } @@ -365,6 +367,14 @@ public class mcSkills { PP.removeAcrobaticsXP(PP.getXpToLevel("acrobatics")); PP.skillUpAcrobatics(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getAcrobaticsInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "acrobatics"); + if(player != null && PP.getAcrobatics() != null) player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by "+skillups+"."+" Total ("+PP.getAcrobatics()+")"); } @@ -378,6 +388,14 @@ public class mcSkills { PP.removeArcheryXP(PP.getXpToLevel("archery")); PP.skillUpArchery(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getArcheryInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "archery"); + if(player != null && PP.getArchery() != null) player.sendMessage(ChatColor.YELLOW+"Archery skill increased by "+skillups+"."+" Total ("+PP.getArchery()+")"); } @@ -391,6 +409,14 @@ public class mcSkills { PP.removeSwordsXP(PP.getXpToLevel("swords")); PP.skillUpSwords(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getSwordsInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "swords"); + if(player != null && PP.getSwords() != null) player.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+skillups+"."+" Total ("+PP.getSwords()+")"); } @@ -404,6 +430,14 @@ public class mcSkills { PP.removeAxesXP(PP.getXpToLevel("axes")); PP.skillUpAxes(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getAxesInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "axes"); + if(player != null && PP.getAxes() != null) player.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+skillups+"."+" Total ("+PP.getAxes()+")"); } @@ -417,6 +451,14 @@ public class mcSkills { PP.removeUnarmedXP(PP.getXpToLevel("unarmed")); PP.skillUpUnarmed(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getUnarmedInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "unarmed"); + if(player != null && PP.getUnarmed() != null) player.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+skillups+"."+" Total ("+PP.getUnarmed()+")"); } @@ -430,6 +472,14 @@ public class mcSkills { PP.removeHerbalismXP(PP.getXpToLevel("herbalism")); PP.skillUpHerbalism(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getHerbalismInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "herbalism"); + if(player != null && PP.getHerbalism() != null) player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by "+skillups+"."+" Total ("+PP.getHerbalism()+")"); } @@ -443,6 +493,14 @@ public class mcSkills { PP.removeMiningXP(PP.getXpToLevel("mining")); PP.skillUpMining(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getMiningInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "mining"); + if(player != null && PP.getMining() != null) player.sendMessage(ChatColor.YELLOW+"Mining skill increased by "+skillups+"."+" Total ("+PP.getMining()+")"); } @@ -456,6 +514,14 @@ public class mcSkills { PP.removeWoodCuttingXP(PP.getXpToLevel("woodcutting")); PP.skillUpWoodCutting(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getWoodCuttingInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "woodcutting"); + if(player != null && PP.getWoodCutting() != null) player.sendMessage(ChatColor.YELLOW+"WoodCutting skill increased by "+skillups+"."+" Total ("+PP.getWoodCutting()+")"); } @@ -469,6 +535,14 @@ public class mcSkills { PP.removeRepairXP(PP.getXpToLevel("repair")); PP.skillUpRepair(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getRepairInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "repair"); + if(player != null && PP.getRepair() != null) player.sendMessage(ChatColor.YELLOW+"Repair skill increased by "+skillups+"."+" Total ("+PP.getRepair()+")"); } @@ -482,11 +556,26 @@ public class mcSkills { PP.removeExcavationXP(PP.getXpToLevel("excavation")); PP.skillUpExcavation(1); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = PP.getExcavationInt(); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "excavation"); + if(player != null && PP.getExcavation() != null) player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by "+skillups+"."+" Total ("+PP.getExcavation()+")"); } + /* + * Leaderboard updating stuff + */ + PlayerStat ps = new PlayerStat(); + ps.statVal = mcm.getPowerLevel(player); + ps.name = player.getName(); + mcLeaderboard.updateLeaderboard(ps, "powerlevel"); } - public boolean isSkill(String skillname){ + public static boolean isSkill(String skillname){ skillname = skillname.toLowerCase(); if(skillname.equals("all")){ return true; @@ -528,11 +617,11 @@ public class mcSkills { return false; } } - public void arrowRetrievalCheck(Entity entity){ + public static void arrowRetrievalCheck(Entity entity){ if(mcConfig.getInstance().isTracked(entity)){ Integer x = 0; while(x < mcConfig.getInstance().getArrowCount(entity)){ - mcm.getInstance().mcDropItem(entity.getLocation(), 262); + mcm.mcDropItem(entity.getLocation(), 262); x++; } } diff --git a/mcMMO/com/gmail/nossr50/mcTaming.java b/mcMMO/com/gmail/nossr50/mcTaming.java index 0ed79bae9..cc1568d35 100644 --- a/mcMMO/com/gmail/nossr50/mcTaming.java +++ b/mcMMO/com/gmail/nossr50/mcTaming.java @@ -15,20 +15,14 @@ public class mcTaming { private static volatile mcTaming instance; - public static mcTaming getInstance() { - if (instance == null) { - instance = new mcTaming(plugin); - } - return instance; - } - public String getOwnerName(Entity theWolf){ + public static String getOwnerName(Entity theWolf){ CraftWolf cWolf = (CraftWolf)theWolf; EntityWolf eWolf = (EntityWolf)cWolf.getHandle(); String playerName = eWolf.v(); return playerName; } - public boolean hasOwner(Entity theWolf, Plugin pluginx){ + public static boolean hasOwner(Entity theWolf, Plugin pluginx){ for(Player x : pluginx.getServer().getOnlinePlayers()){ if(x != null && x.getName().equals(getOwnerName(theWolf))){ return true; @@ -44,4 +38,8 @@ public class mcTaming { } return null; } + public static mcTaming getInstance() { + // TODO Auto-generated method stub + return null; + } } diff --git a/mcMMO/com/gmail/nossr50/mcTimer.java b/mcMMO/com/gmail/nossr50/mcTimer.java index a7fafa43c..6646f6e79 100644 --- a/mcMMO/com/gmail/nossr50/mcTimer.java +++ b/mcMMO/com/gmail/nossr50/mcTimer.java @@ -27,11 +27,11 @@ public class mcTimer extends TimerTask{ /* * MONITOR SKILLS */ - mcSkills.getInstance().monitorSkills(player); + mcSkills.monitorSkills(player); /* * COOLDOWN MONITORING */ - mcSkills.getInstance().watchCooldowns(player); + mcSkills.watchCooldowns(player); /* * PLAYER BLEED MONITORING @@ -45,23 +45,23 @@ public class mcTimer extends TimerTask{ if(thecount == 10 || thecount == 20 || thecount == 30 || thecount == 40){ if(player != null && player.getHealth() > 0 && player.getHealth() < 20 - && mcm.getInstance().getPowerLevel(player) >= 1000){ - player.setHealth(mcm.getInstance().calculateHealth(player.getHealth(), 1)); + && mcm.getPowerLevel(player) >= 1000){ + player.setHealth(mcm.calculateHealth(player.getHealth(), 1)); } } if(thecount == 20 || thecount == 40){ if(player != null && player.getHealth() > 0 && player.getHealth() < 20 - && mcm.getInstance().getPowerLevel(player) >= 500 - && mcm.getInstance().getPowerLevel(player) < 1000){ - player.setHealth(mcm.getInstance().calculateHealth(player.getHealth(), 1)); + && mcm.getPowerLevel(player) >= 500 + && mcm.getPowerLevel(player) < 1000){ + player.setHealth(mcm.calculateHealth(player.getHealth(), 1)); } } if(thecount == 40){ if(player != null && player.getHealth() > 0 && player.getHealth() < 20 - && mcm.getInstance().getPowerLevel(player) < 500){ - player.setHealth(mcm.getInstance().calculateHealth(player.getHealth(), 1)); + && mcm.getPowerLevel(player) < 500){ + player.setHealth(mcm.calculateHealth(player.getHealth(), 1)); } } } @@ -71,7 +71,7 @@ public class mcTimer extends TimerTask{ * NON-PLAYER BLEED MONITORING */ if(thecount % 2 == 0) - mcCombat.getInstance().bleedSimulate(); + mcCombat.bleedSimulate(); if(thecount < 40){ thecount++; diff --git a/mcMMO/com/gmail/nossr50/mcUsers.java b/mcMMO/com/gmail/nossr50/mcUsers.java index bb04ed3b6..dd1e624f7 100644 --- a/mcMMO/com/gmail/nossr50/mcUsers.java +++ b/mcMMO/com/gmail/nossr50/mcUsers.java @@ -160,7 +160,7 @@ class PlayerList private boolean greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true, superBreakerInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, dead, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode, pickaxePreparationMode, axePreparationMode, skullSplitterMode, berserkMode; private long gigaDrillBreakerCooldown = 0, berserkCooldown = 0, superBreakerCooldown = 0, skullSplitterCooldown = 0, serratedStrikesCooldown = 0, greenTerraCooldown = 0, treeFellerCooldown = 0, recentlyHurt = 0, archeryShotATS = 0, berserkATS = 0, berserkDATS = 0, gigaDrillBreakerATS = 0, gigaDrillBreakerDATS = 0, - mySpawnATS = 0, greenTerraATS = 0, greenTerraDATS = 0, superBreakerATS = 0, superBreakerDATS = 0, serratedStrikesATS = 0, serratedStrikesDATS = 0, treeFellerATS = 0, treeFellerDATS = 0, + respawnATS = 0, mySpawnATS = 0, greenTerraATS = 0, greenTerraDATS = 0, superBreakerATS = 0, superBreakerDATS = 0, serratedStrikesATS = 0, serratedStrikesDATS = 0, treeFellerATS = 0, treeFellerDATS = 0, skullSplitterATS = 0, skullSplitterDATS = 0, hoePreparationATS = 0, axePreparationATS = 0, pickaxePreparationATS = 0, fistsPreparationATS = 0, shovelPreparationATS = 0, swordsPreparationATS = 0; private int berserkTicks = 0, bleedticks = 0, greenTerraTicks = 0, gigaDrillBreakerTicks = 0, superBreakerTicks = 0, serratedStrikesTicks = 0, skullSplitterTicks = 0, treeFellerTicks = 0; //ATS = (Time of) Activation Time Stamp @@ -221,23 +221,6 @@ class PlayerList addPlayer(); } - public void scoreBoard() - { - try { - //Open the user file - FileReader file = new FileReader(location); - BufferedReader in = new BufferedReader(file); - String line = ""; - while((line = in.readLine()) != null) - { - - } - in.close(); - } catch (Exception e) { - log.log(Level.SEVERE, "Exception while reading " - + location + " (Are you sure you formatted it correctly?)", e); - } - } public boolean load() { try { @@ -473,6 +456,12 @@ class PlayerList return false; } } + /* + * EXPLOIT PREVENTION + */ + public long getRespawnATS() {return respawnATS;} + public void setRespawnATS(long newvalue) {respawnATS = newvalue;} + /* * ARCHERY NERF STUFF */ @@ -1607,7 +1596,7 @@ class PlayerList axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue); } save(); - mcSkills.getInstance().XpCheck(thisplayer); + mcSkills.XpCheck(thisplayer); } public void modifyskill(int newvalue, String skillname){ if(skillname.toLowerCase().equals("taming")){ diff --git a/mcMMO/com/gmail/nossr50/mcWoodCutting.java b/mcMMO/com/gmail/nossr50/mcWoodCutting.java index e20a1c5e8..49c0b68c6 100644 --- a/mcMMO/com/gmail/nossr50/mcWoodCutting.java +++ b/mcMMO/com/gmail/nossr50/mcWoodCutting.java @@ -14,20 +14,14 @@ import com.gmail.nossr50.PlayerList.PlayerProfile; public class mcWoodCutting { - int w = 0; - private boolean isdone = false; + static int w = 0; + private static boolean isdone = false; private static mcMMO plugin; public mcWoodCutting(mcMMO instance) { plugin = instance; } - private static volatile mcWoodCutting instance; - public static mcWoodCutting getInstance() { - if (instance == null) { - instance = new mcWoodCutting(plugin); - } - return instance; - } - public void woodCuttingProcCheck(Player player, Block block){ + + public static void woodCuttingProcCheck(Player player, Block block){ PlayerProfile PP = mcUsers.getProfile(player.getName()); byte type = block.getData(); Material mat = Material.getMaterial(block.getTypeId()); @@ -38,11 +32,11 @@ public class mcWoodCutting { } } } - public void treeFellerCheck(Player player, Block block, Plugin pluginx){ + public static void treeFellerCheck(Player player, Block block, Plugin pluginx){ PlayerProfile PP = mcUsers.getProfile(player.getName()); - if(mcm.getInstance().isAxes(player.getItemInHand())){ + if(mcm.isAxes(player.getItemInHand())){ if(block != null){ - if(!mcm.getInstance().abilityBlockCheck(block)) + if(!mcm.abilityBlockCheck(block)) return; } /* @@ -58,23 +52,23 @@ public class mcWoodCutting { ticks++; } - if(!PP.getTreeFellerMode() && mcSkills.getInstance().cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), mcLoadProperties.treeFellerCooldown)){ + if(!PP.getTreeFellerMode() && mcSkills.cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), mcLoadProperties.treeFellerCooldown)){ player.sendMessage(ChatColor.GREEN+"**TREE FELLING ACTIVATED**"); for(Player y : pluginx.getServer().getOnlinePlayers()){ - if(y != null && y != player && mcm.getInstance().getDistance(player.getLocation(), y.getLocation()) < 10) + if(y != null && y != player && mcm.getDistance(player.getLocation(), y.getLocation()) < 10) y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Tree Feller!"); } PP.setTreeFellerTicks(ticks * 1000); PP.setTreeFellerActivatedTimeStamp(System.currentTimeMillis()); PP.setTreeFellerMode(true); } - if(!PP.getTreeFellerMode() && !mcSkills.getInstance().cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), mcLoadProperties.treeFellerCooldown)){ + if(!PP.getTreeFellerMode() && !mcSkills.cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), mcLoadProperties.treeFellerCooldown)){ player.sendMessage(ChatColor.RED+"You are too tired to use that ability again." - +ChatColor.YELLOW+" ("+mcSkills.getInstance().calculateTimeLeft(player, PP.getTreeFellerDeactivatedTimeStamp(), mcLoadProperties.treeFellerCooldown)+"s)"); + +ChatColor.YELLOW+" ("+mcSkills.calculateTimeLeft(player, PP.getTreeFellerDeactivatedTimeStamp(), mcLoadProperties.treeFellerCooldown)+"s)"); } } } - public void treeFeller(Block block, Player player){ + public static void treeFeller(Block block, Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); int radius = 1; if(PP.getWoodCuttingXPInt() >= 500) @@ -100,7 +94,7 @@ public class mcWoodCutting { } toAdd.clear(); } - public void addBlocksToTreeFelling(ArrayList blocklist, ArrayList toAdd, Integer radius){ + public static void addBlocksToTreeFelling(ArrayList blocklist, ArrayList toAdd, Integer radius){ int u = 0; for (Block x : blocklist){ u++; diff --git a/mcMMO/com/gmail/nossr50/mcm.java b/mcMMO/com/gmail/nossr50/mcm.java index 571749772..6851a3d8d 100644 --- a/mcMMO/com/gmail/nossr50/mcm.java +++ b/mcMMO/com/gmail/nossr50/mcm.java @@ -25,15 +25,8 @@ public class mcm { public mcm(mcMMO instance) { plugin = instance; } - private static volatile mcm instance; - public static mcm getInstance() { - if (instance == null) { - instance = new mcm(plugin); - } - return instance; - } - public int getPowerLevel(Player player){ + public static int getPowerLevel(Player player){ PlayerProfile PP = mcUsers.getProfile(player.getName()); int x = 0; if(mcPermissions.getInstance().mining(player)) @@ -58,7 +51,7 @@ public class mcm { x+=PP.getRepairInt(); return x; } - public boolean blockBreakSimulate(Block block, Player player, Plugin plugin){ + public static boolean blockBreakSimulate(Block block, Player player, Plugin plugin){ FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player); if(block != null && plugin != null && player != null){ @@ -74,11 +67,11 @@ public class mcm { } } - public void damageTool(Player player, short damage){ + public static void damageTool(Player player, short damage){ if(player.getItemInHand().getTypeId() == 0) return; player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + damage)); - if(player.getItemInHand().getDurability() >= getMaxDurability(mcm.getInstance().getTier(player), player.getItemInHand())){ + if(player.getItemInHand().getDurability() >= getMaxDurability(getTier(player), player.getItemInHand())){ ItemStack[] inventory = player.getInventory().getContents(); for(ItemStack x : inventory){ if(x != null && x.getTypeId() == player.getItemInHand().getTypeId() && x.getDurability() == player.getItemInHand().getDurability()){ @@ -109,7 +102,7 @@ public class mcm { } } } - public Integer getTier(Player player){ + public static Integer getTier(Player player){ int i = player.getItemInHand().getTypeId(); if(i == 268 || i == 269 || i == 270 || i == 271 || i == 290){ return 1; //WOOD @@ -125,7 +118,7 @@ public class mcm { return 1; //UNRECOGNIZED } } - public Integer getMaxDurability(Integer tier, ItemStack item){ + public static Integer getMaxDurability(Integer tier, ItemStack item){ int id = item.getTypeId(); if(tier == 1){ if((id == 276 || id == 277 || id == 278 || id == 279 || id == 293)){ @@ -143,12 +136,12 @@ public class mcm { return 0; } } - public double getDistance(Location loca, Location locb) + public static double getDistance(Location loca, Location locb) { return Math.sqrt(Math.pow(loca.getX() - locb.getX(), 2) + Math.pow(loca.getY() - locb.getY(), 2) + Math.pow(loca.getZ() - locb.getZ(), 2)); } - public boolean abilityBlockCheck(Block block){ + public static boolean abilityBlockCheck(Block block){ int i = block.getTypeId(); if(i == 68 || i == 355 || i == 26 || i == 323 || i == 25 || i == 54 || i == 69 || i == 92 || i == 77 || i == 58 || i == 61 || i == 62 || i == 42 || i == 71 || i == 64 || i == 84 || i == 324 || i == 330){ return false; @@ -156,7 +149,7 @@ public class mcm { return true; } } - public boolean isBlockAround(Location loc, Integer radius, Integer typeid){ + public static boolean isBlockAround(Location loc, Integer radius, Integer typeid){ Block blockx = loc.getBlock(); int ox = blockx.getX(); int oy = blockx.getY(); @@ -174,7 +167,7 @@ public class mcm { } return false; } - public boolean isPvpEnabled(){ + public static boolean isPvpEnabled(){ String propertyName = "pvp"; FileReader fr = null; try { @@ -205,7 +198,7 @@ public class mcm { return false; } } - public boolean shouldBeWatched(Block block){ + public static boolean shouldBeWatched(Block block){ int id = block.getTypeId(); if(id == 49 || id == 81 || id == 83 || id == 86 || id == 91 || id == 1 || id == 17 || id == 42 || id == 87 || id == 89 || id == 2 || id == 3 || id == 12 || id == 13 || id == 21 || id == 15 || id == 14 || id == 56 || id == 38 || id == 37 || id == 39 || id == 40 || id == 24){ return true; @@ -213,7 +206,7 @@ public class mcm { return false; } } - public Integer calculateHealth(Integer health, Integer newvalue){ + public static Integer calculateHealth(Integer health, Integer newvalue){ if((health + newvalue) > 20){ return 20; } else { @@ -227,7 +220,7 @@ public class mcm { return health-newvalue; } } - public Integer getHealth(Entity entity){ + public static Integer getHealth(Entity entity){ if(entity instanceof Monster){ Monster monster = (Monster)entity; return monster.getHealth(); @@ -241,7 +234,7 @@ public class mcm { return 0; } } - public boolean isInt(String string){ + public static boolean isInt(String string){ try { int x = Integer.parseInt(string); } @@ -250,7 +243,7 @@ public class mcm { } return true; } - public void mcDropItem(Location loc, int id){ + public static void mcDropItem(Location loc, int id){ if(loc != null){ Material mat = Material.getMaterial(id); byte damage = 0; @@ -259,14 +252,14 @@ public class mcm { } } - public boolean isSwords(ItemStack is){ + public static boolean isSwords(ItemStack is){ if(is.getTypeId() == 268 || is.getTypeId() == 267 || is.getTypeId() == 272 || is.getTypeId() == 283 || is.getTypeId() == 276){ return true; } else { return false; } } - public boolean isHoe(ItemStack is){ + public static boolean isHoe(ItemStack is){ int id = is.getTypeId(); if(id == 290 || id == 291 || id == 292 || id == 293 || id == 294){ return true; @@ -274,21 +267,21 @@ public class mcm { return false; } } - public boolean isShovel(ItemStack is){ + public static boolean isShovel(ItemStack is){ if(is.getTypeId() == 269 || is.getTypeId() == 273 || is.getTypeId() == 277 || is.getTypeId() == 284 || is.getTypeId() == 256){ return true; } else { return false; } } - public boolean isAxes(ItemStack is){ + public static boolean isAxes(ItemStack is){ if(is.getTypeId() == 271 || is.getTypeId() == 258 || is.getTypeId() == 286 || is.getTypeId() == 279 || is.getTypeId() == 275){ return true; } else { return false; } } - public boolean isMiningPick(ItemStack is){ + public static boolean isMiningPick(ItemStack is){ if(is.getTypeId() == 270 || is.getTypeId() == 274 || is.getTypeId() == 285 || is.getTypeId() == 257 || is.getTypeId() == 278){ return true; } else { @@ -303,7 +296,7 @@ public class mcm { return false; } } - public void mcmmoHelpCheck(String[] split, Player player, PlayerChatEvent event){ + public static void mcmmoHelpCheck(String[] split, Player player, PlayerChatEvent event){ PlayerProfile PP = mcUsers.getProfile(player.getName()); if(split[0].equalsIgnoreCase("/woodcutting")){ event.setCancelled(true); @@ -665,6 +658,7 @@ public class mcm { player.sendMessage("/"+mcLoadProperties.clearmyspawn+" "+ChatColor.RED+"- Clears your MySpawn"); } player.sendMessage(ChatColor.GREEN+"--OTHER COMMANDS--"); + player.sendMessage("/mctop "+ChatColor.RED+"- Leaderboards"); if(mcPermissions.getInstance().mcAbility(player)) player.sendMessage("/"+mcLoadProperties.mcability+ChatColor.RED+" - Toggle ability activation with right click"); if(mcPermissions.getInstance().adminChat(player)){ diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index 3dee3a60b..94e3f0956 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.gmail.nossr50.mcMMO -version: 0.9.30 WIP \ No newline at end of file +version: 1.0 WIP \ No newline at end of file