Reworked some Spout stuff

among other things
This commit is contained in:
bm01
2012-07-01 04:48:23 +02:00
parent c45beec59d
commit 54e21333a3
22 changed files with 629 additions and 780 deletions

View File

@ -1,8 +1,12 @@
package com.gmail.nossr50.datatypes;
public enum HUDType {
public enum HudType {
DISABLED,
STANDARD,
SMALL,
RETRO;
public HudType getNext() {
return values()[(ordinal() + 1) % values().length];
}
}

View File

@ -1,417 +0,0 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.gui.GenericGradient;
import org.getspout.spoutapi.gui.GenericTexture;
import org.getspout.spoutapi.gui.RenderPriority;
import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class HUDmmo {
private int center_x = 427 / 2;
private String playerName;
private final mcMMO plugin;
private Widget xpbar = null;
private GenericGradient xpfill = null;
private GenericGradient xpbg = null;
private GenericGradient xpicon_bg = null;
private GenericGradient xpicon_border = null;
private GenericTexture xpicon = null;
public HUDmmo(Player player, mcMMO plugin) {
this.playerName = player.getName();
this.plugin = plugin;
initializeHUD(player);
}
/**
* Initialize the HUD.
*
* @param player Player whose HUD to initialize
*/
public void initializeHUD(Player player) {
HUDType type = Users.getProfile(player).getHUDType();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
switch (type) {
case RETRO:
initializeXpBarDisplayRetro(sPlayer);
break;
case STANDARD:
initializeXpBarDisplayStandard(sPlayer);
break;
case SMALL:
initializeXpBarDisplaySmall(sPlayer);
break;
case DISABLED:
break;
default:
break;
}
}
/**
* Update the XP bar.
*
* @param type Type of XP bar
* @param player Player whose XP bar to update
*/
public void updateXpBarDisplay(HUDType type, Player player) {
PlayerProfile PP = Users.getProfile(player);
switch (type) {
case RETRO:
updateXpBarRetro(player, PP);
break;
case STANDARD:
updateXpBarStandard(player, PP);
break;
case SMALL:
updateXpBarStandard(player, PP);
break;
case DISABLED:
break;
default:
break;
}
}
/**
* Reset a player's HUD.
*/
public void resetHUD() {
SpoutPlayer sPlayer = SpoutStuff.getSpoutPlayer(playerName);
if (sPlayer != null) {
sPlayer.getMainScreen().removeWidgets(plugin);
//Reset the objects
xpbar = null;
xpfill = null;
xpbg = null;
xpicon = null;
sPlayer.getMainScreen().setDirty(true);
}
}
/**
* Initialize Retro XP bar.
*
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplayRetro(SpoutPlayer sPlayer) {
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
Color green = new Color(0f, 1f, 0f, 1f);
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpicon = new GenericTexture();
xpbar = new GenericGradient();
xpfill = new GenericGradient();
xpbg = new GenericGradient();
xpicon_bg = new GenericGradient();
xpicon_border = new GenericGradient();
xpicon_bg.setBottomColor(darkbg);
xpicon_bg.setTopColor(darkbg);
xpicon_bg.setWidth(4);
xpicon_bg.setHeight(4);
xpicon_bg.setPriority(RenderPriority.High);
xpicon_bg.setX(142);
xpicon_bg.setY(10);
xpicon_bg.setDirty(true);
xpicon_border.setBottomColor(border);
xpicon_border.setTopColor(border);
xpicon_border.setWidth(6);
xpicon_border.setHeight(6);
xpicon_border.setPriority(RenderPriority.Highest);
xpicon_border.setX(141);
xpicon_border.setY(9);
xpicon_border.setDirty(true);
xpicon.setWidth(6);
xpicon.setHeight(6);
xpicon.setX(141);
xpicon.setY(9);
xpicon.setPriority(RenderPriority.Normal);
xpicon.setDirty(true);
xpicon.setUrl("Icon_r.png");
xpbar.setWidth(128);
xpbar.setHeight(4);
xpbar.setX(149);
xpbar.setY(10);
((GenericGradient) xpbar).setBottomColor(border);
((GenericGradient) xpbar).setTopColor(border);
xpbar.setPriority(RenderPriority.Highest);
xpbar.setDirty(true);
xpfill.setWidth(0);
xpfill.setHeight(2);
xpfill.setX(150);
xpfill.setY(11);
xpfill.setBottomColor(green);
xpfill.setTopColor(green);
xpfill.setPriority(RenderPriority.Lowest);
xpfill.setDirty(true);
xpbg.setWidth(126);
xpbg.setHeight(2);
xpbg.setX(150);
xpbg.setY(11);
xpbg.setBottomColor(background);
xpbg.setTopColor(background);
xpbg.setPriority(RenderPriority.Low);
xpbg.setDirty(true);
if (SpoutConfig.getInstance().getXPBarEnabled()) {
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
sPlayer.getMainScreen().attachWidget(plugin, xpfill);
sPlayer.getMainScreen().attachWidget(plugin, xpbg);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_bg);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_border);
}
}
sPlayer.getMainScreen().setDirty(true);
}
/**
* Initialize Standard XP bar.
*
* @param sPlayer Player to initialize XP bar for
*/
public void initializeXpBarDisplayStandard(SpoutPlayer sPlayer) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
xpbar = new GenericTexture();
((GenericTexture) xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(SpoutConfig.getInstance().getXPBarXPosition());
xpbar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpbar.setHeight(8);
xpbar.setWidth(256);
xpbar.setPriority(RenderPriority.Lowest);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(16);
xpicon.setWidth(32);
xpicon.setX(SpoutConfig.getInstance().getXPIconXPosition());
xpicon.setY(SpoutConfig.getInstance().getXPIconYPosition());
xpicon.setPriority(RenderPriority.High);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
}
}
sPlayer.getMainScreen().setDirty(true);
}
/**
* Initialize Small XP bar.
*
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplaySmall(SpoutPlayer sPlayer) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
xpbar = new GenericTexture();
((GenericTexture)xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(center_x - 64);
xpbar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpbar.setHeight(4);
xpbar.setWidth(128);
xpbar.setPriority(RenderPriority.Lowest);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(8);
xpicon.setWidth(16);
xpicon.setX(center_x - (8 + 64));
xpicon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
xpicon.setPriority(RenderPriority.High);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
}
}
sPlayer.getMainScreen().setDirty(true);
}
/**
* Update XP bar for Standard & Small styles.
*
* @param player Player whose XP bar to update
* @param PP Profile of the given player
*/
private void updateXpBarStandard(Player player, PlayerProfile PP) {
if (!SpoutConfig.getInstance().getXPBarEnabled()) {
return;
}
SkillType theType = getType(PP);
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
return;
}
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + ".png");
xpicon.setDirty(true);
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
xpbar.setDirty(true);
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
}
/**
* Update XP bar for Retro styles.
*
* @param player Player whose XP bar to update
* @param PP Profile of the given player
*/
private void updateXpBarRetro(Player player, PlayerProfile PP) {
if (!SpoutConfig.getInstance().getXPBarEnabled()) {
return;
}
SkillType theType = getType(PP);
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
return;
}
Color color = getRetroColor(theType);
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + "_r.png");
xpfill.setBottomColor(color);
xpfill.setTopColor(color);
xpfill.setWidth(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO));
xpfill.setDirty(true);
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
}
private static Color getRetroColor(SkillType type) {
switch (type) {
case ACROBATICS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
case ARCHERY:
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
case AXES:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
case EXCAVATION:
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
case HERBALISM:
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
case MINING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
case REPAIR:
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
case SWORDS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
case TAMING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
case UNARMED:
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
case WOODCUTTING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
case FISHING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);
}
}
private static String getUrlBar(Integer number) {
char[] num = number.toString().toCharArray();
switch (num.length) {
case 1:
return "xpbar_inc00" + number + ".png";
case 2:
return "xpbar_inc0" + number + ".png";
default:
return "xpbar_inc" + number + ".png";
}
}
private static Integer getXpInc(int skillxp, int xptolevel, HUDType hud) {
double percentage = (double) skillxp / xptolevel;
double inc;
switch (hud) {
case RETRO:
inc = 0.0079365079365079;
break;
case STANDARD:
inc = 0.0039370078740157;
break;
default:
return 1;
}
return (int) (percentage / inc);
}
private static SkillType getType(PlayerProfile PP) {
if (PP.getXpBarLocked()) {
return PP.getSkillLock();
}
else {
return PP.getLastGained();
}
}
}

