Skip to content

Commit

Permalink
Another WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nossr50 committed Sep 12, 2011
1 parent ea3c762 commit 5809616
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 48 deletions.
1 change: 1 addition & 0 deletions src/Changelog.txt
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/com/gmail/nossr50/config/LoadProperties.java
Expand Up @@ -23,7 +23,7 @@

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,
Expand Down Expand Up @@ -138,6 +138,8 @@ private void addDefaults()
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);
Expand Down Expand Up @@ -365,6 +367,9 @@ private void loadkeys()
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);
Expand Down
1 change: 1 addition & 0 deletions src/com/gmail/nossr50/datatypes/HUDType.java
Expand Up @@ -18,6 +18,7 @@

public enum HUDType
{
DISABLED,
STANDARD,
SMALL,
RETRO;
Expand Down
19 changes: 14 additions & 5 deletions src/com/gmail/nossr50/datatypes/HUDmmo.java
Expand Up @@ -31,7 +31,6 @@
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
{
Expand All @@ -55,10 +54,11 @@ public HUDmmo(Player player)

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)
{
Expand All @@ -77,6 +77,10 @@ public void initializeHUD(Player player)
initializeXpBarDisplaySmall(SpoutManager.getPlayer(player));
break;
}
case DISABLED:
{
//Do nothing.. :)
}
}
}

Expand All @@ -99,12 +103,17 @@ public void updateXpBarDisplay(HUDType type, Player player)
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);
Expand All @@ -115,8 +124,8 @@ public void resetHUD()
xpbg = null;
xpicon = null;

if(LoadProperties.partybar)
mmoHelper.initialize(sPlayer, plugin);
//if(LoadProperties.partybar && PP.getPartyHUD())
//mmoHelper.initialize(sPlayer, plugin);

sPlayer.getMainScreen().setDirty(true);
}
Expand Down
11 changes: 10 additions & 1 deletion src/com/gmail/nossr50/datatypes/PlayerProfile.java
Expand Up @@ -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;

Expand Down Expand Up @@ -472,6 +472,14 @@ public void addPlayer()
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;
Expand All @@ -492,6 +500,7 @@ public HUDType getHUDType()
public void setHUDType(HUDType type)
{
hud = type;
save();
}
public boolean getXpBarLocked()
{
Expand Down
37 changes: 37 additions & 0 deletions src/com/gmail/nossr50/datatypes/buttons/ButtonPartyToggle.java
@@ -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);
}
}
12 changes: 11 additions & 1 deletion src/com/gmail/nossr50/datatypes/popups/PopupMMO.java
Expand Up @@ -21,13 +21,16 @@
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();
Expand All @@ -46,8 +49,15 @@ public PopupMMO(Player player, PlayerProfile PP, mcMMO plugin)
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);
Expand Down
12 changes: 11 additions & 1 deletion src/com/gmail/nossr50/listeners/mcSpoutScreenListener.java
Expand Up @@ -28,6 +28,7 @@
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;

Expand Down Expand Up @@ -59,8 +60,10 @@ public void onButtonClick(ButtonClickEvent event)
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));
Expand All @@ -70,6 +73,13 @@ public void onButtonClick(ButtonClickEvent event)
} 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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/com/gmail/nossr50/mcMMO.java
Expand Up @@ -22,7 +22,6 @@
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;
Expand Down Expand Up @@ -165,6 +164,7 @@ public void onEnable()
FileManager FM = SpoutManager.getFileManager();
FM.addToPreLoginCache(this, SpoutStuff.getFiles());

/*
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this,
new Runnable() {
Expand All @@ -173,6 +173,7 @@ public void run() {
mmoHelper.updateAll();
}
}, 20, 20);
*/
}

PluginDescriptionFile pdfFile = this.getDescription();
Expand Down
5 changes: 0 additions & 5 deletions src/com/gmail/nossr50/party/Party.java
Expand Up @@ -81,11 +81,6 @@ public static Party getInstance()
}

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()))
Expand Down
32 changes: 25 additions & 7 deletions src/com/gmail/nossr50/spout/mmoHelper.java
Expand Up @@ -37,6 +37,7 @@
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;

Expand Down Expand Up @@ -71,10 +72,13 @@ public static int getHealth(Entity player) {
*/
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();
Expand All @@ -84,7 +88,7 @@ public static String getColor(Player player, LivingEntity target) {
} 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;
Expand Down Expand Up @@ -125,12 +129,22 @@ public static int getArmor(Entity player) {
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 ";
}
Expand All @@ -142,6 +156,8 @@ public static String getSimpleName(LivingEntity target, boolean showOwner) {
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) {
Expand All @@ -150,6 +166,8 @@ public static String getSimpleName(LivingEntity target, boolean showOwner) {
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) {
Expand All @@ -173,7 +191,7 @@ public static String getSimpleName(LivingEntity target, boolean showOwner) {

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()) {
Expand Down

0 comments on commit 5809616

Please sign in to comment.