Xp bars are fully functional, waiting for cache support from Spout now

This commit is contained in:
nossr50 2011-08-04 20:01:52 -07:00
parent dac789ed99
commit e621ab67d2
8 changed files with 309 additions and 98 deletions

View File

@ -1,5 +1,9 @@
Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code
Version 1.0.51
Converted many big numbers to much smaller numbers reducing memory usage
XP Bars
Version 1.0.50
New /xprate command for those with mcmmo.admin permissions!
mcMMO now uses Spout instead of BukkitContrib

View File

@ -83,7 +83,7 @@ public class Combat
PlayerProfile PPd = Users.getProfile(defender);
if(attacker != null && defender != null && LoadProperties.pvpxp)
{
if(System.currentTimeMillis() >= PPd.getRespawnATS() + 5000
if(System.currentTimeMillis() >= (PPd.getRespawnATS()*1000) + 5000
&& ((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis()
&& defender.getHealth() >= 1)
{

View File

@ -1,10 +1,13 @@
package com.gmail.nossr50.contrib;
import java.util.HashMap;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.gui.GenericTexture;
import org.getspout.spoutapi.player.SpoutPlayer;
import org.getspout.spoutapi.sound.SoundEffect;
import org.getspout.spoutapi.sound.SoundManager;
@ -16,6 +19,9 @@ import com.gmail.nossr50.datatypes.SkillType;
public class SpoutStuff
{
public static HashMap<Player, GenericTexture> xpbars = new HashMap<Player, GenericTexture>();
public static HashMap<Player, GenericTexture> xpicons = new HashMap<Player, GenericTexture>();
public static void playSoundForPlayer(SoundEffect effect, Player player, Location location)
{
//Contrib stuff
@ -256,4 +262,134 @@ public class SpoutStuff
else
return 5;
}
public static Integer getXpInc(int skillxp, int xptolevel)
{
double percentage = (double) skillxp/xptolevel;
double inc = 0.0039370078740157;
return (int) (percentage/inc);
}
public static void updateXpBar(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(PP.getLastGained() != null)
{
int num = getXpInc(PP.getSkillXpLevel(PP.getLastGained()), PP.getXpToLevel(PP.getLastGained()));
xpbars.get(player).setUrl(getUrlBar(num)).setDirty(true);
xpicons.get(player).setUrl(getUrlIcon(PP.getLastGained())).setDirty(true);
((SpoutPlayer)player).getMainScreen().setDirty(true);
}
}
public static void updateXpBarFill(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(PP.getLastGained() != null)
{
if(PP.getXpBarInc() < 254)
xpbars.get(player).setUrl(getUrlBar(PP.getXpBarInc()+1)).setDirty(true);
else
xpbars.get(player).setUrl(getUrlBar(0)).setDirty(true);
PP.setXpBarInc(PP.getXpBarInc()+1);
xpicons.get(player).setUrl(getUrlIcon(PP.getLastGained())).setDirty(true);
((SpoutPlayer)player).getMainScreen().setDirty(true);
}
}
public static String getUrlBar(Integer number)
{
if(number.toString().toCharArray().length == 1)
{
return "http://dl.dropbox.com/u/18212134/xpbar/xpbar_inc00"+number+".png";
//return "file:///C:/Users/Rob/Dropbox/Public/xpbar/xpbar_inc00"+number+".png";
} else if (number.toString().toCharArray().length == 2)
{
return "http://dl.dropbox.com/u/18212134/xpbar/xpbar_inc0"+number+".png";
//return "file:///C:/Users/Rob/Dropbox/Public/xpbar/xpbar_inc0"+number+".png";
} else {
return "http://dl.dropbox.com/u/18212134/xpbar/xpbar_inc"+number+".png";
//return "file:///C:/Users/Rob/Dropbox/Public/xpbar/xpbar_inc"+number+".png";
}
}
public static String getUrlIcon(SkillType skillType)
{
String url = "http://dl.dropbox.com/u/18212134/xpbar/";
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)
{
return PP.getXpBarInc() < getXpInc(PP.getSkillXpLevel(PP.getLastGained()), PP.getXpToLevel(PP.getLastGained()));
}
}

View File

@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.contrib.SpoutStuff;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
@ -35,12 +36,14 @@ public class PlayerProfile
//TIMESTAMPS
//ATS = (Time of) Activation Time Stamp
//DATS = (Time of) Deactivation Time Stamp
private long recentlyHurt = 0, archeryShotATS = 0, berserkATS = 0, berserkDATS = 0, gigaDrillBreakerATS = 0, gigaDrillBreakerDATS = 0,
private int recentlyHurt = 0, archeryShotATS = 0, berserkATS = 0, berserkDATS = 0, gigaDrillBreakerATS = 0, gigaDrillBreakerDATS = 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 SkillType lastgained = null;
//MySQL STUFF
private int lastlogin=0, userid = 0, bleedticks = 0;
private int xpbarinc=0, lastlogin=0, userid = 0, bleedticks = 0;
//MAGIC STUFF
private int mana = 0;
@ -143,13 +146,13 @@ public class PlayerProfile
}
else
{
superBreakerDATS = Long.valueOf(cooldowns.get(1).get(0)) * 1000;
treeFellerDATS = Long.valueOf(cooldowns.get(1).get(1)) * 1000;
berserkDATS = Long.valueOf(cooldowns.get(1).get(2)) * 1000;
greenTerraDATS = Long.valueOf(cooldowns.get(1).get(3)) * 1000;
gigaDrillBreakerDATS = Long.valueOf(cooldowns.get(1).get(4)) * 1000;
serratedStrikesDATS = Long.valueOf(cooldowns.get(1).get(5)) * 1000;
skullSplitterDATS = Long.valueOf(cooldowns.get(1).get(6)) * 1000;
superBreakerDATS = Integer.valueOf(cooldowns.get(1).get(0));
treeFellerDATS = Integer.valueOf(cooldowns.get(1).get(1));
berserkDATS = Integer.valueOf(cooldowns.get(1).get(2));
greenTerraDATS = Integer.valueOf(cooldowns.get(1).get(3));
gigaDrillBreakerDATS = Integer.valueOf(cooldowns.get(1).get(4));
serratedStrikesDATS = Integer.valueOf(cooldowns.get(1).get(5));
skullSplitterDATS = Integer.valueOf(cooldowns.get(1).get(6));
}
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM "+LoadProperties.MySQLtablePrefix+"skills WHERE user_id = " + id);
skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0)));
@ -261,19 +264,19 @@ public class PlayerProfile
if(character.length > 25 && m.isInt(character[25]))
skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
if(character.length > 26)
berserkDATS = Long.valueOf(character[26]) * 1000;
berserkDATS = Integer.valueOf(character[26]);
if(character.length > 27)
gigaDrillBreakerDATS = Long.valueOf(character[27]) * 1000;
gigaDrillBreakerDATS = Integer.valueOf(character[27]);
if(character.length > 28)
treeFellerDATS = Long.valueOf(character[28]) * 1000;
treeFellerDATS = Integer.valueOf(character[28]);
if(character.length > 29)
greenTerraDATS = Long.valueOf(character[29]) * 1000;
greenTerraDATS = Integer.valueOf(character[29]);
if(character.length > 30)
serratedStrikesDATS = Long.valueOf(character[30]) * 1000;
serratedStrikesDATS = Integer.valueOf(character[30]);
if(character.length > 31)
skullSplitterDATS = Long.valueOf(character[31]) * 1000;
skullSplitterDATS = Integer.valueOf(character[31]);
if(character.length > 32)
superBreakerDATS = Long.valueOf(character[32]) * 1000;
superBreakerDATS = Integer.valueOf(character[32]);
in.close();
return true;
}
@ -295,13 +298,13 @@ public class PlayerProfile
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"spawn SET world = '" + this.myspawnworld + "', x = " +getX()+", y = "+getY()+", z = "+getZ()+" WHERE user_id = "+this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"cooldowns SET "
+" mining = "+(superBreakerDATS/1000)
+", woodcutting = "+(treeFellerDATS/1000)
+", unarmed = "+(berserkDATS/1000)
+", herbalism = "+(greenTerraDATS/1000)
+", excavation = "+(gigaDrillBreakerDATS/1000)
+", swords = " +(serratedStrikesDATS/1000)
+", axes = "+(skullSplitterDATS/1000)
+" mining = "+(superBreakerDATS)
+", woodcutting = "+(treeFellerDATS)
+", unarmed = "+(berserkDATS)
+", herbalism = "+(greenTerraDATS)
+", excavation = "+(gigaDrillBreakerDATS)
+", swords = " +(serratedStrikesDATS)
+", axes = "+(skullSplitterDATS)
+" WHERE user_id = "+this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills SET "
+" taming = "+skills.get(SkillType.TAMING)
@ -379,13 +382,13 @@ public class PlayerProfile
writer.append(skillsXp.get(SkillType.TAMING) + ":");
//Need to store the DATS of abilities nao
//Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
writer.append(String.valueOf(berserkDATS/1000)+":");
writer.append(String.valueOf(gigaDrillBreakerDATS/1000)+":");
writer.append(String.valueOf(treeFellerDATS/1000)+":");
writer.append(String.valueOf(greenTerraDATS/1000)+":");
writer.append(String.valueOf(serratedStrikesDATS/1000)+":");
writer.append(String.valueOf(skullSplitterDATS/1000)+":");
writer.append(String.valueOf(superBreakerDATS/1000)+":");
writer.append(String.valueOf(berserkDATS)+":");
writer.append(String.valueOf(gigaDrillBreakerDATS)+":");
writer.append(String.valueOf(treeFellerDATS)+":");
writer.append(String.valueOf(greenTerraDATS)+":");
writer.append(String.valueOf(serratedStrikesDATS)+":");
writer.append(String.valueOf(skullSplitterDATS)+":");
writer.append(String.valueOf(superBreakerDATS)+":");
writer.append("\r\n");
}
}
@ -449,6 +452,22 @@ public class PlayerProfile
log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e);
}
}
public int getXpBarInc()
{
return xpbarinc;
}
public void setXpBarInc(int newvalue)
{
xpbarinc = newvalue;
}
public void setLastGained(SkillType newvalue)
{
lastgained = newvalue;
}
public SkillType getLastGained()
{
return lastgained;
}
public boolean getAdminChatMode() {return adminChatMode;}
public boolean getPartyChatMode() {return partyChatMode;}
@ -549,8 +568,9 @@ public class PlayerProfile
public long getMySpawnATS(){
return mySpawnATS;
}
public void setMySpawnATS(long newvalue){
mySpawnATS = newvalue;
public void setMySpawnATS(long newvalue)
{
mySpawnATS = (int) (newvalue/1000);
}
public void decreaseBleedTicks()
{
@ -569,13 +589,13 @@ public class PlayerProfile
* EXPLOIT PREVENTION
*/
public long getRespawnATS() {return respawnATS;}
public void setRespawnATS(long newvalue) {respawnATS = newvalue;}
public void setRespawnATS(long newvalue) {respawnATS = (int) (newvalue/1000);}
/*
* ARCHERY NERF STUFF
*/
public long getArcheryShotATS() {return archeryShotATS;}
public void setArcheryShotATS(long newvalue) {archeryShotATS = newvalue;}
public void setArcheryShotATS(long newvalue) {archeryShotATS = (int) (newvalue/1000);}
/*
* HOE PREPARATION
@ -590,7 +610,7 @@ public class PlayerProfile
return hoePreparationATS;
}
public void setHoePreparationATS(long newvalue){
hoePreparationATS = newvalue;
hoePreparationATS = (int) (newvalue/1000);
}
/*
@ -606,7 +626,7 @@ public class PlayerProfile
return swordsPreparationATS;
}
public void setSwordsPreparationATS(long newvalue){
swordsPreparationATS = newvalue;
swordsPreparationATS = (int) (newvalue/1000);
}
/*
* SHOVEL PREPARATION
@ -621,7 +641,7 @@ public class PlayerProfile
return shovelPreparationATS;
}
public void setShovelPreparationATS(long newvalue){
shovelPreparationATS = newvalue;
shovelPreparationATS = (int) (newvalue/1000);
}
/*
* FISTS PREPARATION
@ -636,7 +656,7 @@ public class PlayerProfile
return fistsPreparationATS;
}
public void setFistsPreparationATS(long newvalue){
fistsPreparationATS = newvalue;
fistsPreparationATS = (int) (newvalue/1000);
}
/*
* AXE PREPARATION
@ -651,7 +671,7 @@ public class PlayerProfile
return axePreparationATS;
}
public void setAxePreparationATS(long newvalue){
axePreparationATS = newvalue;
axePreparationATS = (int) (newvalue/1000);
}
/*
* PICKAXE PREPARATION
@ -666,7 +686,7 @@ public class PlayerProfile
return pickaxePreparationATS;
}
public void setPickaxePreparationATS(long newvalue){
pickaxePreparationATS = newvalue;
pickaxePreparationATS = (int) (newvalue/1000);
}
/*
* GREEN TERRA MODE
@ -683,11 +703,11 @@ public class PlayerProfile
}
public long getGreenTerraActivatedTimeStamp() {return greenTerraATS;}
public void setGreenTerraActivatedTimeStamp(Long newvalue){
greenTerraATS = newvalue;
greenTerraATS = (int) (newvalue/1000);
}
public long getGreenTerraDeactivatedTimeStamp() {return greenTerraDATS;}
public void setGreenTerraDeactivatedTimeStamp(Long newvalue){
greenTerraDATS = newvalue;
greenTerraDATS = (int) (newvalue/1000);
save();
}
/*
@ -705,11 +725,11 @@ public class PlayerProfile
}
public long getBerserkActivatedTimeStamp() {return berserkATS;}
public void setBerserkActivatedTimeStamp(Long newvalue){
berserkATS = newvalue;
berserkATS = (int) (newvalue/1000);
}
public long getBerserkDeactivatedTimeStamp() {return berserkDATS;}
public void setBerserkDeactivatedTimeStamp(Long newvalue){
berserkDATS = newvalue;
berserkDATS = (int) (newvalue/1000);
save();
}
/*
@ -727,11 +747,11 @@ public class PlayerProfile
}
public long getSkullSplitterActivatedTimeStamp() {return skullSplitterATS;}
public void setSkullSplitterActivatedTimeStamp(Long newvalue){
skullSplitterATS = newvalue;
skullSplitterATS = (int) (newvalue/1000);
}
public long getSkullSplitterDeactivatedTimeStamp() {return skullSplitterDATS;}
public void setSkullSplitterDeactivatedTimeStamp(Long newvalue){
skullSplitterDATS = newvalue;
skullSplitterDATS = (int) (newvalue/1000);
save();
}
/*
@ -749,11 +769,11 @@ public class PlayerProfile
}
public long getSerratedStrikesActivatedTimeStamp() {return serratedStrikesATS;}
public void setSerratedStrikesActivatedTimeStamp(Long newvalue){
serratedStrikesATS = newvalue;
serratedStrikesATS = (int) (newvalue/1000);
}
public long getSerratedStrikesDeactivatedTimeStamp() {return serratedStrikesDATS;}
public void setSerratedStrikesDeactivatedTimeStamp(Long newvalue){
serratedStrikesDATS = newvalue;
serratedStrikesDATS = (int) (newvalue/1000);
save();
}
/*
@ -771,11 +791,11 @@ public class PlayerProfile
}
public long getGigaDrillBreakerActivatedTimeStamp() {return gigaDrillBreakerATS;}
public void setGigaDrillBreakerActivatedTimeStamp(Long newvalue){
gigaDrillBreakerATS = newvalue;
gigaDrillBreakerATS = (int) (newvalue/1000);
}
public long getGigaDrillBreakerDeactivatedTimeStamp() {return gigaDrillBreakerDATS;}
public void setGigaDrillBreakerDeactivatedTimeStamp(Long newvalue){
gigaDrillBreakerDATS = newvalue;
gigaDrillBreakerDATS = (int) (newvalue/1000);
save();
}
/*
@ -793,11 +813,11 @@ public class PlayerProfile
}
public long getTreeFellerActivatedTimeStamp() {return treeFellerATS;}
public void setTreeFellerActivatedTimeStamp(Long newvalue){
treeFellerATS = newvalue;
treeFellerATS = (int) (newvalue/1000);
}
public long getTreeFellerDeactivatedTimeStamp() {return treeFellerDATS;}
public void setTreeFellerDeactivatedTimeStamp(Long newvalue){
treeFellerDATS = newvalue;
treeFellerDATS = (int) (newvalue/1000);
save();
}
/*
@ -815,18 +835,18 @@ public class PlayerProfile
}
public long getSuperBreakerActivatedTimeStamp() {return superBreakerATS;}
public void setSuperBreakerActivatedTimeStamp(Long newvalue){
superBreakerATS = newvalue;
superBreakerATS = (int) (newvalue/1000);
}
public long getSuperBreakerDeactivatedTimeStamp() {return superBreakerDATS;}
public void setSuperBreakerDeactivatedTimeStamp(Long newvalue){
superBreakerDATS = newvalue;
superBreakerDATS = (int) (newvalue/1000);
save();
}
public long getRecentlyHurt(){
return recentlyHurt;
}
public void setRecentlyHurt(long newvalue){
recentlyHurt = newvalue;
recentlyHurt = (int) (newvalue/1000);
}
public void skillUp(SkillType skillType, int newvalue)
{
@ -863,6 +883,14 @@ public class PlayerProfile
skillsXp.put(SkillType.SORCERY, skillsXp.get(SkillType.SORCERY)+newvalue);
} else {
skillsXp.put(skillType, skillsXp.get(skillType)+newvalue);
SkillType prevLastGained = lastgained;
lastgained = skillType;
//In case of an xp bar switch
if(prevLastGained != skillType || prevLastGained == null)
xpbarinc = SpoutStuff.getXpInc(this.getSkillXpLevel(lastgained), this.getXpToLevel(lastgained));
}
//save();
}
@ -885,7 +913,7 @@ public class PlayerProfile
} else {
skillsXp.put(skillType, skillsXp.get(skillType)-newvalue);
}
save();
//save();
}
public void acceptInvite()
{

View File

@ -25,6 +25,7 @@ import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.contrib.SpoutStuff;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
@ -89,6 +90,14 @@ public class mcPlayerListener extends PlayerListener
//Discard the PlayerProfile object
Users.removeUser(event.getPlayer());
if(LoadProperties.spoutEnabled)
{
if(SpoutStuff.xpbars.containsKey(event.getPlayer()))
SpoutStuff.xpbars.remove(event.getPlayer());
if(SpoutStuff.xpicons.containsKey(event.getPlayer()))
SpoutStuff.xpicons.remove(event.getPlayer());
}
}
public void onPlayerJoin(PlayerJoinEvent event)
@ -120,7 +129,7 @@ public class mcPlayerListener extends PlayerListener
//Archery Nerf
if(player.getItemInHand().getTypeId() == 261 && LoadProperties.archeryFireRateLimit)
{
if(System.currentTimeMillis() < PP.getArcheryShotATS() + LoadProperties.archeryLimit)
if(System.currentTimeMillis() < (PP.getArcheryShotATS()*1000) + LoadProperties.archeryLimit)
{
/*
if(m.hasArrows(player))

View File

@ -5,6 +5,7 @@ import org.getspout.spoutapi.event.spout.SpoutListener;
import org.getspout.spoutapi.gui.GenericTexture;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.contrib.SpoutStuff;
public class mcSpoutListener extends SpoutListener
{
@ -17,12 +18,36 @@ public class mcSpoutListener extends SpoutListener
{
if(event.getPlayer().isSpoutCraftEnabled())
{
//The bottom right of the screen is x=240, y=427
GenericTexture xpbar = new GenericTexture();
xpbar.setUrl("http://dl.dropbox.com/u/18212134/xpbar/xpbar_inc000.png");
GenericTexture xpicon = new GenericTexture();
event.getPlayer().getMainScreen().attachWidget(xpbar.setX(0).setY(240));
xpicon.setUrl("http://dl.dropbox.com/u/18212134/xpbar/icon.png");
xpicon.setHeight(16).setWidth(32).setX(93).setY(2);
xpbar.setUrl("http://dl.dropbox.com/u/18212134/xpbar/xpbar_inc000.png");
xpbar.setX(110).setY(6).setHeight(8).setWidth(256);
SpoutStuff.xpbars.put(event.getPlayer(), xpbar);
SpoutStuff.xpicons.put(event.getPlayer(), xpicon);
event.getPlayer().getMainScreen().attachWidget(SpoutStuff.xpbars.get(event.getPlayer()));
event.getPlayer().getMainScreen().attachWidget(SpoutStuff.xpicons.get(event.getPlayer()));
event.getPlayer().getMainScreen().setDirty(true);
}
}
/*
public void onServerTick(ServerTickEvent event)
{
for(Player x : SpoutStuff.xpbars.keySet())
{
PlayerProfile PP = Users.getProfile(x);
if(PP.getLastGained() != null)
{
if(SpoutStuff.shouldBeFilled(PP))
SpoutStuff.updateXpBarFill(x);
}
}
}
*/
}

View File

@ -61,45 +61,46 @@ public class Skills {
public static void watchCooldowns(Player player){
PlayerProfile PP = Users.getProfile(player);
if(!PP.getGreenTerraInformed() && System.currentTimeMillis() - PP.getGreenTerraDeactivatedTimeStamp() >= (LoadProperties.greenTerraCooldown * 1000)){
if(!PP.getGreenTerraInformed() && System.currentTimeMillis() - (PP.getGreenTerraDeactivatedTimeStamp()*1000) >= (LoadProperties.greenTerraCooldown * 1000)){
PP.setGreenTerraInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourGreenTerra"));
}
if(!PP.getTreeFellerInformed() && System.currentTimeMillis() - PP.getTreeFellerDeactivatedTimeStamp() >= (LoadProperties.greenTerraCooldown * 1000)){
if(!PP.getTreeFellerInformed() && System.currentTimeMillis() - (PP.getTreeFellerDeactivatedTimeStamp()*1000) >= (LoadProperties.greenTerraCooldown * 1000)){
PP.setTreeFellerInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourTreeFeller"));
}
if(!PP.getSuperBreakerInformed() && System.currentTimeMillis() - PP.getSuperBreakerDeactivatedTimeStamp() >= (LoadProperties.superBreakerCooldown * 1000)){
if(!PP.getSuperBreakerInformed() && System.currentTimeMillis() - (PP.getSuperBreakerDeactivatedTimeStamp()*1000) >= (LoadProperties.superBreakerCooldown * 1000)){
PP.setSuperBreakerInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourSuperBreaker"));
}
if(!PP.getSerratedStrikesInformed() && System.currentTimeMillis() - PP.getSerratedStrikesDeactivatedTimeStamp() >= (LoadProperties.serratedStrikeCooldown * 1000)){
if(!PP.getSerratedStrikesInformed() && System.currentTimeMillis() - (PP.getSerratedStrikesDeactivatedTimeStamp()*1000) >= (LoadProperties.serratedStrikeCooldown * 1000)){
PP.setSerratedStrikesInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourSerratedStrikes"));
}
if(!PP.getBerserkInformed() && System.currentTimeMillis() - PP.getBerserkDeactivatedTimeStamp() >= (LoadProperties.berserkCooldown * 1000)){
if(!PP.getBerserkInformed() && System.currentTimeMillis() - (PP.getBerserkDeactivatedTimeStamp()*1000) >= (LoadProperties.berserkCooldown * 1000)){
PP.setBerserkInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourBerserk"));
}
if(!PP.getSkullSplitterInformed() && System.currentTimeMillis() - PP.getSkullSplitterDeactivatedTimeStamp() >= (LoadProperties.skullSplitterCooldown * 1000)){
if(!PP.getSkullSplitterInformed() && System.currentTimeMillis() - (PP.getSkullSplitterDeactivatedTimeStamp()*1000) >= (LoadProperties.skullSplitterCooldown * 1000)){
PP.setSkullSplitterInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourSkullSplitter"));
}
if(!PP.getGigaDrillBreakerInformed() && System.currentTimeMillis() - PP.getGigaDrillBreakerDeactivatedTimeStamp() >= (LoadProperties.gigaDrillBreakerCooldown * 1000)){
if(!PP.getGigaDrillBreakerInformed() && System.currentTimeMillis() - (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000) >= (LoadProperties.gigaDrillBreakerCooldown * 1000)){
PP.setGigaDrillBreakerInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourGigaDrillBreaker"));
}
}
public static void hoeReadinessCheck(Player player){
public static void hoeReadinessCheck(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(mcPermissions.getInstance().herbalismAbility(player) && m.isHoe(player.getItemInHand()) && !PP.getHoePreparationMode()){
if(!PP.getGreenTerraMode() && !cooldownOver(player, PP.getGreenTerraDeactivatedTimeStamp(), LoadProperties.greenTerraCooldown)){
if(!PP.getGreenTerraMode() && !cooldownOver(player, (PP.getGreenTerraDeactivatedTimeStamp()*1000), LoadProperties.greenTerraCooldown)){
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getGreenTerraDeactivatedTimeStamp(), LoadProperties.greenTerraCooldown)+"s)");
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getGreenTerraDeactivatedTimeStamp()*1000), LoadProperties.greenTerraCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadyHoe"));
PP.setHoePreparationATS(System.currentTimeMillis());
PP.setHoePreparationATS(System.currentTimeMillis()/1000);
PP.setHoePreparationMode(true);
}
}
@ -107,27 +108,27 @@ public class Skills {
PlayerProfile PP = Users.getProfile(player);
if(PP != null)
{
if(PP.getHoePreparationMode() && System.currentTimeMillis() - PP.getHoePreparationATS() >= 4000){
if(PP.getHoePreparationMode() && System.currentTimeMillis() - (PP.getHoePreparationATS()*1000) >= 4000){
PP.setHoePreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerHoe"));
}
if(PP.getAxePreparationMode() && System.currentTimeMillis() - PP.getAxePreparationATS() >= 4000){
if(PP.getAxePreparationMode() && System.currentTimeMillis() - (PP.getAxePreparationATS()*1000) >= 4000){
PP.setAxePreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerAxe"));
}
if(PP.getPickaxePreparationMode() && System.currentTimeMillis() - PP.getPickaxePreparationATS() >= 4000){
if(PP.getPickaxePreparationMode() && System.currentTimeMillis() - (PP.getPickaxePreparationATS()*1000) >= 4000){
PP.setPickaxePreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerPickAxe"));
}
if(PP.getSwordsPreparationMode() && System.currentTimeMillis() - PP.getSwordsPreparationATS() >= 4000){
if(PP.getSwordsPreparationMode() && System.currentTimeMillis() - (PP.getSwordsPreparationATS()*1000) >= 4000){
PP.setSwordsPreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerSword"));
}
if(PP.getFistsPreparationMode() && System.currentTimeMillis() - PP.getFistsPreparationATS() >= 4000){
if(PP.getFistsPreparationMode() && System.currentTimeMillis() - (PP.getFistsPreparationATS()*1000) >= 4000){
PP.setFistsPreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerFists"));
}
if(PP.getShovelPreparationMode() && System.currentTimeMillis() - PP.getShovelPreparationATS() >= 4000){
if(PP.getShovelPreparationMode() && System.currentTimeMillis() - (PP.getShovelPreparationATS()*1000) >= 4000){
PP.setShovelPreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerShovel"));
}
@ -136,7 +137,7 @@ public class Skills {
* HERBALISM ABILITY
*/
if(mcPermissions.getInstance().herbalismAbility(player)){
if(PP.getGreenTerraMode() && PP.getGreenTerraDeactivatedTimeStamp() <= System.currentTimeMillis()){
if(PP.getGreenTerraMode() && (PP.getGreenTerraDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setGreenTerraMode(false);
PP.setGreenTerraInformed(false);
player.sendMessage(mcLocale.getString("Skills.GreenTerraOff"));
@ -146,7 +147,7 @@ public class Skills {
* AXES ABILITY
*/
if(mcPermissions.getInstance().axesAbility(player)){
if(PP.getSkullSplitterMode() && PP.getSkullSplitterDeactivatedTimeStamp() <= System.currentTimeMillis()){
if(PP.getSkullSplitterMode() && (PP.getSkullSplitterDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setSkullSplitterMode(false);
PP.setSkullSplitterInformed(false);
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOff"));
@ -156,7 +157,7 @@ public class Skills {
* WOODCUTTING ABILITY
*/
if(mcPermissions.getInstance().woodCuttingAbility(player)){
if(PP.getTreeFellerMode() && PP.getTreeFellerDeactivatedTimeStamp() <= System.currentTimeMillis()){
if(PP.getTreeFellerMode() && (PP.getTreeFellerDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setTreeFellerMode(false);
PP.setTreeFellerInformed(false);
player.sendMessage(mcLocale.getString("Skills.TreeFellerOff"));
@ -166,7 +167,7 @@ public class Skills {
* MINING ABILITY
*/
if(mcPermissions.getInstance().miningAbility(player)){
if(PP.getSuperBreakerMode() && PP.getSuperBreakerDeactivatedTimeStamp() <= System.currentTimeMillis()){
if(PP.getSuperBreakerMode() && (PP.getSuperBreakerDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setSuperBreakerMode(false);
PP.setSuperBreakerInformed(false);
player.sendMessage(mcLocale.getString("Skills.SuperBreakerOff"));
@ -176,7 +177,7 @@ public class Skills {
* EXCAVATION ABILITY
*/
if(mcPermissions.getInstance().excavationAbility(player)){
if(PP.getGigaDrillBreakerMode() && PP.getGigaDrillBreakerDeactivatedTimeStamp() <= System.currentTimeMillis()){
if(PP.getGigaDrillBreakerMode() && (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setGigaDrillBreakerMode(false);
PP.setGigaDrillBreakerInformed(false);
player.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerOff"));
@ -186,7 +187,7 @@ public class Skills {
* SWORDS ABILITY
*/
if(mcPermissions.getInstance().swordsAbility(player)){
if(PP.getSerratedStrikesMode() && PP.getSerratedStrikesDeactivatedTimeStamp() <= System.currentTimeMillis()){
if(PP.getSerratedStrikesMode() && (PP.getSerratedStrikesDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setSerratedStrikesMode(false);
PP.setSerratedStrikesInformed(false);
player.sendMessage(mcLocale.getString("Skills.SerratedStrikesOff"));
@ -196,7 +197,7 @@ public class Skills {
* UNARMED ABILITY
*/
if(mcPermissions.getInstance().unarmedAbility(player)){
if(PP.getBerserkMode() && PP.getBerserkDeactivatedTimeStamp() <= System.currentTimeMillis()){
if(PP.getBerserkMode() && (PP.getBerserkDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setBerserkMode(false);
PP.setBerserkInformed(false);
player.sendMessage(mcLocale.getString("Skills.BerserkOff"));
@ -213,10 +214,10 @@ public class Skills {
return;
if(mcPermissions.getInstance().miningAbility(player) && m.isMiningPick(player.getItemInHand()) && !PP.getPickaxePreparationMode())
{
if(!PP.getSuperBreakerMode() && !cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown))
if(!PP.getSuperBreakerMode() && !cooldownOver(player, (PP.getSuperBreakerDeactivatedTimeStamp()*1000), LoadProperties.superBreakerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown)+"s)");
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getSuperBreakerDeactivatedTimeStamp()*1000), LoadProperties.superBreakerCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadyPickAxe"));
@ -225,10 +226,10 @@ public class Skills {
}
if(mcPermissions.getInstance().excavationAbility(player) && m.isShovel(player.getItemInHand()) && !PP.getShovelPreparationMode())
{
if(!PP.getGigaDrillBreakerMode() && !cooldownOver(player, PP.getGigaDrillBreakerDeactivatedTimeStamp(), LoadProperties.gigaDrillBreakerCooldown))
if(!PP.getGigaDrillBreakerMode() && !cooldownOver(player, (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000), LoadProperties.gigaDrillBreakerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getGigaDrillBreakerDeactivatedTimeStamp(), LoadProperties.gigaDrillBreakerCooldown)+"s)");
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000), LoadProperties.gigaDrillBreakerCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadyShovel"));
@ -237,10 +238,10 @@ public class Skills {
}
if(mcPermissions.getInstance().swordsAbility(player) && m.isSwords(player.getItemInHand()) && !PP.getSwordsPreparationMode())
{
if(!PP.getSerratedStrikesMode() && !cooldownOver(player, PP.getSerratedStrikesDeactivatedTimeStamp(), LoadProperties.serratedStrikeCooldown))
if(!PP.getSerratedStrikesMode() && !cooldownOver(player, (PP.getSerratedStrikesDeactivatedTimeStamp()*1000), LoadProperties.serratedStrikeCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getSerratedStrikesDeactivatedTimeStamp(), LoadProperties.serratedStrikeCooldown)+"s)");
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getSerratedStrikesDeactivatedTimeStamp()*1000), LoadProperties.serratedStrikeCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadySword"));
@ -249,10 +250,10 @@ public class Skills {
}
if(mcPermissions.getInstance().unarmedAbility(player) && player.getItemInHand().getTypeId() == 0 && !PP.getFistsPreparationMode())
{
if(!PP.getBerserkMode() && !cooldownOver(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown))
if(!PP.getBerserkMode() && !cooldownOver(player, (PP.getBerserkDeactivatedTimeStamp()*1000), LoadProperties.berserkCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown)+"s)");
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getBerserkDeactivatedTimeStamp()*1000), LoadProperties.berserkCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadyFists"));
@ -311,10 +312,11 @@ public class Skills {
if(LoadProperties.spoutEnabled && player instanceof SpoutPlayer)
{
SpoutPlayer sPlayer = SpoutManager.getPlayerFromId(player.getEntityId());
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if(sPlayer.isSpoutCraftEnabled())
{
SpoutStuff.levelUpNotification(skillType, sPlayer);
PP.setXpBarInc(0);
} else
{
player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
@ -322,7 +324,14 @@ public class Skills {
}
else
player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
}
if(LoadProperties.spoutEnabled)
{
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if(sPlayer.isSpoutCraftEnabled())
{
SpoutStuff.updateXpBar(sPlayer);
}
}
}

View File

@ -1,7 +1,7 @@
name: mcMMO
main: com.gmail.nossr50.mcMMO
version: 1.0.51 WIP
softdepend: Spout
softdepend: [Spout]
commands:
xprate:
description: Modify the xp rate or start an event