GJ 13 роки тому
батько
коміт
bb5a9826bc

+ 8 - 8
src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonEscape.java

@@ -2,12 +2,12 @@ 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).setHeight(20);
-		this.setDirty(true);
-	}
+public class ButtonEscape extends GenericButton {
+
+    public ButtonEscape() {
+        this.setText("EXIT");
+        this.setWidth(60);
+        this.setHeight(20);
+        this.setDirty(true);
+    }
 }

+ 10 - 17
src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonHUDStyle.java

@@ -1,21 +1,14 @@
 package com.gmail.nossr50.datatypes.buttons;
 
-import org.getspout.spoutapi.gui.GenericButton;
-
 import com.gmail.nossr50.datatypes.PlayerProfile;
 
-public class ButtonHUDStyle extends GenericButton
-{
-	public ButtonHUDStyle(PlayerProfile PP)
-	{
-		this.setText("HUD Type: "+PP.getHUDType().toString());
-		this.setTooltip("Change your HUD style!");
-		this.setWidth(120).setHeight(20);
-		this.setDirty(true);
-	}
-	public void updateText(PlayerProfile PP)
-	{
-		this.setText("HUD Type: "+PP.getHUDType().toString());
-		this.setDirty(true);
-	}
-}
+public class ButtonHUDStyle extends ButtonToggle {
+
+    public ButtonHUDStyle(PlayerProfile PP) {
+        super("HUD Type: ", PP.getHUDType().toString(), "Change your HUD style!");
+    }
+
+    public void updateText(PlayerProfile PP) {
+        super.updateText("HUD Type: ", PP.getHUDType().toString());
+    }
+}

+ 10 - 17
src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonPartyToggle.java

@@ -1,21 +1,14 @@
 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);
-	}
-}
+public class ButtonPartyToggle extends ButtonToggle {
+
+    public ButtonPartyToggle(PlayerProfile PP) {
+        super("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString(), "Toggle the Party HUD!");
+    }
+
+    public void updateText(PlayerProfile PP) {
+        super.updateText("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString());
+    }
+}

+ 19 - 0
src/main/java/com/gmail/nossr50/datatypes/buttons/ButtonToggle.java

@@ -0,0 +1,19 @@
+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);
+    }
+}