More cleanup. Done with Datatypes. Lack Events, Runnables, and...

Commands.
This commit is contained in:
GJ 2012-03-31 19:00:41 -04:00
parent bb5a9826bc
commit a2f23bd056
8 changed files with 200 additions and 191 deletions

View File

@ -17,7 +17,7 @@ import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.spout.SpoutStuff;
public class HUDmmo { public class HUDmmo {
private int center_x = 427/2; private int center_x = 427 / 2;
private String playerName = null; private String playerName = null;

View File

@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
public class ButtonHUDStyle extends ButtonToggle { public class ButtonHUDStyle extends ButtonToggle {
public ButtonHUDStyle(PlayerProfile PP) { 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) { public void updateText(PlayerProfile PP) {
super.updateText("HUD Type: ", PP.getHUDType().toString()); super.updateText("HUD Type: ", PP.getHUDType().toString()); //TODO: Needs more locale
} }
} }

View File

@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
public class ButtonPartyToggle extends ButtonToggle { public class ButtonPartyToggle extends ButtonToggle {
public ButtonPartyToggle(PlayerProfile PP) { 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) { 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
} }
} }

View File

@ -11,49 +11,58 @@ import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle; import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle; import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
public class PopupMMO extends GenericPopup 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) private ButtonHUDStyle HUDButton = null;
{ private ButtonPartyToggle PartyButton = null;
//240, 427 are the bottom right private ButtonEscape EscapeButton = null;
mcMMO_label.setText(ChatColor.GOLD+"~mcMMO Menu~"); private GenericLabel mcMMO_label = new GenericLabel();
mcMMO_label.setX(center_x-35).setY((center_y/2)-20).setDirty(true); private GenericLabel tip_escape = new GenericLabel();
private int center_x = 427 / 2;
private int center_y = 240 / 2;
tip_escape.setText(ChatColor.GRAY+"Press ESCAPE to exit!"); public PopupMMO(Player player, PlayerProfile PP, mcMMO plugin) {
tip_escape.setX(mcMMO_label.getX()-15).setY(mcMMO_label.getY()+10).setDirty(true);
HUDButton = new ButtonHUDStyle(PP); //240, 427 are the bottom right
HUDButton.setX(center_x-(HUDButton.getWidth()/2)).setY(center_y/2).setDirty(true); 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);
if(LoadProperties.partybar) tip_escape.setText(ChatColor.GRAY + "Press ESCAPE to exit!"); //TODO: Needs more locale
{ tip_escape.setX(mcMMO_label.getX() - 15);
PartyButton = new ButtonPartyToggle(PP); tip_escape.setY(mcMMO_label.getY() + 10);
PartyButton.setX(center_x-(PartyButton.getWidth()/2)).setY(center_y/2+PartyButton.getHeight()).setDirty(true); tip_escape.setDirty(true);
this.attachWidget(plugin, PartyButton);
}
EscapeButton = new ButtonEscape(); HUDButton = new ButtonHUDStyle(PP);
EscapeButton.setX(center_x-(EscapeButton.getWidth()/2)).setY((center_y/2)+(HUDButton.getHeight()*2)+5).setDirty(true); HUDButton.setX(center_x - (HUDButton.getWidth() / 2));
HUDButton.setY(center_y / 2);
HUDButton.setDirty(true);
this.attachWidget(plugin, HUDButton); if (LoadProperties.partybar) {
this.attachWidget(plugin, mcMMO_label); PartyButton = new ButtonPartyToggle(PP);
this.attachWidget(plugin, tip_escape); PartyButton.setX(center_x - (PartyButton.getWidth() / 2));
this.attachWidget(plugin, EscapeButton); PartyButton.setY((center_y / 2) + PartyButton.getHeight());
PartyButton.setDirty(true);
this.attachWidget(plugin, PartyButton);
}
this.setDirty(true); EscapeButton = new ButtonEscape();
} EscapeButton.setX(center_x - (EscapeButton.getWidth() / 2));
EscapeButton.setY((center_y / 2) + (HUDButton.getHeight() * 2) + 5);
EscapeButton.setDirty(true);
public void updateButtons(PlayerProfile PP) this.attachWidget(plugin, HUDButton);
{ this.attachWidget(plugin, mcMMO_label);
HUDButton.updateText(PP); this.attachWidget(plugin, tip_escape);
this.setDirty(true); this.attachWidget(plugin, EscapeButton);
}
this.setDirty(true);
}
public void updateButtons(PlayerProfile PP) {
HUDButton.updateText(PP);
PartyButton.updateText(PP);
this.setDirty(true);
}
} }

View File

