Merge git://github.com/nossr50/mcMMO

This commit is contained in:
mcmmoPolish 2011-08-06 10:55:32 +02:00
commit a84d2f2019
10 changed files with 104 additions and 177 deletions

View File

@ -1,8 +1,14 @@
Changelog: Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code #Versions without changelogs probably had very small misc fixes, like tweaks to the source code
Version 1.0.51 Version 1.0.51
Converted many big numbers to much smaller numbers reducing memory usage Brand new XP Bars and Skill Icons designed by BrandonXP
XP Bars Noises added to leveling
MySpawn now works correctly when you are in the nether
MySpawn message when you right click a bed is now squelched
Intervals at which players renegerate hp have doubled in length
Rewrote many variables stored per player to be integer instead of long, reducing overall memory usage of mcMMO
Rewrote the Timer mcMMO relies on to instead use the BukkitScheduler for performance
Fixed the party member list of /party
Version 1.0.50 Version 1.0.50
New /xprate command for those with mcmmo.admin permissions! New /xprate command for those with mcmmo.admin permissions!

View File

@ -70,10 +70,8 @@ public class Item {
if(PP.getMySpawn(player) != null) if(PP.getMySpawn(player) != null)
{ {
Location mySpawn = PP.getMySpawn(player); Location mySpawn = PP.getMySpawn(player);
if(mySpawn != null && plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)) != null)
mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)));
if(mySpawn != null){ if(mySpawn != null){
player.teleport(mySpawn);//Do it twice to prevent weird stuff player.teleport(mySpawn); //Do it twice to prevent weird stuff
player.teleport(mySpawn); player.teleport(mySpawn);
} }
} else { } else {

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.contrib;
import java.util.HashMap; import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -26,9 +27,18 @@ public class SpoutStuff
{ {
//Contrib stuff //Contrib stuff
SoundManager SM = SpoutManager.getSoundManager(); SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = (SpoutPlayer)player; SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
SM.playSoundEffect(sPlayer, effect, location); SM.playSoundEffect(sPlayer, effect, location);
} }
public static void playLevelUpNoise(Player player)
{
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
String r = String.valueOf((int) (Math.random()*8));
SM.playCustomMusic(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "http://dl.dropbox.com/u/18212134/ANUSOUND/"+r+".wav", false);
}
public static void levelUpNotification(SkillType skillType, SpoutPlayer sPlayer) public static void levelUpNotification(SkillType skillType, SpoutPlayer sPlayer)
{ {
PlayerProfile PP = Users.getProfile(sPlayer); PlayerProfile PP = Users.getProfile(sPlayer);
@ -247,6 +257,7 @@ public class SpoutStuff
break; break;
} }
sPlayer.sendNotification(ChatColor.GREEN+"Level Up!", ChatColor.YELLOW+m.getCapitalized(skillType.toString())+ChatColor.DARK_AQUA+" ("+ChatColor.GREEN+PP.getSkillLevel(skillType)+ChatColor.DARK_AQUA+")", mat); sPlayer.sendNotification(ChatColor.GREEN+"Level Up!", ChatColor.YELLOW+m.getCapitalized(skillType.toString())+ChatColor.DARK_AQUA+" ("+ChatColor.GREEN+PP.getSkillLevel(skillType)+ChatColor.DARK_AQUA+")", mat);
playLevelUpNoise(sPlayer);
} }
public static Integer getNotificationTier(Integer level) public static Integer getNotificationTier(Integer level)
@ -321,72 +332,7 @@ public class SpoutStuff
} }
public static String getUrlIcon(SkillType skillType) public static String getUrlIcon(SkillType skillType)
{ {
String url = "http://dl.dropbox.com/u/18212134/xpbar/"; return "http://dl.dropbox.com/u/18212134/xpbar/+"+m.getCapitalized(skillType.toString())+".png";
switch(skillType)
{
case SORCERY:
{
url+="Sorcery";
break;
}
case TAMING:
{
url+="Taming";
break;
}
case MINING:
{
url+="Mining";
break;
}
case WOODCUTTING:
{
url+="Woodcutting";
break;
}
case REPAIR:
{
url+="Repair";
break;
}
case HERBALISM:
{
url+="Herbalism";
break;
}
case ACROBATICS:
{
url+="Acrobatics";
break;
}
case SWORDS:
{
url+="Swords";
break;
}
case ARCHERY:
{
url+="Archery";
break;
}
case UNARMED:
{
url+="Unarmed";
break;
}
case EXCAVATION:
{
url+="Excavation";
break;
}
case AXES:
{
url+="Axes";
break;
}
}
url+=".png";
return url;
} }
public static boolean shouldBeFilled(PlayerProfile PP) public static boolean shouldBeFilled(PlayerProfile PP)
{ {

View File

@ -10,10 +10,9 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.contrib.SpoutStuff; import com.gmail.nossr50.contrib.SpoutStuff;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
@ -62,41 +61,14 @@ public class PlayerProfile
{ {
//Setup the HashMap for the skills //Setup the HashMap for the skills
skills.put(SkillType.SORCERY, 0); for(SkillType skillType : SkillType.values())
skillsXp.put(SkillType.SORCERY, 0); {
if(skillType != SkillType.ALL)
skills.put(SkillType.UNARMED, 0); {
skillsXp.put(SkillType.UNARMED, 0); skills.put(skillType, 0);
skillsXp.put(skillType, 0);
skills.put(SkillType.TAMING, 0); }
skillsXp.put(SkillType.TAMING, 0); }
skills.put(SkillType.MINING, 0);
skillsXp.put(SkillType.MINING, 0);
skills.put(SkillType.WOODCUTTING, 0);
skillsXp.put(SkillType.WOODCUTTING, 0);
skills.put(SkillType.REPAIR, 0);
skillsXp.put(SkillType.REPAIR, 0);
skills.put(SkillType.HERBALISM, 0);
skillsXp.put(SkillType.HERBALISM, 0);
skills.put(SkillType.EXCAVATION, 0);
skillsXp.put(SkillType.EXCAVATION, 0);
skills.put(SkillType.ARCHERY, 0);
skillsXp.put(SkillType.ARCHERY, 0);
skills.put(SkillType.SWORDS, 0);
skillsXp.put(SkillType.SWORDS, 0);
skills.put(SkillType.AXES, 0);
skillsXp.put(SkillType.AXES, 0);
skills.put(SkillType.ACROBATICS, 0);
skillsXp.put(SkillType.ACROBATICS, 0);
mana = getMaxMana(); mana = getMaxMana();
@ -1025,11 +997,12 @@ public class PlayerProfile
return false; return false;
} }
} }
public String getMySpawnWorld(Plugin plugin){ public String getMySpawnWorld()
{
if(myspawnworld != null && !myspawnworld.equals("") && !myspawnworld.equals("null")){ if(myspawnworld != null && !myspawnworld.equals("") && !myspawnworld.equals("null")){
return myspawnworld; return myspawnworld;
} else { } else {
return plugin.getServer().getWorlds().get(0).toString(); return Bukkit.getServer().getWorlds().get(0).toString();
} }
} }
//Save a users spawn location //Save a users spawn location
@ -1082,7 +1055,12 @@ public class PlayerProfile
loc.setYaw(0); loc.setYaw(0);
loc.setPitch(0); loc.setPitch(0);
if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null){ if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null)
{
if(Bukkit.getServer().getWorld(this.getMySpawnWorld()) != null)
loc.setWorld(Bukkit.getServer().getWorld(this.getMySpawnWorld()));
else
loc.setWorld(Bukkit.getServer().getWorlds().get(0));
return loc; return loc;
} else { } else {
return null; return null;

View File

@ -66,16 +66,18 @@ public class mcPlayerListener extends PlayerListener
if(player != null && PP != null) if(player != null && PP != null)
{ {
PP.setRespawnATS(System.currentTimeMillis()); PP.setRespawnATS(System.currentTimeMillis());
Location mySpawn = PP.getMySpawn(player); Location mySpawn = PP.getMySpawn(player);
if(mySpawn != null && plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)) != null)
mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)));
if(mySpawn != null) if(mySpawn != null)
{
{ {
event.setRespawnLocation(mySpawn); event.setRespawnLocation(mySpawn);
} }
} }
} }
} }
}
public void onPlayerLogin(PlayerLoginEvent event) public void onPlayerLogin(PlayerLoginEvent event)
{ {
Users.addUser(event.getPlayer()); Users.addUser(event.getPlayer());
@ -107,9 +109,7 @@ public class mcPlayerListener extends PlayerListener
if(mcPermissions.getInstance().motd(player) && LoadProperties.enableMotd) if(mcPermissions.getInstance().motd(player) && LoadProperties.enableMotd)
{ {
//player.sendMessage(ChatColor.BLUE +"This server is running mcMMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+LoadProperties.mcmmo+ChatColor.BLUE+ " for help.");
player.sendMessage(mcLocale.getString("mcPlayerListener.MOTD", new Object[] {plugin.getDescription().getVersion(), LoadProperties.mcmmo})); player.sendMessage(mcLocale.getString("mcPlayerListener.MOTD", new Object[] {plugin.getDescription().getVersion(), LoadProperties.mcmmo}));
//player.sendMessage(ChatColor.GREEN+"http://mcmmo.wikia.com"+ChatColor.BLUE+" - mcMMO Wiki");
player.sendMessage(mcLocale.getString("mcPlayerListener.WIKI")); player.sendMessage(mcLocale.getString("mcPlayerListener.WIKI"));
} }
if(plugin.xpevent) if(plugin.xpevent)
@ -156,7 +156,7 @@ public class mcPlayerListener extends PlayerListener
if(mcPermissions.getInstance().setMySpawn(player)){ if(mcPermissions.getInstance().setMySpawn(player)){
PP.setMySpawn(loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName()); PP.setMySpawn(loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName());
} }
player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnSet")); //player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnSet"));
} }
} }

