mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-01 05:04:43 +02:00
More work on McMMOPlayer
This commit is contained in:
224
src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java
Normal file
224
src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java
Normal file
@ -0,0 +1,224 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McMMOPlayer {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
|
||||
public McMMOPlayer (Player player) {
|
||||
this.player = player;
|
||||
this.profile = new PlayerProfile(player, true);
|
||||
this.party = PartyManager.getInstance().getPlayerParty(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of this player.
|
||||
*
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the party bonus multiplier
|
||||
*/
|
||||
private double calculatePartyXPModifier(SkillType skillType) {
|
||||
double bonusModifier = 0.0;
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (party.getLeader().equals(member.getName())) {
|
||||
if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
||||
PlayerProfile partyLeader = Users.getProfile(member);
|
||||
int leaderSkill = partyLeader.getSkillLevel(skillType);
|
||||
int playerSkill = profile.getSkillLevel(skillType);
|
||||
|
||||
if (leaderSkill >= playerSkill) {
|
||||
int difference = leaderSkill - playerSkill;
|
||||
bonusModifier = (difference * 0.75) / 100.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bonusModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, doesn't calculate for XP Rate
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverride(SkillType skillType, int xp) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, type, xp));
|
||||
profile.setSkillXPLevel(type, profile.getSkillXpLevel(type) + xp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
profile.setLastGained(skillType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this ignores skill modifiers.
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverrideBonus(SkillType skillType, int xp) {
|
||||
int modifiedXp = xp * Config.getInstance().xpGainMultiplier;
|
||||
addXPOverride(skillType, modifiedXp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newvalue The amount of XP to add
|
||||
*/
|
||||
public void addXP(SkillType skillType, int newValue) {
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double bonusModifier = 0;
|
||||
|
||||
if (inParty()) {
|
||||
bonusModifier = calculatePartyXPModifier(skillType);
|
||||
}
|
||||
|
||||
int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
|
||||
|
||||
if (bonusModifier > 0) {
|
||||
if (bonusModifier >= 2) {
|
||||
bonusModifier = 2;
|
||||
}
|
||||
|
||||
double trueBonus = bonusModifier * xp;
|
||||
xp += trueBonus;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
|
||||
if (tool != null) {
|
||||
xp = (int) (xp * tool.getXpMultiplier());
|
||||
}
|
||||
}
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
xp = xp * 4;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
xp = xp * 3;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
xp = (int) (xp * 2.5);
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
xp = xp * 2;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||
xp = (int) (xp * 1.5);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
profile.setLastGained(skillType);
|
||||
}
|
||||
|
||||
// Players & Profiles
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public PlayerProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
// Party Stuff
|
||||
|
||||
public void setInvite(Party invite) {
|
||||
this.invite = invite;
|
||||
}
|
||||
|
||||
public Party getInvite() {
|
||||
return invite;
|
||||
}
|
||||
|
||||
public boolean hasPartyInvite() {
|
||||
if (invite != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setParty(Party party) {
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
public Party getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
public boolean inParty() {
|
||||
if (party != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeParty() {
|
||||
party = null;
|
||||
}
|
||||
|
||||
public void removeInvite() {
|
||||
invite = null;
|
||||
}
|
||||
}
|
@ -7,29 +7,20 @@ import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PlayerProfile {
|
||||
|
||||
/* HUD */
|
||||
private SpoutHud spoutHud;
|
||||
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
|
||||
private SkillType lastGained;
|
||||
private SkillType skillLock;
|
||||
|
||||
/* Party Stuff */
|
||||
private Party party;
|
||||
@ -37,7 +28,7 @@ public class PlayerProfile {
|
||||
|
||||
/* Toggles */
|
||||
private boolean loaded;
|
||||
private boolean xpBarLocked;
|
||||
|
||||
private boolean placedAnvil;
|
||||
private boolean partyChatMode, adminChatMode;
|
||||
private boolean godMode;
|
||||
@ -55,17 +46,17 @@ public class PlayerProfile {
|
||||
/* mySQL STUFF */
|
||||
private int userId;
|
||||
|
||||
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
||||
private 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 Player player;
|
||||
private OfflinePlayer player;
|
||||
private String playerName;
|
||||
private final static String location = mcMMO.usersFile;
|
||||
|
||||
public PlayerProfile(OfflinePlayer offlinePlayer, boolean addNew) {
|
||||
this.player = player.getPlayer();
|
||||
public PlayerProfile(OfflinePlayer player, boolean addNew) {
|
||||
this.player = player;
|
||||
this.playerName = player.getName();
|
||||
|
||||
party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||
@ -93,9 +84,9 @@ public class PlayerProfile {
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
// public Player getPlayer() {
|
||||
// return player;
|
||||
// }
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
@ -119,9 +110,9 @@ public class PlayerProfile {
|
||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "huds (user_id) VALUES (" + userId + ")");
|
||||
}
|
||||
else {
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equals(huds.get(1).get(0))) {
|
||||
this.hudType = hudType;
|
||||
for (HudType type : HudType.values()) {
|
||||
if (type.toString().equals(huds.get(1).get(0))) {
|
||||
spoutHud.setHudType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -259,9 +250,9 @@ public class PlayerProfile {
|
||||
if (character.length > 32)
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
||||
if (character.length > 33) {
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equalsIgnoreCase(character[33])) {
|
||||
this.hudType = hudType;
|
||||
for (HudType type : HudType.values()) {
|
||||
if (type.toString().equalsIgnoreCase(character[33])) {
|
||||
spoutHud.setHudType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,7 +281,7 @@ public class PlayerProfile {
|
||||
|
||||
// if we are using mysql save to database
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId);
|
||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "huds SET hudtype = '" + spoutHud.getHudType().toString() + "' WHERE user_id = " + userId);
|
||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + userId);
|
||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "cooldowns SET "
|
||||
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
||||
@ -384,7 +375,7 @@ public class PlayerProfile {
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER)) + ":");
|
||||
writer.append(hudType.toString() + ":");
|
||||
writer.append(spoutHud.getHudType().toString() + ":");
|
||||
writer.append(skills.get(SkillType.FISHING) + ":");
|
||||
writer.append(skillsXp.get(SkillType.FISHING) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING)) + ":");
|
||||
@ -498,14 +489,6 @@ public class PlayerProfile {
|
||||
* HUD Stuff
|
||||
*/
|
||||
|
||||
public HudType getHudType() {
|
||||
return hudType;
|
||||
}
|
||||
|
||||
public void setHudType(HudType hudType) {
|
||||
this.hudType = hudType;
|
||||
}
|
||||
|
||||
public SpoutHud getSpoutHud() {
|
||||
return spoutHud;
|
||||
}
|
||||
@ -515,31 +498,39 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void setXpBarLocked(boolean locked) {
|
||||
xpBarLocked = locked;
|
||||
spoutHud.setXpBarLocked(locked);
|
||||
}
|
||||
|
||||
public boolean getXpBarLocked() {
|
||||
return xpBarLocked;
|
||||
return spoutHud.getXpBarLocked();
|
||||
}
|
||||
|
||||
public void toggleXpBarLocked() {
|
||||
xpBarLocked = !xpBarLocked;
|
||||
spoutHud.toggleXpBarLocked();
|
||||
}
|
||||
|
||||
public void setSkillLock(SkillType newvalue) {
|
||||
skillLock = newvalue;
|
||||
public void setSkillLock(SkillType type) {
|
||||
spoutHud.setSkillLock(type);
|
||||
}
|
||||
|
||||
public SkillType getSkillLock() {
|
||||
return skillLock;
|
||||
return spoutHud.getSkillLock();
|
||||
}
|
||||
|
||||
public void setLastGained(SkillType newvalue) {
|
||||
lastGained = newvalue;
|
||||
public HudType getHudType() {
|
||||
return spoutHud.getHudType();
|
||||
}
|
||||
|
||||
public void setHudType(HudType type) {
|
||||
spoutHud.setHudType(type);
|
||||
}
|
||||
|
||||
public void setLastGained(SkillType type) {
|
||||
spoutHud.setLastGained(type);
|
||||
}
|
||||
|
||||
public SkillType getLastGained() {
|
||||
return lastGained;
|
||||
return spoutHud.getLastGained();
|
||||
}
|
||||
|
||||
public void updateXpBar() {
|
||||
@ -928,99 +919,99 @@ public class PlayerProfile {
|
||||
skills.put(skillType, skills.get(skillType) + newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, doesn't calculate for XP Rate
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverride(SkillType skillType, int newValue) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType x : SkillType.values()) {
|
||||
if (x.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
// /**
|
||||
// * Adds XP to the player, doesn't calculate for XP Rate
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newValue The amount of XP to add
|
||||
// */
|
||||
// public void addXPOverride(SkillType skillType, int newValue) {
|
||||
// if (skillType.equals(SkillType.ALL)) {
|
||||
// for (SkillType x : SkillType.values()) {
|
||||
// if (x.equals(SkillType.ALL)) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
||||
// skillsXp.put(x, skillsXp.get(x) + newValue);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
||||
// skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
|
||||
// spoutHud.setLastGained(skillType);
|
||||
// }
|
||||
// }
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
||||
skillsXp.put(x, skillsXp.get(x) + newValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
|
||||
lastGained = skillType;
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * Adds XP to the player, this ignores skill modifiers.
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newValue The amount of XP to add
|
||||
// */
|
||||
// public void addXPOverrideBonus(SkillType skillType, int newValue) {
|
||||
// int xp = newValue * Config.getInstance().xpGainMultiplier;
|
||||
// addXPOverride(skillType, xp);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this ignores skill modifiers.
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverrideBonus(SkillType skillType, int newValue) {
|
||||
int xp = newValue * Config.getInstance().xpGainMultiplier;
|
||||
addXPOverride(skillType, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newvalue The amount of XP to add
|
||||
*/
|
||||
public void addXP(SkillType skillType, int newValue) {
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double bonusModifier = 0;
|
||||
|
||||
if (inParty()) {
|
||||
bonusModifier = partyModifier(skillType);
|
||||
}
|
||||
|
||||
int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
|
||||
|
||||
if (bonusModifier > 0) {
|
||||
if (bonusModifier >= 2) {
|
||||
bonusModifier = 2;
|
||||
}
|
||||
|
||||
double trueBonus = bonusModifier * xp;
|
||||
xp += trueBonus;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
|
||||
if (tool != null) {
|
||||
xp = (int) (xp * tool.getXpMultiplier());
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Can we make this so we do perks by doing "mcmmo.perks.xp.[multiplier]" ?
|
||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
xp = xp * 4;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
xp = xp * 3;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
xp = (int) (xp * 2.5);
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
xp = xp * 2;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||
xp = (int) (xp * 1.5);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
||||
lastGained = skillType;
|
||||
}
|
||||
// /**
|
||||
// * Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newvalue The amount of XP to add
|
||||
// */
|
||||
// public void addXP(SkillType skillType, int newValue) {
|
||||
// if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// double bonusModifier = 0;
|
||||
//
|
||||
// if (inParty()) {
|
||||
// bonusModifier = partyModifier(skillType);
|
||||
// }
|
||||
//
|
||||
// int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
|
||||
//
|
||||
// if (bonusModifier > 0) {
|
||||
// if (bonusModifier >= 2) {
|
||||
// bonusModifier = 2;
|
||||
// }
|
||||
//
|
||||
// double trueBonus = bonusModifier * xp;
|
||||
// xp += trueBonus;
|
||||
// }
|
||||
//
|
||||
// if (Config.getInstance().getToolModsEnabled()) {
|
||||
// ItemStack item = player.getItemInHand();
|
||||
// CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
//
|
||||
// if (tool != null) {
|
||||
// xp = (int) (xp * tool.getXpMultiplier());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //TODO: Can we make this so we do perks by doing "mcmmo.perks.xp.[multiplier]" ?
|
||||
// if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
// xp = xp * 4;
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
// xp = xp * 3;
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
// xp = (int) (xp * 2.5);
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
// xp = xp * 2;
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||
// xp = (int) (xp * 1.5);
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
// skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
||||
// spoutHud.setLastGained(skillType);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Remove XP from a skill.
|
||||
@ -1096,52 +1087,52 @@ public class PlayerProfile {
|
||||
* @return the XP remaining until next level
|
||||
*/
|
||||
public int getXpToLevel(SkillType skillType) {
|
||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve()); //Do we REALLY need to cast to int here?
|
||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of a player.
|
||||
*
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
// /**
|
||||
// * Gets the power level of a player.
|
||||
// *
|
||||
// * @return the power level of the player
|
||||
// */
|
||||
// public int getPowerLevel() {
|
||||
// int powerLevel = 0;
|
||||
//
|
||||
// for (SkillType type : SkillType.values()) {
|
||||
// if (type.getPermissions(player)) {
|
||||
// powerLevel += getSkillLevel(type);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return powerLevel;
|
||||
// }
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the party bonus multiplier
|
||||
*/
|
||||
private double partyModifier(SkillType skillType) {
|
||||
double bonusModifier = 0.0;
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (party.getLeader().equals(member.getName())) {
|
||||
if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
||||
PlayerProfile PartyLeader = Users.getProfile(member);
|
||||
int leaderSkill = PartyLeader.getSkillLevel(skillType);
|
||||
int playerSkill = getSkillLevel(skillType);
|
||||
|
||||
if (leaderSkill >= playerSkill) {
|
||||
int difference = leaderSkill - playerSkill;
|
||||
bonusModifier = (difference * 0.75) / 100.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bonusModifier;
|
||||
}
|
||||
// /**
|
||||
// * Calculate the party XP modifier.
|
||||
// *
|
||||
// * @param skillType Type of skill to check
|
||||
// * @return the party bonus multiplier
|
||||
// */
|
||||
// private double partyModifier(SkillType skillType) {
|
||||
// double bonusModifier = 0.0;
|
||||
//
|
||||
// for (Player member : party.getOnlineMembers()) {
|
||||
// if (party.getLeader().equals(member.getName())) {
|
||||
// if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
||||
// PlayerProfile PartyLeader = Users.getProfile(member);
|
||||
// int leaderSkill = PartyLeader.getSkillLevel(skillType);
|
||||
// int playerSkill = getSkillLevel(skillType);
|
||||
//
|
||||
// if (leaderSkill >= playerSkill) {
|
||||
// int difference = leaderSkill - playerSkill;
|
||||
// bonusModifier = (difference * 0.75) / 100.0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return bonusModifier;
|
||||
// }
|
||||
|
||||
/*
|
||||
* Party Stuff
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -8,13 +9,20 @@ import com.gmail.nossr50.datatypes.popups.Menu;
|
||||
import com.gmail.nossr50.datatypes.popups.XpBar;
|
||||
|
||||
public class SpoutHud {
|
||||
private PlayerProfile playerProfile;
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
|
||||
private SkillType lastGained;
|
||||
private SkillType skillLock;
|
||||
private boolean xpBarLocked;
|
||||
|
||||
private Menu menu;
|
||||
private XpBar xpBar;
|
||||
|
||||
public SpoutHud(PlayerProfile playerProfile) {
|
||||
this.playerProfile = playerProfile;
|
||||
public SpoutHud(McMMOPlayer mcMMOPlayer) {
|
||||
this.player = mcMMOPlayer.getPlayer();
|
||||
this.profile = mcMMOPlayer.getProfile();
|
||||
|
||||
initializeXpBar();
|
||||
}
|
||||
@ -28,7 +36,7 @@ public class SpoutHud {
|
||||
xpBar.removeWidgets();
|
||||
}
|
||||
|
||||
xpBar = new XpBar(SpoutManager.getPlayer(playerProfile.getPlayer()), playerProfile.getHudType());
|
||||
xpBar = new XpBar(SpoutManager.getPlayer(player), hudType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,13 +44,13 @@ public class SpoutHud {
|
||||
* Update the XP bar.
|
||||
*/
|
||||
public void updateXpBar() {
|
||||
SkillType skillType = playerProfile.getXpBarLocked() ? playerProfile.getSkillLock() : playerProfile.getLastGained();
|
||||
SkillType skillType = xpBarLocked ? skillLock : lastGained;
|
||||
|
||||
if (skillType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
xpBar.update(skillType, playerProfile);
|
||||
xpBar.update(skillType, profile);
|
||||
}
|
||||
|
||||
public boolean isMenuOpened() {
|
||||
@ -50,7 +58,7 @@ public class SpoutHud {
|
||||
}
|
||||
|
||||
public void openMenu() {
|
||||
menu = new Menu(SpoutManager.getPlayer(playerProfile.getPlayer()), playerProfile);
|
||||
menu = new Menu(SpoutManager.getPlayer(player), profile);
|
||||
}
|
||||
|
||||
public void onMenuClose() {
|
||||
@ -62,6 +70,42 @@ public class SpoutHud {
|
||||
menu.close();
|
||||
}
|
||||
|
||||
SpoutManager.getPlayer(playerProfile.getPlayer()).getMainScreen().removeWidgets(mcMMO.p);
|
||||
SpoutManager.getPlayer(player).getMainScreen().removeWidgets(mcMMO.p);
|
||||
}
|
||||
|
||||
public HudType getHudType() {
|
||||
return hudType;
|
||||
}
|
||||
|
||||
public void setHudType(HudType type) {
|
||||
this.hudType = type;
|
||||
}
|
||||
|
||||
public SkillType getLastGained() {
|
||||
return lastGained;
|
||||
}
|
||||
|
||||
public void setLastGained(SkillType type) {
|
||||
this.lastGained = type;
|
||||
}
|
||||
|
||||
public boolean getXpBarLocked() {
|
||||
return xpBarLocked;
|
||||
}
|
||||
|
||||
public void setXpBarLocked(boolean locked) {
|
||||
this.xpBarLocked = locked;
|
||||
}
|
||||
|
||||
public void toggleXpBarLocked() {
|
||||
xpBarLocked = !xpBarLocked;
|
||||
}
|
||||
|
||||
public SkillType getSkillLock() {
|
||||
return skillLock;
|
||||
}
|
||||
|
||||
public void setSkillLock(SkillType type) {
|
||||
this.skillLock = type;
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.popups;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.InGameHUD;
|
||||
@ -22,7 +21,7 @@ public class Menu extends GenericPopup {
|
||||
private static int centerX = 427 / 2;
|
||||
private static int centerY = 240 / 2;
|
||||
|
||||
public Menu(SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) {
|
||||
public Menu(final SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) {
|
||||
//240, 427 are the bottom right
|
||||
titleLabel.setText(ChatColor.GOLD + "~mcMMO Menu~"); //TODO: Needs more locale
|
||||
titleLabel.setWidth(100);
|
||||
@ -63,7 +62,7 @@ public class Menu extends GenericPopup {
|
||||
escapeButton.connect(new Slot() {
|
||||
@Override
|
||||
public void activate() {
|
||||
SpoutManager.getPlayer(playerProfile.getPlayer()).getMainScreen().closePopup();
|
||||
spoutPlayer.getMainScreen().closePopup();
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user