mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 11:03:43 +01:00 
			
		
		
		
	More cleanup on PlayerProfile.java
This commit is contained in:
		@@ -19,111 +19,112 @@ import com.gmail.nossr50.m;
 | 
			
		||||
import com.gmail.nossr50.mcMMO;
 | 
			
		||||
 | 
			
		||||
public class PlayerProfile {
 | 
			
		||||
    //HUD
 | 
			
		||||
 | 
			
		||||
    final static int MAX_BLEED_TICKS = 10;
 | 
			
		||||
 | 
			
		||||
    /* HUD */
 | 
			
		||||
    private HUDType hud;
 | 
			
		||||
    private int xpbarinc = 0;
 | 
			
		||||
    private SkillType lastgained;
 | 
			
		||||
    private SkillType skillLock;
 | 
			
		||||
 | 
			
		||||
    //MISC
 | 
			
		||||
    private String party, invite;
 | 
			
		||||
    /* Party Stuff */
 | 
			
		||||
    private String party;
 | 
			
		||||
    private String invite;
 | 
			
		||||
 | 
			
		||||
    //TOGGLES
 | 
			
		||||
    private boolean loaded = false, partyhud = true, spoutcraft = false, xpbarlocked = false, placedAnvil = false, partyChatMode = false, adminChatMode = false, godMode = false, greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true, 
 | 
			
		||||
    superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, 
 | 
			
		||||
    serratedStrikesMode, hoePreparationMode = false, shovelPreparationMode = false, swordsPreparationMode = false, fistsPreparationMode = false, pickaxePreparationMode = false, axePreparationMode = false, skullSplitterMode, berserkMode;
 | 
			
		||||
    /* Toggles */
 | 
			
		||||
    private boolean loaded = false;
 | 
			
		||||
    private boolean partyhud = true, spoutcraft = false, xpbarlocked = false;
 | 
			
		||||
    private boolean placedAnvil = false;
 | 
			
		||||
    private boolean partyChatMode = false, partyChatOnly = false, adminChatMode = false;
 | 
			
		||||
    private boolean godMode = false;
 | 
			
		||||
    private boolean greenTerraMode, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, skullSplitterMode, berserkMode;
 | 
			
		||||
    private boolean greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
 | 
			
		||||
                    superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
 | 
			
		||||
    private boolean hoePreparationMode = false, shovelPreparationMode = false, swordsPreparationMode = false, fistsPreparationMode = false,
 | 
			
		||||
                    pickaxePreparationMode = false, axePreparationMode = false;
 | 
			
		||||
    private boolean abilityuse = true;
 | 
			
		||||
 | 
			
		||||
    //TIMESTAMPS
 | 
			
		||||
    //ATS = (Time of) Activation Time Stamp
 | 
			
		||||
    //DATS = (Time of) Deactivation Time Stamp
 | 
			
		||||
    private int xpGainATS = 0, recentlyHurt = 0, respawnATS, hoePreparationATS, shovelPreparationATS, swordsPreparationATS, fistsPreparationATS, axePreparationATS, pickaxePreparationATS;
 | 
			
		||||
    /* Timestamps */
 | 
			
		||||
    private int xpGainATS = 0;
 | 
			
		||||
    private int recentlyHurt = 0;
 | 
			
		||||
    private int respawnATS;
 | 
			
		||||
 | 
			
		||||
    private SkillType lastgained = null, skillLock = null;
 | 
			
		||||
    /* mySQL STUFF */
 | 
			
		||||
    private int lastlogin = 0;
 | 
			
		||||
    private int userid = 0;
 | 
			
		||||
    private int bleedticks = 0;
 | 
			
		||||
 | 
			
		||||
    //MySQL STUFF
 | 
			
		||||
    private int xpbarinc=0, lastlogin=0, userid = 0, bleedticks = 0;
 | 
			
		||||
    HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
 | 
			
		||||
    HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
 | 
			
		||||
    HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
 | 
			
		||||
    HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
 | 
			
		||||
 | 
			
		||||
    private String playerName;
 | 
			
		||||
    private String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
 | 
			
		||||
 | 
			
		||||
    //Time to HashMap this shiz
 | 
			
		||||
    HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and XP
 | 
			
		||||
    HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
 | 
			
