diff --git a/mcMMO/com/gmail/nossr50/Database.java b/mcMMO/com/gmail/nossr50/Database.java new file mode 100644 index 000000000..f13e98174 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/Database.java @@ -0,0 +1,127 @@ +package com.gmail.nossr50; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.HashMap; +import java.util.ArrayList; +import java.sql.PreparedStatement; + + +import org.bukkit.entity.Player; + + +public class Database { + + private Connection conn; + + public Database() { + + // Load the driver instance + try { + Class.forName("com.mysql.jdbc.Driver").newInstance(); + } catch (Exception ex) { + // handle the error + } + + // make the connection + try { + conn = DriverManager.getConnection("jdbc:mysql://" + mcLoadProperties.MySQLserverName + ":" + mcLoadProperties.MySQLport + "/" + mcLoadProperties.MySQLdbName + "?user=" + mcLoadProperties.MySQLuserName + "&password=" + mcLoadProperties.MySQLdbPass); + } catch (SQLException ex) { + // handle any errors + System.out.println("SQLException: " + ex.getMessage()); + System.out.println("SQLState: " + ex.getSQLState()); + System.out.println("VendorError: " + ex.getErrorCode()); + } + } + + // write query + public boolean Write(String sql) { + try { + PreparedStatement stmt = null; + stmt = this.conn.prepareStatement(sql); + stmt.executeUpdate(); + return true; + } catch(SQLException ex) { + System.out.println("SQLException: " + ex.getMessage()); + System.out.println("SQLState: " + ex.getSQLState()); + System.out.println("VendorError: " + ex.getErrorCode()); + return false; + } + } + + // Get Int + // only return first row / first field + public Integer GetInt(String sql) { + PreparedStatement stmt = null; + ResultSet rs = null; + Integer result = 0; + + try { + stmt = this.conn.prepareStatement(sql); + if (stmt.executeQuery() != null) { + stmt.executeQuery(); + rs = stmt.getResultSet(); + rs.next(); + result = rs.getInt(1); + } + } + catch (SQLException ex) { + System.out.println("SQLException: " + ex.getMessage()); + System.out.println("SQLState: " + ex.getSQLState()); + System.out.println("VendorError: " + ex.getErrorCode()); + } + + return result; + } + + // read query + public HashMap> Read(String sql) { + PreparedStatement stmt = null; + ResultSet rs = null; + HashMap> Rows = new HashMap>(); + + + + try { + stmt = this.conn.prepareStatement(sql); + if (stmt.executeQuery() != null) { + stmt.executeQuery(); + rs = stmt.getResultSet(); + while (rs.next()) { + ArrayList Col = new ArrayList(); + for(int i=1;i<=rs.getMetaData().getColumnCount();i++) { + Col.add(rs.getString(i)); + } + Rows.put(rs.getRow(),Col); + } + } + } + catch (SQLException ex) { + System.out.println("SQLException: " + ex.getMessage()); + System.out.println("SQLState: " + ex.getSQLState()); + System.out.println("VendorError: " + ex.getErrorCode()); + } + + + + // release dataset + if (rs != null) { + try { + rs.close(); + } catch (SQLException sqlEx) { } // ignore + rs = null; + } + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException sqlEx) { } // ignore + stmt = null; + } + + return Rows; + } + +} diff --git a/mcMMO/com/gmail/nossr50/datatypes/FakeBlockBreakEvent.java b/mcMMO/com/gmail/nossr50/datatypes/FakeBlockBreakEvent.java new file mode 100644 index 000000000..205190502 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/datatypes/FakeBlockBreakEvent.java @@ -0,0 +1,11 @@ +package com.gmail.nossr50.datatypes; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockBreakEvent; + +public class FakeBlockBreakEvent extends BlockBreakEvent { + public FakeBlockBreakEvent(Block theBlock, Player player) { + super(theBlock, player); + } +} \ No newline at end of file diff --git a/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java b/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java new file mode 100644 index 000000000..8f38c19c5 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -0,0 +1,1686 @@ +package com.gmail.nossr50.datatypes; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.util.HashMap; +import java.util.ArrayList; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; + + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import com.gmail.nossr50.Database; +import com.gmail.nossr50.mcLoadProperties; +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcSkills; + + + +public class PlayerProfile +{ + protected final Logger log = Logger.getLogger("Minecraft"); + private String taming, tamingXP, playerName, miningXP, woodCuttingXP, woodcutting, repair, mining, party, myspawn, myspawnworld, unarmed, herbalism, excavation, + archery, swords, axes, invite, acrobatics, repairXP, unarmedXP, herbalismXP, excavationXP, archeryXP, swordsXP, axesXP, acrobaticsXP; + 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, + 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 lastlogin=0, userid = 0, berserkTicks = 0, bleedticks = 0, greenTerraTicks = 0, gigaDrillBreakerTicks = 0, superBreakerTicks = 0, serratedStrikesTicks = 0, skullSplitterTicks = 0, treeFellerTicks = 0; + //ATS = (Time of) Activation Time Stamp + //DATS = (Time of) Deactivation Time Stamp + Player thisplayer; + char defaultColor; + + + String location = "plugins/mcMMO/mcmmo.users"; + + + public PlayerProfile(Player player) + { + + if (mcLoadProperties.useMySQL) { + // if usemysql load from database + if(!loadMySQL(player)) { addMySQLPlayer(player); } + } else { + // load from flat file + if(!load()) { addPlayer(); } + } + } + + + + public boolean loadMySQL(Player p) { + /* returns a list of all the users ordered by their username + HashMap> userslist = mcMMO.database.Read("SELECT id, lastlogin, party FROM users ORDER BY user"); + for(int i=1;i<=userslist.size();i++) { + System.out.println("User: " + userslist.get(i).get(0) + ", Lastlogin: " + userslist.get(i).get(1)); + } + */ + + + Integer id = 0; + id = mcMMO.database.GetInt("SELECT id FROM users WHERE user = '" + p.getName() + "'"); + this.userid = id; + if (id > 0) { + HashMap> users = mcMMO.database.Read("SELECT lastlogin, party FROM users WHERE id = " + id); + lastlogin = Integer.parseInt(users.get(1).get(0)); + party = users.get(1).get(1); + HashMap> spawn = mcMMO.database.Read("SELECT world, x, y, z FROM spawn WHERE user_id = " + id); + myspawnworld = spawn.get(1).get(0); + myspawn = spawn.get(1).get(1) + "," + spawn.get(1).get(2) + "," + spawn.get(1).get(3); + HashMap> skills = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM skills WHERE user_id = " + id); + taming = skills.get(1).get(0); + mining = skills.get(1).get(1);; + repair = skills.get(1).get(2);; + woodcutting = skills.get(1).get(3); + unarmed = skills.get(1).get(4); + herbalism = skills.get(1).get(5); + excavation = skills.get(1).get(6); + archery = skills.get(1).get(7); + swords = skills.get(1).get(8); + axes = skills.get(1).get(9); + acrobatics = skills.get(1).get(10); + HashMap> experience = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM experience WHERE user_id = " + id); + tamingXP = experience.get(1).get(0); + miningXP = experience.get(1).get(1);; + repairXP = experience.get(1).get(2);; + woodCuttingXP = experience.get(1).get(3); + unarmedXP = experience.get(1).get(4); + herbalismXP = experience.get(1).get(5); + excavationXP = experience.get(1).get(6); + archeryXP = experience.get(1).get(7); + swordsXP = experience.get(1).get(8); + axesXP = experience.get(1).get(9); + acrobaticsXP = experience.get(1).get(10); + return true; + } + else { + return false; + } + } + public void addMySQLPlayer(Player p) { + Integer id = 0; + mcMMO.database.Write("INSERT INTO users (user, lastlogin) VALUES ('" + p.getName() + "'," + System.currentTimeMillis() / 1000 +")"); + id = mcMMO.database.GetInt("SELECT id FROM users WHERE user = '" + p.getName() + "'"); + mcMMO.database.Write("INSERT INTO spawn (user_id) VALUES ("+id+")"); + mcMMO.database.Write("INSERT INTO skills (user_id) VALUES ("+id+")"); + mcMMO.database.Write("INSERT INTO experience (user_id) VALUES ("+id+")"); + this.userid = id; + + } + + public boolean load() + { + try { + //Open the user file + FileReader file = new FileReader(location); + BufferedReader in = new BufferedReader(file); + String line = ""; + while((line = in.readLine()) != null) + { + //Find if the line contains the player we want. + String[] character = line.split(":"); + + if(!character[0].equals(playerName)){continue;} + + //Get Mining + if(character.length > 1) + mining = character[1]; + //Myspawn + if(character.length > 2) + myspawn = character[2]; + //Party + if(character.length > 3) + party = character[3]; + //Mining XP + if(character.length > 4) + miningXP = character[4]; + if(character.length > 5) + woodcutting = character[5]; + if(character.length > 6) + woodCuttingXP = character[6]; + if(character.length > 7) + repair = character[7]; + if(character.length > 8) + unarmed = character[8]; + if(character.length > 9) + herbalism = character[9]; + if(character.length > 10) + excavation = character[10]; + if(character.length > 11) + archery = character[11]; + if(character.length > 12) + swords = character[12]; + if(character.length > 13) + axes = character[13]; + if(character.length > 14) + acrobatics = character[14]; + if(character.length > 15) + repairXP = character[15]; + if(character.length > 16) + unarmedXP = character[16]; + if(character.length > 17) + herbalismXP = character[17]; + if(character.length > 18) + excavationXP = character[18]; + if(character.length > 19) + archeryXP = character[19]; + if(character.length > 20) + swordsXP = character[20]; + if(character.length > 21) + axesXP = character[21]; + if(character.length > 22) + acrobaticsXP = character[22]; + if(character.length > 23) + myspawnworld = character[23]; + if(character.length > 24) + taming = character[24]; + if(character.length > 25) + tamingXP = character[25]; + in.close(); + return true; + } + in.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while reading " + + location + " (Are you sure you formatted it correctly?)", e); + } + return false; + } + + public void save() + { + Long timestamp = System.currentTimeMillis(); + + // if we are using mysql save to database + if (mcLoadProperties.useMySQL) { + mcMMO.database.Write("UPDATE users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid); + mcMMO.database.Write("UPDATE spawn SET world = '" + this.myspawnworld + "', x = " +getX()+", y = "+getY()+", z = "+getZ()+" WHERE user_id = "+this.userid); + mcMMO.database.Write("UPDATE skills SET " + +" taming = "+taming + +", woodcutting = "+woodcutting + +", unarmed = "+unarmed + +", herbalism = "+herbalism + +", excavation = "+excavation + +", archery = " +archery + +", swords = " +swords + +", axes = "+axes + +", acrobatics = "+acrobatics + +" WHERE user_id = "+this.userid); + mcMMO.database.Write("UPDATE experience SET " + +" taming = "+tamingXP + +", woodcutting = "+woodCuttingXP + +", unarmed = "+unarmedXP + +", herbalism = "+herbalismXP + +", excavation = "+excavationXP + +", archery = " +archeryXP + +", swords = " +swordsXP + +", axes = "+axesXP + +", acrobatics = "+acrobaticsXP + +" WHERE user_id = "+this.userid); + + } + else { + // otherwise save to flatfile + try { + //Open the file + FileReader file = new FileReader(location); + BufferedReader in = new BufferedReader(file); + StringBuilder writer = new StringBuilder(); + String line = ""; + + //While not at the end of the file + while((line = in.readLine()) != null) + { + //Read the line in and copy it to the output it's not the player + //we want to edit + if(!line.split(":")[0].equalsIgnoreCase(playerName)) + { + writer.append(line).append("\r\n"); + + //Otherwise write the new player information + } else { + writer.append(playerName + ":"); + writer.append(mining + ":"); + writer.append(myspawn + ":"); + writer.append(party+":"); + writer.append(miningXP+":"); + writer.append(woodcutting+":"); + writer.append(woodCuttingXP+":"); + writer.append(repair+":"); + writer.append(unarmed+":"); + writer.append(herbalism+":"); + writer.append(excavation+":"); + writer.append(archery+":"); + writer.append(swords+":"); + writer.append(axes+":"); + writer.append(acrobatics+":"); + writer.append(repairXP+":"); + writer.append(unarmedXP+":"); + writer.append(herbalismXP+":"); + writer.append(excavationXP+":"); + writer.append(archeryXP+":"); + writer.append(swordsXP+":"); + writer.append(axesXP+":"); + writer.append(acrobaticsXP+":"); + writer.append(myspawnworld+":"); + writer.append(taming+":"); + writer.append(tamingXP+":"); + writer.append("\r\n"); + } + } + in.close(); + //Write the new file + FileWriter out = new FileWriter(location); + out.write(writer.toString()); + out.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e); + } + } + } + public void addPlayer() + { + try { + //Open the file to write the player + FileWriter file = new FileWriter(location, true); + BufferedWriter out = new BufferedWriter(file); + + //Add the player to the end + out.append(playerName + ":"); + out.append(0 + ":"); //mining + out.append(myspawn+":"); + out.append(party+":"); + out.append(0+":"); //XP + out.append(0+":"); //woodcutting + out.append(0+":"); //woodCuttingXP + out.append(0+":"); //repair + out.append(0+":"); //unarmed + out.append(0+":"); //herbalism + out.append(0+":"); //excavation + out.append(0+":"); //archery + out.append(0+":"); //swords + out.append(0+":"); //axes + out.append(0+":"); //acrobatics + out.append(0+":"); //repairXP + out.append(0+":"); //unarmedXP + out.append(0+":"); //herbalismXP + out.append(0+":"); //excavationXP + out.append(0+":"); //archeryXP + out.append(0+":"); //swordsXP + out.append(0+":"); //axesXP + out.append(0+":"); //acrobaticsXP + out.append(thisplayer.getWorld().getName()); + out.append(0+":"); //taming + out.append(0+":"); //tamingXP + //Add more in the same format as the line above + + out.newLine(); + out.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e); + } + } + + + public boolean isPlayer(String player) + { + return player.equals(playerName); + } + public boolean getPartyChatOnlyToggle(){return partyChatOnly;} + public void togglePartyChatOnly(){partyChatOnly = !partyChatOnly;} + public boolean getAbilityUse(){ + return abilityuse; + } + public void toggleAbilityUse(){ + if(abilityuse == false){ + abilityuse = true; + } else { + abilityuse = false; + } + } + public long getMySpawnATS(){ + return mySpawnATS; + } + public void setMySpawnATS(long newvalue){ + mySpawnATS = newvalue; + } + public void decreaseBleedTicks(){ + if(bleedticks >= 1){ + bleedticks--; + } + } + public Integer getBleedTicks(){ + return bleedticks; + } + public void setBleedTicks(Integer newvalue){ + bleedticks = newvalue; + } + public void addBleedTicks(Integer newvalue){ + bleedticks+=newvalue; + } + public Boolean hasCooldowns(){ + if((treeFellerCooldown + superBreakerCooldown) >= 1){ + return true; + } else { + return false; + } + } + /* + * EXPLOIT PREVENTION + */ + public long getRespawnATS() {return respawnATS;} + public void setRespawnATS(long newvalue) {respawnATS = newvalue;} + + /* + * ARCHERY NERF STUFF + */ + public long getArcheryShotATS() {return archeryShotATS;} + public void setArcheryShotATS(long newvalue) {archeryShotATS = newvalue;} + + /* + * HOE PREPARATION + */ + public boolean getHoePreparationMode(){ + return hoePreparationMode; + } + public void setHoePreparationMode(Boolean bool){ + hoePreparationMode = bool; + } + public long getHoePreparationATS(){ + return hoePreparationATS; + } + public void setHoePreparationATS(long newvalue){ + hoePreparationATS = newvalue; + } + + /* + * SWORDS PREPARATION + */ + public boolean getSwordsPreparationMode(){ + return swordsPreparationMode; + } + public void setSwordsPreparationMode(Boolean bool){ + swordsPreparationMode = bool; + } + public long getSwordsPreparationATS(){ + return swordsPreparationATS; + } + public void setSwordsPreparationATS(long newvalue){ + swordsPreparationATS = newvalue; + } + /* + * SHOVEL PREPARATION + */ + public boolean getShovelPreparationMode(){ + return shovelPreparationMode; + } + public void setShovelPreparationMode(Boolean bool){ + shovelPreparationMode = bool; + } + public long getShovelPreparationATS(){ + return shovelPreparationATS; + } + public void setShovelPreparationATS(long newvalue){ + shovelPreparationATS = newvalue; + } + /* + * FISTS PREPARATION + */ + public boolean getFistsPreparationMode(){ + return fistsPreparationMode; + } + public void setFistsPreparationMode(Boolean bool){ + fistsPreparationMode = bool; + } + public long getFistsPreparationATS(){ + return fistsPreparationATS; + } + public void setFistsPreparationATS(long newvalue){ + fistsPreparationATS = newvalue; + } + /* + * AXE PREPARATION + */ + public boolean getAxePreparationMode(){ + return axePreparationMode; + } + public void setAxePreparationMode(Boolean bool){ + axePreparationMode = bool; + } + public long getAxePreparationATS(){ + return axePreparationATS; + } + public void setAxePreparationATS(long newvalue){ + axePreparationATS = newvalue; + } + /* + * PICKAXE PREPARATION + */ + public boolean getPickaxePreparationMode(){ + return pickaxePreparationMode; + } + public void setPickaxePreparationMode(Boolean bool){ + pickaxePreparationMode = bool; + } + public long getPickaxePreparationATS(){ + return pickaxePreparationATS; + } + public void setPickaxePreparationATS(long newvalue){ + pickaxePreparationATS = newvalue; + } + /* + * GREEN TERRA MODE + */ + public boolean getGreenTerraInformed() {return greenTerraInformed;} + public void setGreenTerraInformed(Boolean bool){ + greenTerraInformed = bool; + } + public boolean getGreenTerraMode(){ + return greenTerraMode; + } + public void setGreenTerraMode(Boolean bool){ + greenTerraMode = bool; + } + public long getGreenTerraActivatedTimeStamp() {return greenTerraATS;} + public void setGreenTerraActivatedTimeStamp(Long newvalue){ + greenTerraATS = newvalue; + } + public long getGreenTerraDeactivatedTimeStamp() {return greenTerraDATS;} + public void setGreenTerraDeactivatedTimeStamp(Long newvalue){ + greenTerraDATS = newvalue; + } + public void setGreenTerraCooldown(Long newvalue){ + greenTerraCooldown = newvalue; + } + public long getGreenTerraCooldown(){ + return greenTerraCooldown; + } + public void setGreenTerraTicks(Integer newvalue){greenTerraTicks = newvalue;} + public int getGreenTerraTicks(){return greenTerraTicks;} + /* + * BERSERK MODE + */ + public boolean getBerserkInformed() {return berserkInformed;} + public void setBerserkInformed(Boolean bool){ + berserkInformed = bool; + } + public boolean getBerserkMode(){ + return berserkMode; + } + public void setBerserkMode(Boolean bool){ + berserkMode = bool; + } + public long getBerserkActivatedTimeStamp() {return berserkATS;} + public void setBerserkActivatedTimeStamp(Long newvalue){ + berserkATS = newvalue; + } + public long getBerserkDeactivatedTimeStamp() {return berserkDATS;} + public void setBerserkDeactivatedTimeStamp(Long newvalue){ + berserkDATS = newvalue; + } + public void setBerserkCooldown(Long newvalue){ + berserkCooldown = newvalue; + } + public long getBerserkCooldown(){ + return berserkCooldown; + } + public void setBerserkTicks(Integer newvalue){berserkTicks = newvalue;} + public int getBerserkTicks(){return berserkTicks;} + /* + * SKULL SPLITTER + */ + public boolean getSkullSplitterInformed() {return skullSplitterInformed;} + public void setSkullSplitterInformed(Boolean bool){ + skullSplitterInformed = bool; + } + public boolean getSkullSplitterMode(){ + return skullSplitterMode; + } + public void setSkullSplitterMode(Boolean bool){ + skullSplitterMode = bool; + } + public long getSkullSplitterActivatedTimeStamp() {return skullSplitterATS;} + public void setSkullSplitterActivatedTimeStamp(Long newvalue){ + skullSplitterATS = newvalue; + } + public long getSkullSplitterDeactivatedTimeStamp() {return skullSplitterDATS;} + public void setSkullSplitterDeactivatedTimeStamp(Long newvalue){ + skullSplitterDATS = newvalue; + } + public void setSkullSplitterCooldown(Long newvalue){ + skullSplitterCooldown = newvalue; + } + public long getSkullSplitterCooldown(){ + return skullSplitterCooldown; + } + public void setSkullSplitterTicks(Integer newvalue){skullSplitterTicks = newvalue;} + public int getSkullSplitterTicks(){return skullSplitterTicks;} + /* + * SERRATED STRIKES + */ + public boolean getSerratedStrikesInformed() {return serratedStrikesInformed;} + public void setSerratedStrikesInformed(Boolean bool){ + serratedStrikesInformed = bool; + } + public boolean getSerratedStrikesMode(){ + return serratedStrikesMode; + } + public void setSerratedStrikesMode(Boolean bool){ + serratedStrikesMode = bool; + } + public long getSerratedStrikesActivatedTimeStamp() {return serratedStrikesATS;} + public void setSerratedStrikesActivatedTimeStamp(Long newvalue){ + serratedStrikesATS = newvalue; + } + public long getSerratedStrikesDeactivatedTimeStamp() {return serratedStrikesDATS;} + public void setSerratedStrikesDeactivatedTimeStamp(Long newvalue){ + serratedStrikesDATS = newvalue; + } + public void setSerratedStrikesCooldown(Long newvalue){ + serratedStrikesCooldown = newvalue; + } + public long getSerratedStrikesCooldown(){ + return serratedStrikesCooldown; + } + public void setSerratedStrikesTicks(Integer newvalue){serratedStrikesTicks = newvalue;} + public int getSerratedStrikesTicks(){return serratedStrikesTicks;} + /* + * GIGA DRILL BREAKER + */ + public boolean getGigaDrillBreakerInformed() {return gigaDrillBreakerInformed;} + public void setGigaDrillBreakerInformed(Boolean bool){ + gigaDrillBreakerInformed = bool; + } + public boolean getGigaDrillBreakerMode(){ + return gigaDrillBreakerMode; + } + public void setGigaDrillBreakerMode(Boolean bool){ + gigaDrillBreakerMode = bool; + } + public long getGigaDrillBreakerActivatedTimeStamp() {return gigaDrillBreakerATS;} + public void setGigaDrillBreakerActivatedTimeStamp(Long newvalue){ + gigaDrillBreakerATS = newvalue; + } + public long getGigaDrillBreakerDeactivatedTimeStamp() {return gigaDrillBreakerDATS;} + public void setGigaDrillBreakerDeactivatedTimeStamp(Long newvalue){ + gigaDrillBreakerDATS = newvalue; + } + public void setGigaDrillBreakerCooldown(Long newvalue){ + gigaDrillBreakerCooldown = newvalue; + } + public long getGigaDrillBreakerCooldown(){ + return gigaDrillBreakerCooldown; + } + public void setGigaDrillBreakerTicks(Integer newvalue){gigaDrillBreakerTicks = newvalue;} + public int getGigaDrillBreakerTicks(){return gigaDrillBreakerTicks;} + /* + * TREE FELLER STUFF + */ + public boolean getTreeFellerInformed() {return treeFellerInformed;} + public void setTreeFellerInformed(Boolean bool){ + treeFellerInformed = bool; + } + public boolean getTreeFellerMode(){ + return treeFellerMode; + } + public void setTreeFellerMode(Boolean bool){ + treeFellerMode = bool; + } + public long getTreeFellerActivatedTimeStamp() {return treeFellerATS;} + public void setTreeFellerActivatedTimeStamp(Long newvalue){ + treeFellerATS = newvalue; + } + public long getTreeFellerDeactivatedTimeStamp() {return treeFellerDATS;} + public void setTreeFellerDeactivatedTimeStamp(Long newvalue){ + treeFellerDATS = newvalue; + } + public void setTreeFellerCooldown(Long newvalue){ + treeFellerCooldown = newvalue; + } + public long getTreeFellerCooldown(){ + return treeFellerCooldown; + } + public void setTreeFellerTicks(Integer newvalue){treeFellerTicks = newvalue;} + public int getTreeFellerTicks(){return treeFellerTicks;} + /* + * MINING + */ + public boolean getSuperBreakerInformed() {return superBreakerInformed;} + public void setSuperBreakerInformed(Boolean bool){ + superBreakerInformed = bool; + } + public boolean getSuperBreakerMode(){ + return superBreakerMode; + } + public void setSuperBreakerMode(Boolean bool){ + superBreakerMode = bool; + } + public long getSuperBreakerActivatedTimeStamp() {return superBreakerATS;} + public void setSuperBreakerActivatedTimeStamp(Long newvalue){ + superBreakerATS = newvalue; + } + public long getSuperBreakerDeactivatedTimeStamp() {return superBreakerDATS;} + public void setSuperBreakerDeactivatedTimeStamp(Long newvalue){ + superBreakerDATS = newvalue; + } + public void setSuperBreakerCooldown(Long newvalue){ + superBreakerCooldown = newvalue; + } + public long getSuperBreakerCooldown(){ + return superBreakerCooldown; + } + public void setSuperBreakerTicks(Integer newvalue){superBreakerTicks = newvalue;} + public int getSuperBreakerTicks(){return superBreakerTicks;} + + public long getRecentlyHurt(){ + return recentlyHurt; + } + public void setRecentlyHurt(long newvalue){ + recentlyHurt = newvalue; + } + public void skillUpTaming(int newskill){ + int x = 0; + if(taming != null){ + if(isInt(taming)){ + x = Integer.parseInt(taming); + }else { + taming = "0"; + x = Integer.parseInt(taming); + } + } + x += newskill; + taming = Integer.toString(x); + save(); + } + public void skillUpAxes(int newskill){ + int x = 0; + if(axes != null){ + if(isInt(axes)){ + x = Integer.parseInt(axes); + }else { + axes = "0"; + x = Integer.parseInt(axes); + } + } + x += newskill; + axes = Integer.toString(x); + save(); + } + public void skillUpAcrobatics(int newskill){ + int x = 0; + if(acrobatics != null){ + if(isInt(acrobatics)){ + x = Integer.parseInt(acrobatics); + }else { + acrobatics = "0"; + x = Integer.parseInt(acrobatics); + } + } + x += newskill; + acrobatics = Integer.toString(x); + save(); + } + public void skillUpSwords(int newskill){ + int x = 0; + if(swords != null){ + if(isInt(swords)){ + x = Integer.parseInt(swords); + }else { + swords = "0"; + x = Integer.parseInt(swords); + } + } + x += newskill; + swords = Integer.toString(x); + save(); + } + public void skillUpArchery(int newskill){ + int x = 0; + if(archery != null){ + if(isInt(archery)){ + x = Integer.parseInt(archery); + }else { + archery = "0"; + x = Integer.parseInt(archery); + } + } + x += newskill; + archery = Integer.toString(x); + save(); + } + public void skillUpRepair(int newskill){ + int x = 0; + if(repair != null){ + if(isInt(repair)){ + x = Integer.parseInt(repair); + }else { + repair = "0"; + x = Integer.parseInt(repair); + } + } + x += newskill; + repair = Integer.toString(x); + save(); + } + public void skillUpMining(int newmining){ + int x = 0; + if(mining != null){ + if(isInt(mining)){ + x = Integer.parseInt(mining); + }else { + mining = "0"; + x = Integer.parseInt(mining); + } + } + x += newmining; + mining = Integer.toString(x); + save(); + } + public void skillUpUnarmed(int newskill){ + int x = 0; + if(unarmed != null){ + if(isInt(unarmed)){ + x = Integer.parseInt(unarmed); + }else { + unarmed = "0"; + x = Integer.parseInt(unarmed); + } + } + x += newskill; + unarmed = Integer.toString(x); + save(); + } + public void skillUpHerbalism(int newskill){ + int x = 0; + if(herbalism != null){ + if(isInt(herbalism)){ + x = Integer.parseInt(herbalism); + }else { + herbalism = "0"; + x = Integer.parseInt(herbalism); + } + } + x += newskill; + herbalism = Integer.toString(x); + save(); + } + public void skillUpExcavation(int newskill){ + int x = 0; + if(excavation != null){ + if(isInt(excavation)){ + x = Integer.parseInt(excavation); + }else { + excavation = "0"; + x = Integer.parseInt(excavation); + } + } + x += newskill; + excavation = Integer.toString(x); + save(); + } + public void skillUpWoodCutting(int newskill){ + int x = 0; + if(woodcutting != null){ + if(isInt(woodcutting)){ + x = Integer.parseInt(woodcutting); + }else { + woodcutting = "0"; + x = Integer.parseInt(woodcutting); + } + } + x += newskill; + woodcutting = Integer.toString(x); + save(); + } + public String getTaming(){ + if(taming != null && !taming.equals("") && !taming.equals("null")){ + return taming; + } else { + return "0"; + } + } + public String getRepair(){ + if(repair != null && !repair.equals("") && !repair.equals("null")){ + return repair; + } else { + return "0"; + } + } + public String getMining(){ + if(mining != null && !mining.equals("") && !mining.equals("null")){ + return mining; + } else { + return "0"; + } + } + public String getUnarmed(){ + if(unarmed != null && !unarmed.equals("") && !unarmed.equals("null")){ + return unarmed; + } else { + return "0"; + } + } + public String getHerbalism(){ + if(herbalism != null && !herbalism.equals("") && !herbalism.equals("null")){ + return herbalism; + } else { + return "0"; + } + } + public String getExcavation(){ + if(excavation != null && !excavation.equals("") && !excavation.equals("null")){ + return excavation; + } else { + return "0"; + } + } + public String getArchery(){ + if(archery != null && !archery.equals("") && !archery.equals("null")){ + return archery; + } else { + return "0"; + } + } + public String getSwords(){ + if(swords != null && !swords.equals("") && !swords.equals("null")){ + return swords; + } else { + return "0"; + } + } + public String getAxes(){ + if(axes != null && !axes.equals("") && !axes.equals("null")){ + return axes; + } else { + return "0"; + } + } + public String getAcrobatics(){ + if(acrobatics != null && !acrobatics.equals("") && !acrobatics.equals("null")){ + return acrobatics; + } else { + return "0"; + } + } + public int getTamingInt(){ + if(isInt(taming)){ + int x = Integer.parseInt(taming); + return x; + } else{ + return 0; + } + } + public int getMiningInt(){ + if(isInt(mining)){ + int x = Integer.parseInt(mining); + return x; + } else{ + return 0; + } + } + public int getUnarmedInt(){ + if(isInt(unarmed)){ + int x = Integer.parseInt(unarmed); + return x; + } else{ + return 0; + } + } + public int getArcheryInt(){ + if(isInt(archery)){ + int x = Integer.parseInt(archery); + return x; + } else{ + return 0; + } + } + public int getSwordsInt(){ + if(isInt(swords)){ + int x = Integer.parseInt(swords); + return x; + } else{ + return 0; + } + } + public int getAxesInt(){ + if(isInt(axes)){ + int x = Integer.parseInt(axes); + return x; + } else{ + return 0; + } + } + public int getAcrobaticsInt(){ + if(isInt(acrobatics)){ + int x = Integer.parseInt(acrobatics); + return x; + } else{ + return 0; + } + } + public int getHerbalismInt(){ + if(isInt(herbalism)){ + int x = Integer.parseInt(herbalism); + return x; + } else{ + return 0; + } + } + public int getExcavationInt(){ + if(isInt(excavation)){ + int x = Integer.parseInt(excavation); + return x; + } else{ + return 0; + } + } + public int getRepairInt(){ + if(isInt(repair)){ + int x = Integer.parseInt(repair); + return x; + } else{ + return 0; + } + } + public int getWoodCuttingInt(){ + if(isInt(woodcutting)){ + int x = Integer.parseInt(woodcutting); + return x; + } else{ + return 0; + } + } + public String getWoodCutting(){ + if(woodcutting != null && !woodcutting.equals("") && !woodcutting.equals("null")){ + return woodcutting; + } else { + return "0"; + } + } + /* + * EXPERIENCE STUFF + */ + public void clearTamingXP(){ + tamingXP = "0"; + } + public void clearRepairXP(){ + repairXP = "0"; + } + public void clearUnarmedXP(){ + unarmedXP = "0"; + } + public void clearHerbalismXP(){ + herbalismXP = "0"; + } + public void clearExcavationXP(){ + excavationXP = "0"; + } + public void clearArcheryXP(){ + archeryXP = "0"; + } + public void clearSwordsXP(){ + swordsXP = "0"; + } + public void clearAxesXP(){ + axesXP = "0"; + } + public void clearAcrobaticsXP(){ + acrobaticsXP = "0"; + } + public void addTamingXP(int newXP) + { + int x = 0; + if(isInt(tamingXP)){ + x = Integer.parseInt(tamingXP); + } + x += newXP; + acrobaticsXP = String.valueOf(x); + save(); + } + public void addAcrobaticsXP(int newXP) + { + int x = 0; + if(isInt(acrobaticsXP)){ + x = Integer.parseInt(acrobaticsXP); + } + x += newXP; + acrobaticsXP = String.valueOf(x); + save(); + } + public void addAxesXP(int newXP) + { + int x = 0; + if(isInt(axesXP)){ + x = Integer.parseInt(axesXP); + } + x += newXP; + axesXP = String.valueOf(x); + save(); + } + public void addSwordsXP(int newXP) + { + int x = 0; + if(isInt(swordsXP)){ + x = Integer.parseInt(swordsXP); + } + x += newXP; + swordsXP = String.valueOf(x); + save(); + } + public void addArcheryXP(int newXP) + { + int x = 0; + if(isInt(archeryXP)){ + x = Integer.parseInt(archeryXP); + } + x += newXP; + archeryXP = String.valueOf(x); + save(); + } + public void addExcavationXP(int newXP) + { + int x = 0; + if(isInt(excavationXP)){ + x = Integer.parseInt(excavationXP); + } + x += newXP; + excavationXP = String.valueOf(x); + save(); + } + public void addHerbalismXP(int newXP) + { + int x = 0; + if(isInt(herbalismXP)){ + x = Integer.parseInt(herbalismXP); + } + x += newXP; + herbalismXP = String.valueOf(x); + save(); + } + public void addRepairXP(int newXP) + { + int x = 0; + if(isInt(repairXP)){ + x = Integer.parseInt(repairXP); + } + x += newXP; + repairXP = String.valueOf(x); + save(); + } + public void addUnarmedXP(int newXP) + { + int x = 0; + if(isInt(unarmedXP)){ + x = Integer.parseInt(unarmedXP); + } + x += newXP; + unarmedXP = String.valueOf(x); + save(); + } + public void addWoodcuttingXP(int newXP) + { + int x = 0; + if(isInt(woodCuttingXP)){ + x = Integer.parseInt(woodCuttingXP); + } + x += newXP; + woodCuttingXP = String.valueOf(x); + save(); + } + public void removeTamingXP(int newXP){ + int x = 0; + if(isInt(tamingXP)){ + x = Integer.parseInt(tamingXP); + } + x -= newXP; + tamingXP = String.valueOf(x); + save(); + } + public void removeWoodCuttingXP(int newXP){ + int x = 0; + if(isInt(woodCuttingXP)){ + x = Integer.parseInt(woodCuttingXP); + } + x -= newXP; + woodCuttingXP = String.valueOf(x); + save(); + } + public void addMiningXP(int newXP) + { + int x = 0; + if(isInt(miningXP)){ + x = Integer.parseInt(miningXP); + } else { + x = 0; + } + x += newXP; + miningXP = String.valueOf(x); + save(); + } + public void removeMiningXP(int newXP){ + int x = 0; + if(isInt(miningXP)){ + x = Integer.parseInt(miningXP); + } + x -= newXP; + miningXP = String.valueOf(x); + save(); + } + public void removeRepairXP(int newXP){ + int x = 0; + if(isInt(repairXP)){ + x = Integer.parseInt(repairXP); + } + x -= newXP; + repairXP = String.valueOf(x); + save(); + } + public void removeUnarmedXP(int newXP){ + int x = 0; + if(isInt(unarmedXP)){ + x = Integer.parseInt(unarmedXP); + } + x -= newXP; + unarmedXP = String.valueOf(x); + save(); + } + public void removeHerbalismXP(int newXP){ + int x = 0; + if(isInt(herbalismXP)){ + x = Integer.parseInt(herbalismXP); + } + x -= newXP; + herbalismXP = String.valueOf(x); + save(); + } + public void removeExcavationXP(int newXP){ + int x = 0; + if(isInt(excavationXP)){ + x = Integer.parseInt(excavationXP); + } + x -= newXP; + excavationXP = String.valueOf(x); + save(); + } + public void removeArcheryXP(int newXP){ + int x = 0; + if(isInt(archeryXP)){ + x = Integer.parseInt(archeryXP); + } + x -= newXP; + archeryXP = String.valueOf(x); + save(); + } + public void removeSwordsXP(int newXP){ + int x = 0; + if(isInt(swordsXP)){ + x = Integer.parseInt(swordsXP); + } + x -= newXP; + swordsXP = String.valueOf(x); + save(); + } + public void removeAxesXP(int newXP){ + int x = 0; + if(isInt(axesXP)){ + x = Integer.parseInt(axesXP); + } + x -= newXP; + axesXP = String.valueOf(x); + save(); + } + public void removeAcrobaticsXP(int newXP){ + int x = 0; + if(isInt(acrobaticsXP)){ + x = Integer.parseInt(acrobaticsXP); + } + x -= newXP; + acrobaticsXP = String.valueOf(x); + save(); + } + + public boolean isInt(String string){ + try { + //int x = Integer.parseInt(string); + } + catch(NumberFormatException nFE) { + return false; + } + return true; + } + public boolean isDouble(String string){ + try { + //Double x = Double.valueOf(string); + } + catch(NumberFormatException nFE) { + return false; + } + return true; + } + public void acceptInvite(){ + party = invite; + invite = ""; + save(); + } + public void modifyInvite(String invitename){ + invite = invitename; + } + //Returns player XP + public String getTamingXP(){ + if(tamingXP != null && !tamingXP.equals("") && !tamingXP.equals("null")){ + return tamingXP; + } else { + return "0"; + } + } + public String getMiningXP(){ + if(miningXP != null && !miningXP.equals("") && !miningXP.equals("null")){ + return miningXP; + } else { + return "0"; + } + } + public String getInvite() { return invite; } + public String getWoodCuttingXP(){ + if(woodCuttingXP != null && !woodCuttingXP.equals("") && !woodCuttingXP.equals("null")){ + return woodCuttingXP; + } else { + return "0"; + } + } + public String getRepairXP(){ + if(repairXP != null && !repairXP.equals("") && !repairXP.equals("null")){ + return repairXP; + } else { + return "0"; + } + } + public String getHerbalismXP(){ + if(herbalismXP != null && !herbalismXP.equals("") && !herbalismXP.equals("null")){ + return herbalismXP; + } else { + return "0"; + } + } + public String getExcavationXP(){ + if(excavationXP != null && !excavationXP.equals("") && !excavationXP.equals("null")){ + return excavationXP; + } else { + return "0"; + } + } + public String getArcheryXP(){ + if(archeryXP != null && !archeryXP.equals("") && !archeryXP.equals("null")){ + return archeryXP; + } else { + return "0"; + } + } + public String getSwordsXP(){ + if(swordsXP != null && !swordsXP.equals("") && !swordsXP.equals("null")){ + return swordsXP; + } else { + return "0"; + } + } + public String getAxesXP(){ + if(axesXP != null && !axesXP.equals("") && !axesXP.equals("null")){ + return axesXP; + } else { + return "0"; + } + } + public String getAcrobaticsXP(){ + if(acrobaticsXP != null && !acrobaticsXP.equals("") && !acrobaticsXP.equals("null")){ + return acrobaticsXP; + } else { + return "0"; + } + } + public String getUnarmedXP(){ + if(unarmedXP != null && !unarmedXP.equals("") && !unarmedXP.equals("null")){ + return unarmedXP; + } else { + return "0"; + } + } + public int getTamingXPInt() { + if(isInt(tamingXP)){ + return Integer.parseInt(tamingXP); + } else { + tamingXP = "0"; + save(); + return 0; + } + } + public int getWoodCuttingXPInt() { + if(isInt(woodCuttingXP)){ + return Integer.parseInt(woodCuttingXP); + } else { + woodCuttingXP = "0"; + save(); + return 0; + } + } + public int getRepairXPInt() { + if(isInt(repairXP)){ + return Integer.parseInt(repairXP); + } else { + repairXP = "0"; + save(); + return 0; + } + } + public int getUnarmedXPInt() { + if(isInt(unarmedXP)){ + return Integer.parseInt(unarmedXP); + } else { + unarmedXP = "0"; + save(); + return 0; + } + } + public int getHerbalismXPInt() { + if(isInt(herbalismXP)){ + return Integer.parseInt(herbalismXP); + } else { + herbalismXP = "0"; + save(); + return 0; + } + } + public int getExcavationXPInt() { + if(isInt(excavationXP)){ + return Integer.parseInt(excavationXP); + } else { + excavationXP = "0"; + save(); + return 0; + } + } + public int getArcheryXPInt() { + if(isInt(archeryXP)){ + return Integer.parseInt(archeryXP); + } else { + archeryXP = "0"; + save(); + return 0; + } + } + public int getSwordsXPInt() { + if(isInt(swordsXP)){ + return Integer.parseInt(swordsXP); + } else { + swordsXP = "0"; + save(); + return 0; + } + } + public int getAxesXPInt() { + if(isInt(axesXP)){ + return Integer.parseInt(axesXP); + } else { + axesXP = "0"; + save(); + return 0; + } + } + public int getAcrobaticsXPInt() { + if(isInt(acrobaticsXP)){ + return Integer.parseInt(acrobaticsXP); + } else { + acrobaticsXP = "0"; + save(); + return 0; + } + } + public void addXpToSkill(int newvalue, String skillname){ + if(!isInt(tamingXP)) + tamingXP = String.valueOf(0); + if(!isInt(miningXP)) + miningXP = String.valueOf(0); + if(!isInt(woodCuttingXP)) + woodCuttingXP = String.valueOf(0); + if(!isInt(repairXP)) + repairXP = String.valueOf(0); + if(!isInt(herbalismXP)) + herbalismXP = String.valueOf(0); + if(!isInt(acrobaticsXP)) + acrobaticsXP = String.valueOf(0); + if(!isInt(swordsXP)) + swordsXP = String.valueOf(0); + if(!isInt(archeryXP)) + archeryXP = String.valueOf(0); + if(!isInt(unarmedXP)) + unarmedXP = String.valueOf(0); + if(!isInt(excavationXP)) + excavationXP = String.valueOf(0); + if(!isInt(axesXP)) + axesXP = String.valueOf(0); + + if(skillname.toLowerCase().equals("taming")){ + tamingXP = String.valueOf(Integer.valueOf(tamingXP)+newvalue); + } + if(skillname.toLowerCase().equals("mining")){ + miningXP = String.valueOf(Integer.valueOf(miningXP)+newvalue); + } + if(skillname.toLowerCase().equals("woodcutting")){ + woodCuttingXP = String.valueOf(Integer.valueOf(woodCuttingXP)+newvalue); + } + if(skillname.toLowerCase().equals("repair")){ + repairXP = String.valueOf(Integer.valueOf(repairXP)+newvalue); + } + if(skillname.toLowerCase().equals("herbalism")){ + herbalismXP = String.valueOf(Integer.valueOf(herbalismXP)+newvalue); + } + if(skillname.toLowerCase().equals("acrobatics")){ + acrobaticsXP = String.valueOf(Integer.valueOf(acrobaticsXP)+newvalue); + } + if(skillname.toLowerCase().equals("swords")){ + swordsXP = String.valueOf(Integer.valueOf(swordsXP)+newvalue); + } + if(skillname.toLowerCase().equals("archery")){ + archeryXP = String.valueOf(Integer.valueOf(archeryXP)+newvalue); + } + if(skillname.toLowerCase().equals("unarmed")){ + unarmedXP = String.valueOf(Integer.valueOf(unarmedXP)+newvalue); + } + if(skillname.toLowerCase().equals("excavation")){ + excavationXP = String.valueOf(Integer.valueOf(excavationXP)+newvalue); + } + if(skillname.toLowerCase().equals("axes")){ + axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue); + } + if(skillname.toLowerCase().equals("all")){ + tamingXP = String.valueOf(Integer.valueOf(tamingXP)+newvalue); + miningXP = String.valueOf(Integer.valueOf(miningXP)+newvalue); + woodCuttingXP = String.valueOf(Integer.valueOf(woodCuttingXP)+newvalue); + repairXP = String.valueOf(Integer.valueOf(repairXP)+newvalue); + herbalismXP = String.valueOf(Integer.valueOf(herbalismXP)+newvalue); + acrobaticsXP = String.valueOf(Integer.valueOf(acrobaticsXP)+newvalue); + swordsXP = String.valueOf(Integer.valueOf(swordsXP)+newvalue); + archeryXP = String.valueOf(Integer.valueOf(archeryXP)+newvalue); + unarmedXP = String.valueOf(Integer.valueOf(unarmedXP)+newvalue); + excavationXP = String.valueOf(Integer.valueOf(excavationXP)+newvalue); + axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue); + } + save(); + mcSkills.XpCheck(thisplayer); + } + public void modifyskill(int newvalue, String skillname){ + if(skillname.toLowerCase().equals("taming")){ + taming = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("mining")){ + mining = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("woodcutting")){ + woodcutting = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("repair")){ + repair = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("herbalism")){ + herbalism = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("acrobatics")){ + acrobatics = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("swords")){ + swords = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("archery")){ + archery = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("unarmed")){ + unarmed = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("excavation")){ + excavation = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("axes")){ + axes = String.valueOf(newvalue); + } + if(skillname.toLowerCase().equals("all")){ + taming = String.valueOf(newvalue); + mining = String.valueOf(newvalue); + woodcutting = String.valueOf(newvalue); + repair = String.valueOf(newvalue); + herbalism = String.valueOf(newvalue); + acrobatics = String.valueOf(newvalue); + swords = String.valueOf(newvalue); + archery = String.valueOf(newvalue); + unarmed = String.valueOf(newvalue); + excavation = String.valueOf(newvalue); + axes = String.valueOf(newvalue); + } + save(); + } + public Integer getXpToLevel(String skillname){ + if(skillname.equals("taming")){ + return ((getTamingInt() + 50) * mcLoadProperties.tamingxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("mining")){ + return ((getMiningInt() + 50) * mcLoadProperties.miningxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("woodcutting")){ + return ((getWoodCuttingInt() + 50) * mcLoadProperties.woodcuttingxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("repair")){ + return ((getRepairInt() + 50) * mcLoadProperties.repairxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("herbalism")){ + return ((getHerbalismInt() + 50) * mcLoadProperties.herbalismxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("acrobatics")){ + return ((getAcrobaticsInt() + 50) * mcLoadProperties.acrobaticsxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("swords")){ + return ((getSwordsInt() + 50) * mcLoadProperties.swordsxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("archery")){ + return ((getArcheryInt() + 50) * mcLoadProperties.archeryxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("unarmed")){ + return ((getUnarmedInt() + 50) * mcLoadProperties.unarmedxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("excavation")){ + return ((getExcavationInt() + 50) * mcLoadProperties.excavationxpmodifier) * mcLoadProperties.globalxpmodifier; + } + if(skillname.equals("axes")){ + return ((getAxesInt() + 50) * mcLoadProperties.axesxpmodifier) * mcLoadProperties.globalxpmodifier; + } else { + return 0; + } + } + public int getMiningXPInt() { + if(isInt(miningXP)){ + return Integer.parseInt(miningXP); + } else { + miningXP = "0"; + save(); + return 0; + } + } + + //Store the player's party + public void setParty(String newParty) + { + party = newParty; + save(); + } + //Retrieve the player's party + public String getParty() {return party;} + //Remove party + public void removeParty() { + party = null; + save(); + } + //Retrieve whether or not the player is in a party + public boolean inParty() { + if(party != null && !party.equals("") && !party.equals("null")){ + return true; + } else { + return false; + } + } + //Retrieve whether or not the player has an invite + public boolean hasPartyInvite() { + if(invite != null && !invite.equals("") && !invite.equals("null")){ + return true; + } else { + return false; + } + } + public String getMySpawnWorld(Plugin plugin){ + if(myspawnworld != null && !myspawnworld.equals("") && !myspawnworld.equals("null")){ + return myspawnworld; + } else { + return plugin.getServer().getWorlds().get(0).toString(); + } + } + //Save a users spawn location + public void setMySpawn(double x, double y, double z, String myspawnworldlocation){ + myspawn = x+","+y+","+z; + myspawnworld = myspawnworldlocation; + save(); + } + public String getX(){ + String[] split = myspawn.split(","); + String x = split[0]; + return x; + } + public String getY(){ + String[] split = myspawn.split(","); + String y = split[1]; + return y; + } + public String getZ(){ + String[] split = myspawn.split(","); + String z = split[2]; + return z; + } + public void setDead(boolean x){ + dead = x; + save(); + } + public boolean isDead(){ + return dead; + } + public Location getMySpawn(Player player){ + Location loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ())); + loc.setYaw(0); + loc.setPitch(0); + return loc; + } +} diff --git a/mcMMO/com/gmail/nossr50/datatypes/Tree.java b/mcMMO/com/gmail/nossr50/datatypes/Tree.java new file mode 100644 index 000000000..e623baaba --- /dev/null +++ b/mcMMO/com/gmail/nossr50/datatypes/Tree.java @@ -0,0 +1,29 @@ +package com.gmail.nossr50.datatypes; + +import java.util.ArrayList; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.PlayerStat; + +public class Tree { + + TreeNode root = null; + + public Tree(){} + + public void add(String p, int in) + { + if(root == null) + root = new TreeNode(p, in); + else + root.add(p,in); + } + + public PlayerStat[] inOrder() + { + ArrayList order = root.inOrder(new ArrayList()); + return order.toArray(new PlayerStat[order.size()]); + } + +} diff --git a/mcMMO/com/gmail/nossr50/datatypes/TreeNode.java b/mcMMO/com/gmail/nossr50/datatypes/TreeNode.java new file mode 100644 index 000000000..83ee122ff --- /dev/null +++ b/mcMMO/com/gmail/nossr50/datatypes/TreeNode.java @@ -0,0 +1,45 @@ +package com.gmail.nossr50.datatypes; + +import java.util.ArrayList; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.PlayerStat; + +public class TreeNode { + TreeNode left = null + , right = null; + PlayerStat ps = new PlayerStat(); + + public TreeNode(String p, int in) {ps.statVal = in; ps.name = p;} + + 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 < ps.statVal) + { + if (right == null) + right = new TreeNode(p,in); + else + right.add(p, in); + } + } + + public ArrayList inOrder(ArrayList a) + { + if(left != null) + a = left.inOrder(a); + + a.add(ps); + + if(right != null) + a = right.inOrder(a); + + return a; + } +} diff --git a/mcMMO/com/gmail/nossr50/mcAcrobatics.java b/mcMMO/com/gmail/nossr50/mcAcrobatics.java index 42f9574f2..17f1b26c9 100644 --- a/mcMMO/com/gmail/nossr50/mcAcrobatics.java +++ b/mcMMO/com/gmail/nossr50/mcAcrobatics.java @@ -4,8 +4,7 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; - -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcAcrobatics { @@ -18,7 +17,7 @@ public class mcAcrobatics { } public void acrobaticsCheck(Player player, EntityDamageEvent event, Location loc, int xx, int y, int z){ if(player != null && mcPermissions.getInstance().acrobatics(player)){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); int acrovar = PP.getAcrobaticsInt(); if(player.isSneaking()) acrovar = acrovar * 2; diff --git a/mcMMO/com/gmail/nossr50/mcBlockListener.java b/mcMMO/com/gmail/nossr50/mcBlockListener.java index afdb4eafb..eb50df59d 100644 --- a/mcMMO/com/gmail/nossr50/mcBlockListener.java +++ b/mcMMO/com/gmail/nossr50/mcBlockListener.java @@ -1,6 +1,7 @@ package com.gmail.nossr50; import org.bukkit.ChatColor; +import com.gmail.nossr50.datatypes.PlayerProfile; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; @@ -12,7 +13,7 @@ import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.FakeBlockBreakEvent; public class mcBlockListener extends BlockListener { @@ -43,7 +44,7 @@ public class mcBlockListener extends BlockListener { public void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); Block block = event.getBlock(); ItemStack inhand = player.getItemInHand(); if(event.isCancelled()) @@ -159,7 +160,7 @@ public class mcBlockListener extends BlockListener { if(event.isCancelled()) return; Player player = event.getPlayer(); - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); ItemStack inhand = player.getItemInHand(); Block block = event.getBlock(); /* diff --git a/mcMMO/com/gmail/nossr50/mcCombat.java b/mcMMO/com/gmail/nossr50/mcCombat.java index a0ce9dc5d..08bd24781 100644 --- a/mcMMO/com/gmail/nossr50/mcCombat.java +++ b/mcMMO/com/gmail/nossr50/mcCombat.java @@ -17,9 +17,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.PlayerList.PlayerProfile; - +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcCombat { private static mcMMO plugin; @@ -32,16 +30,16 @@ public class mcCombat { event.setCancelled(true); return; } - PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); + PlayerProfile PPa = mcUsers.getProfile(attacker); Player defender = (Player)x; - PlayerProfile PPd = mcUsers.getProfile(defender.getName()); + PlayerProfile PPd = mcUsers.getProfile(defender); /* * COMPATABILITY CHECKS (Stuff that wouldn't happen normally in MC basically...) */ - if(mcUsers.getProfile(defender.getName()) == null) + if(mcUsers.getProfile(defender) == null) mcUsers.addUser(defender); - if(attacker != null && defender != null && mcUsers.getProfile(attacker.getName()).inParty() && mcUsers.getProfile(defender.getName()).inParty()){ + if(attacker != null && defender != null && mcUsers.getProfile(attacker).inParty() && mcUsers.getProfile(defender).inParty()){ if(mcParty.getInstance().inSameParty(defender, attacker)){ event.setCancelled(true); return; @@ -101,7 +99,7 @@ public class mcCombat { } } public static void playerVersusSquidChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ - PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); + PlayerProfile PPa = mcUsers.getProfile(attacker); if(x instanceof Squid){ if(!mcConfig.getInstance().isBleedTracked(x)){ bleedCheck(attacker, x); @@ -146,7 +144,7 @@ public class mcCombat { } } public static void playerVersusAnimalsChecks(Entity x, Player attacker, EntityDamageByEntityEvent event, int type){ - PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); + PlayerProfile PPa = mcUsers.getProfile(attacker); if(x instanceof Animals){ if(!mcConfig.getInstance().isBleedTracked(x)){ bleedCheck(attacker, x); @@ -171,7 +169,7 @@ public class mcCombat { } } public static void playerVersusMonsterChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ - PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); + PlayerProfile PPa = mcUsers.getProfile(attacker); if(x instanceof Monster){ /* * AXE PROC CHECKS @@ -257,7 +255,7 @@ public class mcCombat { Entity x = event.getEntity(); if(event.getProjectile().toString().equals("CraftArrow") && x instanceof Player){ Player defender = (Player)x; - PlayerProfile PPd = mcUsers.getProfile(defender.getName()); + PlayerProfile PPd = mcUsers.getProfile(defender); if(PPd == null) mcUsers.addUser(defender); if(mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getTypeId() == 0){ @@ -279,7 +277,7 @@ public class mcCombat { */ if(y instanceof Player){ Player attacker = (Player)y; - PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); + PlayerProfile PPa = mcUsers.getProfile(attacker); if(event.getProjectile().toString().equals("CraftArrow") && mcPermissions.getInstance().archery(attacker)){ if(!mcConfig.getInstance().isTracked(x) && event.getDamage() > 0){ mcConfig.getInstance().addArrowTrack(x, 0); @@ -396,7 +394,7 @@ public class mcCombat { return; } Player defender = (Player)x; - PlayerProfile PPd = mcUsers.getProfile(defender.getName()); + PlayerProfile PPd = mcUsers.getProfile(defender); /* * Stuff for the daze proc */ @@ -449,7 +447,7 @@ public class mcCombat { } } public static boolean simulateUnarmedProc(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(PP.getUnarmedInt() >= 1000){ if(Math.random() * 4000 <= 1000){ return true; @@ -462,7 +460,7 @@ public class mcCombat { return false; } public static void bleedCheck(Player attacker, Entity x){ - PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); + PlayerProfile PPa = mcUsers.getProfile(attacker); if(mcPermissions.getInstance().swords(attacker) && mcm.isSwords(attacker.getItemInHand())){ if(PPa.getSwordsInt() >= 750){ if(Math.random() * 1000 >= 750){ @@ -470,7 +468,7 @@ public class mcCombat { mcConfig.getInstance().addToBleedQue(x); if(x instanceof Player){ Player target = (Player)x; - mcUsers.getProfile(target.getName()).addBleedTicks(3); + mcUsers.getProfile(target).addBleedTicks(3); } attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**"); } @@ -479,7 +477,7 @@ public class mcCombat { mcConfig.getInstance().addToBleedQue(x); if(x instanceof Player){ Player target = (Player)x; - mcUsers.getProfile(target.getName()).addBleedTicks(2); + mcUsers.getProfile(target).addBleedTicks(2); } attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**"); } @@ -542,7 +540,7 @@ public class mcCombat { if(!target.getName().equals(attacker.getName()) && targets >= 1){ target.damage(event.getDamage() / 4); target.sendMessage(ChatColor.DARK_RED+"Struck by Serrated Strikes!"); - mcUsers.getProfile(target.getName()).addBleedTicks(5); + mcUsers.getProfile(target).addBleedTicks(5); targets--; } } @@ -568,7 +566,7 @@ public class mcCombat { } } public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Entity x){ - PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); + PlayerProfile PPa = mcUsers.getProfile(attacker); if(mcm.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ if(PPa.getAxesInt() >= 750){ if(Math.random() * 1000 <= 750){ @@ -598,7 +596,7 @@ public class mcCombat { } } public static void parryCheck(Player defender, EntityDamageByEntityEvent event, Entity y){ - PlayerProfile PPd = mcUsers.getProfile(defender.getName()); + PlayerProfile PPd = mcUsers.getProfile(defender); if(defender != null && mcm.isSwords(defender.getItemInHand()) && mcPermissions.getInstance().swords(defender)){ if(PPd.getSwordsInt() >= 900){ diff --git a/mcMMO/com/gmail/nossr50/mcEntityListener.java b/mcMMO/com/gmail/nossr50/mcEntityListener.java index 674d2fd2d..f01c0baa6 100644 --- a/mcMMO/com/gmail/nossr50/mcEntityListener.java +++ b/mcMMO/com/gmail/nossr50/mcEntityListener.java @@ -17,7 +17,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityListener; import org.bukkit.inventory.ItemStack; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcEntityListener extends EntityListener { @@ -82,7 +82,7 @@ public class mcEntityListener extends EntityListener { */ if(e instanceof Player){ Player defender = (Player)e; - PlayerProfile PPd = mcUsers.getProfile(defender.getName()); + PlayerProfile PPd = mcUsers.getProfile(defender); if(defender != null && mcConfig.getInstance().isGodModeToggled(defender.getName())) event.setCancelled(true); if(PPd == null) @@ -119,7 +119,7 @@ public class mcEntityListener extends EntityListener { */ mcSkills.monitorSkills(attacker); - PlayerProfile PPa = mcUsers.getProfile(attacker.getName()); + PlayerProfile PPa = mcUsers.getProfile(attacker); /* * ACTIVATE ABILITIES */ @@ -167,7 +167,7 @@ public class mcEntityListener extends EntityListener { */ if(e instanceof Player){ Player defender = (Player)e; - PlayerProfile PPd = mcUsers.getProfile(defender.getName()); + PlayerProfile PPd = mcUsers.getProfile(defender); if(f instanceof Player){ Player attacker = (Player)f; if(mcParty.getInstance().inSameParty(defender, attacker)){ @@ -240,7 +240,7 @@ public class mcEntityListener extends EntityListener { 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"); + mcUsers.getProfile(wolfMaster).addXpToSkill(event.getDamage(), "Taming"); } } } @@ -252,7 +252,7 @@ public class mcEntityListener extends EntityListener { */ if(x instanceof Player && !event.isCancelled()){ Player herpderp = (Player)x; - mcUsers.getProfile(herpderp.getName()).setRecentlyHurt(System.currentTimeMillis()); + mcUsers.getProfile(herpderp).setRecentlyHurt(System.currentTimeMillis()); } } } @@ -272,7 +272,7 @@ public class mcEntityListener extends EntityListener { } if(x instanceof Player){ Player player = (Player)x; - mcUsers.getProfile(player.getName()).setBleedTicks(0); + mcUsers.getProfile(player).setBleedTicks(0); } } public boolean isPlayer(Entity entity){ diff --git a/mcMMO/com/gmail/nossr50/mcExcavation.java b/mcMMO/com/gmail/nossr50/mcExcavation.java index 91d95a61c..23307dc12 100644 --- a/mcMMO/com/gmail/nossr50/mcExcavation.java +++ b/mcMMO/com/gmail/nossr50/mcExcavation.java @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcExcavation { @@ -17,7 +17,7 @@ public class mcExcavation { plugin = instance; } public static void gigaDrillBreakerActivationCheck(Player player, Block block, Plugin pluginx){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(mcm.isShovel(player.getItemInHand())){ if(block != null){ if(!mcm.abilityBlockCheck(block)) @@ -55,7 +55,7 @@ public class mcExcavation { } } public static void excavationProcCheck(Block block, Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); int type = block.getTypeId(); Location loc = block.getLocation(); ItemStack is = null; diff --git a/mcMMO/com/gmail/nossr50/mcHerbalism.java b/mcMMO/com/gmail/nossr50/mcHerbalism.java index 8c460dcb9..a166b3734 100644 --- a/mcMMO/com/gmail/nossr50/mcHerbalism.java +++ b/mcMMO/com/gmail/nossr50/mcHerbalism.java @@ -10,7 +10,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcHerbalism { @@ -22,7 +22,7 @@ public class mcHerbalism { 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()); + PlayerProfile PP = mcUsers.getProfile(player); Material mat = Material.getMaterial(296); Location loc = block.getLocation(); ItemStack is = new ItemStack(mat, 1, (byte)0, (byte)0); @@ -80,7 +80,7 @@ public class mcHerbalism { } } public static void greenTerraCheck(Player player, Block block, Plugin pluginx){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(mcm.isHoe(player.getItemInHand())){ if(block != null){ if(!mcm.abilityBlockCheck(block)) @@ -110,7 +110,7 @@ public class mcHerbalism { } } public static void herbalismProcCheck(Block block, Player player, BlockBreakEvent event){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); int type = block.getTypeId(); Location loc = block.getLocation(); ItemStack is = null; @@ -215,7 +215,7 @@ public class mcHerbalism { mcSkills.XpCheck(player); } public static void breadCheck(Player player, ItemStack is){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(is.getTypeId() == 297){ if(PP.getHerbalismInt() >= 50 && PP.getHerbalismInt() < 150){ player.setHealth(player.getHealth() + 1); @@ -237,7 +237,7 @@ public class mcHerbalism { } } public static void stewCheck(Player player, ItemStack is){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(is.getTypeId() == 282){ if(PP.getHerbalismInt() >= 50 && PP.getHerbalismInt() < 150){ player.setHealth(player.getHealth() + 1); diff --git a/mcMMO/com/gmail/nossr50/mcItem.java b/mcMMO/com/gmail/nossr50/mcItem.java index 859310749..dbf23be53 100644 --- a/mcMMO/com/gmail/nossr50/mcItem.java +++ b/mcMMO/com/gmail/nossr50/mcItem.java @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcItem { @@ -20,7 +20,7 @@ public class mcItem { } } public static void chimaerawing(Player player, Plugin plugin){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); ItemStack is = player.getItemInHand(); Block block = player.getLocation().getBlock(); if(mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == 288){ diff --git a/mcMMO/com/gmail/nossr50/mcLeaderboard.java b/mcMMO/com/gmail/nossr50/mcLeaderboard.java index 5e4fc3869..f8689e422 100644 --- a/mcMMO/com/gmail/nossr50/mcLeaderboard.java +++ b/mcMMO/com/gmail/nossr50/mcLeaderboard.java @@ -8,6 +8,8 @@ import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; +import com.gmail.nossr50.datatypes.Tree; + public class mcLeaderboard { static String location = "plugins/mcMMO/mcmmo.users"; protected static final Logger log = Logger.getLogger("Minecraft"); @@ -38,6 +40,7 @@ public class mcLeaderboard { String line = ""; while((line = in.readLine()) != null) { + String[] character = line.split(":"); String p = character[0]; @@ -187,6 +190,8 @@ public class mcLeaderboard { return null; //Shouldn't get here } public static void updateLeaderboard(PlayerStat ps, String statName){ + if(mcLoadProperties.useMySQL) + return; String theLocation = "plugins/mcMMO/" + statName + ".mcmmo"; try { //Open the file diff --git a/mcMMO/com/gmail/nossr50/mcLoadProperties.java b/mcMMO/com/gmail/nossr50/mcLoadProperties.java index 51e23b187..cb13c165d 100644 --- a/mcMMO/com/gmail/nossr50/mcLoadProperties.java +++ b/mcMMO/com/gmail/nossr50/mcLoadProperties.java @@ -1,9 +1,9 @@ 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 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 Boolean useMySQL, 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 MySQLuserName, MySQLserverName, MySQLdbName, MySQLdbPass, mctop, addxp, mcability, mcmmo, mcc, mcrefresh, mcitem, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn; + public static int MySQLport, 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(){ String propertiesFile = mcMMO.maindirectory + "mcmmo.properties"; @@ -20,9 +20,22 @@ public class mcLoadProperties { berserkCooldown = properties.getInteger("berserkCooldown", 240); serratedStrikeCooldown = properties.getInteger("serratedStrikeCooldown", 240); skullSplitterCooldown = properties.getInteger("skullSplitterCooldown", 240); + + /* + * MySQL Stuff + */ + + MySQLserverName = properties.getString("MySQLServer", "ipofserver"); + MySQLdbPass = properties.getString("MySQLdbPass", "defaultdbpass"); + MySQLdbName = properties.getString("MySQLdbName", "defaultdbname"); + MySQLuserName = properties.getString("MySQLuserName", "defaultusername"); + MySQLport = properties.getInteger("MySQLport", 3306); + useMySQL = properties.getBoolean("mysql", false); + /* * OTHER */ + archeryFireRateLimit = properties.getBoolean("archeryFireRateLimit", true); myspawnclearsinventory = properties.getBoolean("mySpawnClearsInventory", true); xpGainMultiplier = properties.getInteger("xpGainMultiplier", 1); diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index f2b836a10..41ba90047 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -1,6 +1,6 @@ package com.gmail.nossr50; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; import com.nijikokun.bukkit.Permissions.Permissions; import com.nijiko.Messaging; import com.nijiko.permissions.PermissionHandler; @@ -11,7 +11,17 @@ import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; + +import java.sql.PreparedStatement; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; +import java.sql.Connection; +import java.sql.Statement; +import java.sql.ResultSet; + + import java.util.ArrayList; +import java.util.HashMap; import java.util.Timer; import java.util.logging.Level; import java.util.logging.Logger; @@ -34,6 +44,7 @@ public class mcMMO extends JavaPlugin { public static PermissionHandler PermissionsHandler = null; private Permissions permissions; private Timer mcMMO_Timer = new Timer(true); + public static Database database = null; public void onEnable() { mcMMO_Timer.schedule(new mcTimer(this), 0, (long)(1000)); @@ -81,12 +92,23 @@ public class mcMMO extends JavaPlugin { pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_ITEM_HELD, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Highest, this); + pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); PluginDescriptionFile pdfFile = this.getDescription(); mcPermissions.initialize(getServer()); - mcLeaderboard.makeLeaderboards(); //Make the leaderboards + mcLoadMySQL(); + + //mcLeaderboard.makeLeaderboards(); //Make the leaderboards System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); } + + private void mcLoadMySQL() { + if (mcLoadProperties.useMySQL) { + // create database object + database = new Database(); + } + } + public void setupPermissions() { Plugin test = this.getServer().getPluginManager().getPlugin("Permissions"); if(this.PermissionsHandler == null) { @@ -106,8 +128,8 @@ public class mcMMO extends JavaPlugin { } } public boolean inSameParty(Player playera, Player playerb){ - if(mcUsers.getProfile(playera.getName()).inParty() && mcUsers.getProfile(playerb.getName()).inParty()){ - if(mcUsers.getProfile(playera.getName()).getParty().equals(mcUsers.getProfile(playerb.getName()).getParty())){ + if(mcUsers.getProfile(playera).inParty() && mcUsers.getProfile(playerb).inParty()){ + if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){ return true; } else { return false; @@ -117,12 +139,12 @@ public class mcMMO extends JavaPlugin { } } public void addXp(Player player, String skillname, Integer newvalue){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); PP.addXpToSkill(newvalue, skillname); mcSkills.XpCheck(player); } public void modifySkill(Player player, String skillname, Integer newvalue){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); PP.modifyskill(newvalue, skillname); } public ArrayList getParties(){ @@ -151,11 +173,11 @@ public class mcMMO extends JavaPlugin { return parties; } public static String getPartyName(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); return PP.getParty(); } public static boolean inParty(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); return PP.inParty(); } public boolean isAdminChatToggled(Player player){ diff --git a/mcMMO/com/gmail/nossr50/mcMining.java b/mcMMO/com/gmail/nossr50/mcMining.java index 93a627f12..7afeef207 100644 --- a/mcMMO/com/gmail/nossr50/mcMining.java +++ b/mcMMO/com/gmail/nossr50/mcMining.java @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcMining { @@ -18,7 +18,7 @@ public class mcMining { } public static void superBreakerCheck(Player player, Block block, Plugin pluginx){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(mcm.isMiningPick(player.getItemInHand())){ if(block != null){ if(!mcm.abilityBlockCheck(block)) @@ -94,7 +94,7 @@ public class mcMining { } } public static void blockProcCheck(Block block, Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(player != null){ if(Math.random() * 1000 <= PP.getMiningInt()){ blockProcSimulate(block); @@ -103,7 +103,7 @@ public class mcMining { } } public static void miningBlockCheck(Player player, Block block){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(mcConfig.getInstance().isBlockWatched(block) || block.getData() == (byte) 5) return; int xp = 0; @@ -171,7 +171,7 @@ public class mcMining { } } public static void SuperBreakerBlockCheck(Player player, Block block){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(mcLoadProperties.toolsLoseDurabilityFromAbilities) mcm.damageTool(player, (short) mcLoadProperties.abilityDurabilityLoss); Location loc = block.getLocation(); diff --git a/mcMMO/com/gmail/nossr50/mcParty.java b/mcMMO/com/gmail/nossr50/mcParty.java index 849837f2c..c076c3973 100644 --- a/mcMMO/com/gmail/nossr50/mcParty.java +++ b/mcMMO/com/gmail/nossr50/mcParty.java @@ -17,12 +17,12 @@ public class mcParty { return instance; } public boolean inSameParty(Player playera, Player playerb){ - if(mcUsers.getProfile(playera.getName()) == null || mcUsers.getProfile(playerb.getName()) == null){ + if(mcUsers.getProfile(playera) == null || mcUsers.getProfile(playerb) == null){ mcUsers.addUser(playera); mcUsers.addUser(playerb); } - if(mcUsers.getProfile(playera.getName()).inParty() && mcUsers.getProfile(playerb.getName()).inParty()){ - if(mcUsers.getProfile(playera.getName()).getParty().equals(mcUsers.getProfile(playerb.getName()).getParty())){ + if(mcUsers.getProfile(playera).inParty() && mcUsers.getProfile(playerb).inParty()){ + if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){ return true; } else { return false; @@ -36,7 +36,7 @@ public class mcParty { int x = 0; for(Player hurrdurr : players){ if(player != null && hurrdurr != null){ - if(mcUsers.getProfile(player.getName()).getParty().equals(mcUsers.getProfile(hurrdurr.getName()).getParty())) + if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(hurrdurr).getParty())) x++; } } diff --git a/mcMMO/com/gmail/nossr50/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/mcPlayerListener.java index a0b5ce6a7..5806d4a5a 100644 --- a/mcMMO/com/gmail/nossr50/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/mcPlayerListener.java @@ -15,10 +15,11 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcPlayerListener extends PlayerListener { @@ -29,10 +30,11 @@ 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()); + PlayerProfile PP = mcUsers.getProfile(player); if(player != null){ PP.setRespawnATS(System.currentTimeMillis()); Location mySpawn = PP.getMySpawn(player); @@ -64,8 +66,11 @@ public class mcPlayerListener extends PlayerListener { } public void onPlayerLogin(PlayerLoginEvent event) { Player player = event.getPlayer(); - mcUsers.addUser(player); + mcUsers.addUser(player); } + public void onPlayerQuit(PlayerQuitEvent event) { + mcUsers.removeUser(event.getPlayer()); + } public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); if(mcPermissions.getInstance().motd(player)){ @@ -75,7 +80,7 @@ public class mcPlayerListener extends PlayerListener { } public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); Action action = event.getAction(); Block block = event.getClickedBlock(); //Archery Nerf @@ -162,7 +167,7 @@ public class mcPlayerListener extends PlayerListener { } public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); String[] split = event.getMessage().split(" "); String playerName = player.getName(); //Check if the command is an mcMMO related help command @@ -378,7 +383,7 @@ public class mcPlayerListener extends PlayerListener { if(split.length == 4){ 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]); + mcUsers.getProfile(getPlayer(split[1])).modifyskill(newvalue, split[2]); player.sendMessage(ChatColor.RED+split[2]+" has been modified."); } } @@ -408,7 +413,7 @@ public class mcPlayerListener extends PlayerListener { if(split.length == 4){ 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]); + mcUsers.getProfile(getPlayer(split[1])).addXpToSkill(newvalue, split[2]); getPlayer(split[1]).sendMessage(ChatColor.GREEN+"Experience granted!"); player.sendMessage(ChatColor.RED+split[2]+" has been modified."); } @@ -439,7 +444,7 @@ public class mcPlayerListener extends PlayerListener { } if(isPlayer(split[1])){ Player target = getPlayer(split[1]); - PlayerProfile PPt = mcUsers.getProfile(target.getName()); + PlayerProfile PPt = mcUsers.getProfile(target); if(PP.getParty().equals(PPt.getParty())){ player.teleportTo(target); player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName()); @@ -459,7 +464,7 @@ public class mcPlayerListener extends PlayerListener { //if split[1] is a player if(isPlayer(split[1])){ Player target = getPlayer(split[1]); - PlayerProfile PPt = mcUsers.getProfile(target.getName()); + PlayerProfile PPt = mcUsers.getProfile(target); double x,y,z; x = target.getLocation().getX(); y = target.getLocation().getY(); @@ -590,7 +595,7 @@ public class mcPlayerListener extends PlayerListener { } if(PP.inParty() && split.length >= 2 && isPlayer(split[1])){ Player target = getPlayer(split[1]); - PlayerProfile PPt = mcUsers.getProfile(target.getName()); + PlayerProfile PPt = mcUsers.getProfile(target); PPt.modifyInvite(PP.getParty()); player.sendMessage(ChatColor.GREEN+"Invite sent successfully"); target.sendMessage(ChatColor.RED+"ALERT: "+ChatColor.GREEN+"You have received a party invite for "+PPt.getInvite()+" from "+player.getName()); @@ -627,7 +632,7 @@ public class mcPlayerListener extends PlayerListener { int x = 0; for(Player p : plugin.getServer().getOnlinePlayers()) { - if(PP.getParty().equals(mcUsers.getProfile(p.getName()).getParty())){ + if(PP.getParty().equals(mcUsers.getProfile(p).getParty())){ if(p != null && x+1 >= mcParty.getInstance().partyCount(player, getPlayersOnline())){ tempList+= p.getName(); x++; @@ -733,16 +738,18 @@ public class mcPlayerListener extends PlayerListener { } } } + + public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); String x = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") "; String y = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} "; if(mcConfig.getInstance().isPartyToggled(player.getName())){ event.setCancelled(true); log.log(Level.INFO, "[P]("+PP.getParty()+")"+"<"+player.getName()+"> "+event.getMessage()); for(Player herp : plugin.getServer().getOnlinePlayers()){ - if(mcUsers.getProfile(herp.getName()).inParty()){ + if(mcUsers.getProfile(herp).inParty()){ if(mcParty.getInstance().inSameParty(herp, player)){ herp.sendMessage(x+event.getMessage()); } @@ -759,7 +766,7 @@ public class mcPlayerListener extends PlayerListener { } } return; - } + } /* * Remove from normal chat if toggled for(Player z : event.getRecipients()){ diff --git a/mcMMO/com/gmail/nossr50/mcRepair.java b/mcMMO/com/gmail/nossr50/mcRepair.java index e630486ac..5c74e6e61 100644 --- a/mcMMO/com/gmail/nossr50/mcRepair.java +++ b/mcMMO/com/gmail/nossr50/mcRepair.java @@ -5,7 +5,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcRepair { @@ -16,7 +16,7 @@ public class mcRepair { private static volatile mcRepair instance; public static void repairCheck(Player player, ItemStack is, Block block){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); short durabilityBefore = player.getItemInHand().getDurability(); short durabilityAfter = 0; short dif = 0; @@ -267,7 +267,7 @@ public class mcRepair { return false; } public static short repairCalculate(Player player, short durability, short ramt){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); float bonus = (PP.getRepairInt() / 500); bonus = (ramt * bonus); ramt = ramt+=bonus; @@ -396,7 +396,7 @@ public class mcRepair { return repairCalculate(player, durability, ramt); } public static void needMoreVespeneGas(ItemStack is, Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getRepairInt() < mcLoadProperties.repairdiamondlevel){ player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond"); } else if (isDiamondTools(is) && !hasDiamond(player) || isIronTools(is) && !hasIron(player) || isGoldTools(is) && !hasGold(player)){ @@ -417,7 +417,7 @@ public class mcRepair { player.sendMessage(ChatColor.DARK_RED+"You can't repair stacked items"); } public static boolean checkPlayerProcRepair(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(player != null){ if(Math.random() * 1000 <= PP.getRepairInt()){ player.sendMessage(ChatColor.GRAY + "That felt easy."); diff --git a/mcMMO/com/gmail/nossr50/mcSkills.java b/mcMMO/com/gmail/nossr50/mcSkills.java index 5b0ddd173..c740f6bc3 100644 --- a/mcMMO/com/gmail/nossr50/mcSkills.java +++ b/mcMMO/com/gmail/nossr50/mcSkills.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcSkills { @@ -51,7 +51,7 @@ public class mcSkills { return x; } public static void watchCooldowns(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(!PP.getGreenTerraInformed() && System.currentTimeMillis() - PP.getGreenTerraDeactivatedTimeStamp() >= (mcLoadProperties.greenTerraCooldown * 1000)){ PP.setGreenTerraInformed(true); player.sendMessage(ChatColor.GREEN+"Your "+ChatColor.YELLOW+"Green Terra "+ChatColor.GREEN+"ability is refreshed!"); @@ -82,7 +82,7 @@ public class mcSkills { } } public static void hoeReadinessCheck(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); 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." @@ -95,7 +95,7 @@ public class mcSkills { } } public static void abilityActivationCheck(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(!PP.getAbilityUse()) return; if(mcPermissions.getInstance().miningAbility(player) && mcm.isMiningPick(player.getItemInHand()) && !PP.getPickaxePreparationMode()){ @@ -147,7 +147,7 @@ public class mcSkills { } } public static void serratedStrikesActivationCheck(Player player, Plugin pluginx){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(mcm.isSwords(player.getItemInHand())){ if(PP.getSwordsPreparationMode()){ PP.setSwordsPreparationMode(false); @@ -173,7 +173,7 @@ public class mcSkills { } } public static void berserkActivationCheck(Player player, Plugin pluginx){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(player.getItemInHand().getTypeId() == 0){ if(PP.getFistsPreparationMode()){ PP.setFistsPreparationMode(false); @@ -198,7 +198,7 @@ public class mcSkills { } } public static void skullSplitterCheck(Player player, Plugin pluginx){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(mcm.isAxes(player.getItemInHand()) && mcPermissions.getInstance().axesAbility(player)){ /* * CHECK FOR AXE PREP MODE @@ -230,7 +230,7 @@ public class mcSkills { } } public static void monitorSkills(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(PP == null) mcUsers.addUser(player); if(PP.getHoePreparationMode() && System.currentTimeMillis() - PP.getHoePreparationATS() >= 4000){ @@ -336,7 +336,7 @@ public class mcSkills { } } public static void XpCheck(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); /* * TAMING */ diff --git a/mcMMO/com/gmail/nossr50/mcTimer.java b/mcMMO/com/gmail/nossr50/mcTimer.java index 6646f6e79..be71a4464 100644 --- a/mcMMO/com/gmail/nossr50/mcTimer.java +++ b/mcMMO/com/gmail/nossr50/mcTimer.java @@ -5,7 +5,7 @@ import java.util.TimerTask; import org.bukkit.ChatColor; import org.bukkit.entity.*; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcTimer extends TimerTask{ @@ -19,7 +19,7 @@ public class mcTimer extends TimerTask{ public void run() { Player[] playerlist = plugin.getServer().getOnlinePlayers(); for(Player player : playerlist){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(player == null) continue; if(PP == null) diff --git a/mcMMO/com/gmail/nossr50/mcUsers.java b/mcMMO/com/gmail/nossr50/mcUsers.java index dd1e624f7..2a0252b5f 100644 --- a/mcMMO/com/gmail/nossr50/mcUsers.java +++ b/mcMMO/com/gmail/nossr50/mcUsers.java @@ -5,17 +5,22 @@ import java.util.ArrayList; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.HashMap; import org.bukkit.Location; import org.bukkit.entity.*; import org.bukkit.plugin.Plugin; +import com.gmail.nossr50.datatypes.PlayerProfile; + public class mcUsers { private static volatile mcUsers instance; protected static final Logger log = Logger.getLogger("Minecraft"); String location = "plugins/mcMMO/mcmmo.users"; - public static PlayerList players = new PlayerList(); + + //public static ArrayList players; + public static HashMap players = new HashMap(); private Properties properties = new Properties(); //To load @@ -61,34 +66,20 @@ public class mcUsers { } } - //===================================================================== - //Function: addUser - //Input: Player player: The player to create a profile for - //Output: none - //Use: Loads the profile for the specified player - //===================================================================== + public static void addUser(Player player){ - players.addPlayer(player); + //players.add(new PlayerProfile(player)); + players.put(player, new PlayerProfile(player)); } - //===================================================================== - //Function: removeUser - //Input: Player player: The player to stop following - //Output: none - //Use: Creates the player profile - //===================================================================== - public static void removeUser(String playername){ - players.removePlayer(playername); + + public static void removeUser(Player player){ + //players.remove(getProfile(playername)); + players.remove(player); } - //===================================================================== - //Function: getProfile - //Input: Player player: The player to find the profile for - //Output: PlayerList.PlayerProfile: The profile - //Use: Gets the player profile - //===================================================================== - public static PlayerList.PlayerProfile getProfile(String playername){ - return players.findProfile(playername); + public static PlayerProfile getProfile(Player player){ + return players.get(player); } public static mcUsers getInstance() { @@ -100,1679 +91,5 @@ public class mcUsers { public static void getRow(){ } -} -class PlayerList -{ - protected static final Logger log = Logger.getLogger("Minecraft"); - ArrayList players; - - //===================================================================== - //Function: PlayerList - //Input: Player player: The player to create a profile object for - //Output: none - //Use: Initializes the ArrayList - //===================================================================== - public PlayerList() { players = new ArrayList(); } - - //===================================================================== - //Function: addPlayer - //Input: Player player: The player to add - //Output: None - //Use: Add a profile of the specified player - //===================================================================== - public void addPlayer(Player player) - { - players.add(new PlayerProfile(player)); - } - - //===================================================================== - //Function: removePlayer - //Input: Player player: The player to remove - //Output: None - //Use: Remove the profile of the specified player - //===================================================================== - public void removePlayer(String playername) - { - players.remove(findProfile(playername)); - } - - //===================================================================== - //Function: findProfile - //Input: Player player: The player to find's profile - //Output: PlayerProfile: The profile of the specified player - //Use: Get the profile for the specified player - //===================================================================== - public PlayerProfile findProfile(String playername) - { - for(PlayerProfile ply : players) - { - if(ply.isPlayer(playername)) - return ply; - } - return null; - } - - class PlayerProfile - { - protected final Logger log = Logger.getLogger("Minecraft"); - private String taming, tamingXP, playerName, miningXP, woodCuttingXP, woodcutting, repair, mining, party, myspawn, myspawnworld, unarmed, herbalism, excavation, - archery, swords, axes, invite, acrobatics, repairXP, unarmedXP, herbalismXP, excavationXP, archeryXP, swordsXP, axesXP, acrobaticsXP; - 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, - 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 - //DATS = (Time of) Deactivation Time Stamp - Player thisplayer; - char defaultColor; - - String location = "plugins/mcMMO/mcmmo.users"; - - - //===================================================================== - //Function: PlayerProfile - //Input: Player player: The player to create a profile object for - //Output: none - //Use: Loads settings for the player or creates them if they don't - // exist. - //===================================================================== - public PlayerProfile(Player player) - { - //Declare things - playerName = player.getName(); - thisplayer = player; - party = new String(); - myspawn = new String(); - myspawnworld = new String(); - mining = new String(); - repair = new String(); - repairXP = new String(); - unarmed = new String(); - unarmedXP = new String(); - herbalism = new String(); - herbalismXP = new String(); - excavation = new String(); - excavationXP = new String(); - archery = new String(); - archeryXP = new String(); - swords = new String(); - swordsXP = new String(); - axes = new String(); - axesXP = new String(); - acrobatics = new String(); - acrobaticsXP = new String(); - taming = new String(); - tamingXP = new String(); - invite = new String(); - //mining = "0"; - woodCuttingXP = new String(); - //woodCuttingXP = "0"; - woodcutting = new String(); - //woodcutting = "0"; - miningXP = new String(); - //XP = "0"; - party = null; - dead = false; - treeFellerMode = false; - //Try to load the player and if they aren't found, append them - if(!load()) - addPlayer(); - } - - public boolean load() - { - try { - //Open the user file - FileReader file = new FileReader(location); - BufferedReader in = new BufferedReader(file); - String line = ""; - while((line = in.readLine()) != null) - { - //Find if the line contains the player we want. - String[] character = line.split(":"); - if(!character[0].equals(playerName)){continue;} - - //Get Mining - if(character.length > 1) - mining = character[1]; - //Myspawn - if(character.length > 2) - myspawn = character[2]; - //Party - if(character.length > 3) - party = character[3]; - //Mining XP - if(character.length > 4) - miningXP = character[4]; - if(character.length > 5) - woodcutting = character[5]; - if(character.length > 6) - woodCuttingXP = character[6]; - if(character.length > 7) - repair = character[7]; - if(character.length > 8) - unarmed = character[8]; - if(character.length > 9) - herbalism = character[9]; - if(character.length > 10) - excavation = character[10]; - if(character.length > 11) - archery = character[11]; - if(character.length > 12) - swords = character[12]; - if(character.length > 13) - axes = character[13]; - if(character.length > 14) - acrobatics = character[14]; - if(character.length > 15) - repairXP = character[15]; - if(character.length > 16) - unarmedXP = character[16]; - if(character.length > 17) - herbalismXP = character[17]; - if(character.length > 18) - excavationXP = character[18]; - if(character.length > 19) - archeryXP = character[19]; - if(character.length > 20) - swordsXP = character[20]; - if(character.length > 21) - axesXP = character[21]; - if(character.length > 22) - acrobaticsXP = character[22]; - if(character.length > 23) - myspawnworld = character[23]; - if(character.length > 24) - taming = character[24]; - if(character.length > 25) - tamingXP = character[25]; - in.close(); - return true; - } - in.close(); - } catch (Exception e) { - log.log(Level.SEVERE, "Exception while reading " - + location + " (Are you sure you formatted it correctly?)", e); - } - return false; - } - - //===================================================================== - // Function: save - // Input: none - // Output: None - // Use: Writes current values of PlayerProfile to disk - // Call this function to save current values - //===================================================================== - public void save() - { - try { - //Open the file - FileReader file = new FileReader(location); - BufferedReader in = new BufferedReader(file); - StringBuilder writer = new StringBuilder(); - String line = ""; - - //While not at the end of the file - while((line = in.readLine()) != null) - { - //Read the line in and copy it to the output it's not the player - //we want to edit - if(!line.split(":")[0].equalsIgnoreCase(playerName)) - { - writer.append(line).append("\r\n"); - - //Otherwise write the new player information - } else { - writer.append(playerName + ":"); - writer.append(mining + ":"); - writer.append(myspawn + ":"); - writer.append(party+":"); - writer.append(miningXP+":"); - writer.append(woodcutting+":"); - writer.append(woodCuttingXP+":"); - writer.append(repair+":"); - writer.append(unarmed+":"); - writer.append(herbalism+":"); - writer.append(excavation+":"); - writer.append(archery+":"); - writer.append(swords+":"); - writer.append(axes+":"); - writer.append(acrobatics+":"); - writer.append(repairXP+":"); - writer.append(unarmedXP+":"); - writer.append(herbalismXP+":"); - writer.append(excavationXP+":"); - writer.append(archeryXP+":"); - writer.append(swordsXP+":"); - writer.append(axesXP+":"); - writer.append(acrobaticsXP+":"); - writer.append(myspawnworld+":"); - writer.append(taming+":"); - writer.append(tamingXP+":"); - writer.append("\r\n"); - } - } - in.close(); - //Write the new file - FileWriter out = new FileWriter(location); - out.write(writer.toString()); - out.close(); - } catch (Exception e) { - log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e); - } - } - public void addPlayer() - { - try { - //Open the file to write the player - FileWriter file = new FileWriter(location, true); - BufferedWriter out = new BufferedWriter(file); - - //Add the player to the end - out.append(playerName + ":"); - out.append(0 + ":"); //mining - out.append(myspawn+":"); - out.append(party+":"); - out.append(0+":"); //XP - out.append(0+":"); //woodcutting - out.append(0+":"); //woodCuttingXP - out.append(0+":"); //repair - out.append(0+":"); //unarmed - out.append(0+":"); //herbalism - out.append(0+":"); //excavation - out.append(0+":"); //archery - out.append(0+":"); //swords - out.append(0+":"); //axes - out.append(0+":"); //acrobatics - out.append(0+":"); //repairXP - out.append(0+":"); //unarmedXP - out.append(0+":"); //herbalismXP - out.append(0+":"); //excavationXP - out.append(0+":"); //archeryXP - out.append(0+":"); //swordsXP - out.append(0+":"); //axesXP - out.append(0+":"); //acrobaticsXP - out.append(thisplayer.getWorld().getName()); - out.append(0+":"); //taming - out.append(0+":"); //tamingXP - //Add more in the same format as the line above - - out.newLine(); - out.close(); - } catch (Exception e) { - log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e); - } - } - - //===================================================================== - //Function: isPlayer - //Input: None - //Output: Player: The player this profile belongs to - //Use: Finds if this profile belongs to a specified player - //===================================================================== - public boolean isPlayer(String player) - { - return player.equals(playerName); - } - public boolean getPartyChatOnlyToggle(){return partyChatOnly;} - public void togglePartyChatOnly(){partyChatOnly = !partyChatOnly;} - public boolean getAbilityUse(){ - return abilityuse; - } - public void toggleAbilityUse(){ - if(abilityuse == false){ - abilityuse = true; - } else { - abilityuse = false; - } - } - public long getMySpawnATS(){ - return mySpawnATS; - } - public void setMySpawnATS(long newvalue){ - mySpawnATS = newvalue; - } - public void decreaseBleedTicks(){ - if(bleedticks >= 1){ - bleedticks--; - } - } - public Integer getBleedTicks(){ - return bleedticks; - } - public void setBleedTicks(Integer newvalue){ - bleedticks = newvalue; - } - public void addBleedTicks(Integer newvalue){ - bleedticks+=newvalue; - } - public Boolean hasCooldowns(){ - if((treeFellerCooldown + superBreakerCooldown) >= 1){ - return true; - } else { - return false; - } - } - /* - * EXPLOIT PREVENTION - */ - public long getRespawnATS() {return respawnATS;} - public void setRespawnATS(long newvalue) {respawnATS = newvalue;} - - /* - * ARCHERY NERF STUFF - */ - public long getArcheryShotATS() {return archeryShotATS;} - public void setArcheryShotATS(long newvalue) {archeryShotATS = newvalue;} - - /* - * HOE PREPARATION - */ - public boolean getHoePreparationMode(){ - return hoePreparationMode; - } - public void setHoePreparationMode(Boolean bool){ - hoePreparationMode = bool; - } - public long getHoePreparationATS(){ - return hoePreparationATS; - } - public void setHoePreparationATS(long newvalue){ - hoePreparationATS = newvalue; - } - - /* - * SWORDS PREPARATION - */ - public boolean getSwordsPreparationMode(){ - return swordsPreparationMode; - } - public void setSwordsPreparationMode(Boolean bool){ - swordsPreparationMode = bool; - } - public long getSwordsPreparationATS(){ - return swordsPreparationATS; - } - public void setSwordsPreparationATS(long newvalue){ - swordsPreparationATS = newvalue; - } - /* - * SHOVEL PREPARATION - */ - public boolean getShovelPreparationMode(){ - return shovelPreparationMode; - } - public void setShovelPreparationMode(Boolean bool){ - shovelPreparationMode = bool; - } - public long getShovelPreparationATS(){ - return shovelPreparationATS; - } - public void setShovelPreparationATS(long newvalue){ - shovelPreparationATS = newvalue; - } - /* - * FISTS PREPARATION - */ - public boolean getFistsPreparationMode(){ - return fistsPreparationMode; - } - public void setFistsPreparationMode(Boolean bool){ - fistsPreparationMode = bool; - } - public long getFistsPreparationATS(){ - return fistsPreparationATS; - } - public void setFistsPreparationATS(long newvalue){ - fistsPreparationATS = newvalue; - } - /* - * AXE PREPARATION - */ - public boolean getAxePreparationMode(){ - return axePreparationMode; - } - public void setAxePreparationMode(Boolean bool){ - axePreparationMode = bool; - } - public long getAxePreparationATS(){ - return axePreparationATS; - } - public void setAxePreparationATS(long newvalue){ - axePreparationATS = newvalue; - } - /* - * PICKAXE PREPARATION - */ - public boolean getPickaxePreparationMode(){ - return pickaxePreparationMode; - } - public void setPickaxePreparationMode(Boolean bool){ - pickaxePreparationMode = bool; - } - public long getPickaxePreparationATS(){ - return pickaxePreparationATS; - } - public void setPickaxePreparationATS(long newvalue){ - pickaxePreparationATS = newvalue; - } - /* - * GREEN TERRA MODE - */ - public boolean getGreenTerraInformed() {return greenTerraInformed;} - public void setGreenTerraInformed(Boolean bool){ - greenTerraInformed = bool; - } - public boolean getGreenTerraMode(){ - return greenTerraMode; - } - public void setGreenTerraMode(Boolean bool){ - greenTerraMode = bool; - } - public long getGreenTerraActivatedTimeStamp() {return greenTerraATS;} - public void setGreenTerraActivatedTimeStamp(Long newvalue){ - greenTerraATS = newvalue; - } - public long getGreenTerraDeactivatedTimeStamp() {return greenTerraDATS;} - public void setGreenTerraDeactivatedTimeStamp(Long newvalue){ - greenTerraDATS = newvalue; - } - public void setGreenTerraCooldown(Long newvalue){ - greenTerraCooldown = newvalue; - } - public long getGreenTerraCooldown(){ - return greenTerraCooldown; - } - public void setGreenTerraTicks(Integer newvalue){greenTerraTicks = newvalue;} - public int getGreenTerraTicks(){return greenTerraTicks;} - /* - * BERSERK MODE - */ - public boolean getBerserkInformed() {return berserkInformed;} - public void setBerserkInformed(Boolean bool){ - berserkInformed = bool; - } - public boolean getBerserkMode(){ - return berserkMode; - } - public void setBerserkMode(Boolean bool){ - berserkMode = bool; - } - public long getBerserkActivatedTimeStamp() {return berserkATS;} - public void setBerserkActivatedTimeStamp(Long newvalue){ - berserkATS = newvalue; - } - public long getBerserkDeactivatedTimeStamp() {return berserkDATS;} - public void setBerserkDeactivatedTimeStamp(Long newvalue){ - berserkDATS = newvalue; - } - public void setBerserkCooldown(Long newvalue){ - berserkCooldown = newvalue; - } - public long getBerserkCooldown(){ - return berserkCooldown; - } - public void setBerserkTicks(Integer newvalue){berserkTicks = newvalue;} - public int getBerserkTicks(){return berserkTicks;} - /* - * SKULL SPLITTER - */ - public boolean getSkullSplitterInformed() {return skullSplitterInformed;} - public void setSkullSplitterInformed(Boolean bool){ - skullSplitterInformed = bool; - } - public boolean getSkullSplitterMode(){ - return skullSplitterMode; - } - public void setSkullSplitterMode(Boolean bool){ - skullSplitterMode = bool; - } - public long getSkullSplitterActivatedTimeStamp() {return skullSplitterATS;} - public void setSkullSplitterActivatedTimeStamp(Long newvalue){ - skullSplitterATS = newvalue; - } - public long getSkullSplitterDeactivatedTimeStamp() {return skullSplitterDATS;} - public void setSkullSplitterDeactivatedTimeStamp(Long newvalue){ - skullSplitterDATS = newvalue; - } - public void setSkullSplitterCooldown(Long newvalue){ - skullSplitterCooldown = newvalue; - } - public long getSkullSplitterCooldown(){ - return skullSplitterCooldown; - } - public void setSkullSplitterTicks(Integer newvalue){skullSplitterTicks = newvalue;} - public int getSkullSplitterTicks(){return skullSplitterTicks;} - /* - * SERRATED STRIKES - */ - public boolean getSerratedStrikesInformed() {return serratedStrikesInformed;} - public void setSerratedStrikesInformed(Boolean bool){ - serratedStrikesInformed = bool; - } - public boolean getSerratedStrikesMode(){ - return serratedStrikesMode; - } - public void setSerratedStrikesMode(Boolean bool){ - serratedStrikesMode = bool; - } - public long getSerratedStrikesActivatedTimeStamp() {return serratedStrikesATS;} - public void setSerratedStrikesActivatedTimeStamp(Long newvalue){ - serratedStrikesATS = newvalue; - } - public long getSerratedStrikesDeactivatedTimeStamp() {return serratedStrikesDATS;} - public void setSerratedStrikesDeactivatedTimeStamp(Long newvalue){ - serratedStrikesDATS = newvalue; - } - public void setSerratedStrikesCooldown(Long newvalue){ - serratedStrikesCooldown = newvalue; - } - public long getSerratedStrikesCooldown(){ - return serratedStrikesCooldown; - } - public void setSerratedStrikesTicks(Integer newvalue){serratedStrikesTicks = newvalue;} - public int getSerratedStrikesTicks(){return serratedStrikesTicks;} - /* - * GIGA DRILL BREAKER - */ - public boolean getGigaDrillBreakerInformed() {return gigaDrillBreakerInformed;} - public void setGigaDrillBreakerInformed(Boolean bool){ - gigaDrillBreakerInformed = bool; - } - public boolean getGigaDrillBreakerMode(){ - return gigaDrillBreakerMode; - } - public void setGigaDrillBreakerMode(Boolean bool){ - gigaDrillBreakerMode = bool; - } - public long getGigaDrillBreakerActivatedTimeStamp() {return gigaDrillBreakerATS;} - public void setGigaDrillBreakerActivatedTimeStamp(Long newvalue){ - gigaDrillBreakerATS = newvalue; - } - public long getGigaDrillBreakerDeactivatedTimeStamp() {return gigaDrillBreakerDATS;} - public void setGigaDrillBreakerDeactivatedTimeStamp(Long newvalue){ - gigaDrillBreakerDATS = newvalue; - } - public void setGigaDrillBreakerCooldown(Long newvalue){ - gigaDrillBreakerCooldown = newvalue; - } - public long getGigaDrillBreakerCooldown(){ - return gigaDrillBreakerCooldown; - } - public void setGigaDrillBreakerTicks(Integer newvalue){gigaDrillBreakerTicks = newvalue;} - public int getGigaDrillBreakerTicks(){return gigaDrillBreakerTicks;} - /* - * TREE FELLER STUFF - */ - public boolean getTreeFellerInformed() {return treeFellerInformed;} - public void setTreeFellerInformed(Boolean bool){ - treeFellerInformed = bool; - } - public boolean getTreeFellerMode(){ - return treeFellerMode; - } - public void setTreeFellerMode(Boolean bool){ - treeFellerMode = bool; - } - public long getTreeFellerActivatedTimeStamp() {return treeFellerATS;} - public void setTreeFellerActivatedTimeStamp(Long newvalue){ - treeFellerATS = newvalue; - } - public long getTreeFellerDeactivatedTimeStamp() {return treeFellerDATS;} - public void setTreeFellerDeactivatedTimeStamp(Long newvalue){ - treeFellerDATS = newvalue; - } - public void setTreeFellerCooldown(Long newvalue){ - treeFellerCooldown = newvalue; - } - public long getTreeFellerCooldown(){ - return treeFellerCooldown; - } - public void setTreeFellerTicks(Integer newvalue){treeFellerTicks = newvalue;} - public int getTreeFellerTicks(){return treeFellerTicks;} - /* - * MINING - */ - public boolean getSuperBreakerInformed() {return superBreakerInformed;} - public void setSuperBreakerInformed(Boolean bool){ - superBreakerInformed = bool; - } - public boolean getSuperBreakerMode(){ - return superBreakerMode; - } - public void setSuperBreakerMode(Boolean bool){ - superBreakerMode = bool; - } - public long getSuperBreakerActivatedTimeStamp() {return superBreakerATS;} - public void setSuperBreakerActivatedTimeStamp(Long newvalue){ - superBreakerATS = newvalue; - } - public long getSuperBreakerDeactivatedTimeStamp() {return superBreakerDATS;} - public void setSuperBreakerDeactivatedTimeStamp(Long newvalue){ - superBreakerDATS = newvalue; - } - public void setSuperBreakerCooldown(Long newvalue){ - superBreakerCooldown = newvalue; - } - public long getSuperBreakerCooldown(){ - return superBreakerCooldown; - } - public void setSuperBreakerTicks(Integer newvalue){superBreakerTicks = newvalue;} - public int getSuperBreakerTicks(){return superBreakerTicks;} - - public long getRecentlyHurt(){ - return recentlyHurt; - } - public void setRecentlyHurt(long newvalue){ - recentlyHurt = newvalue; - } - public void skillUpTaming(int newskill){ - int x = 0; - if(taming != null){ - if(isInt(taming)){ - x = Integer.parseInt(taming); - }else { - taming = "0"; - x = Integer.parseInt(taming); - } - } - x += newskill; - taming = Integer.toString(x); - save(); - } - public void skillUpAxes(int newskill){ - int x = 0; - if(axes != null){ - if(isInt(axes)){ - x = Integer.parseInt(axes); - }else { - axes = "0"; - x = Integer.parseInt(axes); - } - } - x += newskill; - axes = Integer.toString(x); - save(); - } - public void skillUpAcrobatics(int newskill){ - int x = 0; - if(acrobatics != null){ - if(isInt(acrobatics)){ - x = Integer.parseInt(acrobatics); - }else { - acrobatics = "0"; - x = Integer.parseInt(acrobatics); - } - } - x += newskill; - acrobatics = Integer.toString(x); - save(); - } - public void skillUpSwords(int newskill){ - int x = 0; - if(swords != null){ - if(isInt(swords)){ - x = Integer.parseInt(swords); - }else { - swords = "0"; - x = Integer.parseInt(swords); - } - } - x += newskill; - swords = Integer.toString(x); - save(); - } - public void skillUpArchery(int newskill){ - int x = 0; - if(archery != null){ - if(isInt(archery)){ - x = Integer.parseInt(archery); - }else { - archery = "0"; - x = Integer.parseInt(archery); - } - } - x += newskill; - archery = Integer.toString(x); - save(); - } - public void skillUpRepair(int newskill){ - int x = 0; - if(repair != null){ - if(isInt(repair)){ - x = Integer.parseInt(repair); - }else { - repair = "0"; - x = Integer.parseInt(repair); - } - } - x += newskill; - repair = Integer.toString(x); - save(); - } - public void skillUpMining(int newmining){ - int x = 0; - if(mining != null){ - if(isInt(mining)){ - x = Integer.parseInt(mining); - }else { - mining = "0"; - x = Integer.parseInt(mining); - } - } - x += newmining; - mining = Integer.toString(x); - save(); - } - public void skillUpUnarmed(int newskill){ - int x = 0; - if(unarmed != null){ - if(isInt(unarmed)){ - x = Integer.parseInt(unarmed); - }else { - unarmed = "0"; - x = Integer.parseInt(unarmed); - } - } - x += newskill; - unarmed = Integer.toString(x); - save(); - } - public void skillUpHerbalism(int newskill){ - int x = 0; - if(herbalism != null){ - if(isInt(herbalism)){ - x = Integer.parseInt(herbalism); - }else { - herbalism = "0"; - x = Integer.parseInt(herbalism); - } - } - x += newskill; - herbalism = Integer.toString(x); - save(); - } - public void skillUpExcavation(int newskill){ - int x = 0; - if(excavation != null){ - if(isInt(excavation)){ - x = Integer.parseInt(excavation); - }else { - excavation = "0"; - x = Integer.parseInt(excavation); - } - } - x += newskill; - excavation = Integer.toString(x); - save(); - } - public void skillUpWoodCutting(int newskill){ - int x = 0; - if(woodcutting != null){ - if(isInt(woodcutting)){ - x = Integer.parseInt(woodcutting); - }else { - woodcutting = "0"; - x = Integer.parseInt(woodcutting); - } - } - x += newskill; - woodcutting = Integer.toString(x); - save(); - } - public String getTaming(){ - if(taming != null && !taming.equals("") && !taming.equals("null")){ - return taming; - } else { - return "0"; - } - } - public String getRepair(){ - if(repair != null && !repair.equals("") && !repair.equals("null")){ - return repair; - } else { - return "0"; - } - } - public String getMining(){ - if(mining != null && !mining.equals("") && !mining.equals("null")){ - return mining; - } else { - return "0"; - } - } - public String getUnarmed(){ - if(unarmed != null && !unarmed.equals("") && !unarmed.equals("null")){ - return unarmed; - } else { - return "0"; - } - } - public String getHerbalism(){ - if(herbalism != null && !herbalism.equals("") && !herbalism.equals("null")){ - return herbalism; - } else { - return "0"; - } - } - public String getExcavation(){ - if(excavation != null && !excavation.equals("") && !excavation.equals("null")){ - return excavation; - } else { - return "0"; - } - } - public String getArchery(){ - if(archery != null && !archery.equals("") && !archery.equals("null")){ - return archery; - } else { - return "0"; - } - } - public String getSwords(){ - if(swords != null && !swords.equals("") && !swords.equals("null")){ - return swords; - } else { - return "0"; - } - } - public String getAxes(){ - if(axes != null && !axes.equals("") && !axes.equals("null")){ - return axes; - } else { - return "0"; - } - } - public String getAcrobatics(){ - if(acrobatics != null && !acrobatics.equals("") && !acrobatics.equals("null")){ - return acrobatics; - } else { - return "0"; - } - } - public int getTamingInt(){ - if(isInt(taming)){ - int x = Integer.parseInt(taming); - return x; - } else{ - return 0; - } - } - public int getMiningInt(){ - if(isInt(mining)){ - int x = Integer.parseInt(mining); - return x; - } else{ - return 0; - } - } - public int getUnarmedInt(){ - if(isInt(unarmed)){ - int x = Integer.parseInt(unarmed); - return x; - } else{ - return 0; - } - } - public int getArcheryInt(){ - if(isInt(archery)){ - int x = Integer.parseInt(archery); - return x; - } else{ - return 0; - } - } - public int getSwordsInt(){ - if(isInt(swords)){ - int x = Integer.parseInt(swords); - return x; - } else{ - return 0; - } - } - public int getAxesInt(){ - if(isInt(axes)){ - int x = Integer.parseInt(axes); - return x; - } else{ - return 0; - } - } - public int getAcrobaticsInt(){ - if(isInt(acrobatics)){ - int x = Integer.parseInt(acrobatics); - return x; - } else{ - return 0; - } - } - public int getHerbalismInt(){ - if(isInt(herbalism)){ - int x = Integer.parseInt(herbalism); - return x; - } else{ - return 0; - } - } - public int getExcavationInt(){ - if(isInt(excavation)){ - int x = Integer.parseInt(excavation); - return x; - } else{ - return 0; - } - } - public int getRepairInt(){ - if(isInt(repair)){ - int x = Integer.parseInt(repair); - return x; - } else{ - return 0; - } - } - public int getWoodCuttingInt(){ - if(isInt(woodcutting)){ - int x = Integer.parseInt(woodcutting); - return x; - } else{ - return 0; - } - } - public String getWoodCutting(){ - if(woodcutting != null && !woodcutting.equals("") && !woodcutting.equals("null")){ - return woodcutting; - } else { - return "0"; - } - } - /* - * EXPERIENCE STUFF - */ - public void clearTamingXP(){ - tamingXP = "0"; - } - public void clearRepairXP(){ - repairXP = "0"; - } - public void clearUnarmedXP(){ - unarmedXP = "0"; - } - public void clearHerbalismXP(){ - herbalismXP = "0"; - } - public void clearExcavationXP(){ - excavationXP = "0"; - } - public void clearArcheryXP(){ - archeryXP = "0"; - } - public void clearSwordsXP(){ - swordsXP = "0"; - } - public void clearAxesXP(){ - axesXP = "0"; - } - public void clearAcrobaticsXP(){ - acrobaticsXP = "0"; - } - public void addTamingXP(int newXP) - { - int x = 0; - if(isInt(tamingXP)){ - x = Integer.parseInt(tamingXP); - } - x += newXP; - acrobaticsXP = String.valueOf(x); - save(); - } - public void addAcrobaticsXP(int newXP) - { - int x = 0; - if(isInt(acrobaticsXP)){ - x = Integer.parseInt(acrobaticsXP); - } - x += newXP; - acrobaticsXP = String.valueOf(x); - save(); - } - public void addAxesXP(int newXP) - { - int x = 0; - if(isInt(axesXP)){ - x = Integer.parseInt(axesXP); - } - x += newXP; - axesXP = String.valueOf(x); - save(); - } - public void addSwordsXP(int newXP) - { - int x = 0; - if(isInt(swordsXP)){ - x = Integer.parseInt(swordsXP); - } - x += newXP; - swordsXP = String.valueOf(x); - save(); - } - public void addArcheryXP(int newXP) - { - int x = 0; - if(isInt(archeryXP)){ - x = Integer.parseInt(archeryXP); - } - x += newXP; - archeryXP = String.valueOf(x); - save(); - } - public void addExcavationXP(int newXP) - { - int x = 0; - if(isInt(excavationXP)){ - x = Integer.parseInt(excavationXP); - } - x += newXP; - excavationXP = String.valueOf(x); - save(); - } - public void addHerbalismXP(int newXP) - { - int x = 0; - if(isInt(herbalismXP)){ - x = Integer.parseInt(herbalismXP); - } - x += newXP; - herbalismXP = String.valueOf(x); - save(); - } - public void addRepairXP(int newXP) - { - int x = 0; - if(isInt(repairXP)){ - x = Integer.parseInt(repairXP); - } - x += newXP; - repairXP = String.valueOf(x); - save(); - } - public void addUnarmedXP(int newXP) - { - int x = 0; - if(isInt(unarmedXP)){ - x = Integer.parseInt(unarmedXP); - } - x += newXP; - unarmedXP = String.valueOf(x); - save(); - } - public void addWoodcuttingXP(int newXP) - { - int x = 0; - if(isInt(woodCuttingXP)){ - x = Integer.parseInt(woodCuttingXP); - } - x += newXP; - woodCuttingXP = String.valueOf(x); - save(); - } - public void removeTamingXP(int newXP){ - int x = 0; - if(isInt(tamingXP)){ - x = Integer.parseInt(tamingXP); - } - x -= newXP; - tamingXP = String.valueOf(x); - save(); - } - public void removeWoodCuttingXP(int newXP){ - int x = 0; - if(isInt(woodCuttingXP)){ - x = Integer.parseInt(woodCuttingXP); - } - x -= newXP; - woodCuttingXP = String.valueOf(x); - save(); - } - public void addMiningXP(int newXP) - { - int x = 0; - if(isInt(miningXP)){ - x = Integer.parseInt(miningXP); - } else { - x = 0; - } - x += newXP; - miningXP = String.valueOf(x); - save(); - } - public void removeMiningXP(int newXP){ - int x = 0; - if(isInt(miningXP)){ - x = Integer.parseInt(miningXP); - } - x -= newXP; - miningXP = String.valueOf(x); - save(); - } - public void removeRepairXP(int newXP){ - int x = 0; - if(isInt(repairXP)){ - x = Integer.parseInt(repairXP); - } - x -= newXP; - repairXP = String.valueOf(x); - save(); - } - public void removeUnarmedXP(int newXP){ - int x = 0; - if(isInt(unarmedXP)){ - x = Integer.parseInt(unarmedXP); - } - x -= newXP; - unarmedXP = String.valueOf(x); - save(); - } - public void removeHerbalismXP(int newXP){ - int x = 0; - if(isInt(herbalismXP)){ - x = Integer.parseInt(herbalismXP); - } - x -= newXP; - herbalismXP = String.valueOf(x); - save(); - } - public void removeExcavationXP(int newXP){ - int x = 0; - if(isInt(excavationXP)){ - x = Integer.parseInt(excavationXP); - } - x -= newXP; - excavationXP = String.valueOf(x); - save(); - } - public void removeArcheryXP(int newXP){ - int x = 0; - if(isInt(archeryXP)){ - x = Integer.parseInt(archeryXP); - } - x -= newXP; - archeryXP = String.valueOf(x); - save(); - } - public void removeSwordsXP(int newXP){ - int x = 0; - if(isInt(swordsXP)){ - x = Integer.parseInt(swordsXP); - } - x -= newXP; - swordsXP = String.valueOf(x); - save(); - } - public void removeAxesXP(int newXP){ - int x = 0; - if(isInt(axesXP)){ - x = Integer.parseInt(axesXP); - } - x -= newXP; - axesXP = String.valueOf(x); - save(); - } - public void removeAcrobaticsXP(int newXP){ - int x = 0; - if(isInt(acrobaticsXP)){ - x = Integer.parseInt(acrobaticsXP); - } - x -= newXP; - acrobaticsXP = String.valueOf(x); - save(); - } - - public boolean isInt(String string){ - try { - int x = Integer.parseInt(string); - } - catch(NumberFormatException nFE) { - return false; - } - return true; - } - public boolean isDouble(String string){ - try { - Double x = Double.valueOf(string); - } - catch(NumberFormatException nFE) { - return false; - } - return true; - } - public void acceptInvite(){ - party = invite; - invite = ""; - save(); - } - public void modifyInvite(String invitename){ - invite = invitename; - } - //Returns player XP - public String getTamingXP(){ - if(tamingXP != null && !tamingXP.equals("") && !tamingXP.equals("null")){ - return tamingXP; - } else { - return "0"; - } - } - public String getMiningXP(){ - if(miningXP != null && !miningXP.equals("") && !miningXP.equals("null")){ - return miningXP; - } else { - return "0"; - } - } - public String getInvite() { return invite; } - public String getWoodCuttingXP(){ - if(woodCuttingXP != null && !woodCuttingXP.equals("") && !woodCuttingXP.equals("null")){ - return woodCuttingXP; - } else { - return "0"; - } - } - public String getRepairXP(){ - if(repairXP != null && !repairXP.equals("") && !repairXP.equals("null")){ - return repairXP; - } else { - return "0"; - } - } - public String getHerbalismXP(){ - if(herbalismXP != null && !herbalismXP.equals("") && !herbalismXP.equals("null")){ - return herbalismXP; - } else { - return "0"; - } - } - public String getExcavationXP(){ - if(excavationXP != null && !excavationXP.equals("") && !excavationXP.equals("null")){ - return excavationXP; - } else { - return "0"; - } - } - public String getArcheryXP(){ - if(archeryXP != null && !archeryXP.equals("") && !archeryXP.equals("null")){ - return archeryXP; - } else { - return "0"; - } - } - public String getSwordsXP(){ - if(swordsXP != null && !swordsXP.equals("") && !swordsXP.equals("null")){ - return swordsXP; - } else { - return "0"; - } - } - public String getAxesXP(){ - if(axesXP != null && !axesXP.equals("") && !axesXP.equals("null")){ - return axesXP; - } else { - return "0"; - } - } - public String getAcrobaticsXP(){ - if(acrobaticsXP != null && !acrobaticsXP.equals("") && !acrobaticsXP.equals("null")){ - return acrobaticsXP; - } else { - return "0"; - } - } - public String getUnarmedXP(){ - if(unarmedXP != null && !unarmedXP.equals("") && !unarmedXP.equals("null")){ - return unarmedXP; - } else { - return "0"; - } - } - public int getTamingXPInt() { - if(isInt(tamingXP)){ - return Integer.parseInt(tamingXP); - } else { - tamingXP = "0"; - save(); - return 0; - } - } - public int getWoodCuttingXPInt() { - if(isInt(woodCuttingXP)){ - return Integer.parseInt(woodCuttingXP); - } else { - woodCuttingXP = "0"; - save(); - return 0; - } - } - public int getRepairXPInt() { - if(isInt(repairXP)){ - return Integer.parseInt(repairXP); - } else { - repairXP = "0"; - save(); - return 0; - } - } - public int getUnarmedXPInt() { - if(isInt(unarmedXP)){ - return Integer.parseInt(unarmedXP); - } else { - unarmedXP = "0"; - save(); - return 0; - } - } - public int getHerbalismXPInt() { - if(isInt(herbalismXP)){ - return Integer.parseInt(herbalismXP); - } else { - herbalismXP = "0"; - save(); - return 0; - } - } - public int getExcavationXPInt() { - if(isInt(excavationXP)){ - return Integer.parseInt(excavationXP); - } else { - excavationXP = "0"; - save(); - return 0; - } - } - public int getArcheryXPInt() { - if(isInt(archeryXP)){ - return Integer.parseInt(archeryXP); - } else { - archeryXP = "0"; - save(); - return 0; - } - } - public int getSwordsXPInt() { - if(isInt(swordsXP)){ - return Integer.parseInt(swordsXP); - } else { - swordsXP = "0"; - save(); - return 0; - } - } - public int getAxesXPInt() { - if(isInt(axesXP)){ - return Integer.parseInt(axesXP); - } else { - axesXP = "0"; - save(); - return 0; - } - } - public int getAcrobaticsXPInt() { - if(isInt(acrobaticsXP)){ - return Integer.parseInt(acrobaticsXP); - } else { - acrobaticsXP = "0"; - save(); - return 0; - } - } - public void addXpToSkill(int newvalue, String skillname){ - if(!isInt(tamingXP)) - tamingXP = String.valueOf(0); - if(!isInt(miningXP)) - miningXP = String.valueOf(0); - if(!isInt(woodCuttingXP)) - woodCuttingXP = String.valueOf(0); - if(!isInt(repairXP)) - repairXP = String.valueOf(0); - if(!isInt(herbalismXP)) - herbalismXP = String.valueOf(0); - if(!isInt(acrobaticsXP)) - acrobaticsXP = String.valueOf(0); - if(!isInt(swordsXP)) - swordsXP = String.valueOf(0); - if(!isInt(archeryXP)) - archeryXP = String.valueOf(0); - if(!isInt(unarmedXP)) - unarmedXP = String.valueOf(0); - if(!isInt(excavationXP)) - excavationXP = String.valueOf(0); - if(!isInt(axesXP)) - axesXP = String.valueOf(0); - - if(skillname.toLowerCase().equals("taming")){ - tamingXP = String.valueOf(Integer.valueOf(tamingXP)+newvalue); - } - if(skillname.toLowerCase().equals("mining")){ - miningXP = String.valueOf(Integer.valueOf(miningXP)+newvalue); - } - if(skillname.toLowerCase().equals("woodcutting")){ - woodCuttingXP = String.valueOf(Integer.valueOf(woodCuttingXP)+newvalue); - } - if(skillname.toLowerCase().equals("repair")){ - repairXP = String.valueOf(Integer.valueOf(repairXP)+newvalue); - } - if(skillname.toLowerCase().equals("herbalism")){ - herbalismXP = String.valueOf(Integer.valueOf(herbalismXP)+newvalue); - } - if(skillname.toLowerCase().equals("acrobatics")){ - acrobaticsXP = String.valueOf(Integer.valueOf(acrobaticsXP)+newvalue); - } - if(skillname.toLowerCase().equals("swords")){ - swordsXP = String.valueOf(Integer.valueOf(swordsXP)+newvalue); - } - if(skillname.toLowerCase().equals("archery")){ - archeryXP = String.valueOf(Integer.valueOf(archeryXP)+newvalue); - } - if(skillname.toLowerCase().equals("unarmed")){ - unarmedXP = String.valueOf(Integer.valueOf(unarmedXP)+newvalue); - } - if(skillname.toLowerCase().equals("excavation")){ - excavationXP = String.valueOf(Integer.valueOf(excavationXP)+newvalue); - } - if(skillname.toLowerCase().equals("axes")){ - axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue); - } - if(skillname.toLowerCase().equals("all")){ - tamingXP = String.valueOf(Integer.valueOf(tamingXP)+newvalue); - miningXP = String.valueOf(Integer.valueOf(miningXP)+newvalue); - woodCuttingXP = String.valueOf(Integer.valueOf(woodCuttingXP)+newvalue); - repairXP = String.valueOf(Integer.valueOf(repairXP)+newvalue); - herbalismXP = String.valueOf(Integer.valueOf(herbalismXP)+newvalue); - acrobaticsXP = String.valueOf(Integer.valueOf(acrobaticsXP)+newvalue); - swordsXP = String.valueOf(Integer.valueOf(swordsXP)+newvalue); - archeryXP = String.valueOf(Integer.valueOf(archeryXP)+newvalue); - unarmedXP = String.valueOf(Integer.valueOf(unarmedXP)+newvalue); - excavationXP = String.valueOf(Integer.valueOf(excavationXP)+newvalue); - axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue); - } - save(); - mcSkills.XpCheck(thisplayer); - } - public void modifyskill(int newvalue, String skillname){ - if(skillname.toLowerCase().equals("taming")){ - taming = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("mining")){ - mining = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("woodcutting")){ - woodcutting = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("repair")){ - repair = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("herbalism")){ - herbalism = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("acrobatics")){ - acrobatics = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("swords")){ - swords = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("archery")){ - archery = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("unarmed")){ - unarmed = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("excavation")){ - excavation = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("axes")){ - axes = String.valueOf(newvalue); - } - if(skillname.toLowerCase().equals("all")){ - taming = String.valueOf(newvalue); - mining = String.valueOf(newvalue); - woodcutting = String.valueOf(newvalue); - repair = String.valueOf(newvalue); - herbalism = String.valueOf(newvalue); - acrobatics = String.valueOf(newvalue); - swords = String.valueOf(newvalue); - archery = String.valueOf(newvalue); - unarmed = String.valueOf(newvalue); - excavation = String.valueOf(newvalue); - axes = String.valueOf(newvalue); - } - save(); - } - public Integer getXpToLevel(String skillname){ - if(skillname.equals("taming")){ - return ((getTamingInt() + 50) * mcLoadProperties.tamingxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("mining")){ - return ((getMiningInt() + 50) * mcLoadProperties.miningxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("woodcutting")){ - return ((getWoodCuttingInt() + 50) * mcLoadProperties.woodcuttingxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("repair")){ - return ((getRepairInt() + 50) * mcLoadProperties.repairxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("herbalism")){ - return ((getHerbalismInt() + 50) * mcLoadProperties.herbalismxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("acrobatics")){ - return ((getAcrobaticsInt() + 50) * mcLoadProperties.acrobaticsxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("swords")){ - return ((getSwordsInt() + 50) * mcLoadProperties.swordsxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("archery")){ - return ((getArcheryInt() + 50) * mcLoadProperties.archeryxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("unarmed")){ - return ((getUnarmedInt() + 50) * mcLoadProperties.unarmedxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("excavation")){ - return ((getExcavationInt() + 50) * mcLoadProperties.excavationxpmodifier) * mcLoadProperties.globalxpmodifier; - } - if(skillname.equals("axes")){ - return ((getAxesInt() + 50) * mcLoadProperties.axesxpmodifier) * mcLoadProperties.globalxpmodifier; - } else { - return 0; - } - } - public int getMiningXPInt() { - if(isInt(miningXP)){ - return Integer.parseInt(miningXP); - } else { - miningXP = "0"; - save(); - return 0; - } - } - - //Store the player's party - public void setParty(String newParty) - { - party = newParty; - save(); - } - //Retrieve the player's party - public String getParty() {return party;} - //Remove party - public void removeParty() { - party = null; - save(); - } - //Retrieve whether or not the player is in a party - public boolean inParty() { - if(party != null && !party.equals("") && !party.equals("null")){ - return true; - } else { - return false; - } - } - //Retrieve whether or not the player has an invite - public boolean hasPartyInvite() { - if(invite != null && !invite.equals("") && !invite.equals("null")){ - return true; - } else { - return false; - } - } - public String getMySpawnWorld(Plugin plugin){ - if(myspawnworld != null && !myspawnworld.equals("") && !myspawnworld.equals("null")){ - return myspawnworld; - } else { - return plugin.getServer().getWorlds().get(0).toString(); - } - } - //Save a users spawn location - public void setMySpawn(double x, double y, double z, String myspawnworldlocation){ - myspawn = x+","+y+","+z; - myspawnworld = myspawnworldlocation; - save(); - } - public String getX(){ - String[] split = myspawn.split(","); - String x = split[0]; - return x; - } - public String getY(){ - String[] split = myspawn.split(","); - String y = split[1]; - return y; - } - public String getZ(){ - String[] split = myspawn.split(","); - String z = split[2]; - return z; - } - public void setDead(boolean x){ - dead = x; - save(); - } - public boolean isDead(){ - return dead; - } - public Location getMySpawn(Player player){ - Location loc = player.getWorld().getSpawnLocation(); - if(isDouble(getX()) && isDouble(getY()) && isDouble(getX())){ - loc.setX(Double.parseDouble(mcUsers.getProfile(player.getName()).getX())); - loc.setY(Double.parseDouble(mcUsers.getProfile(player.getName()).getY())); - loc.setZ(Double.parseDouble(mcUsers.getProfile(player.getName()).getZ())); - } else { - return null; - } - loc.setYaw(0); - loc.setPitch(0); - return loc; - } - } -} - - +} \ No newline at end of file diff --git a/mcMMO/com/gmail/nossr50/mcWoodCutting.java b/mcMMO/com/gmail/nossr50/mcWoodCutting.java index 49c0b68c6..a0e9b9ff9 100644 --- a/mcMMO/com/gmail/nossr50/mcWoodCutting.java +++ b/mcMMO/com/gmail/nossr50/mcWoodCutting.java @@ -10,7 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; public class mcWoodCutting { @@ -22,7 +22,7 @@ public class mcWoodCutting { } public static void woodCuttingProcCheck(Player player, Block block){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); byte type = block.getData(); Material mat = Material.getMaterial(block.getTypeId()); if(player != null){ @@ -33,7 +33,7 @@ public class mcWoodCutting { } } public static void treeFellerCheck(Player player, Block block, Plugin pluginx){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(mcm.isAxes(player.getItemInHand())){ if(block != null){ if(!mcm.abilityBlockCheck(block)) @@ -69,7 +69,7 @@ public class mcWoodCutting { } } public static void treeFeller(Block block, Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); int radius = 1; if(PP.getWoodCuttingXPInt() >= 500) radius++; diff --git a/mcMMO/com/gmail/nossr50/mcm.java b/mcMMO/com/gmail/nossr50/mcm.java index 6851a3d8d..4c67f90fb 100644 --- a/mcMMO/com/gmail/nossr50/mcm.java +++ b/mcMMO/com/gmail/nossr50/mcm.java @@ -14,7 +14,8 @@ import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import com.gmail.nossr50.PlayerList.PlayerProfile; +import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.FakeBlockBreakEvent; public class mcm { /* @@ -27,7 +28,7 @@ public class mcm { } public static int getPowerLevel(Player player){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); int x = 0; if(mcPermissions.getInstance().mining(player)) x+=PP.getMiningInt(); @@ -297,7 +298,7 @@ public class mcm { } } public static void mcmmoHelpCheck(String[] split, Player player, PlayerChatEvent event){ - PlayerProfile PP = mcUsers.getProfile(player.getName()); + PlayerProfile PP = mcUsers.getProfile(player); if(split[0].equalsIgnoreCase("/woodcutting")){ event.setCancelled(true); float skillvalue = (float)PP.getWoodCuttingInt();