View File

@ -34,7 +34,6 @@ import java.io.OutputStream;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Timer;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -78,7 +77,7 @@ public class mcMMO extends JavaPlugin
public static mcPermissions permissionHandler = new mcPermissions(); public static mcPermissions permissionHandler = new mcPermissions();
private Permissions permissions; private Permissions permissions;
private Timer mcMMO_Timer = new Timer(true); //BLEED AND REGENERATION private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION
//private Timer mcMMO_SpellTimer = new Timer(true); //private Timer mcMMO_SpellTimer = new Timer(true);
public static Database database = null; public static Database database = null;
@ -167,7 +166,7 @@ public class mcMMO extends JavaPlugin
for(Player player : getServer().getOnlinePlayers()){Users.addUser(player);} //In case of reload add all users back into PlayerProfile for(Player player : getServer().getOnlinePlayers()){Users.addUser(player);} //In case of reload add all users back into PlayerProfile
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
mcMMO_Timer.schedule(new mcTimer(this), (long)0, (long)(1000)); Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, mcMMO_Timer, 0, 20);
} }
public static void download(Logger log, URL url, File file) throws IOException public static void download(Logger log, URL url, File file) throws IOException
@ -1175,23 +1174,30 @@ public class mcMMO extends JavaPlugin
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp"); player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp");
} }
} }
else if(LoadProperties.ptpEnable && label.equalsIgnoreCase(LoadProperties.ptp) && PP != null && PP.inParty()){ else if(LoadProperties.ptpEnable && label.equalsIgnoreCase(LoadProperties.ptp) && PP.inParty())
{
if(!mcPermissions.getInstance().partyTeleport(player)){
if(!mcPermissions.getInstance().partyTeleport(player))
{
player.sendMessage(ChatColor.YELLOW+"[mcMMO] "+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW+"[mcMMO] "+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;
} }
if(split.length < 2){ if(split.length < 2)
{
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.ptp+" <playername>"); player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.ptp+" <playername>");
return true; return true;
} }
if(!isPlayer(split[1])){ if(!isPlayer(split[1]))
{
player.sendMessage("That is not a valid player"); player.sendMessage("That is not a valid player");
} }
if(isPlayer(split[1])){ if(isPlayer(split[1]))
{
Player target = getPlayer(split[1]); Player target = getPlayer(split[1]);
PlayerProfile PPt = Users.getProfile(target); PlayerProfile PPt = Users.getProfile(target);
if(PP.getParty().equals(PPt.getParty())){ if(PP.getParty().equals(PPt.getParty()))
{
player.teleport(target); player.teleport(target);
player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName()); player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName());
target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you."); target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you.");
@ -1400,12 +1406,12 @@ public class mcMMO extends JavaPlugin
{ {
if(Pinstance.isPartyLeader(p, PP.getParty())) if(Pinstance.isPartyLeader(p, PP.getParty()))
{ {
tempList+=ChatColor.GOLD+p.getName(); tempList+=ChatColor.GOLD+p.getName()+", ";
x++; x++;
} }
else else
{ {
tempList+= ChatColor.WHITE+p.getName(); tempList+= ChatColor.WHITE+p.getName()+", ";
x++; x++;
} }
} }
@ -1697,18 +1703,18 @@ public class mcMMO extends JavaPlugin
player.sendMessage(ChatColor.YELLOW+"[mcMMO] "+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW+"[mcMMO] "+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;
} }
if(System.currentTimeMillis() < PP.getMySpawnATS() + 3600000){ if(System.currentTimeMillis() < (PP.getMySpawnATS()*1000) + 3600000){
long x = ((PP.getMySpawnATS() + 3600000) - System.currentTimeMillis()); long x = (((PP.getMySpawnATS()*1000) + 3600000) - System.currentTimeMillis());
int y = (int) (x/60000); int y = (int) (x/60000);
int z = (int) ((x/1000) - (y*60)); int z = (int) ((x/1000) - (y*60));
player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnTimeNotice", new Object[] {y, z})); player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnTimeNotice", new Object[] {y, z}));
return true; return true;
} }
PP.setMySpawnATS(System.currentTimeMillis()); PP.setMySpawnATS(System.currentTimeMillis());
if(PP.getMySpawn(player) != null){ if(PP.getMySpawn(player) != null)
{
Location mySpawn = PP.getMySpawn(player); Location mySpawn = PP.getMySpawn(player);
if(mySpawn != null && this.getServer().getWorld(PP.getMySpawnWorld(this)) != null)
mySpawn.setWorld(this.getServer().getWorld(PP.getMySpawnWorld(this)));
if(mySpawn != null){ if(mySpawn != null){
//It's done twice because it acts oddly when you are in another world //It's done twice because it acts oddly when you are in another world
player.teleport(mySpawn); player.teleport(mySpawn);

View File

@ -1,6 +1,4 @@
package com.gmail.nossr50; package com.gmail.nossr50;
import java.util.TimerTask;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
@ -9,7 +7,7 @@ import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Swords; import com.gmail.nossr50.skills.Swords;
public class mcTimer extends TimerTask public class mcTimer implements Runnable
{ {
private final mcMMO plugin; private final mcMMO plugin;
int thecount = 1; int thecount = 1;
@ -40,23 +38,6 @@ public class mcTimer extends TimerTask
*/ */
Skills.watchCooldowns(player); Skills.watchCooldowns(player);
/*
* MANA MONITORING
*/
/*
if(mcPermissions.getInstance().sorcery(player) && thecount == 20 && PP.getCurrentMana() < PP.getMaxMana())
{
PP.setMana(PP.getCurrentMana()+PP.getMaxMana()/5);
//MAKE SURE THE MANA IS NOT ABOVE MAXIMUM
if(PP.getMaxMana() < PP.getCurrentMana())
PP.setMana(PP.getMaxMana());
if(PP.getMaxMana() != PP.getCurrentMana())
player.sendMessage(Messages.getString("Sorcery.Current_Mana")+" "+ChatColor.GREEN+PP.getCurrentMana()+"/"+PP.getMaxMana());
}
*/
/* /*
* PLAYER BLEED MONITORING * PLAYER BLEED MONITORING
*/ */
@ -68,14 +49,14 @@ public class mcTimer extends TimerTask
if(LoadProperties.enableRegen && mcPermissions.getInstance().regeneration(player) && System.currentTimeMillis() >= PP.getRecentlyHurt() + 60000) if(LoadProperties.enableRegen && mcPermissions.getInstance().regeneration(player) && System.currentTimeMillis() >= PP.getRecentlyHurt() + 60000)
{ {
if(thecount == 10 || thecount == 20 || thecount == 30 || thecount == 40){ if(thecount == 20 || thecount == 40 || thecount == 60 || thecount == 80){
if(player != null && if(player != null &&
player.getHealth() > 0 && player.getHealth() < 20 player.getHealth() > 0 && player.getHealth() < 20
&& m.getPowerLevel(player) >= 1000){ && m.getPowerLevel(player) >= 1000){
player.setHealth(m.calculateHealth(player.getHealth(), 1)); player.setHealth(m.calculateHealth(player.getHealth(), 1));
} }
} }
if(thecount == 20 || thecount == 40){ if(thecount == 40 || thecount == 80){
if(player != null && if(player != null &&
player.getHealth() > 0 && player.getHealth() < 20 player.getHealth() > 0 && player.getHealth() < 20
&& m.getPowerLevel(player) >= 500 && m.getPowerLevel(player) >= 500
@ -83,7 +64,7 @@ public class mcTimer extends TimerTask
player.setHealth(m.calculateHealth(player.getHealth(), 1)); player.setHealth(m.calculateHealth(player.getHealth(), 1));
} }
} }
if(thecount == 40) if(thecount == 80)
{ {
if(player != null && if(player != null &&
player.getHealth() > 0 && player.getHealth() < 20 player.getHealth() > 0 && player.getHealth() < 20
@ -104,7 +85,7 @@ public class mcTimer extends TimerTask
//SETUP FOR HP REGEN/BLEED //SETUP FOR HP REGEN/BLEED
thecount++; thecount++;
if(thecount >= 41) if(thecount >= 81)
thecount = 1; thecount = 1;
} }
} }

View File

@ -35,7 +35,8 @@ public class Axes {
ticks++; ticks++;
} }
if(!PP.getSkullSplitterMode() && Skills.cooldownOver(player, PP.getSkullSplitterDeactivatedTimeStamp(), LoadProperties.skullSplitterCooldown)){ if(!PP.getSkullSplitterMode() && Skills.cooldownOver(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown))
{
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOn")); player.sendMessage(mcLocale.getString("Skills.SkullSplitterOn"));
for(Player y : pluginx.getServer().getOnlinePlayers()){ for(Player y : pluginx.getServer().getOnlinePlayers()){
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10) if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
@ -45,9 +46,9 @@ public class Axes {
PP.setSkullSplitterDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000)); PP.setSkullSplitterDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setSkullSplitterMode(true); PP.setSkullSplitterMode(true);
} }
if(!PP.getSkullSplitterMode() && !Skills.cooldownOver(player, PP.getSkullSplitterDeactivatedTimeStamp(), LoadProperties.skullSplitterCooldown)){ if(!PP.getSkullSplitterMode() && !Skills.cooldownOver(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown)){
player.sendMessage(mcLocale.getString("Skills.TooTired") player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, PP.getSkullSplitterDeactivatedTimeStamp(), LoadProperties.skullSplitterCooldown)+"s)"); +ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown)+"s)");
} }
} }
} }