View File

@ -25,9 +25,9 @@ import com.gmail.nossr50.util.Users;
public class PlayerProfile {
/* HUD */
private HUDType hud;
private int xpbarinc;
private SkillType lastgained;
private SpoutHud spoutHud;
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
private SkillType lastGained;
private SkillType skillLock;
/* Party Stuff */
@ -36,7 +36,7 @@ public class PlayerProfile {
/* Toggles */
private boolean loaded;
private boolean partyhud = true, spoutcraft, xpbarlocked;
private boolean xpBarLocked;
private boolean placedAnvil;
private boolean partyChatMode, adminChatMode;
private boolean godMode;
@ -45,14 +45,14 @@ public class PlayerProfile {
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
pickaxePreparationMode, axePreparationMode;
private boolean abilityuse = true;
private boolean abilityUse = true;
/* Timestamps */
private int recentlyHurt;
private int respawnATS;
/* mySQL STUFF */
private int userid;
private int userId;
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
@ -64,7 +64,6 @@ public class PlayerProfile {
private final static String location = mcMMO.usersFile;
public PlayerProfile(Player player, String playerName, boolean addNew) {
hud = SpoutConfig.getInstance().defaulthud;
this.player = player;
this.playerName = playerName;
@ -107,38 +106,33 @@ public class PlayerProfile {
}
public boolean loadMySQL() {
userid = mcMMO.database.getInt("SELECT id FROM " + Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
userId = mcMMO.database.getInt("SELECT id FROM " + Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
if (userid == 0) {
if (userId == 0) {
return false;
}
else {
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM " + Config.getInstance().getMySQLTablePrefix() + "huds WHERE user_id = " + userid);
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM " + Config.getInstance().getMySQLTablePrefix() + "huds WHERE user_id = " + userId);
if (huds.get(1) == null) {
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "huds (user_id) VALUES (" + userid + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "huds (user_id) VALUES (" + userId + ")");
}
else {
if (huds.get(1).get(0) != null) {
for (HUDType x : HUDType.values()) {
if (x.toString().equals(huds.get(1).get(0))) {
hud = x;
}
for (HudType hudType : HudType.values()) {
if (hudType.toString().equals(huds.get(1).get(0))) {
this.hudType = hudType;
}
}
else {
hud = SpoutConfig.getInstance().defaulthud;
}
}
/*
* I'm still learning MySQL, this is a fix for adding a new table
* its not pretty but it works
*/
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + Config.getInstance().getMySQLTablePrefix() + "cooldowns WHERE user_id = " + userid);
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + Config.getInstance().getMySQLTablePrefix() + "cooldowns WHERE user_id = " + userId);
if(cooldowns.get(1) == null) {
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userId + ")");
}
else {
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldowns.get(1).get(0)));
@ -151,7 +145,7 @@ public class PlayerProfile {
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldowns.get(1).get(7)));
}
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + userid);
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + userId);
skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0)));
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2)));
@ -164,7 +158,7 @@ public class PlayerProfile {
skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9)));
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11)));
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + userid);
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + userId);
skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0)));
skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
@ -184,10 +178,10 @@ public class PlayerProfile {
public void addMySQLPlayer() {
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 + ")");
userid = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "skills (user_id) VALUES (" + userid + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "experience (user_id) VALUES (" + userid + ")");
userId = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userId + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "skills (user_id) VALUES (" + userId + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "experience (user_id) VALUES (" + userId + ")");
}
public boolean load() {
@ -264,9 +258,9 @@ public class PlayerProfile {
if (character.length > 32)
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
if (character.length > 33) {
for (HUDType x : HUDType.values()) {
if (x.toString().equalsIgnoreCase(character[33])) {
hud = x;
for (HudType hudType : HudType.values()) {
if (hudType.toString().equalsIgnoreCase(character[33])) {
this.hudType = hudType;
}
}
}
@ -295,8 +289,8 @@ 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 = '" + hud.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() + "huds SET hudtype = '" + hudType.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)
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
@ -306,7 +300,7 @@ public class PlayerProfile {
+ ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
+ " WHERE user_id = " + userid);
+ " WHERE user_id = " + userId);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "skills SET "
+ " taming = " + skills.get(SkillType.TAMING)
+ ", mining = " + skills.get(SkillType.MINING)
@ -320,7 +314,7 @@ public class PlayerProfile {
+ ", axes = " + skills.get(SkillType.AXES)
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
+ ", fishing = " + skills.get(SkillType.FISHING)
+ " WHERE user_id = " + userid);
+ " WHERE user_id = " + userId);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "experience SET "
+ " taming = " + skillsXp.get(SkillType.TAMING)
+ ", mining = " + skillsXp.get(SkillType.MINING)
@ -334,7 +328,7 @@ public class PlayerProfile {
+ ", axes = " + skillsXp.get(SkillType.AXES)
+ ", acrobatics = " + skillsXp.get(SkillType.ACROBATICS)
+ ", fishing = " + skillsXp.get(SkillType.FISHING)
+ " WHERE user_id = " + userid);
+ " WHERE user_id = " + userId);
}
else {
// otherwise save to flatfile
@ -389,7 +383,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(hud.toString() + ":");
writer.append(hudType.toString() + ":");
writer.append(skills.get(SkillType.FISHING) + ":");
writer.append(skillsXp.get(SkillType.FISHING) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING)) + ":");
@ -449,7 +443,7 @@ public class PlayerProfile {
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(SpoutConfig.getInstance().defaulthud.toString() + ":");//HUD
out.append(SpoutConfig.getInstance().defaultHudType.toString() + ":");//HUD
out.append(0 + ":"); //Fishing
out.append(0 +":"); //FishingXP
out.append(0 + ":"); //Blast Mining
@ -468,7 +462,7 @@ public class PlayerProfile {
*/
public int getMySQLuserId() {
return userid;
return userId;
}
public boolean isLoaded() {
@ -503,45 +497,32 @@ public class PlayerProfile {
* HUD Stuff
*/
public void togglePartyHUD() {
partyhud = !partyhud;
public HudType getHudType() {
return hudType;
}
public boolean getPartyHUD() {
return partyhud;
public void setHudType(HudType hudType) {
this.hudType = hudType;
}
public void toggleSpoutEnabled() {
spoutcraft = !spoutcraft;
public SpoutHud getSpoutHud() {
return spoutHud;
}
public HUDType getHUDType() {
return hud;
}
public void setHUDType(HUDType type) {
hud = type;
save();
public void setSpoutHud(SpoutHud spoutHud) {
this.spoutHud = spoutHud;
}
public void setXpBarLocked(boolean locked) {
xpbarlocked = locked;
xpBarLocked = locked;
}
public boolean getXpBarLocked() {
return xpbarlocked;
return xpBarLocked;
}
public void toggleXpBarLocked() {
xpbarlocked = !xpbarlocked;
}
public int getXpBarInc() {
return xpbarinc;
}
public void setXpBarInc(int newvalue) {
xpbarinc = newvalue;
xpBarLocked = !xpBarLocked;
}
public void setSkillLock(SkillType newvalue) {
@ -553,11 +534,15 @@ public class PlayerProfile {
}
public void setLastGained(SkillType newvalue) {
lastgained = newvalue;
lastGained = newvalue;
}
public SkillType getLastGained() {
return lastgained;
return lastGained;
}
public void updateXpBar() {
spoutHud.updateXpBar();
}
/*
@ -853,11 +838,11 @@ public class PlayerProfile {
}
public boolean getAbilityUse() {
return abilityuse;
return abilityUse;
}
public void toggleAbilityUse() {
abilityuse = !abilityuse;
abilityUse = !abilityUse;
}
/*
@ -962,7 +947,7 @@ public class PlayerProfile {
else {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
lastgained = skillType;
lastGained = skillType;
}
}
@ -1033,7 +1018,7 @@ public class PlayerProfile {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
lastgained = skillType;
lastGained = skillType;
}
/**
@ -1101,8 +1086,6 @@ public class PlayerProfile {
skills.put(skillType, skills.get(skillType) + levels);
skillsXp.put(skillType, 0);
}
save();
}
/**

View File

@ -0,0 +1,67 @@
package com.gmail.nossr50.datatypes;
import org.getspout.spoutapi.SpoutManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.popups.Menu;
import com.gmail.nossr50.datatypes.popups.XpBar;
public class SpoutHud {
private PlayerProfile playerProfile;
private Menu menu;
private XpBar xpBar;
public SpoutHud(PlayerProfile playerProfile) {
this.playerProfile = playerProfile;
initializeXpBar();
}
/**
* Initialize the HUD.
*/
public void initializeXpBar() {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
if (xpBar != null) {
xpBar.removeWidgets();
}
xpBar = new XpBar(SpoutManager.getPlayer(playerProfile.getPlayer()), playerProfile.getHudType());
}
}
/**
* Update the XP bar.
*/
public void updateXpBar() {
SkillType skillType = playerProfile.getXpBarLocked() ? playerProfile.getSkillLock() : playerProfile.getLastGained();
if (skillType == null) {
return;
}
xpBar.update(skillType, playerProfile);
}
public boolean isMenuOpened() {
return (menu != null) ? true : false;
}
public void openMenu() {
menu = new Menu(SpoutManager.getPlayer(playerProfile.getPlayer()), playerProfile);
}
public void onMenuClose() {
menu = null;
}
public void removeWidgets() {
if (menu != null) {
menu.close();
}
SpoutManager.getPlayer(playerProfile.getPlayer()).getMainScreen().removeWidgets(mcMMO.p);
}
}

View File

@ -1,13 +0,0 @@
package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
public class ButtonEscape extends GenericButton {
public ButtonEscape() {
this.setText("EXIT");
this.setWidth(60);
this.setHeight(20);
this.setDirty(true);
}
}

View File

@ -1,14 +0,0 @@
package com.gmail.nossr50.datatypes.buttons;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class ButtonHUDStyle extends ButtonToggle {
public ButtonHUDStyle(PlayerProfile PP) {
super("HUD Type: ", PP.getHUDType().toString(), "Change your HUD style!"); //TODO: Needs more locale
}
public void updateText(PlayerProfile PP) {
super.updateText("HUD Type: ", PP.getHUDType().toString()); //TODO: Needs more locale
}
}

View File

@ -1,14 +0,0 @@
package com.gmail.nossr50.datatypes.buttons;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class ButtonPartyToggle extends ButtonToggle {
public ButtonPartyToggle(PlayerProfile PP) {
super("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString(), "Toggle the Party HUD!"); //TODO: Needs more locale
}
public void updateText(PlayerProfile PP) {
super.updateText("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString()); //TODO: Needs more locale
}
}

View File

@ -1,19 +0,0 @@
package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
public class ButtonToggle extends GenericButton{
public ButtonToggle(String text1, String text2, String tooltip) {
this.setText(text1 + text2);
this.setTooltip(tooltip);
this.setWidth(120);
this.setHeight(20);
this.setDirty(true);
}
public void updateText(String text1, String text2) {
this.setText(text1 + text2);
this.setDirty(true);
}
}

View File

@ -0,0 +1,24 @@
package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
public class McmmoButton extends GenericButton {
private Slot slot;
public McmmoButton(String text, String toolTip) {
this.setText(text);
this.setTooltip(toolTip);
}
public void connect(Slot slot) {
this.slot = slot;
}
public void activate() {
slot.activate();
}
public interface Slot {
public void activate();
}
}

View File

@ -0,0 +1,80 @@
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;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HudType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SpoutHud;
import com.gmail.nossr50.datatypes.buttons.McmmoButton;
import com.gmail.nossr50.datatypes.buttons.McmmoButton.Slot;
public class Menu extends GenericPopup {
private McmmoButton hudButton;
private McmmoButton escapeButton;
private GenericLabel titleLabel = new GenericLabel();
private GenericLabel escapeLabel = new GenericLabel();
private static int centerX = 427 / 2;
private static int centerY = 240 / 2;
public Menu(SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) {
//240, 427 are the bottom right
titleLabel.setText(ChatColor.GOLD + "~mcMMO Menu~"); //TODO: Needs more locale
titleLabel.setWidth(100);
titleLabel.setHeight(100);
titleLabel.setX(centerX - 35);
titleLabel.setY((centerY / 2) - 20);
escapeLabel.setText(ChatColor.GRAY + "Press ESCAPE to exit!"); //TODO: Needs more locale
escapeLabel.setWidth(100);
escapeLabel.setHeight(100);
escapeLabel.setX(titleLabel.getX() - 15);
escapeLabel.setY(titleLabel.getY() + 10);
hudButton = new McmmoButton("HUD Type: " + playerProfile.getHudType().toString(), "Change your HUD style!");
hudButton.setWidth(120);
hudButton.setHeight(20);
hudButton.setX(centerX - (hudButton.getWidth() / 2));
hudButton.setY(centerY / 2);
hudButton.connect(new Slot() {
@Override
public void activate() {
HudType nextHudType = playerProfile.getHudType().getNext();
SpoutHud spoutHud = playerProfile.getSpoutHud();
playerProfile.setHudType(nextHudType);
spoutHud.initializeXpBar();
spoutHud.updateXpBar();
hudButton.setText("HUD Type: " + nextHudType.toString());
hudButton.setDirty(true);
}
});
escapeButton = new McmmoButton("EXIT", null);
escapeButton.setWidth(60);
escapeButton.setHeight(20);
escapeButton.setX(centerX - (escapeButton.getWidth() / 2));
escapeButton.setY((centerY / 2) + (escapeButton.getHeight() * 2) + 5);
escapeButton.connect(new Slot() {
@Override
public void activate() {
SpoutManager.getPlayer(playerProfile.getPlayer()).getMainScreen().closePopup();
}
});
attachWidget(mcMMO.p, hudButton);
attachWidget(mcMMO.p, titleLabel);
attachWidget(mcMMO.p, escapeLabel);
attachWidget(mcMMO.p, escapeButton);
InGameHUD inGameHud = spoutPlayer.getMainScreen();
inGameHud.attachPopupScreen(this);
inGameHud.setDirty(true);
}
}

View File

@ -1,58 +0,0 @@
package com.gmail.nossr50.datatypes.popups;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.gui.GenericPopup;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
public class PopupMMO extends GenericPopup {
private ButtonHUDStyle HUDButton = null;
private ButtonEscape EscapeButton = null;
private GenericLabel mcMMO_label = new GenericLabel();
private GenericLabel tip_escape = new GenericLabel();
private int center_x = 427 / 2;
private int center_y = 240 / 2;
public PopupMMO(Player player, PlayerProfile PP, mcMMO plugin) {
//240, 427 are the bottom right
mcMMO_label.setText(ChatColor.GOLD + "~mcMMO Menu~"); //TODO: Needs more locale
mcMMO_label.setX(center_x - 35);
mcMMO_label.setY((center_y / 2) - 20);
mcMMO_label.setDirty(true);
tip_escape.setText(ChatColor.GRAY + "Press ESCAPE to exit!"); //TODO: Needs more locale
tip_escape.setX(mcMMO_label.getX() - 15);
tip_escape.setY(mcMMO_label.getY() + 10);
tip_escape.setDirty(true);
HUDButton = new ButtonHUDStyle(PP);
HUDButton.setX(center_x - (HUDButton.getWidth() / 2));
HUDButton.setY(center_y / 2);
HUDButton.setDirty(true);
EscapeButton = new ButtonEscape();
EscapeButton.setX(center_x - (EscapeButton.getWidth() / 2));
EscapeButton.setY((center_y / 2) + (HUDButton.getHeight() * 2) + 5);
EscapeButton.setDirty(true);
this.attachWidget(plugin, HUDButton);
this.attachWidget(plugin, mcMMO_label);
this.attachWidget(plugin, tip_escape);
this.attachWidget(plugin, EscapeButton);
this.setDirty(true);
}
public void updateButtons(PlayerProfile PP) {
HUDButton.updateText(PP);
//PartyButton.updateText(PP);
this.setDirty(true);
}
}

View File

@ -0,0 +1,320 @@
package com.gmail.nossr50.datatypes.popups;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.gui.GenericGradient;
import org.getspout.spoutapi.gui.GenericTexture;
import org.getspout.spoutapi.gui.InGameHUD;
import org.getspout.spoutapi.gui.RenderPriority;
import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.HudType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Misc;
public class XpBar {
private SpoutPlayer spoutPlayer;
private Widget xpBar;
private GenericGradient xpFill;
private GenericGradient xpBackground;
private GenericGradient xpIconBackground;
private GenericGradient xpIconBorder;
private GenericTexture xpIcon;
public XpBar(SpoutPlayer spoutPlayer, HudType hudType) {
this.spoutPlayer = spoutPlayer;
switch (hudType) {
case RETRO:
initializeXpBarRetro();
break;
case STANDARD:
initializeXpBarStandard();
break;
case SMALL:
initializeXpBarSmall();
break;
case DISABLED:
break;
}
spoutPlayer.getMainScreen().setDirty(true);
}
/**
* Initialize Retro XP bar.
*/
private void initializeXpBarRetro() {
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
Color green = new Color(0f, 1f, 0f, 1f);
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
xpBar = new GenericGradient();
xpFill = new GenericGradient();
xpBackground = new GenericGradient();
xpBar.setWidth(128);
xpBar.setHeight(4);
xpBar.setX(149);
xpBar.setY(10);
((GenericGradient) xpBar).setBottomColor(border);
((GenericGradient) xpBar).setTopColor(border);
xpBar.setPriority(RenderPriority.Highest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
xpFill.setWidth(0);
xpFill.setHeight(2);
xpFill.setX(150);
xpFill.setY(11);
xpFill.setBottomColor(green);
xpFill.setTopColor(green);
xpFill.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
xpBackground.setWidth(126);
xpBackground.setHeight(2);
xpBackground.setX(150);
xpBackground.setY(11);
xpBackground.setBottomColor(background);
xpBackground.setTopColor(background);
xpBackground.setPriority(RenderPriority.Low);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBackground);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpIconBackground = new GenericGradient();
xpIconBorder = new GenericGradient();
xpIcon = new GenericTexture();
xpIconBackground.setBottomColor(darkbg);
xpIconBackground.setTopColor(darkbg);
xpIconBackground.setWidth(4);
xpIconBackground.setHeight(4);
xpIconBackground.setPriority(RenderPriority.High);
xpIconBackground.setX(142);
xpIconBackground.setY(10);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBackground);
xpIconBorder.setBottomColor(border);
xpIconBorder.setTopColor(border);
xpIconBorder.setWidth(6);
xpIconBorder.setHeight(6);
xpIconBorder.setPriority(RenderPriority.Highest);
xpIconBorder.setX(141);
xpIconBorder.setY(9);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBorder);
xpIcon.setWidth(6);
xpIcon.setHeight(6);
xpIcon.setX(141);
xpIcon.setY(9);
xpIcon.setPriority(RenderPriority.Normal);
xpIcon.setUrl("Icon_r.png");
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Initialize Standard XP bar.
*/
private void initializeXpBarStandard() {
xpBar = new GenericTexture();
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
xpBar.setX(SpoutConfig.getInstance().getXPBarXPosition());
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpBar.setHeight(8);
xpBar.setWidth(256);
xpBar.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpIcon = new GenericTexture();
xpIcon.setUrl("Icon.png");
xpIcon.setHeight(16);
xpIcon.setWidth(32);
xpIcon.setX(SpoutConfig.getInstance().getXPIconXPosition());
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition());
xpIcon.setPriority(RenderPriority.High);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Initialize Small XP bar.
*/
private void initializeXpBarSmall() {
xpBar = new GenericTexture();
((GenericTexture)xpBar).setUrl("xpbar_inc000.png");
xpBar.setX(427 / 2 - 64);
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpBar.setHeight(4);
xpBar.setWidth(128);
xpBar.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpIcon = new GenericTexture();
xpIcon.setUrl("Icon.png");
xpIcon.setHeight(8);
xpIcon.setWidth(16);
xpIcon.setX(427 / 2 - (8 + 64));
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
xpIcon.setPriority(RenderPriority.High);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Update the XP bar.
*
* @param skillType
* @param playerProfile
*/
public void update(SkillType skillType, PlayerProfile playerProfile) {
switch (playerProfile.getHudType()) {
case RETRO:
updateXpBarRetro(skillType, playerProfile);
break;
case STANDARD:
case SMALL:
updateXpBarStandard(skillType, playerProfile);
break;
case DISABLED:
break;
}
}
/**
* Update XP bar for Standard & Small styles.
*
* @param skillType
* @param playerProfile
*/
private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) {
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + ".png");
((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD)));
spoutPlayer.getMainScreen().setDirty(true);
}
/**
* Update XP bar for Retro styles.
*
* @param skillType
*/
private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) {
Color color = getRetroColor(skillType);
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + "_r.png");
xpFill.setBottomColor(color);
xpFill.setTopColor(color);
xpFill.setWidth(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.RETRO));
spoutPlayer.getMainScreen().setDirty(true);
}
private static Color getRetroColor(SkillType type) {
switch (type) {
case ACROBATICS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
case ARCHERY:
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
case AXES:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
case EXCAVATION:
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
case HERBALISM:
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
case MINING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
case REPAIR:
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
case SWORDS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
case TAMING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
case UNARMED:
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
case WOODCUTTING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
case FISHING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);
}
}
private static String getUrlBar(Integer number) {
char[] num = number.toString().toCharArray();
switch (num.length) {
case 1:
return "xpbar_inc00" + number + ".png";
case 2:
return "xpbar_inc0" + number + ".png";
default:
return "xpbar_inc" + number + ".png";
}
}
private static Integer getXpInc(int skillXp, int xpToLevel, HudType hudType) {
double percentage = (double) skillXp / xpToLevel;
double inc;
switch (hudType) {
case RETRO:
inc = 0.0079365079365079;
break;
case STANDARD:
inc = 0.0039370078740157;
break;
default:
return 1;
}
return (int) (percentage / inc);
}
public void removeWidgets() {
InGameHUD inGameHud = spoutPlayer.getMainScreen();
if (xpBar != null) inGameHud.removeWidget(xpBar);
if (xpFill != null) inGameHud.removeWidget(xpFill);
if (xpBackground != null) inGameHud.removeWidget(xpBackground);
if (xpIconBackground != null) inGameHud.removeWidget(xpIconBackground);
if (xpIconBorder != null) inGameHud.removeWidget(xpIconBorder);
if (xpIcon != null) inGameHud.removeWidget(xpIcon);
}
}