mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Another WIP
This commit is contained in:
parent
ea3c762de5
commit
580961662e
@ -6,6 +6,7 @@ Version 1.1.14
|
||||
[1.8] Swords no longer parry, no need to compete with in game mechanics
|
||||
[1.8] mcMMO no longer has an HP Regen system, no need to compete with in game mechanics
|
||||
[SPOUT] mcMMO now transfers files between [MC Server] -> [Client] rather than [Webserver] -> [Client]
|
||||
[SPOUT] Temporarily disabled the PartyHUD due to some performance issues
|
||||
[SPOUT/CONFIG] mcMMO now allows for disabling of the party HUD with the node Spout.Party.HUD.Enabled
|
||||
[BUG] Fixed a few problems with readying abilities for Woodcutting/Axes
|
||||
[MYSQL] Improvements have been made to the performance of MySQL thanks to krinsdeath
|
||||
|
@ -23,7 +23,7 @@ import com.gmail.nossr50.datatypes.HUDType;
|
||||
|
||||
public class LoadProperties
|
||||
{
|
||||
public static Boolean watch, xplockEnable, xpbar, xpicon, partybar, string, bucket, web, xprateEnable, slimeballs, spoutEnabled,
|
||||
public static Boolean showDisplayName, showFaces, watch, xplockEnable, xpbar, xpicon, partybar, string, bucket, web, xprateEnable, slimeballs, spoutEnabled,
|
||||
donateMessage, chimaeraWingEnable, xpGainsMobSpawners, myspawnEnable, mccEnable, mcmmoEnable, partyEnable, inviteEnable, acceptEnable,
|
||||
whoisEnable, statsEnable, addxpEnable, ptpEnable, mmoeditEnable, clearmyspawnEnable, mcgodEnable, mcabilityEnable, mctopEnable,
|
||||
mcrefreshEnable, enableMotd, enableMySpawn, enableRegen, enableCobbleToMossy, useMySQL, cocoabeans, archeryFireRateLimit, mushrooms,
|
||||
@ -138,6 +138,8 @@ public class LoadProperties
|
||||
write("Spout.XP.Icon.X_POS", 78);
|
||||
write("Spout.XP.Icon.Y_POS", 2);
|
||||
write("Spout.Party.HUD.Enabled", true);
|
||||
write("Spout.Party.HUD.Show_Faces", true);
|
||||
write("Spout.Party.HUD.Show_Display_Name", false);
|
||||
write("Spout.Menu.Key", "KEY_M");
|
||||
write("Spout.HUD.Retro.Colors.Acrobatics.RED", 0.3);
|
||||
write("Spout.HUD.Retro.Colors.Acrobatics.GREEN", 0.3);
|
||||
@ -365,6 +367,9 @@ public class LoadProperties
|
||||
xpbar_y = readInteger("Spout.XP.Bar.Y_POS", 6);
|
||||
xpicon_x = readInteger("Spout.XP.Icon.X_POS", 78);
|
||||
xpicon_y = readInteger("Spout.XP.Icon.Y_POS", 2);
|
||||
|
||||
showFaces = readBoolean("Spout.Party.HUD.Show_Faces", true);
|
||||
showDisplayName = readBoolean("Spout.Party.HUD.Show_Display_Name", false);
|
||||
partybar = readBoolean("Spout.Party.HUD.Enabled", true);
|
||||
|
||||
acrobatics_r = readDouble("Spout.HUD.Retro.Colors.Acrobatics.RED", 0.3);
|
||||
|
@ -18,6 +18,7 @@ package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum HUDType
|
||||
{
|
||||
DISABLED,
|
||||
STANDARD,
|
||||
SMALL,
|
||||
RETRO;
|
||||
|
@ -31,7 +31,6 @@ import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.spout.mmoHelper;
|
||||
|
||||
public class HUDmmo
|
||||
{
|
||||
@ -55,10 +54,11 @@ public class HUDmmo
|
||||
|
||||
public void initializeHUD(Player player)
|
||||
{
|
||||
//PlayerProfile PP = Users.getProfile(player);
|
||||
HUDType type = Users.getProfile(player).getHUDType();
|
||||
|
||||
if(LoadProperties.partybar)
|
||||
mmoHelper.initialize(SpoutManager.getPlayer(player), plugin); //PARTY HUD
|
||||
//if(LoadProperties.partybar && PP.getPartyHUD())
|
||||
//mmoHelper.initialize(SpoutManager.getPlayer(player), plugin); //PARTY HUD
|
||||
|
||||
switch(type)
|
||||
{
|
||||
@ -77,6 +77,10 @@ public class HUDmmo
|
||||
initializeXpBarDisplaySmall(SpoutManager.getPlayer(player));
|
||||
break;
|
||||
}
|
||||
case DISABLED:
|
||||
{
|
||||
//Do nothing.. :)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,12 +103,17 @@ public class HUDmmo
|
||||
updateXpBarStandard(player, Users.getProfile(player));
|
||||
break;
|
||||
}
|
||||
case DISABLED:
|
||||
{
|
||||
//Do nothing.. :)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetHUD()
|
||||
{
|
||||
SpoutPlayer sPlayer = SpoutStuff.getSpoutPlayer(playerName);
|
||||
//PlayerProfile PP = Users.getProfile(sPlayer);
|
||||
if(sPlayer != null)
|
||||
{
|
||||
sPlayer.getMainScreen().removeWidgets(plugin);
|
||||
@ -115,8 +124,8 @@ public class HUDmmo
|
||||
xpbg = null;
|
||||
xpicon = null;
|
||||
|
||||
if(LoadProperties.partybar)
|
||||
mmoHelper.initialize(sPlayer, plugin);
|
||||
//if(LoadProperties.partybar && PP.getPartyHUD())
|
||||
//mmoHelper.initialize(sPlayer, plugin);
|
||||
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class PlayerProfile
|
||||
private String party, myspawn, myspawnworld, invite;
|
||||
|
||||
//TOGGLES
|
||||
private boolean spoutcraft = false, filling = false, xpbarlocked = false, placedAnvil = false, partyChatMode = false, adminChatMode = false, godMode = false, greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
|
||||
private boolean partyhud = true, spoutcraft = false, filling = false, xpbarlocked = false, placedAnvil = false, partyChatMode = false, adminChatMode = false, godMode = false, greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
|
||||
superBreakerInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, dead, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode,
|
||||
serratedStrikesMode, hoePreparationMode = false, shovelPreparationMode = false, swordsPreparationMode = false, fistsPreparationMode = false, pickaxePreparationMode = false, axePreparationMode = false, skullSplitterMode, berserkMode;
|
||||
|
||||
@ -472,6 +472,14 @@ public class PlayerProfile
|
||||
log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e);
|
||||
}
|
||||
}
|
||||
public void togglePartyHUD()
|
||||
{
|
||||
partyhud = !partyhud;
|
||||
}
|
||||
public boolean getPartyHUD()
|
||||
{
|
||||
return partyhud;
|
||||
}
|
||||
public void toggleSpoutEnabled()
|
||||
{
|
||||
spoutcraft = !spoutcraft;
|
||||
@ -492,6 +500,7 @@ public class PlayerProfile
|
||||
public void setHUDType(HUDType type)
|
||||
{
|
||||
hud = type;
|
||||
save();
|
||||
}
|
||||
public boolean getXpBarLocked()
|
||||
{
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
public class ButtonPartyToggle extends GenericButton
|
||||
{
|
||||
public ButtonPartyToggle(PlayerProfile PP)
|
||||
{
|
||||
this.setText("Party HUD: "+PP.getPartyHUD());
|
||||
this.setTooltip("Toggle the Party HUD!");
|
||||
this.setWidth(120).setHeight(20);
|
||||
this.setDirty(true);
|
||||
}
|
||||
public void updateText(PlayerProfile PP)
|
||||
{
|
||||
this.setText("Party HUD: "+PP.getPartyHUD());
|
||||
this.setDirty(true);
|
||||
}
|
||||
}
|
@ -21,13 +21,16 @@ 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.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
|
||||
|
||||
public class PopupMMO extends GenericPopup
|
||||
{
|
||||
ButtonHUDStyle HUDButton = null;
|
||||
ButtonPartyToggle PartyButton = null;
|
||||
ButtonEscape EscapeButton = null;
|
||||
GenericLabel mcMMO_label = new GenericLabel();
|
||||
GenericLabel tip_escape = new GenericLabel();
|
||||
@ -46,8 +49,15 @@ public class PopupMMO extends GenericPopup
|
||||
HUDButton = new ButtonHUDStyle(PP);
|
||||
HUDButton.setX(center_x-(HUDButton.getWidth()/2)).setY(center_y/2).setDirty(true);
|
||||
|
||||
if(LoadProperties.partybar)
|
||||
{
|
||||
PartyButton = new ButtonPartyToggle(PP);
|
||||
PartyButton.setX(center_x-(PartyButton.getWidth()/2)).setY(center_y/2+PartyButton.getHeight()).setDirty(true);
|
||||
this.attachWidget(plugin, PartyButton);
|
||||
}
|
||||
|
||||
EscapeButton = new ButtonEscape();
|
||||
EscapeButton.setX(center_x-(EscapeButton.getWidth()/2)).setY((center_y/2)+HUDButton.getHeight()+5).setDirty(true);
|
||||
EscapeButton.setX(center_x-(EscapeButton.getWidth()/2)).setY((center_y/2)+(HUDButton.getHeight()*2)+5).setDirty(true);
|
||||
|
||||
this.attachWidget(plugin, HUDButton);
|
||||
this.attachWidget(plugin, mcMMO_label);
|
||||
|
@ -28,6 +28,7 @@ import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
|
||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
|
||||
@ -59,8 +60,10 @@ public class mcSpoutScreenListener extends ScreenListener
|
||||
PP.setHUDType(HUDType.SMALL);
|
||||
break;
|
||||
case SMALL:
|
||||
PP.setHUDType(HUDType.RETRO);
|
||||
PP.setHUDType(HUDType.DISABLED);
|
||||
break;
|
||||
case DISABLED:
|
||||
PP.setHUDType(HUDType.RETRO);
|
||||
}
|
||||
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer));
|
||||
@ -70,6 +73,13 @@ public class mcSpoutScreenListener extends ScreenListener
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ import com.gmail.nossr50.command.Commands;
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.runnables.mcTimer;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.spout.mmoHelper;
|
||||
import com.gmail.nossr50.listeners.mcBlockListener;
|
||||
import com.gmail.nossr50.listeners.mcEntityListener;
|
||||
import com.gmail.nossr50.listeners.mcPlayerListener;
|
||||
@ -165,6 +164,7 @@ public class mcMMO extends JavaPlugin
|
||||
FileManager FM = SpoutManager.getFileManager();
|
||||
FM.addToPreLoginCache(this, SpoutStuff.getFiles());
|
||||
|
||||
/*
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this,
|
||||
new Runnable() {
|
||||
|
||||
@ -173,6 +173,7 @@ public class mcMMO extends JavaPlugin
|
||||
mmoHelper.updateAll();
|
||||
}
|
||||
}, 20, 20);
|
||||
*/
|
||||
}
|
||||
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
|
@ -81,11 +81,6 @@ public class Party
|
||||
}
|
||||
|
||||
public boolean inSameParty(Player playera, Player playerb){
|
||||
if(Users.getProfile(playera) == null || Users.getProfile(playerb) == null)
|
||||
{
|
||||
Users.addUser(playera);
|
||||
Users.addUser(playerb);
|
||||
}
|
||||
if(Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty())
|
||||
{
|
||||
if(Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty()))
|
||||
|
@ -37,6 +37,7 @@ import org.getspout.spoutapi.gui.WidgetAnchor;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.spout.util.GenericLivingEntity;
|
||||
|
||||
@ -71,10 +72,13 @@ public class mmoHelper
|
||||
*/
|
||||
public static String getColor(Player player, LivingEntity target) {
|
||||
if (target instanceof Player) {
|
||||
if (((Player) target).isOp()) {
|
||||
return ChatColor.GOLD.toString();
|
||||
}
|
||||
return ChatColor.YELLOW.toString();
|
||||
} else {
|
||||
if (target instanceof Monster) {
|
||||
if (player != null && player.equals(((Creature) target).getTarget())) {
|
||||
if (player != null && player.equals(((Monster) target).getTarget())) {
|
||||
return ChatColor.RED.toString();
|
||||
} else {
|
||||
return ChatColor.YELLOW.toString();
|
||||
@ -84,7 +88,7 @@ public class mmoHelper
|
||||
} else if (target instanceof Flying) {
|
||||
return ChatColor.YELLOW.toString();
|
||||
} else if (target instanceof Animals) {
|
||||
if (player != null && player.equals(((Creature) target).getTarget())) {
|
||||
if (player != null && player.equals(((Animals) target).getTarget())) {
|
||||
return ChatColor.RED.toString();
|
||||
} else if (target instanceof Tameable) {
|
||||
Tameable pet = (Tameable) target;
|
||||
@ -125,12 +129,22 @@ public class mmoHelper
|
||||
public static String getSimpleName(LivingEntity target, boolean showOwner) {
|
||||
String name = "";
|
||||
if (target instanceof Player) {
|
||||
name += ((Player)target).getName();
|
||||
if (LoadProperties.showDisplayName) {
|
||||
name += ((Player) target).getName();
|
||||
} else {
|
||||
name += ((Player) target).getDisplayName();
|
||||
}
|
||||
} else if (target instanceof HumanEntity) {
|
||||
name += ((HumanEntity) target).getName();
|
||||
} else {
|
||||
if (target instanceof Tameable) {
|
||||
if (((Tameable)target).isTamed()) {
|
||||
if (showOwner && ((Tameable)target).getOwner() instanceof Player) {
|
||||
name += ((Player)((Tameable)target).getOwner()).getName() + "'s ";
|
||||
if (((Tameable) target).isTamed()) {
|
||||
if (showOwner && ((Tameable) target).getOwner() instanceof Player) {
|
||||
if (LoadProperties.showDisplayName) {
|
||||
name += ((Player) ((Tameable) target).getOwner()).getName() + "'s ";
|
||||
} else {
|
||||
name += ((Player) ((Tameable) target).getOwner()).getDisplayName() + "'s ";
|
||||
}
|
||||
} else {
|
||||
name += "Pet ";
|
||||
}
|
||||
@ -142,6 +156,8 @@ public class mmoHelper
|
||||
name += "Cow";
|
||||
} else if (target instanceof Creeper) {
|
||||
name += "Creeper";
|
||||
} else if (target instanceof Ghast) {
|
||||
name += "Ghast";
|
||||
} else if (target instanceof Giant) {
|
||||
name += "Giant";
|
||||
} else if (target instanceof Pig) {
|
||||
@ -150,6 +166,8 @@ public class mmoHelper
|
||||
name += "PigZombie";
|
||||
} else if (target instanceof Sheep) {
|
||||
name += "Sheep";
|
||||
} else if (target instanceof Slime) {
|
||||
name += "Slime";
|
||||
} else if (target instanceof Skeleton) {
|
||||
name += "Skeleton";
|
||||
} else if (target instanceof Spider) {
|
||||
@ -173,7 +191,7 @@ public class mmoHelper
|
||||
|
||||
public static LivingEntity[] getPets(HumanEntity player) {
|
||||
ArrayList<LivingEntity> pets = new ArrayList<LivingEntity>();
|
||||
if (player != null && (!(player instanceof Player) || ((Player)player).isOnline())) {
|
||||
if (player != null && (!(player instanceof Player) || ((Player) player).isOnline())) {
|
||||
String name = player.getName();
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
for (LivingEntity entity : world.getLivingEntities()) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of mmoMinecraft (http://code.google.com/p/mmo-minecraft/).
|
||||
*
|
||||
* This file is part of mmoMinecraft (https://github.com/mmoMinecraftDev).
|
||||
*
|
||||
* mmoMinecraft is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
@ -10,15 +10,16 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.gmail.nossr50.spout.util;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericTexture;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
|
||||
public final class GenericFace extends GenericTexture {
|
||||
|
||||
private static String facePath = "http://face.rycochet.net/";
|
||||
@ -26,18 +27,20 @@ public final class GenericFace extends GenericTexture {
|
||||
private String name;
|
||||
|
||||
public GenericFace() {
|
||||
this.setWidth(defaultSize).setHeight(defaultSize).setFixed(true);
|
||||
setName("");
|
||||
this("", defaultSize);
|
||||
}
|
||||
|
||||
public GenericFace(String name) {
|
||||
this.setWidth(defaultSize).setHeight(defaultSize).setFixed(true);
|
||||
setName(name);
|
||||
this(name, defaultSize);
|
||||
}
|
||||
|
||||
public GenericFace(String name, int size) {
|
||||
this.setWidth(size).setHeight(size).setFixed(true);
|
||||
setName(name);
|
||||
if (LoadProperties.showFaces) {
|
||||
this.setWidth(size).setHeight(size).setFixed(true);
|
||||
setName(name);
|
||||
} else {
|
||||
this.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -45,14 +48,18 @@ public final class GenericFace extends GenericTexture {
|
||||
}
|
||||
|
||||
public GenericFace setName(String name) {
|
||||
this.name = name == null ? "" : name;
|
||||
super.setUrl(facePath + this.name + ".png");
|
||||
super.setDirty(true);
|
||||
if (LoadProperties.showFaces) {
|
||||
this.name = name == null ? "" : name;
|
||||
super.setUrl(facePath + this.name + ".png");
|
||||
super.setDirty(true);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenericFace setSize(int size) {
|
||||
super.setWidth(size).setHeight(size);
|
||||
if (LoadProperties.showFaces) {
|
||||
super.setWidth(size).setHeight(size);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is from mmoMinecraft (http://code.google.com/p/mmo-minecraft/).
|
||||
*
|
||||
* mmoMinecraft is free software: you can redistribute it and/or modify
|
||||
* This file is part of mmoHelperMinecraft (https://github.com/mmoHelperMinecraftDev).
|
||||
*
|
||||
* mmoHelperMinecraft is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
@ -10,13 +10,12 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.spout.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.gui.*;
|
||||
@ -25,7 +24,6 @@ import com.gmail.nossr50.spout.mmoHelper;
|
||||
|
||||
public class GenericLivingEntity extends GenericContainer {
|
||||
|
||||
private Container _bars;
|
||||
private Container _space;
|
||||
private Label _label;
|
||||
private Gradient _health;
|
||||
@ -54,7 +52,7 @@ public class GenericLivingEntity extends GenericContainer {
|
||||
.setTopColor(black)
|
||||
.setBottomColor(black)
|
||||
.setPriority(RenderPriority.Highest),
|
||||
_bars = (Container) new GenericContainer(
|
||||
new GenericContainer(
|
||||
_health = (Gradient) new GenericGradient(),
|
||||
_armor = (Gradient) new GenericGradient()
|
||||
) .setMargin(1)
|
||||
@ -96,7 +94,7 @@ public class GenericLivingEntity extends GenericContainer {
|
||||
* @return
|
||||
*/
|
||||
public GenericLivingEntity setEntity(String name, String prefix) {
|
||||
Player player = Bukkit.getServer().getPlayer(name);
|
||||
Player player = this.getPlugin().getServer().getPlayer(name);
|
||||
if (player != null && player.isOnline()) {
|
||||
return setEntity(player, prefix);
|
||||
}
|
||||
@ -127,7 +125,7 @@ public class GenericLivingEntity extends GenericContainer {
|
||||
setHealth(mmoHelper.getHealth(entity)); // Needs a maxHealth() check
|
||||
setArmor(mmoHelper.getArmor(entity));
|
||||
setLabel((!"".equals(prefix) ? prefix : "") + mmoHelper.getColor(screen != null ? screen.getPlayer() : null, entity) + mmoHelper.getSimpleName(entity, !target));
|
||||
setFace(entity instanceof Player ? ((Player)entity).getName() : "");
|
||||
setFace(entity instanceof Player ? ((Player)entity).getName() : "+" + mmoHelper.getSimpleName(entity,false).replaceAll(" ", ""));
|
||||
} else {
|
||||
setHealth(0);
|
||||
setArmor(0);
|
||||
@ -222,8 +220,8 @@ public class GenericLivingEntity extends GenericContainer {
|
||||
@Override
|
||||
public Container updateLayout() {
|
||||
super.updateLayout();
|
||||
_armor.setWidth((_bars.getWidth() * armor) / 100).setDirty(true);
|
||||
_health.setWidth((_bars.getWidth() * health) / 100).setDirty(true);
|
||||
_armor.setWidth((_armor.getContainer().getWidth() * armor) / 100).setDirty(true);
|
||||
_health.setWidth((_health.getContainer().getWidth() * health) / 100).setDirty(true);
|
||||
return this;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user