@ -3,125 +3,126 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class ExcavationTreasure extends Treasure { 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) { // dirt | grass | sand | gravel | clay | mycel | soulsand
super(drop, xp, dropChance, dropLevel); // 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 ExcavationTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel) {
public byte getDropsFrom() { super(drop, xp, dropChance, dropLevel);
return dropsFrom; }
}
public void setDropsFrom(byte dropsFrom) { // Raw getters and setters
this.dropsFrom = dropsFrom; public byte getDropsFrom() {
} return dropsFrom;
}
// Getters public void setDropsFrom(byte dropsFrom) {
public boolean getDropsFromDirt() { this.dropsFrom = dropsFrom;
return getDropFromMask(1); }
}
public boolean getDropsFromGrass() { // Getters
return getDropFromMask(2); public boolean getDropsFromDirt() {
} return getDropFromMask(1);
}
public boolean getDropsFromSand() { public boolean getDropsFromGrass() {
return getDropFromMask(4); return getDropFromMask(2);
} }
public boolean getDropsFromGravel() { public boolean getDropsFromSand() {
return getDropFromMask(8); return getDropFromMask(4);
} }
public boolean getDropsFromClay() { public boolean getDropsFromGravel() {
return getDropFromMask(16); return getDropFromMask(8);
} }
public boolean getDropsFromMycel() { public boolean getDropsFromClay() {
return getDropFromMask(32); return getDropFromMask(16);
} }
public boolean getDropsFromSoulSand() { public boolean getDropsFromMycel() {
return getDropFromMask(64); return getDropFromMask(32);
} }
private boolean getDropFromMask(int mask) { public boolean getDropsFromSoulSand() {
return ((dropsFrom & mask) > 0) ? true : false; return getDropFromMask(64);
} }
// Setters private boolean getDropFromMask(int mask) {
public void setDropsFromDirt() { return ((dropsFrom & mask) > 0) ? true : false;
setDropFromMask(1); }
}
public void setDropsFromGrass() { // Setters
setDropFromMask(2); public void setDropsFromDirt() {
} setDropFromMask(1);
}
public void setDropsFromSand() { public void setDropsFromGrass() {
setDropFromMask(4); setDropFromMask(2);
} }
public void setDropsFromGravel() { public void setDropsFromSand() {
setDropFromMask(8); setDropFromMask(4);
} }
public void setDropsFromClay() { public void setDropsFromGravel() {
setDropFromMask(16); setDropFromMask(8);
} }
public void setDropsFromMycel() { public void setDropsFromClay() {
setDropFromMask(32); setDropFromMask(16);
} }
public void setDropsFromSoulSand() { public void setDropsFromMycel() {
setDropFromMask(64); setDropFromMask(32);
} }
private void setDropFromMask(int mask) { public void setDropsFromSoulSand() {
dropsFrom |= mask; setDropFromMask(64);
} }
// Un-setters private void setDropFromMask(int mask) {
public void unsetDropsFromDirt() { dropsFrom |= mask;
unsetDropFromMask(1); }
}
public void unsetDropsFromGrass() { // Un-setters
unsetDropFromMask(2); public void unsetDropsFromDirt() {
} unsetDropFromMask(1);
}
public void unsetDropsFromSand() { public void unsetDropsFromGrass() {
unsetDropFromMask(4); unsetDropFromMask(2);
} }
public void unsetDropsFromGravel() { public void unsetDropsFromSand() {
unsetDropFromMask(8); unsetDropFromMask(4);
} }
public void unsetDropsFromClay() { public void unsetDropsFromGravel() {
unsetDropFromMask(16); unsetDropFromMask(8);
} }
public void unsetDropsFromMycel() { public void unsetDropsFromClay() {
unsetDropFromMask(32); unsetDropFromMask(16);
} }
public void unsetDropsFromSoulSand() { public void unsetDropsFromMycel() {
unsetDropFromMask(64); unsetDropFromMask(32);
} }
private void unsetDropFromMask(int mask) { public void unsetDropsFromSoulSand() {
dropsFrom &= ~mask; unsetDropFromMask(64);
} }
private void unsetDropFromMask(int mask) {
dropsFrom &= ~mask;
}
} }

View File

@ -3,18 +3,18 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class FishingTreasure extends Treasure { public class FishingTreasure extends Treasure {
private int maxLevel; private int maxLevel;
public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) { public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) {
super(drop, xp, dropChance, dropLevel); super(drop, xp, dropChance, dropLevel);
this.setMaxLevel(maxLevel); this.setMaxLevel(maxLevel);
} }
public int getMaxLevel() { public int getMaxLevel() {
return maxLevel; return maxLevel;
} }
public void setMaxLevel(int maxLevel) { public void setMaxLevel(int maxLevel) {
this.maxLevel = maxLevel; this.maxLevel = maxLevel;
} }
} }

View File

@ -3,48 +3,47 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public abstract class Treasure { public abstract class Treasure {
private int xp; private int xp;
private Double dropChance; private Double dropChance;
private int dropLevel; 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) { public ItemStack getDrop() {
this.drop = drop; return drop;
this.xp = xp; }
this.dropChance = dropChance;
this.dropLevel = dropLevel;
}
public ItemStack getDrop() { public void setDrop(ItemStack drop) {
return drop; this.drop = drop;
} }
public void setDrop(ItemStack drop) { public int getXp() {
this.drop = drop; return xp;
} }
public int getXp() { public void setXp(int xp) {
return xp; this.xp = xp;
} }
public void setXp(int xp) { public Double getDropChance() {
this.xp = xp; return dropChance;
} }
public Double getDropChance() { public void setDropChance(Double dropChance) {
return dropChance; this.dropChance = dropChance;
} }
public void setDropChance(Double dropChance) { public int getDropLevel() {
this.dropChance = dropChance; return dropLevel;
} }
public int getDropLevel() { public void setDropLevel(int dropLevel) {
return dropLevel; this.dropLevel = dropLevel;
} }
public void setDropLevel(int dropLevel) {
this.dropLevel = dropLevel;
}
} }