		||||
    HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); //Skill ATS
 | 
			
		||||
    
 | 
			
		||||
    String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
 | 
			
		||||
 | 
			
		||||
    public PlayerProfile(String name)
 | 
			
		||||
    {
 | 
			
		||||
    public PlayerProfile(String name) {
 | 
			
		||||
        hud = LoadProperties.defaulthud;
 | 
			
		||||
        //Setup the HashMap for ability DATS
 | 
			
		||||
        for(AbilityType abilityType : AbilityType.values())
 | 
			
		||||
        {
 | 
			
		||||
        playerName = name;
 | 
			
		||||
 | 
			
		||||
        for (AbilityType abilityType : AbilityType.values()) {
 | 
			
		||||
            skillsDATS.put(abilityType, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Setup the HashMap for the skills
 | 
			
		||||
        for(SkillType skillType : SkillType.values())
 | 
			
		||||
        {
 | 
			
		||||
            if(skillType != SkillType.ALL)
 | 
			
		||||
            {
 | 
			
		||||
        for (SkillType skillType : SkillType.values()) {
 | 
			
		||||
            if (skillType != SkillType.ALL) {
 | 
			
		||||
                skills.put(skillType, 0);
 | 
			
		||||
                skillsXp.put(skillType, 0);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        playerName = name;
 | 
			
		||||
        if (LoadProperties.useMySQL) 
 | 
			
		||||
        {
 | 
			
		||||
        if (LoadProperties.useMySQL) {
 | 
			
		||||
            if (!loadMySQL()) {
 | 
			
		||||
                addMySQLPlayer();
 | 
			
		||||
                loadMySQL();//This is probably not needed anymore, could just delete
 | 
			
		||||
                loadMySQL(); //This is probably not needed anymore, could just delete. // So can we remove this whole function, or just this line?
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if(!load()) { addPlayer();}
 | 
			
		||||
        }
 | 
			
		||||
        else if (!load()) {
 | 
			
		||||
            addPlayer();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        lastlogin = ((Long) (System.currentTimeMillis() / 1000)).intValue();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public PlayerProfile(String name, boolean addNew)
 | 
			
		||||
    {
 | 
			
		||||
    /*
 | 
			
		||||
     * Why do we even have this? The only time it's called, it's false.
 | 
			
		||||
     * Why not combine the two?
 | 
			
		||||
     */
 | 
			
		||||
    public PlayerProfile(String name, boolean addNew) {
 | 
			
		||||
        hud = LoadProperties.defaulthud;
 | 
			
		||||
        //Setup the HashMap for ability DATS
 | 
			
		||||
        for(AbilityType abilityType : AbilityType.values())
 | 
			
		||||
        {
 | 
			
		||||
        playerName = name;
 | 
			
		||||
 | 
			
		||||
        for (AbilityType abilityType : AbilityType.values()) {
 | 
			
		||||
            skillsDATS.put(abilityType, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Setup the HashMap for the skills
 | 
			
		||||
        for(SkillType skillType : SkillType.values())
 | 
			
		||||
        {
 | 
			
		||||
            if(skillType != SkillType.ALL)
 | 
			
		||||
            {
 | 
			
		||||
        for (SkillType skillType : SkillType.values()) {
 | 
			
		||||
            if (skillType != SkillType.ALL) {
 | 
			
		||||
                skills.put(skillType, 0);
 | 
			
		||||
                skillsXp.put(skillType, 0);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        playerName = name;
 | 
			
		||||
        if (LoadProperties.useMySQL) 
 | 
			
		||||
        {
 | 
			
		||||
        if (LoadProperties.useMySQL) {
 | 
			
		||||
            if (!loadMySQL() && addNew) {
 | 
			
		||||
                addMySQLPlayer();
 | 
			
		||||
                loadMySQL();//This is probably not needed anymore, could just delete
 | 
			
		||||
                loadMySQL(); //This is probably not needed anymore, could just delete. // So can we remove this whole function, or just this line?
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if(!load() && addNew) { addPlayer(); loaded = true; }
 | 
			
		||||
        }
 | 
			
		||||
        else if (!load() && addNew) {
 | 
			
		||||
            addPlayer();
 | 
			
		||||
            loaded = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        lastlogin = ((Long) (System.currentTimeMillis() / 1000)).intValue();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getLastLogin()
 | 
			
		||||
    {
 | 
			
		||||
        return lastlogin;
 | 
			
		||||
    }
 | 
			
		||||
    public int getMySQLuserId()
 | 
			
		||||
    {
 | 
			
		||||
        return userid;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean loadMySQL() 
 | 
			
		||||
    {
 | 
			
		||||
    public boolean loadMySQL() {
 | 
			
		||||
        Integer id = 0;
 | 
			
		||||
        id = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
 | 
			
		||||
        if(id == 0)
 | 
			
		||||
@@ -204,6 +205,7 @@ public class PlayerProfile {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addMySQLPlayer() {
 | 
			
		||||
        Integer id = 0;
 | 
			
		||||
        mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
 | 
			
		||||
@@ -440,19 +442,16 @@ public class PlayerProfile {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void resetAllData()
 | 
			
		||||
    {
 | 
			
		||||
    public void resetAllData() {
 | 
			
		||||
        //This will reset everything to default values and then save the information to FlatFile/MySQL
 | 
			
		||||
        for(SkillType skillType : SkillType.values())
 | 
			
		||||
        {
 | 
			
		||||
            if(skillType == SkillType.ALL)
 | 
			
		||||
                continue;
 | 
			
		||||
        for (SkillType skillType : SkillType.values()) {
 | 
			
		||||
            if (skillType != SkillType.ALL) {
 | 
			
		||||
                skills.put(skillType, 0);
 | 
			
		||||
                skillsXp.put(skillType, 0);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for(AbilityType abilityType : AbilityType.values())
 | 
			
		||||
        {
 | 
			
		||||
        for (AbilityType abilityType : AbilityType.values()) {
 | 
			
		||||
            skillsDATS.put(abilityType, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -516,134 +515,170 @@ public class PlayerProfile {
 | 
			
		||||
            Bukkit.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public void togglePartyHUD()
 | 
			
		||||
    {
 | 
			
		||||
        partyhud = !partyhud;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * mySQL Stuff
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public int getLastLogin() {
 | 
			
		||||
        return lastlogin;
 | 
			
		||||
    }
 | 
			
		||||
    public boolean isLoaded()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMySQLuserId() {
 | 
			
		||||
        return userid;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isLoaded() {
 | 
			
		||||
        return loaded;
 | 
			
		||||
    }
 | 
			
		||||
    public boolean getPartyHUD()
 | 
			
		||||
    {
 | 
			
		||||
        return partyhud;
 | 
			
		||||
    }
 | 
			
		||||
    public void toggleSpoutEnabled()
 | 
			
		||||
    {
 | 
			
		||||
        spoutcraft = !spoutcraft;
 | 
			
		||||
    }
 | 
			
		||||
    public HUDType getHUDType()
 | 
			
		||||
    {
 | 
			
		||||
        return hud;
 | 
			
		||||
    }
 | 
			
		||||
    public void setHUDType(HUDType type)
 | 
			
		||||
    {
 | 
			
		||||
        hud = type;
 | 
			
		||||
        save();
 | 
			
		||||
    }
 | 
			
		||||
    public boolean getXpBarLocked()
 | 
			
		||||
    {
 | 
			
		||||
        return xpbarlocked;
 | 
			
		||||
    }
 | 
			
		||||
    public void toggleXpBarLocked()
 | 
			
		||||
    {
 | 
			
		||||
        xpbarlocked = !xpbarlocked;
 | 
			
		||||
    }
 | 
			
		||||
    public int getXpBarInc()
 | 
			
		||||
    {
 | 
			
		||||
        return xpbarinc;
 | 
			
		||||
    }
 | 
			
		||||
    public void setXpBarInc(int newvalue)
 | 
			
		||||
    {
 | 
			
		||||
        xpbarinc = newvalue;
 | 
			
		||||
    }
 | 
			
		||||
    public void setSkillLock(SkillType newvalue)
 | 
			
		||||
    {
 | 
			
		||||
        skillLock = newvalue;
 | 
			
		||||
    }
 | 
			
		||||
    public SkillType getSkillLock()
 | 
			
		||||
    {
 | 
			
		||||
        return skillLock;
 | 
			
		||||
    }
 | 
			
		||||
    public void setLastGained(SkillType newvalue)
 | 
			
		||||
    {
 | 
			
		||||
        lastgained = newvalue;
 | 
			
		||||
    }
 | 
			
		||||
    public SkillType getLastGained()
 | 
			
		||||
    {
 | 
			
		||||
        return lastgained;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * God Mode
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public boolean getGodMode() {
 | 
			
		||||
        return godMode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean getAdminChatMode() {return adminChatMode;}
 | 
			
		||||
    public boolean getPartyChatMode() {return partyChatMode;}
 | 
			
		||||
    
 | 
			
		||||
    public boolean getGodMode() {return godMode;}
 | 
			
		||||
    
 | 
			
		||||
    public void togglePlacedAnvil()
 | 
			
		||||
    {
 | 
			
		||||
        placedAnvil = !placedAnvil;
 | 
			
		||||
    }
 | 
			
		||||
    public Boolean getPlacedAnvil()
 | 
			
		||||
    {
 | 
			
		||||
        return placedAnvil;
 | 
			
		||||
    }
 | 
			
		||||
    public void toggleAdminChat()
 | 
			
		||||
    {
 | 
			
		||||
        adminChatMode = !adminChatMode;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void toggleGodMode()
 | 
			
		||||
    {
 | 
			
		||||
    public void toggleGodMode() {
 | 
			
		||||
        godMode = !godMode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void togglePartyChat()
 | 
			
		||||
    {
 | 
			
		||||
    /*
 | 
			
		||||
     * Anvil Placement
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public void togglePlacedAnvil() {
 | 
			
		||||
        placedAnvil = !placedAnvil;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Boolean getPlacedAnvil() {
 | 
			
		||||
        return placedAnvil;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * HUD Stuff
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public void togglePartyHUD() {
 | 
			
		||||
        partyhud = !partyhud;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean getPartyHUD() {
 | 
			
		||||
        return partyhud;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void toggleSpoutEnabled() {
 | 
			
		||||
        spoutcraft = !spoutcraft;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public HUDType getHUDType() {
 | 
			
		||||
        return hud;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHUDType(HUDType type) {
 | 
			
		||||
        hud = type;
 | 
			
		||||
        save();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean getXpBarLocked() {
 | 
			
		||||
        return xpbarlocked;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void toggleXpBarLocked() {
 | 
			
		||||
        xpbarlocked = !xpbarlocked;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getXpBarInc() {
 | 
			
		||||
        return xpbarinc;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setXpBarInc(int newvalue) {
 | 
			
		||||
        xpbarinc = newvalue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSkillLock(SkillType newvalue) {
 | 
			
		||||
        skillLock = newvalue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public SkillType getSkillLock() {
 | 
			
		||||
        return skillLock;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setLastGained(SkillType newvalue) {
 | 
			
		||||
        lastgained = newvalue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public SkillType getLastGained() {
 | 
			
		||||
        return lastgained;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Chat Stuff
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public boolean getAdminChatMode() {
 | 
			
		||||
        return adminChatMode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void toggleAdminChat() {
 | 
			
		||||
        adminChatMode = !adminChatMode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean getPartyChatMode() {
 | 
			
		||||
        return partyChatMode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void togglePartyChat() {
 | 
			
		||||
        partyChatMode = !partyChatMode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isPlayer(String player)
 | 
			
		||||
    {
 | 
			
		||||
        return player.equals(Bukkit.getPlayer(playerName));
 | 
			
		||||
    public boolean getPartyChatOnlyToggle() {
 | 
			
		||||
        return partyChatOnly;
 | 
			
		||||
    }
 | 
			
		||||
    public boolean getPartyChatOnlyToggle(){return partyChatOnly;}
 | 
			
		||||
    public void togglePartyChatOnly(){partyChatOnly = !partyChatOnly;}
 | 
			
		||||
    public boolean getAbilityUse(){
 | 
			
		||||
        return abilityuse;
 | 
			
		||||
 | 
			
		||||
    public void togglePartyChatOnly() {
 | 
			
		||||
        partyChatOnly = !partyChatOnly;
 | 
			
		||||
    }
 | 
			
		||||
    public void toggleAbilityUse()
 | 
			
		||||
    {
 | 
			
		||||
        abilityuse = !abilityuse;
 | 
			
		||||
    }
 | 
			
		||||
    public void decreaseBleedTicks()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Bleed Stuff
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public void decreaseBleedTicks() {
 | 
			
		||||
        bleedticks--;
 | 
			
		||||
    }
 | 
			
		||||
    public Integer getBleedTicks(){
 | 
			
		||||
 | 
			
		||||
    public int getBleedTicks() {
 | 
			
		||||
        return bleedticks;
 | 
			
		||||
    }
 | 
			
		||||
    public void setBleedTicks(Integer newvalue){
 | 
			
		||||
        bleedticks = newvalue;
 | 
			
		||||
 | 
			
		||||
        //Cap maximum ticks at 10
 | 
			
		||||
        if(bleedticks > 10)
 | 
			
		||||
            bleedticks = 10;
 | 
			
		||||
    public void resetBleedTicks() {
 | 
			
		||||
        bleedticks = 0;
 | 
			
		||||
    }
 | 
			
		||||
    public void addBleedTicks(Integer newvalue){
 | 
			
		||||
 | 
			
		||||
    public void addBleedTicks(int newvalue){
 | 
			
		||||
        bleedticks += newvalue;
 | 
			
		||||
 | 
			
		||||
        //Cap maximum ticks at 10
 | 
			
		||||
        if(bleedticks > 10)
 | 
			
		||||
            bleedticks = 10;
 | 
			
		||||
        if (bleedticks > MAX_BLEED_TICKS) {
 | 
			
		||||
            bleedticks = MAX_BLEED_TICKS;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /*
 | 
			
		||||
     * EXPLOIT PREVENTION
 | 
			
		||||
     */
 | 
			
		||||
    public long getRespawnATS() {return respawnATS;}
 | 
			
		||||
    public void setRespawnATS(long newvalue) {respawnATS = (int) (newvalue/1000);}
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * TOOLS
 | 
			
		||||
     * Exploit Prevention
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public long getRespawnATS() {
 | 
			
		||||
        return respawnATS;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setRespawnATS(long newvalue) {
 | 
			
		||||
        respawnATS = (int) (newvalue / 1000);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Tools
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -721,28 +756,7 @@ public class PlayerProfile {
 | 
			
		||||
     * @return the ATS for the tool
 | 
			
		||||
     */
 | 
			
		||||
    public long getToolPreparationATS(ToolType tool) {
 | 
			
		||||
        switch (tool) {
 | 
			
		||||
        case AXE:
 | 
			
		||||
            return axePreparationATS;
 | 
			
		||||
 | 
			
		||||
        case FISTS:
 | 
			
		||||
            return fistsPreparationATS;
 | 
			
		||||
 | 
			
		||||
        case HOE:
 | 
			
		||||
            return hoePreparationATS;
 | 
			
		||||
 | 
			
		||||
        case PICKAXE:
 | 
			
		||||
            return pickaxePreparationATS;
 | 
			
		||||
 | 
			
		||||
        case SHOVEL:
 | 
			
		||||
            return shovelPreparationATS;
 | 
			
		||||
 | 
			
		||||
        case SWORD:
 | 
			
		||||
            return swordsPreparationATS;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
            return 0;
 | 
			
		||||
        }
 | 
			
		||||
        return skillsDATS.get(tool);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -752,38 +766,12 @@ public class PlayerProfile {
 | 
			
		||||
     * @param ATS the ATS of the tool
 | 
			
		||||
     */
 | 
			
		||||
    public void setToolPreparationATS(ToolType tool, long ATS) {
 | 
			
		||||
        switch (tool) {
 | 
			
		||||
        case AXE:
 | 
			
		||||
            axePreparationATS = (int) (ATS / 1000);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case FISTS:
 | 
			
		||||
            fistsPreparationATS = (int) (ATS / 1000);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case HOE:
 | 
			
		||||
            hoePreparationATS = (int) (ATS / 1000);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case PICKAXE:
 | 
			
		||||
            pickaxePreparationATS = (int) (ATS / 1000);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case SHOVEL:
 | 
			
		||||
            shovelPreparationATS = (int) (ATS / 1000);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case SWORD:
 | 
			
		||||
            swordsPreparationATS = (int) (ATS / 1000);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        int startTime = (int) (ATS / 1000);
 | 
			
		||||
        toolATS.put(tool, startTime);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * ABILITIES
 | 
			
		||||
     * Abilities
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -943,52 +931,72 @@ public class PlayerProfile {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean getAbilityUse() {
 | 
			
		||||
        return abilityuse;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void toggleAbilityUse() {
 | 
			
		||||
        abilityuse = !abilityuse;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * RECENTLY HURT
 | 
			
		||||
     * Recently Hurt
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public long getRecentlyHurt() {
 | 
			
		||||
        return recentlyHurt;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setRecentlyHurt(long newvalue) {
 | 
			
		||||
        recentlyHurt = (int) (newvalue / 1000);
 | 
			
		||||
    }
 | 
			
		||||
    public void skillUp(SkillType skillType, int newvalue)
 | 
			
		||||
    {
 | 
			
		||||
        skills.put(skillType, skills.get(skillType)+newvalue);
 | 
			
		||||
    }
 | 
			
		||||
    public Integer getSkillLevel(SkillType skillType)
 | 
			
		||||
    {
 | 
			
		||||
        return skills.get(skillType);
 | 
			
		||||
    }
 | 
			
		||||
    public Integer getSkillXpLevel(SkillType skillType)
 | 
			
		||||
    {
 | 
			
		||||
        return skillsXp.get(skillType);
 | 
			
		||||
    }
 | 
			
		||||
    public void resetSkillXp(SkillType skillType)
 | 
			
		||||
    {
 | 
			
		||||
        skills.put(skillType, 0);
 | 
			
		||||
    }
 | 
			
		||||
    public long getSkillDATS(AbilityType abilityType)
 | 
			
		||||
    {
 | 
			
		||||
        //Is this actually unused, or should it actually be returning the convertedBack variable?
 | 
			
		||||
        //It *is* unused, I don't think I put this here so I'm going to comment it out - nossr50
 | 
			
		||||
        //long convertedBack = skillsDATS.get(abilityType) * 1000;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Cooldowns
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the current DATS of a skill.
 | 
			
		||||
     *
 | 
			
		||||
     * @param abilityType Ability to get the DATS for
 | 
			
		||||
     * @return the DATS for the ability
 | 
			
		||||
     */
 | 
			
		||||
    public long getSkillDATS(AbilityType abilityType) {
 | 
			
		||||
        return skillsDATS.get(abilityType);
 | 
			
		||||
    }
 | 
			
		||||
    public void setSkillDATS(AbilityType abilityType, long value)
 | 
			
		||||
    {
 | 
			
		||||
        int wearsOff = (int) (value * .001D);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the current DATS of a skill.
 | 
			
		||||
     *
 | 
			
		||||
     * @param abilityType Ability to set the DATS for
 | 
			
		||||
     * @param DATS the DATS of the ability
 | 
			
		||||
     */
 | 
			
		||||
    public void setSkillDATS(AbilityType abilityType, long DATS) {
 | 
			
		||||
        int wearsOff = (int) (DATS * .001D);
 | 
			
		||||
        skillsDATS.put(abilityType, wearsOff);
 | 
			
		||||
    }
 | 
			
		||||
    public void resetCooldowns()
 | 
			
		||||
    {
 | 
			
		||||
        for(AbilityType x : skillsDATS.keySet())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Reset all skill cooldowns.
 | 
			
		||||
     */
 | 
			
		||||
    public void resetCooldowns() {
 | 
			
		||||
        for (AbilityType x : skillsDATS.keySet()) {
 | 
			
		||||
            skillsDATS.put(x, 0);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * XP Functions
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public Integer getSkillLevel(SkillType skillType) {
 | 
			
		||||
        return skills.get(skillType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getSkillXpLevel(SkillType skillType) {
 | 
			
		||||
        return skillsXp.get(skillType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds XP to the player, doesn't calculate for XP Rate
 | 
			
		||||
     *
 | 
			
		||||
@@ -1091,40 +1099,6 @@ public class PlayerProfile {
 | 
			
		||||
        lastgained = skillType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Remove XP from a skill.
 | 
			
		||||
     *
 | 
			
		||||
     * @param skillType Type of skill to modify
 | 
			
		||||
     * @param xp Amount of xp to remove
 | 
			
		||||
     */
 | 
			
		||||
    public void removeXP(SkillType skillType, int xp) {
 | 
			
		||||
        if (skillType.equals(SkillType.ALL)) {
 | 
			
		||||
            for (SkillType skill : SkillType.values()) {
 | 
			
		||||
                if (skill.equals(SkillType.ALL)) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                skillsXp.put(skill, skillsXp.get(skill) - xp);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            skillsXp.put(skillType, skillsXp.get(skillType) - xp);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void acceptInvite() {
 | 
			
		||||
        party = invite;
 | 
			
		||||
        invite = "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void modifyInvite(String invitename) {
 | 
			
		||||
        invite = invitename;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getInvite() {
 | 
			
		||||
        return invite;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Modify a skill level.
 | 
			
		||||
     *
 | 
			
		||||
@@ -1150,8 +1124,6 @@ public class PlayerProfile {
 | 
			
		||||
        save();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add levels to a skill.
 | 
			
		||||
     *
 | 
			
		||||
@@ -1177,8 +1149,6 @@ public class PlayerProfile {
 | 
			
		||||
        save();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the amount of XP remaining before the next level.
 | 
			
		||||
     *
 | 
			
		||||
@@ -1189,39 +1159,50 @@ public class PlayerProfile {
 | 
			
		||||
        return (int) (1020 + (skills.get(skillType) *  20)); //Do we REALLY need to cast to int here?
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Party Stuff
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public void acceptInvite() {
 | 
			
		||||
        party = invite;
 | 
			
		||||
        invite = "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void modifyInvite(String invitename) {
 | 
			
		||||
        invite = invitename;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getInvite() {
 | 
			
		||||
        return invite;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean hasPartyInvite() {
 | 
			
		||||
        if (invite != null && !invite.equals("") && !invite.equals("null")) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //Store the player's party
 | 
			
		||||
    public void setParty(String newParty) {
 | 
			
		||||
        party = newParty;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //Retrieve the player's party
 | 
			
		||||
    public String getParty() {return party;}
 | 
			
		||||
            //Remove party
 | 
			
		||||
    public String getParty() {
 | 
			
		||||
        return party;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void removeParty() {
 | 
			
		||||
        party = null;
 | 
			
		||||
    }
 | 
			
		||||
    //Retrieve whether or not the player is in a party
 | 
			
		||||
    public boolean inParty() 
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean inParty() {
 | 
			
		||||
        if (party != null && !party.equals("") && !party.equals("null")) {
 | 
			
		||||
            return true;
 | 
			
		||||
        } else {
 | 
			
		||||
        }
 | 
			
		||||
        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 getPlayerName()
 | 
			
		||||
    {
 | 
			
		||||
        return playerName;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -152,7 +152,7 @@ public class mcEntityListener implements Listener {
 | 
			
		||||
        Archery.arrowRetrievalCheck(x, plugin);
 | 
			
		||||
 | 
			
		||||
        if (x instanceof Player) {
 | 
			
		||||
            Users.getProfile((Player)x).setBleedTicks(0);
 | 
			
		||||
            Users.getProfile((Player)x).resetBleedTicks();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -190,21 +190,22 @@ public class Skills {
 | 
			
		||||
     */
 | 
			
		||||
    public static void XpCheckSkill(SkillType skillType, Player player) {
 | 
			
		||||
        PlayerProfile PP = Users.getProfile(player);
 | 
			
		||||
        int skillXpLevel = PP.getSkillXpLevel(skillType);
 | 
			
		||||
        int xpToNextLevel = PP.getXpToLevel(skillType);
 | 
			
		||||
 | 
			
		||||
        if (PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) {
 | 
			
		||||
        if (skillXpLevel >= xpToNextLevel) {
 | 
			
		||||
            int skillups = 0;
 | 
			
		||||
            
 | 
			
		||||
            while (PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) {
 | 
			
		||||
            while (skillXpLevel >= xpToNextLevel) {
 | 
			
		||||
                if (skillType.getMaxLevel() >= PP.getSkillLevel(skillType) + 1) {
 | 
			
		||||
                    skillups++;
 | 
			
		||||
                    PP.removeXP(skillType, PP.getXpToLevel(skillType));
 | 
			
		||||
                    PP.skillUp(skillType, 1);
 | 
			
		||||
                    PP.addLevels(skillType, 1);
 | 
			
		||||
 | 
			
		||||
                    McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType);
 | 
			
		||||
                    Bukkit.getPluginManager().callEvent(eventToFire);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    PP.removeXP(skillType, PP.getXpToLevel(skillType));
 | 
			
		||||
                    PP.addLevels(skillType, 0);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -95,7 +95,7 @@ public class Taming {
 | 
			
		||||
                Player target = (Player) entity;
 | 
			
		||||
 | 
			
		||||
                target.sendMessage(mcLocale.getString("Combat.StruckByGore"));
 | 
			
		||||
                Users.getProfile(target).setBleedTicks(2);
 | 
			
		||||
                Users.getProfile(target).addBleedTicks(2);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                mcBleedTimer.add((LivingEntity) entity);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user