mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Reworked some Spout stuff
among other things
This commit is contained in:
parent
c45beec59d
commit
54e21333a3
@ -12,6 +12,8 @@ Version 1.3.10-dev
|
|||||||
+ Added ability for custom blocks to drop a range of items.
|
+ Added ability for custom blocks to drop a range of items.
|
||||||
+ Added Ability API functions
|
+ Added Ability API functions
|
||||||
+ Added 50% & 150% XP boost perks
|
+ Added 50% & 150% XP boost perks
|
||||||
|
= Fixed "GenericLabel belonging to mcMMO..." message
|
||||||
|
= Fixed menu exit button not working
|
||||||
= Fixed Repair enchant downgrade not working
|
= Fixed Repair enchant downgrade not working
|
||||||
= Fixed NPE caused by Spout players after a /reload
|
= Fixed NPE caused by Spout players after a /reload
|
||||||
= Fixed ConcurrentModificationException on world unload
|
= Fixed ConcurrentModificationException on world unload
|
||||||
|
@ -16,6 +16,7 @@ import com.gmail.nossr50.commands.CommandHelper;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.spout.SpoutStuff;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class McremoveCommand implements CommandExecutor {
|
public class McremoveCommand implements CommandExecutor {
|
||||||
@ -102,10 +103,12 @@ public class McremoveCommand implements CommandExecutor {
|
|||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
if (playerProfile != null) {
|
if (playerProfile != null) {
|
||||||
|
playerProfile.getSpoutHud().removeWidgets();
|
||||||
Users.remove(player.getName());
|
Users.remove(player.getName());
|
||||||
|
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
Users.addUser((Player) player);
|
Users.addUser((Player) player);
|
||||||
|
SpoutStuff.reloadSpoutPlayer((Player) player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,20 +9,13 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
import com.gmail.nossr50.config.SpoutConfig;
|
import com.gmail.nossr50.config.SpoutConfig;
|
||||||
import com.gmail.nossr50.datatypes.HUDType;
|
import com.gmail.nossr50.datatypes.HudType;
|
||||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.spout.SpoutStuff;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class MchudCommand implements CommandExecutor {
|
public class MchudCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public MchudCommand (mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
String usage = ChatColor.RED + "Proper usage is /mchud <hud-type>"; //TODO: Locale
|
String usage = ChatColor.RED + "Proper usage is /mchud <hud-type>"; //TODO: Locale
|
||||||
@ -40,33 +33,24 @@ public class MchudCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
HUDType hud;
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("disabled")) {
|
for (HudType hudType : HudType.values()) {
|
||||||
hud = HUDType.DISABLED;
|
if (hudType.toString().equalsIgnoreCase(args[0])) {
|
||||||
|
playerProfile.setHudType(hudType);
|
||||||
|
|
||||||
|
SpoutHud spoutHud = playerProfile.getSpoutHud();
|
||||||
|
|
||||||
|
if (spoutHud != null) {
|
||||||
|
spoutHud.initializeXpBar();
|
||||||
|
spoutHud.updateXpBar();
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("standard")) {
|
|
||||||
hud = HUDType.STANDARD;
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("small")) {
|
|
||||||
hud = HUDType.SMALL;
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("retro")) {
|
|
||||||
hud = HUDType.RETRO;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(invalid);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SpoutStuff.playerHUDs.containsKey(player)) {
|
|
||||||
SpoutStuff.playerHUDs.get(player).resetHUD();
|
|
||||||
SpoutStuff.playerHUDs.remove(player);
|
|
||||||
PP.setHUDType(hud);
|
|
||||||
SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.sendMessage(invalid);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -13,7 +13,6 @@ import com.gmail.nossr50.config.SpoutConfig;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.spout.SpoutStuff;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Skills;
|
import com.gmail.nossr50.util.Skills;
|
||||||
@ -34,49 +33,48 @@ public class XplockCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
if (PP.getXpBarLocked()) {
|
if (playerProfile.getXpBarLocked()) {
|
||||||
PP.toggleXpBarLocked();
|
playerProfile.toggleXpBarLocked();
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
player.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillType lastGained = PP.getLastGained();
|
SkillType lastGained = playerProfile.getLastGained();
|
||||||
|
|
||||||
if (lastGained != null) {
|
if (lastGained != null) {
|
||||||
PP.toggleXpBarLocked();
|
playerProfile.toggleXpBarLocked();
|
||||||
PP.setSkillLock(lastGained);
|
playerProfile.setSkillLock(lastGained);
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(lastGained.toString()) }));
|
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(lastGained.toString()) }));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(usage);
|
player.sendMessage(usage);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (Skills.isSkill(args[0])) {
|
if (Skills.isSkill(args[0])) {
|
||||||
if (Permissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) {
|
if (Permissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) {
|
||||||
PP.setXpBarLocked(true);
|
playerProfile.setXpBarLocked(true);
|
||||||
PP.setSkillLock(Skills.getSkillType(args[0]));
|
playerProfile.setSkillLock(Skills.getSkillType(args[0]));
|
||||||
SpoutStuff.updateXpBar(player);
|
playerProfile.updateXpBar();
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
|
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
player.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
player.sendMessage(usage);
|
player.sendMessage(usage);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.HUDType;
|
import com.gmail.nossr50.datatypes.HudType;
|
||||||
|
|
||||||
public class SpoutConfig extends ConfigLoader {
|
public class SpoutConfig extends ConfigLoader {
|
||||||
private static SpoutConfig instance;
|
private static SpoutConfig instance;
|
||||||
@ -15,7 +15,7 @@ public class SpoutConfig extends ConfigLoader {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HUDType defaulthud;
|
public HudType defaultHudType;
|
||||||
|
|
||||||
private SpoutConfig(mcMMO plugin) {
|
private SpoutConfig(mcMMO plugin) {
|
||||||
super(plugin, "spout.yml");
|
super(plugin, "spout.yml");
|
||||||
@ -85,14 +85,15 @@ public class SpoutConfig extends ConfigLoader {
|
|||||||
// Setup default HUD
|
// Setup default HUD
|
||||||
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
||||||
|
|
||||||
for (HUDType x : HUDType.values()) {
|
for (HudType hudType : HudType.values()) {
|
||||||
if (x.toString().equalsIgnoreCase(temp.toString())) {
|
if (hudType.toString().equalsIgnoreCase(temp.toString())) {
|
||||||
defaulthud = x;
|
defaultHudType = hudType;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaulthud == null) {
|
if (defaultHudType == null) {
|
||||||
defaulthud = HUDType.STANDARD;
|
defaultHudType = HudType.STANDARD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.gmail.nossr50.datatypes;
|
package com.gmail.nossr50.datatypes;
|
||||||
|
|
||||||
public enum HUDType {
|
public enum HudType {
|
||||||
DISABLED,
|
DISABLED,
|
||||||
STANDARD,
|
STANDARD,
|
||||||
SMALL,
|
SMALL,
|
||||||
RETRO;
|
RETRO;
|
||||||
|
|
||||||
|
public HudType getNext() {
|
||||||
|
return values()[(ordinal() + 1) % values().length];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,9 +25,9 @@ import com.gmail.nossr50.util.Users;
|
|||||||
public class PlayerProfile {
|
public class PlayerProfile {
|
||||||
|
|
||||||
/* HUD */
|
/* HUD */
|
||||||
private HUDType hud;
|
private SpoutHud spoutHud;
|
||||||
private int xpbarinc;
|
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
|
||||||
private SkillType lastgained;
|
private SkillType lastGained;
|
||||||
private SkillType skillLock;
|
private SkillType skillLock;
|
||||||
|
|
||||||
/* Party Stuff */
|
/* Party Stuff */
|
||||||
@ -36,7 +36,7 @@ public class PlayerProfile {
|
|||||||
|
|
||||||
/* Toggles */
|
/* Toggles */
|
||||||
private boolean loaded;
|
private boolean loaded;
|
||||||
private boolean partyhud = true, spoutcraft, xpbarlocked;
|
private boolean xpBarLocked;
|
||||||
private boolean placedAnvil;
|
private boolean placedAnvil;
|
||||||
private boolean partyChatMode, adminChatMode;
|
private boolean partyChatMode, adminChatMode;
|
||||||
private boolean godMode;
|
private boolean godMode;
|
||||||
@ -45,14 +45,14 @@ public class PlayerProfile {
|
|||||||
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
|
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
|
||||||
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
|
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
|
||||||
pickaxePreparationMode, axePreparationMode;
|
pickaxePreparationMode, axePreparationMode;
|
||||||
private boolean abilityuse = true;
|
private boolean abilityUse = true;
|
||||||
|
|
||||||
/* Timestamps */
|
/* Timestamps */
|
||||||
private int recentlyHurt;
|
private int recentlyHurt;
|
||||||
private int respawnATS;
|
private int respawnATS;
|
||||||
|
|
||||||
/* mySQL STUFF */
|
/* mySQL STUFF */
|
||||||
private int userid;
|
private int userId;
|
||||||
|
|
||||||
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
||||||
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
|
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;
|
private final static String location = mcMMO.usersFile;
|
||||||
|
|
||||||
public PlayerProfile(Player player, String playerName, boolean addNew) {
|
public PlayerProfile(Player player, String playerName, boolean addNew) {
|
||||||
hud = SpoutConfig.getInstance().defaulthud;
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
|
|
||||||
@ -107,38 +106,33 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadMySQL() {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
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 {
|
else {
|
||||||
if (huds.get(1).get(0) != null) {
|
for (HudType hudType : HudType.values()) {
|
||||||
for (HUDType x : HUDType.values()) {
|
if (hudType.toString().equals(huds.get(1).get(0))) {
|
||||||
if (x.toString().equals(huds.get(1).get(0))) {
|
this.hudType = hudType;
|
||||||
hud = x;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
hud = SpoutConfig.getInstance().defaulthud;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I'm still learning MySQL, this is a fix for adding a new table
|
* I'm still learning MySQL, this is a fix for adding a new table
|
||||||
* its not pretty but it works
|
* 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) {
|
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 {
|
else {
|
||||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldowns.get(1).get(0)));
|
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)));
|
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.TAMING, Integer.valueOf(stats.get(1).get(0)));
|
||||||
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
|
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
|
||||||
skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2)));
|
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.AXES, Integer.valueOf(stats.get(1).get(9)));
|
||||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
|
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
|
||||||
skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11)));
|
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.TAMING, Integer.valueOf(experience.get(1).get(0)));
|
||||||
skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
|
skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
|
||||||
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
|
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
|
||||||
@ -184,10 +178,10 @@ public class PlayerProfile {
|
|||||||
|
|
||||||
public void addMySQLPlayer() {
|
public void addMySQLPlayer() {
|
||||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 + ")");
|
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 + "'");
|
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() + "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() + "skills (user_id) VALUES (" + userId + ")");
|
||||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "experience (user_id) VALUES (" + userid + ")");
|
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "experience (user_id) VALUES (" + userId + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean load() {
|
public boolean load() {
|
||||||
@ -264,9 +258,9 @@ public class PlayerProfile {
|
|||||||
if (character.length > 32)
|
if (character.length > 32)
|
||||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
||||||
if (character.length > 33) {
|
if (character.length > 33) {
|
||||||
for (HUDType x : HUDType.values()) {
|
for (HudType hudType : HudType.values()) {
|
||||||
if (x.toString().equalsIgnoreCase(character[33])) {
|
if (hudType.toString().equalsIgnoreCase(character[33])) {
|
||||||
hud = x;
|
this.hudType = hudType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,8 +289,8 @@ public class PlayerProfile {
|
|||||||
|
|
||||||
// if we are using mysql save to database
|
// if we are using mysql save to database
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
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() + "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() + "users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + userId);
|
||||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "cooldowns SET "
|
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "cooldowns SET "
|
||||||
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
||||||
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
||||||
@ -306,7 +300,7 @@ public class PlayerProfile {
|
|||||||
+ ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
|
+ ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
|
||||||
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
|
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
|
||||||
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
||||||
+ " WHERE user_id = " + userid);
|
+ " WHERE user_id = " + userId);
|
||||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "skills SET "
|
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "skills SET "
|
||||||
+ " taming = " + skills.get(SkillType.TAMING)
|
+ " taming = " + skills.get(SkillType.TAMING)
|
||||||
+ ", mining = " + skills.get(SkillType.MINING)
|
+ ", mining = " + skills.get(SkillType.MINING)
|
||||||
@ -320,7 +314,7 @@ public class PlayerProfile {
|
|||||||
+ ", axes = " + skills.get(SkillType.AXES)
|
+ ", axes = " + skills.get(SkillType.AXES)
|
||||||
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
|
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
|
||||||
+ ", fishing = " + skills.get(SkillType.FISHING)
|
+ ", fishing = " + skills.get(SkillType.FISHING)
|
||||||
+ " WHERE user_id = " + userid);
|
+ " WHERE user_id = " + userId);
|
||||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "experience SET "
|
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "experience SET "
|
||||||
+ " taming = " + skillsXp.get(SkillType.TAMING)
|
+ " taming = " + skillsXp.get(SkillType.TAMING)
|
||||||
+ ", mining = " + skillsXp.get(SkillType.MINING)
|
+ ", mining = " + skillsXp.get(SkillType.MINING)
|
||||||
@ -334,7 +328,7 @@ public class PlayerProfile {
|
|||||||
+ ", axes = " + skillsXp.get(SkillType.AXES)
|
+ ", axes = " + skillsXp.get(SkillType.AXES)
|
||||||
+ ", acrobatics = " + skillsXp.get(SkillType.ACROBATICS)
|
+ ", acrobatics = " + skillsXp.get(SkillType.ACROBATICS)
|
||||||
+ ", fishing = " + skillsXp.get(SkillType.FISHING)
|
+ ", fishing = " + skillsXp.get(SkillType.FISHING)
|
||||||
+ " WHERE user_id = " + userid);
|
+ " WHERE user_id = " + userId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// otherwise save to flatfile
|
// 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.SERRATED_STRIKES)) + ":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER)) + ":");
|
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER)) + ":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER)) + ":");
|
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(skills.get(SkillType.FISHING) + ":");
|
||||||
writer.append(skillsXp.get(SkillType.FISHING) + ":");
|
writer.append(skillsXp.get(SkillType.FISHING) + ":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING)) + ":");
|
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(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 + ":"); //Fishing
|
||||||
out.append(0 +":"); //FishingXP
|
out.append(0 +":"); //FishingXP
|
||||||
out.append(0 + ":"); //Blast Mining
|
out.append(0 + ":"); //Blast Mining
|
||||||
@ -468,7 +462,7 @@ public class PlayerProfile {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public int getMySQLuserId() {
|
public int getMySQLuserId() {
|
||||||
return userid;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoaded() {
|
public boolean isLoaded() {
|
||||||
@ -503,45 +497,32 @@ public class PlayerProfile {
|
|||||||
* HUD Stuff
|
* HUD Stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void togglePartyHUD() {
|
public HudType getHudType() {
|
||||||
partyhud = !partyhud;
|
return hudType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getPartyHUD() {
|
public void setHudType(HudType hudType) {
|
||||||
return partyhud;
|
this.hudType = hudType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleSpoutEnabled() {
|
public SpoutHud getSpoutHud() {
|
||||||
spoutcraft = !spoutcraft;
|
return spoutHud;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HUDType getHUDType() {
|
public void setSpoutHud(SpoutHud spoutHud) {
|
||||||
return hud;
|
this.spoutHud = spoutHud;
|
||||||
}
|
|
||||||
|
|
||||||
public void setHUDType(HUDType type) {
|
|
||||||
hud = type;
|
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setXpBarLocked(boolean locked) {
|
public void setXpBarLocked(boolean locked) {
|
||||||
xpbarlocked = locked;
|
xpBarLocked = locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getXpBarLocked() {
|
public boolean getXpBarLocked() {
|
||||||
return xpbarlocked;
|
return xpBarLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleXpBarLocked() {
|
public void toggleXpBarLocked() {
|
||||||
xpbarlocked = !xpbarlocked;
|
xpBarLocked = !xpBarLocked;
|
||||||
}
|
|
||||||
|
|
||||||
public int getXpBarInc() {
|
|
||||||
return xpbarinc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setXpBarInc(int newvalue) {
|
|
||||||
xpbarinc = newvalue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSkillLock(SkillType newvalue) {
|
public void setSkillLock(SkillType newvalue) {
|
||||||
@ -553,11 +534,15 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLastGained(SkillType newvalue) {
|
public void setLastGained(SkillType newvalue) {
|
||||||
lastgained = newvalue;
|
lastGained = newvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkillType getLastGained() {
|
public SkillType getLastGained() {
|
||||||
return lastgained;
|
return lastGained;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateXpBar() {
|
||||||
|
spoutHud.updateXpBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -853,11 +838,11 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAbilityUse() {
|
public boolean getAbilityUse() {
|
||||||
return abilityuse;
|
return abilityUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleAbilityUse() {
|
public void toggleAbilityUse() {
|
||||||
abilityuse = !abilityuse;
|
abilityUse = !abilityUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -962,7 +947,7 @@ public class PlayerProfile {
|
|||||||
else {
|
else {
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
||||||
skillsXp.put(skillType, skillsXp.get(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));
|
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||||
skillsXp.put(skillType, skillsXp.get(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);
|
skills.put(skillType, skills.get(skillType) + levels);
|
||||||
skillsXp.put(skillType, 0);
|
skillsXp.put(skillType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
67
src/main/java/com/gmail/nossr50/datatypes/SpoutHud.java
Normal file
67
src/main/java/com/gmail/nossr50/datatypes/SpoutHud.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
80
src/main/java/com/gmail/nossr50/datatypes/popups/Menu.java
Normal file
80
src/main/java/com/gmail/nossr50/datatypes/popups/Menu.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
320
src/main/java/com/gmail/nossr50/datatypes/popups/XpBar.java
Normal file
320
src/main/java/com/gmail/nossr50/datatypes/popups/XpBar.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -36,7 +36,6 @@ import com.gmail.nossr50.skills.gathering.BlastMining;
|
|||||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.spout.SpoutStuff;
|
|
||||||
import com.gmail.nossr50.util.BlockChecks;
|
import com.gmail.nossr50.util.BlockChecks;
|
||||||
import com.gmail.nossr50.util.Item;
|
import com.gmail.nossr50.util.Item;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -137,11 +136,6 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* GARBAGE COLLECTION */
|
/* GARBAGE COLLECTION */
|
||||||
|
|
||||||
//Remove Spout Stuff
|
|
||||||
if (mcMMO.spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
|
|
||||||
SpoutStuff.playerHUDs.remove(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Bleed it out
|
//Bleed it out
|
||||||
BleedTimer.bleedOut(player);
|
BleedTimer.bleedOut(player);
|
||||||
}
|
}
|
||||||
|
@ -7,28 +7,19 @@ import org.getspout.spoutapi.event.input.KeyPressedEvent;
|
|||||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||||
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
|
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
|
||||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||||
|
import org.getspout.spoutapi.gui.Button;
|
||||||
import org.getspout.spoutapi.gui.ScreenType;
|
import org.getspout.spoutapi.gui.ScreenType;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.SpoutConfig;
|
import com.gmail.nossr50.config.SpoutConfig;
|
||||||
import com.gmail.nossr50.datatypes.HUDType;
|
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
|
import com.gmail.nossr50.datatypes.buttons.McmmoButton;
|
||||||
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
|
import com.gmail.nossr50.datatypes.popups.Menu;
|
||||||
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
|
|
||||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
|
||||||
import com.gmail.nossr50.spout.SpoutStuff;
|
import com.gmail.nossr50.spout.SpoutStuff;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class SpoutListener implements Listener {
|
public class SpoutListener implements Listener {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public SpoutListener(mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor SpoutCraftEnable events.
|
* Monitor SpoutCraftEnable events.
|
||||||
*
|
*
|
||||||
@ -36,19 +27,15 @@ public class SpoutListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
|
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
|
||||||
SpoutPlayer sPlayer = event.getPlayer();
|
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||||
PlayerProfile PPs = Users.getProfile(sPlayer);
|
PlayerProfile playerProfile = Users.getProfile(spoutPlayer);
|
||||||
|
|
||||||
//TODO: Add custom titles based on skills
|
//TODO: Add custom titles based on skills
|
||||||
if (SpoutConfig.getInstance().getShowPowerLevel()) {
|
if (SpoutConfig.getInstance().getShowPowerLevel()) {
|
||||||
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl" + ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PPs.getPowerLevel()));
|
spoutPlayer.setTitle(spoutPlayer.getName() + "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl" + ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(playerProfile.getPowerLevel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sPlayer.isSpoutCraftEnabled()) {
|
playerProfile.setSpoutHud(new SpoutHud(playerProfile)); //Setup Party HUD stuff
|
||||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff
|
|
||||||
|
|
||||||
PPs.toggleSpoutEnabled();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,48 +45,10 @@ public class SpoutListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onButtonClick(ButtonClickEvent event) {
|
public void onButtonClick(ButtonClickEvent event) {
|
||||||
SpoutPlayer sPlayer = event.getPlayer();
|
Button button = event.getButton();
|
||||||
PlayerProfile PP = Users.getProfile(sPlayer);
|
|
||||||
|
|
||||||
if (event.getButton() instanceof ButtonHUDStyle) {
|
if (button instanceof McmmoButton) {
|
||||||
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
|
((McmmoButton) button).activate();
|
||||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
|
||||||
SpoutStuff.playerHUDs.remove(sPlayer);
|
|
||||||
|
|
||||||
switch (PP.getHUDType()) {
|
|
||||||
case RETRO:
|
|
||||||
PP.setHUDType(HUDType.STANDARD);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STANDARD:
|
|
||||||
PP.setHUDType(HUDType.SMALL);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SMALL:
|
|
||||||
PP.setHUDType(HUDType.DISABLED);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DISABLED:
|
|
||||||
PP.setHUDType(HUDType.RETRO);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin));
|
|
||||||
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event.getButton() instanceof ButtonEscape) {
|
|
||||||
sPlayer.getMainScreen().closePopup();
|
|
||||||
}
|
|
||||||
else if (event.getButton() instanceof ButtonPartyToggle) {
|
|
||||||
PP.togglePartyHUD();
|
|
||||||
ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
|
|
||||||
bpt.updateText(PP);
|
|
||||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
|
||||||
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +59,11 @@ public class SpoutListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onScreenClose(ScreenCloseEvent event) {
|
public void onScreenClose(ScreenCloseEvent event) {
|
||||||
if (event.getScreen() instanceof PopupMMO) {
|
if (event.getScreen() instanceof Menu) {
|
||||||
SpoutStuff.playerScreens.remove(event.getPlayer());
|
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||||
|
|
||||||
|
Users.getProfile(spoutPlayer).getSpoutHud().onMenuClose();
|
||||||
|
spoutPlayer.getMainScreen().setDirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,23 +74,17 @@ public class SpoutListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onKeyPressedEvent(KeyPressedEvent event) {
|
public void onKeyPressedEvent(KeyPressedEvent event) {
|
||||||
SpoutPlayer sPlayer = event.getPlayer();
|
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||||
|
|
||||||
if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
|
if (spoutPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getKey() == SpoutStuff.keypress) {
|
if (event.getKey() == SpoutStuff.keypress) {
|
||||||
if (!SpoutStuff.playerScreens.containsKey(sPlayer)) {
|
SpoutHud spoutHud = Users.getProfile(spoutPlayer).getSpoutHud();
|
||||||
PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin);
|
|
||||||
|
|
||||||
SpoutStuff.playerScreens.put(sPlayer, mmoPop);
|
if (!spoutHud.isMenuOpened()) {
|
||||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
spoutHud.openMenu();
|
||||||
sPlayer.getMainScreen().setDirty(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
|
||||||
sPlayer.getMainScreen().setDirty(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
getCommand("xplock").setExecutor(new XplockCommand());
|
getCommand("xplock").setExecutor(new XplockCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommand("mchud").setExecutor(new MchudCommand(this));
|
getCommand("mchud").setExecutor(new MchudCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,7 +8,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
@ -22,10 +21,8 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.SpoutConfig;
|
import com.gmail.nossr50.config.SpoutConfig;
|
||||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
|
||||||
import com.gmail.nossr50.listeners.SpoutListener;
|
import com.gmail.nossr50.listeners.SpoutListener;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
@ -39,11 +36,7 @@ public class SpoutStuff {
|
|||||||
public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
|
public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
|
||||||
public final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
|
public final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
|
||||||
|
|
||||||
private final static SpoutListener spoutListener = new SpoutListener(plugin);
|
private final static SpoutListener spoutListener = new SpoutListener();
|
||||||
|
|
||||||
public static HashMap<Player, HUDmmo> playerHUDs = new HashMap<Player, HUDmmo>();
|
|
||||||
public static HashMap<SpoutPlayer, PopupMMO> playerScreens = new HashMap<SpoutPlayer, PopupMMO>();
|
|
||||||
|
|
||||||
public static Keyboard keypress;
|
public static Keyboard keypress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,21 +193,6 @@ public class SpoutStuff {
|
|||||||
plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin);
|
plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a Spout player from a player name.
|
|
||||||
*
|
|
||||||
* @param playerName The player name
|
|
||||||
* @return the SpoutPlayer related to this player name, null if there's no player online with that name.
|
|
||||||
*/
|
|
||||||
public static SpoutPlayer getSpoutPlayer(String playerName) {
|
|
||||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
|
||||||
if (x.getName().equalsIgnoreCase(playerName)) {
|
|
||||||
return SpoutManager.getPlayer(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle level-up notifications through Spout.
|
* Handle level-up notifications through Spout.
|
||||||
*
|
*
|
||||||
@ -567,15 +545,6 @@ public class SpoutStuff {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a player's Spout XP bar.
|
|
||||||
*
|
|
||||||
* @param player The player whose bar to update
|
|
||||||
*/
|
|
||||||
public static void updateXpBar(Player player) {
|
|
||||||
playerHUDs.get(player).updateXpBarDisplay(Users.getProfile(player).getHUDType(), player); //Is there a reason we can't just do HUDmmo.updateXpBarDisplay?
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-enable SpoutCraft for players after a /reload
|
* Re-enable SpoutCraft for players after a /reload
|
||||||
*/
|
*/
|
||||||
@ -585,4 +554,13 @@ public class SpoutStuff {
|
|||||||
mcMMO.p.getServer().getPluginManager().callEvent(spoutCraftEnableEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(spoutCraftEnableEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void reloadSpoutPlayer(Player player) {
|
||||||
|
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (spoutPlayer != null) {
|
||||||
|
SpoutCraftEnableEvent spoutCraftEnableEvent = new SpoutCraftEnableEvent(spoutPlayer);
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(spoutCraftEnableEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ public class Skills {
|
|||||||
|
|
||||||
if (sPlayer.isSpoutCraftEnabled()) {
|
if (sPlayer.isSpoutCraftEnabled()) {
|
||||||
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||||
SpoutStuff.updateXpBar(player);
|
profile.updateXpBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
SpoutStuff.levelUpNotification(skillType, sPlayer);
|
SpoutStuff.levelUpNotification(skillType, sPlayer);
|
||||||
@ -254,7 +254,7 @@ public class Skills {
|
|||||||
SpoutPlayer sPlayer = (SpoutPlayer) player;
|
SpoutPlayer sPlayer = (SpoutPlayer) player;
|
||||||
if (sPlayer.isSpoutCraftEnabled()) {
|
if (sPlayer.isSpoutCraftEnabled()) {
|
||||||
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||||
SpoutStuff.updateXpBar(player);
|
profile.updateXpBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user