Some improvements to the settings menu
This commit is contained in:
parent
be006d02c3
commit
8c9ec25ce8
|
@ -73,6 +73,10 @@ rotation.change.broadcast.previous = Previous: {0}
|
|||
rotation.change.broadcast.current = Current: {0}
|
||||
rotation.change.broadcast.info = The rotations have been changed to accommodate the number of online players.
|
||||
|
||||
setting.types.chat = Chat
|
||||
setting.types.gameplay = Gameplay
|
||||
setting.types.misc = Miscellaneous
|
||||
|
||||
command.match.matchInfo.title = Match
|
||||
command.match.matchInfo.title.tip = View this match on the web
|
||||
command.match.matchInfo.time = Time
|
||||
|
|
|
@ -32,15 +32,12 @@ public class SettingMenuHelper {
|
|||
for (Setting s : misc) { settings.put(s,SettingType.MISC); }
|
||||
}
|
||||
|
||||
public static List<Setting> getAllOfType (SettingType settingType) {
|
||||
public static List<Setting> getAllOfType(SettingType settingType) {
|
||||
return PlayerSettings.getRegistry().getSettings().stream().filter(setting -> getSettingType(setting) == settingType).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static SettingType getSettingType(Setting setting) {
|
||||
if (settings.get(setting) != null) {
|
||||
return settings.get(setting);
|
||||
}
|
||||
return SettingType.MISC;
|
||||
return settings.getOrDefault(setting, SettingType.MISC);
|
||||
}
|
||||
|
||||
public enum SettingType {
|
||||
|
|
|
@ -13,7 +13,11 @@ import tc.oc.commons.bukkit.gui.interfaces.SinglePageInterface;
|
|||
import tc.oc.commons.bukkit.util.Constants;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class SettingsInterface extends SinglePageInterface {
|
||||
|
||||
|
@ -65,6 +69,8 @@ public class SettingsInterface extends SinglePageInterface {
|
|||
@Override
|
||||
public void setDefaultButtons() {
|
||||
defaultButtons.clear();
|
||||
|
||||
// "Go back" button
|
||||
defaultButtons.add(new Button(new ItemCreator(Material.WOOL)
|
||||
.setData(14)
|
||||
.setName(ChatColor.GREEN + "Go Back"), 49) {
|
||||
|
@ -73,6 +79,8 @@ public class SettingsInterface extends SinglePageInterface {
|
|||
player.openInventory(new MainMenuInterface(player).getInventory());
|
||||
}
|
||||
});
|
||||
|
||||
// Create empty buttons at unused slots
|
||||
for (Integer integer : new Integer[]{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 17,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package tc.oc.pgm.menu.gui;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.commons.bukkit.gui.buttons.Button;
|
||||
|
@ -8,8 +9,11 @@ import tc.oc.commons.bukkit.gui.buttons.empty.EmptyButton;
|
|||
import tc.oc.commons.bukkit.gui.interfaces.SinglePageInterface;
|
||||
import tc.oc.commons.bukkit.util.Constants;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
import tc.oc.commons.core.chat.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SettingsTypeInterface extends SinglePageInterface {
|
||||
|
||||
|
@ -23,7 +27,7 @@ public class SettingsTypeInterface extends SinglePageInterface {
|
|||
List<Button> buttons = new ArrayList<>();
|
||||
buttons.add(new Button(
|
||||
new ItemCreator(Material.BOOK_AND_QUILL)
|
||||
.setName(Constants.PREFIX + "Chat")
|
||||
.setName(Constants.PREFIX + new Component(new TranslatableComponent("setting.types.chat")).getText())
|
||||
, 11) {
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
|
@ -32,7 +36,7 @@ public class SettingsTypeInterface extends SinglePageInterface {
|
|||
});
|
||||
buttons.add(new Button(
|
||||
new ItemCreator(Material.DIAMOND_SWORD)
|
||||
.setName(Constants.PREFIX + "Gameplay")
|
||||
.setName(Constants.PREFIX + new Component(new TranslatableComponent("setting.types.gameplay")).getText())
|
||||
, 13) {
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
|
@ -41,7 +45,7 @@ public class SettingsTypeInterface extends SinglePageInterface {
|
|||
});
|
||||
buttons.add(new Button(
|
||||
new ItemCreator(Material.SLIME_BALL)
|
||||
.setName(Constants.PREFIX + "Miscellaneous")
|
||||
.setName(Constants.PREFIX + new Component(new TranslatableComponent("setting.types.misc")).getText())
|
||||
, 15) {
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
|
@ -56,6 +60,8 @@ public class SettingsTypeInterface extends SinglePageInterface {
|
|||
@Override
|
||||
public void setDefaultButtons() {
|
||||
defaultButtons.clear();
|
||||
|
||||
// "Go back" button
|
||||
defaultButtons.add(new Button(new ItemCreator(Material.WOOL)
|
||||
.setData(14)
|
||||
.setName(ChatColor.GREEN + "Go Back"), 22) {
|
||||
|
@ -64,6 +70,8 @@ public class SettingsTypeInterface extends SinglePageInterface {
|
|||
player.openInventory(new MainMenuInterface(player).getInventory());
|
||||
}
|
||||
});
|
||||
|
||||
// Create empty buttons at unused slots
|
||||
for (Integer integer : new Integer[]{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 12, 14, 16, 17,
|
||||
|
|
Loading…
Reference in New Issue