View File

@ -22,8 +22,8 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
public class Skills { public class Skills
{
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
public void updateSQLfromFile(Player player){ public void updateSQLfromFile(Player player){

View File

@ -19,16 +19,20 @@ import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.config.*; import com.gmail.nossr50.config.*;
public class WoodCutting { public class WoodCutting
{
static int w = 0; static int w = 0;
private static boolean isdone = false; private static boolean isdone = false;
public static void woodCuttingProcCheck(Player player, Block block){ public static void woodCuttingProcCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
byte type = block.getData(); byte type = block.getData();
Material mat = Material.getMaterial(block.getTypeId()); Material mat = Material.getMaterial(block.getTypeId());
if(player != null){ if(player != null)
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.WOODCUTTING)){ {
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.WOODCUTTING))
{
ItemStack item = new ItemStack(mat, 1, (short) 0, type); ItemStack item = new ItemStack(mat, 1, (short) 0, type);
block.getWorld().dropItemNaturally(block.getLocation(), item); block.getWorld().dropItemNaturally(block.getLocation(), item);
} }
@ -53,14 +57,17 @@ public class WoodCutting {
} }
int ticks = 2; int ticks = 2;
int x = PP.getSkillLevel(SkillType.WOODCUTTING); int x = PP.getSkillLevel(SkillType.WOODCUTTING);
while(x >= 50){ while(x >= 50)
{
x-=50; x-=50;
ticks++; ticks++;
} }
if(!PP.getTreeFellerMode() && Skills.cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)){ if(!PP.getTreeFellerMode() && Skills.cooldownOver(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TreeFellerOn")); player.sendMessage(mcLocale.getString("Skills.TreeFellerOn"));
for(Player y : pluginx.getServer().getOnlinePlayers()){ for(Player y : pluginx.getServer().getOnlinePlayers())
{
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10) if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(mcLocale.getString("Skills.TreeFellerPlayer", new Object[] {player.getName()})); y.sendMessage(mcLocale.getString("Skills.TreeFellerPlayer", new Object[] {player.getName()}));
} }
@ -68,9 +75,9 @@ public class WoodCutting {
PP.setTreeFellerDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000)); PP.setTreeFellerDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setTreeFellerMode(true); PP.setTreeFellerMode(true);
} }
if(!PP.getTreeFellerMode() && !Skills.cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)){ if(!PP.getTreeFellerMode() && !Skills.cooldownOver(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown)){
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again." player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)+"s)"); +ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown)+"s)");
} }
} }
} }
@ -101,9 +108,11 @@ public class WoodCutting {
} }
toAdd.clear(); toAdd.clear();
} }
public static void addBlocksToTreeFelling(ArrayList<Block> blocklist, ArrayList<Block> toAdd, Integer radius){ public static void addBlocksToTreeFelling(ArrayList<Block> blocklist, ArrayList<Block> toAdd, Integer radius)
{
int u = 0; int u = 0;
for (Block x : blocklist){ for (Block x : blocklist)
{
u++; u++;
if(toAdd.contains(x)) if(toAdd.contains(x))
continue; continue;
@ -131,11 +140,13 @@ public class WoodCutting {
/* /*
* Add more blocks to blocklist so they can be 'felled' * Add more blocks to blocklist so they can be 'felled'
*/ */
for(Block xx : toAdd){ for(Block xx : toAdd)
{
if(!blocklist.contains(xx)) if(!blocklist.contains(xx))
blocklist.add(xx); blocklist.add(xx);
} }
if(u >= blocklist.size()){ if(u >= blocklist.size())
{
isdone = true; isdone = true;
} else { } else {
isdone = false; isdone = false;