From a2f23bd0562531852599d7b674e7b2fbd1463804 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 31 Mar 2012 19:00:41 -0400 Subject: [PATCH] More cleanup. Done with Datatypes. Lack Events, Runnables, and... Commands. --- .../com/gmail/nossr50/datatypes/HUDmmo.java | 2 +- .../datatypes/buttons/ButtonEscape.java | 2 +- .../datatypes/buttons/ButtonHUDStyle.java | 4 +- .../datatypes/buttons/ButtonPartyToggle.java | 4 +- .../nossr50/datatypes/popups/PopupMMO.java | 99 ++++----- .../treasure/ExcavationTreasure.java | 189 +++++++++--------- .../datatypes/treasure/FishingTreasure.java | 22 +- .../nossr50/datatypes/treasure/Treasure.java | 69 ++++--- 8 files changed, 200 insertions(+), 191 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java b/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java index f5e981e48..0c037e8a2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java +++ b/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java @@ -17,7 +17,7 @@ import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.spout.SpoutStuff; public class HUDmmo { - private int center_x = 427/2; + private int center_x = 427 / 2; private String playerName = null; diff --git a/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonEscape.java b/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonEscape.java index 966da3ed4..642a13d32 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonEscape.java +++ b/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonEscape.java @@ -10,4 +10,4 @@ public class ButtonEscape extends GenericButton { this.setHeight(20); this.setDirty(true); } -} \ No newline at end of file +} diff --git a/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonHUDStyle.java b/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonHUDStyle.java index 34d30b5d2..4ba1229b0 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonHUDStyle.java +++ b/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonHUDStyle.java @@ -5,10 +5,10 @@ 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!"); + 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()); + super.updateText("HUD Type: ", PP.getHUDType().toString()); //TODO: Needs more locale } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonPartyToggle.java b/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonPartyToggle.java index 39692e3a1..0c496d305 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonPartyToggle.java +++ b/src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonPartyToggle.java @@ -5,10 +5,10 @@ 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!"); + 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()); + super.updateText("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString()); //TODO: Needs more locale } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/popups/PopupMMO.java b/src/main/java/com/gmail/nossr50/datatypes/popups/PopupMMO.java index cbcfc329e..ce832c0e8 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/popups/PopupMMO.java +++ b/src/main/java/com/gmail/nossr50/datatypes/popups/PopupMMO.java @@ -11,49 +11,58 @@ 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(); - int center_x = 427/2; - 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~"); - mcMMO_label.setX(center_x-35).setY((center_y/2)-20).setDirty(true); - - tip_escape.setText(ChatColor.GRAY+"Press ESCAPE to exit!"); - tip_escape.setX(mcMMO_label.getX()-15).setY(mcMMO_label.getY()+10).setDirty(true); - - 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()*2)+5).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); - this.setDirty(true); - } +public class PopupMMO extends GenericPopup { + + private ButtonHUDStyle HUDButton = null; + private ButtonPartyToggle PartyButton = 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); + + if (LoadProperties.partybar) { + PartyButton = new ButtonPartyToggle(PP); + PartyButton.setX(center_x - (PartyButton.getWidth() / 2)); + PartyButton.setY((center_y / 2) + PartyButton.getHeight()); + PartyButton.setDirty(true); + this.attachWidget(plugin, PartyButton); + } + + 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); + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java index 06b3f5dd5..093d79769 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java +++ b/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java @@ -3,125 +3,126 @@ package com.gmail.nossr50.datatypes.treasure; import org.bukkit.inventory.ItemStack; public class ExcavationTreasure extends Treasure { - // dirt grass sand gravel clay mycel soulsand - // 00000001 - dirt 1 - // 00000010 - grass 2 - // 00000100 - sand 4 - // 00001000 - gravel 8 - // 00010000 - clay 16 - // 00100000 - mycel 32 - // 01000000 - soulsand 64 - private byte dropsFrom = 0x0; - public ExcavationTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel) { - super(drop, xp, dropChance, dropLevel); - } + // dirt | grass | sand | gravel | clay | mycel | soulsand + // 00000001 - dirt 1 + // 00000010 - grass 2 + // 00000100 - sand 4 + // 00001000 - gravel 8 + // 00010000 - clay 16 + // 00100000 - mycel 32 + // 01000000 - soulsand 64 + private byte dropsFrom = 0x0; - // Raw getters and setters - public byte getDropsFrom() { - return dropsFrom; - } + public ExcavationTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel) { + super(drop, xp, dropChance, dropLevel); + } - public void setDropsFrom(byte dropsFrom) { - this.dropsFrom = dropsFrom; - } + // Raw getters and setters + public byte getDropsFrom() { + return dropsFrom; + } - // Getters - public boolean getDropsFromDirt() { - return getDropFromMask(1); - } + public void setDropsFrom(byte dropsFrom) { + this.dropsFrom = dropsFrom; + } - public boolean getDropsFromGrass() { - return getDropFromMask(2); - } + // Getters + public boolean getDropsFromDirt() { + return getDropFromMask(1); + } - public boolean getDropsFromSand() { - return getDropFromMask(4); - } + public boolean getDropsFromGrass() { + return getDropFromMask(2); + } - public boolean getDropsFromGravel() { - return getDropFromMask(8); - } + public boolean getDropsFromSand() { + return getDropFromMask(4); + } - public boolean getDropsFromClay() { - return getDropFromMask(16); - } + public boolean getDropsFromGravel() { + return getDropFromMask(8); + } - public boolean getDropsFromMycel() { - return getDropFromMask(32); - } + public boolean getDropsFromClay() { + return getDropFromMask(16); + } - public boolean getDropsFromSoulSand() { - return getDropFromMask(64); - } + public boolean getDropsFromMycel() { + return getDropFromMask(32); + } - private boolean getDropFromMask(int mask) { - return ((dropsFrom & mask) > 0) ? true : false; - } + public boolean getDropsFromSoulSand() { + return getDropFromMask(64); + } - // Setters - public void setDropsFromDirt() { - setDropFromMask(1); - } + private boolean getDropFromMask(int mask) { + return ((dropsFrom & mask) > 0) ? true : false; + } - public void setDropsFromGrass() { - setDropFromMask(2); - } + // Setters + public void setDropsFromDirt() { + setDropFromMask(1); + } - public void setDropsFromSand() { - setDropFromMask(4); - } + public void setDropsFromGrass() { + setDropFromMask(2); + } - public void setDropsFromGravel() { - setDropFromMask(8); - } + public void setDropsFromSand() { + setDropFromMask(4); + } - public void setDropsFromClay() { - setDropFromMask(16); - } + public void setDropsFromGravel() { + setDropFromMask(8); + } - public void setDropsFromMycel() { - setDropFromMask(32); - } + public void setDropsFromClay() { + setDropFromMask(16); + } - public void setDropsFromSoulSand() { - setDropFromMask(64); - } + public void setDropsFromMycel() { + setDropFromMask(32); + } - private void setDropFromMask(int mask) { - dropsFrom |= mask; - } + public void setDropsFromSoulSand() { + setDropFromMask(64); + } - // Un-setters - public void unsetDropsFromDirt() { - unsetDropFromMask(1); - } + private void setDropFromMask(int mask) { + dropsFrom |= mask; + } - public void unsetDropsFromGrass() { - unsetDropFromMask(2); - } + // Un-setters + public void unsetDropsFromDirt() { + unsetDropFromMask(1); + } - public void unsetDropsFromSand() { - unsetDropFromMask(4); - } + public void unsetDropsFromGrass() { + unsetDropFromMask(2); + } - public void unsetDropsFromGravel() { - unsetDropFromMask(8); - } + public void unsetDropsFromSand() { + unsetDropFromMask(4); + } - public void unsetDropsFromClay() { - unsetDropFromMask(16); - } + public void unsetDropsFromGravel() { + unsetDropFromMask(8); + } - public void unsetDropsFromMycel() { - unsetDropFromMask(32); - } + public void unsetDropsFromClay() { + unsetDropFromMask(16); + } - public void unsetDropsFromSoulSand() { - unsetDropFromMask(64); - } + public void unsetDropsFromMycel() { + unsetDropFromMask(32); + } - private void unsetDropFromMask(int mask) { - dropsFrom &= ~mask; - } + public void unsetDropsFromSoulSand() { + unsetDropFromMask(64); + } + + private void unsetDropFromMask(int mask) { + dropsFrom &= ~mask; + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasure.java index ad7331283..be0527389 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasure.java +++ b/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasure.java @@ -3,18 +3,18 @@ package com.gmail.nossr50.datatypes.treasure; import org.bukkit.inventory.ItemStack; public class FishingTreasure extends Treasure { - private int maxLevel; + private int maxLevel; - public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) { - super(drop, xp, dropChance, dropLevel); - this.setMaxLevel(maxLevel); - } + public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) { + super(drop, xp, dropChance, dropLevel); + this.setMaxLevel(maxLevel); + } - public int getMaxLevel() { - return maxLevel; - } + public int getMaxLevel() { + return maxLevel; + } - public void setMaxLevel(int maxLevel) { - this.maxLevel = maxLevel; - } + public void setMaxLevel(int maxLevel) { + this.maxLevel = maxLevel; + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java index 1ef6337eb..8c3d18e49 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java +++ b/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java @@ -3,48 +3,47 @@ package com.gmail.nossr50.datatypes.treasure; import org.bukkit.inventory.ItemStack; public abstract class Treasure { - private int xp; - private Double dropChance; - private int dropLevel; + private int xp; + private Double dropChance; + private int dropLevel; + private ItemStack drop; - private ItemStack drop; + public Treasure(ItemStack drop, int xp, Double dropChance, int dropLevel) { + this.drop = drop; + this.xp = xp; + this.dropChance = dropChance; + this.dropLevel = dropLevel; + } - public Treasure(ItemStack drop, int xp, Double dropChance, int dropLevel) { - this.drop = drop; - this.xp = xp; - this.dropChance = dropChance; - this.dropLevel = dropLevel; - } + public ItemStack getDrop() { + return drop; + } - public ItemStack getDrop() { - return drop; - } + public void setDrop(ItemStack drop) { + this.drop = drop; + } - public void setDrop(ItemStack drop) { - this.drop = drop; - } + public int getXp() { + return xp; + } - public int getXp() { - return xp; - } + public void setXp(int xp) { + this.xp = xp; + } - public void setXp(int xp) { - this.xp = xp; - } + public Double getDropChance() { + return dropChance; + } - public Double getDropChance() { - return dropChance; - } + public void setDropChance(Double dropChance) { + this.dropChance = dropChance; + } - public void setDropChance(Double dropChance) { - this.dropChance = dropChance; - } + public int getDropLevel() { + return dropLevel; + } - public int getDropLevel() { - return dropLevel; - } - - public void setDropLevel(int dropLevel) { - this.dropLevel = dropLevel; - } + public void setDropLevel(int dropLevel) { + this.dropLevel = dropLevel; + } }