mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-03 22:47:40 +01:00
More cleanup on PlayerProfile.java
This commit is contained in:
parent
83c326fb39
commit
ac384c5d95
@ -19,111 +19,112 @@ import com.gmail.nossr50.m;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public class PlayerProfile {
|
public class PlayerProfile {
|
||||||
//HUD
|
|
||||||
|
final static int MAX_BLEED_TICKS = 10;
|
||||||
|
|
||||||
|
/* HUD */
|
||||||
private HUDType hud;
|
private HUDType hud;
|
||||||
|
private int xpbarinc = 0;
|
||||||
|
private SkillType lastgained;
|
||||||
|
private SkillType skillLock;
|
||||||
|
|
||||||
//MISC
|
/* Party Stuff */
|
||||||
private String party, invite;
|
private String party;
|
||||||
|
private String invite;
|
||||||
|
|
||||||
//TOGGLES
|
/* 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,
|
private boolean loaded = false;
|
||||||
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode,
|
private boolean partyhud = true, spoutcraft = false, xpbarlocked = false;
|
||||||
serratedStrikesMode, hoePreparationMode = false, shovelPreparationMode = false, swordsPreparationMode = false, fistsPreparationMode = false, pickaxePreparationMode = false, axePreparationMode = false, skullSplitterMode, berserkMode;
|
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
|
/* Timestamps */
|
||||||
//ATS = (Time of) Activation Time Stamp
|
private int xpGainATS = 0;
|
||||||
//DATS = (Time of) Deactivation Time Stamp
|
private int recentlyHurt = 0;
|
||||||
private int xpGainATS = 0, recentlyHurt = 0, respawnATS, hoePreparationATS, shovelPreparationATS, swordsPreparationATS, fistsPreparationATS, axePreparationATS, pickaxePreparationATS;
|
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
|
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
||||||
private int xpbarinc=0, lastlogin=0, userid = 0, bleedticks = 0;
|
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 playerName;
|
||||||
|
private String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
||||||
|
|
||||||
//Time to HashMap this shiz
|
public PlayerProfile(String name) {
|
||||||
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)
|
|
||||||
{
|
|
||||||
hud = LoadProperties.defaulthud;
|
hud = LoadProperties.defaulthud;
|
||||||
//Setup the HashMap for ability DATS
|
playerName = name;
|
||||||
for(AbilityType abilityType : AbilityType.values())
|
|
||||||
{
|
for (AbilityType abilityType : AbilityType.values()) {
|
||||||
skillsDATS.put(abilityType, 0);
|
skillsDATS.put(abilityType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Setup the HashMap for the skills
|
for (SkillType skillType : SkillType.values()) {
|
||||||
for(SkillType skillType : SkillType.values())
|
if (skillType != SkillType.ALL) {
|
||||||
{
|
|
||||||
if(skillType != SkillType.ALL)
|
|
||||||
{
|
|
||||||
skills.put(skillType, 0);
|
skills.put(skillType, 0);
|
||||||
skillsXp.put(skillType, 0);
|
skillsXp.put(skillType, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
playerName = name;
|
if (LoadProperties.useMySQL) {
|
||||||
if (LoadProperties.useMySQL)
|
if (!loadMySQL()) {
|
||||||
{
|
|
||||||
if(!loadMySQL()) {
|
|
||||||
addMySQLPlayer();
|
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();}
|
|
||||||
}
|
}
|
||||||
lastlogin = ((Long) (System.currentTimeMillis()/1000)).intValue();
|
else if (!load()) {
|
||||||
|
addPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerProfile(String name, boolean addNew)
|
lastlogin = ((Long) (System.currentTimeMillis() / 1000)).intValue();
|
||||||
{
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
hud = LoadProperties.defaulthud;
|
||||||
//Setup the HashMap for ability DATS
|
playerName = name;
|
||||||
for(AbilityType abilityType : AbilityType.values())
|
|
||||||
{
|
for (AbilityType abilityType : AbilityType.values()) {
|
||||||
skillsDATS.put(abilityType, 0);
|
skillsDATS.put(abilityType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Setup the HashMap for the skills
|
for (SkillType skillType : SkillType.values()) {
|
||||||
for(SkillType skillType : SkillType.values())
|
if (skillType != SkillType.ALL) {
|
||||||
{
|
|
||||||
if(skillType != SkillType.ALL)
|
|
||||||
{
|
|
||||||
skills.put(skillType, 0);
|
skills.put(skillType, 0);
|
||||||
skillsXp.put(skillType, 0);
|
skillsXp.put(skillType, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
playerName = name;
|
if (LoadProperties.useMySQL) {
|
||||||
if (LoadProperties.useMySQL)
|
if (!loadMySQL() && addNew) {
|
||||||
{
|
|
||||||
if(!loadMySQL() && addNew) {
|
|
||||||
addMySQLPlayer();
|
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; }
|
|
||||||
}
|
}
|
||||||
lastlogin = ((Long) (System.currentTimeMillis()/1000)).intValue();
|
else if (!load() && addNew) {
|
||||||
|
addPlayer();
|
||||||
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLastLogin()
|
lastlogin = ((Long) (System.currentTimeMillis() / 1000)).intValue();
|
||||||
{
|
|
||||||
return lastlogin;
|
|
||||||
}
|
|
||||||
public int getMySQLuserId()
|
|
||||||
{
|
|
||||||
return userid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadMySQL()
|
public boolean loadMySQL() {
|
||||||
{
|
|
||||||
Integer id = 0;
|
Integer id = 0;
|
||||||
id = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
|
id = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
|
||||||
if(id == 0)
|
if(id == 0)
|
||||||
@ -204,6 +205,7 @@ public class PlayerProfile {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMySQLPlayer() {
|
public void addMySQLPlayer() {
|
||||||
Integer id = 0;
|
Integer id = 0;
|
||||||
mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
|
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
|
//This will reset everything to default values and then save the information to FlatFile/MySQL
|
||||||
for(SkillType skillType : SkillType.values())
|
for (SkillType skillType : SkillType.values()) {
|
||||||
{
|
if (skillType != SkillType.ALL) {
|
||||||
if(skillType == SkillType.ALL)
|
|
||||||
continue;
|
|
||||||
skills.put(skillType, 0);
|
skills.put(skillType, 0);
|
||||||
skillsXp.put(skillType, 0);
|
skillsXp.put(skillType, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(AbilityType abilityType : AbilityType.values())
|
for (AbilityType abilityType : AbilityType.values()) {
|
||||||
{
|
|
||||||
skillsDATS.put(abilityType, 0);
|
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());
|
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;
|
return loaded;
|
||||||
}
|
}
|
||||||
public boolean getPartyHUD()
|
|
||||||
{
|
/*
|
||||||
return partyhud;
|
* God Mode
|
||||||
}
|
*/
|
||||||
public void toggleSpoutEnabled()
|
|
||||||
{
|
public boolean getGodMode() {
|
||||||
spoutcraft = !spoutcraft;
|
return godMode;
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAdminChatMode() {return adminChatMode;}
|
public void toggleGodMode() {
|
||||||
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()
|
|
||||||
{
|
|
||||||
godMode = !godMode;
|
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;
|
partyChatMode = !partyChatMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayer(String player)
|
public boolean getPartyChatOnlyToggle() {
|
||||||
{
|
return partyChatOnly;
|
||||||
return player.equals(Bukkit.getPlayer(playerName));
|
|
||||||
}
|
}
|
||||||
public boolean getPartyChatOnlyToggle(){return partyChatOnly;}
|
|
||||||
public void togglePartyChatOnly(){partyChatOnly = !partyChatOnly;}
|
public void togglePartyChatOnly() {
|
||||||
public boolean getAbilityUse(){
|
partyChatOnly = !partyChatOnly;
|
||||||
return abilityuse;
|
|
||||||
}
|
}
|
||||||
public void toggleAbilityUse()
|
|
||||||
{
|
/*
|
||||||
abilityuse = !abilityuse;
|
* Bleed Stuff
|
||||||
}
|
*/
|
||||||
public void decreaseBleedTicks()
|
|
||||||
{
|
public void decreaseBleedTicks() {
|
||||||
bleedticks--;
|
bleedticks--;
|
||||||
}
|
}
|
||||||
public Integer getBleedTicks(){
|
|
||||||
|
public int getBleedTicks() {
|
||||||
return bleedticks;
|
return bleedticks;
|
||||||
}
|
}
|
||||||
public void setBleedTicks(Integer newvalue){
|
|
||||||
bleedticks = newvalue;
|
|
||||||
|
|
||||||
//Cap maximum ticks at 10
|
public void resetBleedTicks() {
|
||||||
if(bleedticks > 10)
|
bleedticks = 0;
|
||||||
bleedticks = 10;
|
|
||||||
}
|
}
|
||||||
public void addBleedTicks(Integer newvalue){
|
|
||||||
bleedticks+=newvalue;
|
|
||||||
|
|
||||||
//Cap maximum ticks at 10
|
public void addBleedTicks(int newvalue){
|
||||||
if(bleedticks > 10)
|
bleedticks += newvalue;
|
||||||
bleedticks = 10;
|
|
||||||
|
if (bleedticks > MAX_BLEED_TICKS) {
|
||||||
|
bleedticks = MAX_BLEED_TICKS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EXPLOIT PREVENTION
|
* Exploit Prevention
|
||||||
*/
|
*/
|
||||||
public long getRespawnATS() {return respawnATS;}
|
|
||||||
public void setRespawnATS(long newvalue) {respawnATS = (int) (newvalue/1000);}
|
public long getRespawnATS() {
|
||||||
|
return respawnATS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRespawnATS(long newvalue) {
|
||||||
|
respawnATS = (int) (newvalue / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TOOLS
|
* Tools
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -721,28 +756,7 @@ public class PlayerProfile {
|
|||||||
* @return the ATS for the tool
|
* @return the ATS for the tool
|
||||||
*/
|
*/
|
||||||
public long getToolPreparationATS(ToolType tool) {
|
public long getToolPreparationATS(ToolType tool) {
|
||||||
switch (tool) {
|
return skillsDATS.get(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -752,38 +766,12 @@ public class PlayerProfile {
|
|||||||
* @param ATS the ATS of the tool
|
* @param ATS the ATS of the tool
|
||||||
*/
|
*/
|
||||||
public void setToolPreparationATS(ToolType tool, long ATS) {
|
public void setToolPreparationATS(ToolType tool, long ATS) {
|
||||||
switch (tool) {
|
int startTime = (int) (ATS / 1000);
|
||||||
case AXE:
|
toolATS.put(tool, startTime);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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(){
|
public long getRecentlyHurt() {
|
||||||
return recentlyHurt;
|
return recentlyHurt;
|
||||||
}
|
}
|
||||||
public void setRecentlyHurt(long newvalue){
|
|
||||||
recentlyHurt = (int) (newvalue/1000);
|
public void setRecentlyHurt(long newvalue) {
|
||||||
|
recentlyHurt = (int) (newvalue / 1000);
|
||||||
}
|
}
|
||||||
public void skillUp(SkillType skillType, int newvalue)
|
|
||||||
{
|
/*
|
||||||
skills.put(skillType, skills.get(skillType)+newvalue);
|
* Cooldowns
|
||||||
}
|
*/
|
||||||
public Integer getSkillLevel(SkillType skillType)
|
|
||||||
{
|
/**
|
||||||
return skills.get(skillType);
|
* Get the current DATS of a skill.
|
||||||
}
|
*
|
||||||
public Integer getSkillXpLevel(SkillType skillType)
|
* @param abilityType Ability to get the DATS for
|
||||||
{
|
* @return the DATS for the ability
|
||||||
return skillsXp.get(skillType);
|
*/
|
||||||
}
|
public long getSkillDATS(AbilityType abilityType) {
|
||||||
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;
|
|
||||||
return skillsDATS.get(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);
|
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);
|
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
|
* Adds XP to the player, doesn't calculate for XP Rate
|
||||||
*
|
*
|
||||||
@ -1091,40 +1099,6 @@ public class PlayerProfile {
|
|||||||
lastgained = skillType;
|
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.
|
* Modify a skill level.
|
||||||
*
|
*
|
||||||
@ -1150,8 +1124,6 @@ public class PlayerProfile {
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add levels to a skill.
|
* Add levels to a skill.
|
||||||
*
|
*
|
||||||
@ -1177,8 +1149,6 @@ public class PlayerProfile {
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of XP remaining before the next level.
|
* 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?
|
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) {
|
public void setParty(String newParty) {
|
||||||
party = newParty;
|
party = newParty;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retrieve the player's party
|
public String getParty() {
|
||||||
public String getParty() {return party;}
|
return party;
|
||||||
//Remove party
|
}
|
||||||
|
|
||||||
public void removeParty() {
|
public void removeParty() {
|
||||||
party = null;
|
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")) {
|
||||||
if(party != null && !party.equals("") && !party.equals("null")){
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return false;
|
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);
|
Archery.arrowRetrievalCheck(x, plugin);
|
||||||
|
|
||||||
if (x instanceof Player) {
|
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) {
|
public static void XpCheckSkill(SkillType skillType, Player player) {
|
||||||
PlayerProfile PP = Users.getProfile(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;
|
int skillups = 0;
|
||||||
|
|
||||||
while (PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) {
|
while (skillXpLevel >= xpToNextLevel) {
|
||||||
if (skillType.getMaxLevel() >= PP.getSkillLevel(skillType) + 1) {
|
if (skillType.getMaxLevel() >= PP.getSkillLevel(skillType) + 1) {
|
||||||
skillups++;
|
skillups++;
|
||||||
PP.removeXP(skillType, PP.getXpToLevel(skillType));
|
PP.addLevels(skillType, 1);
|
||||||
PP.skillUp(skillType, 1);
|
|
||||||
|
|
||||||
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType);
|
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType);
|
||||||
Bukkit.getPluginManager().callEvent(eventToFire);
|
Bukkit.getPluginManager().callEvent(eventToFire);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PP.removeXP(skillType, PP.getXpToLevel(skillType));
|
PP.addLevels(skillType, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class Taming {
|
|||||||
Player target = (Player) entity;
|
Player target = (Player) entity;
|
||||||
|
|
||||||
target.sendMessage(mcLocale.getString("Combat.StruckByGore"));
|
target.sendMessage(mcLocale.getString("Combat.StruckByGore"));
|
||||||
Users.getProfile(target).setBleedTicks(2);
|
Users.getProfile(target).addBleedTicks(2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcBleedTimer.add((LivingEntity) entity);
|
mcBleedTimer.add((LivingEntity) entity);
|
||||||
|
Loading…
Reference in New Issue
Block a user