mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-25 11:46:50 +01:00
Fixes for Client UI
This commit is contained in:
parent
ba6af4d66d
commit
b707f2cc0c
@ -89,7 +89,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Host-Menu.Server-Menu"))) {
|
||||
player.closeInventory();
|
||||
gui.serverMenu(1, null, null);
|
||||
} else if (!item.equals(ChatColor.RESET.toString()) && !item.equals(plugin.api.getLang("SubServers", "Interface.Host-Menu.No-Hosts"))) {
|
||||
} else if ((item.length() != 0 && !item.equals(ChatColor.RESET.toString())) && !item.equals(plugin.api.getLang("SubServers", "Interface.Host-Menu.No-Hosts"))) {
|
||||
player.closeInventory();
|
||||
String obj;
|
||||
if (event.getCurrentItem().getItemMeta().getLore() != null && event.getCurrentItem().getItemMeta().getLore().size() > 0 && event.getCurrentItem().getItemMeta().getLore().get(0).startsWith(ChatColor.GRAY.toString())) {
|
||||
@ -193,7 +193,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
|
||||
player.closeInventory();
|
||||
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
|
||||
} else {
|
||||
} else if ((item.length() != 0 && !item.equals(ChatColor.RESET.toString())) && !item.equals(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Template.No-Templates"))) {
|
||||
player.closeInventory();
|
||||
String obj;
|
||||
if (event.getCurrentItem().getItemMeta().getLore() != null && event.getCurrentItem().getItemMeta().getLore().size() > 0 && event.getCurrentItem().getItemMeta().getLore().get(0).startsWith(ChatColor.GRAY.toString())) {
|
||||
@ -219,7 +219,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
|
||||
player.closeInventory();
|
||||
gui.back();
|
||||
} else {
|
||||
} else if ((item.length() != 0 && !item.equals(ChatColor.RESET.toString())) && !item.equals(plugin.api.getLang("SubServers", "Interface.Host-Plugin.No-Plugins"))) {
|
||||
player.closeInventory();
|
||||
final Value<PluginRenderer<Host>> plugin = new Container<PluginRenderer<Host>>(null);
|
||||
for (PluginRenderer<Host> renderer : DefaultUIRenderer.hostPlugins.values()) {
|
||||
@ -254,7 +254,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Group-Menu.Server-Menu"))) {
|
||||
player.closeInventory();
|
||||
gui.serverMenu(1, null, null);
|
||||
} else if (!item.equals(ChatColor.RESET.toString()) && !item.equals(plugin.api.getLang("SubServers", "Interface.Group-Menu.No-Groups"))) {
|
||||
} else if ((item.length() != 0 && !item.equals(ChatColor.RESET.toString())) && !item.equals(plugin.api.getLang("SubServers", "Interface.Group-Menu.No-Groups"))) {
|
||||
player.closeInventory();
|
||||
gui.serverMenu(1, null, ChatColor.stripColor(item));
|
||||
}
|
||||
@ -281,7 +281,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
|
||||
player.closeInventory();
|
||||
gui.back();
|
||||
} else if (!item.equals(ChatColor.RESET.toString()) && !item.startsWith(ChatColor.WHITE.toString()) && !item.equals(plugin.api.getLang("SubServers", "Interface.Server-Menu.No-Servers"))) {
|
||||
} else if ((item.length() != 0 && !item.equals(ChatColor.RESET.toString())) && !item.startsWith(ChatColor.WHITE.toString()) && !item.equals(plugin.api.getLang("SubServers", "Interface.Server-Menu.No-Servers"))) {
|
||||
player.closeInventory();
|
||||
String obj;
|
||||
if (event.getCurrentItem().getItemMeta().getLore() != null && event.getCurrentItem().getItemMeta().getLore().size() > 0 && event.getCurrentItem().getItemMeta().getLore().get(0).startsWith(ChatColor.GRAY.toString())) {
|
||||
@ -424,7 +424,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
|
||||
player.closeInventory();
|
||||
gui.back();
|
||||
} else {
|
||||
} else if ((item.length() != 0 && !item.equals(ChatColor.RESET.toString())) && !item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.No-Plugins"))) {
|
||||
player.closeInventory();
|
||||
Value<PluginRenderer<SubServer>> plugin = new Container<PluginRenderer<SubServer>>(null);
|
||||
for (PluginRenderer<SubServer> renderer : DefaultUIRenderer.subserverPlugins.values()) {
|
||||
|
@ -0,0 +1,15 @@
|
||||
package net.ME1312.SubServers.Client.Bukkit.Library;
|
||||
|
||||
/**
|
||||
* SubServers.Client Access Mode Enum
|
||||
*/
|
||||
public enum AccessMode {
|
||||
DEFAULT(0),
|
||||
NO_COMMANDS(-1),
|
||||
NO_INTEGRATIONS(-2),
|
||||
;
|
||||
public final byte value;
|
||||
AccessMode(int value) {
|
||||
this.value = (byte) value;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import net.ME1312.SubData.Client.DataClient;
|
||||
import net.ME1312.SubData.Client.DataProtocol;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Graphic.UIHandler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.AccessMode;
|
||||
import net.ME1312.SubServers.Client.Common.ClientAPI;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -19,11 +20,13 @@ public final class SubAPI extends ClientAPI {
|
||||
LinkedList<Runnable> reloadListeners = new LinkedList<Runnable>();
|
||||
private final SubPlugin plugin;
|
||||
private static SubAPI api;
|
||||
AccessMode access;
|
||||
String name;
|
||||
|
||||
SubAPI(SubPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
GAME_VERSION = getGameVersion();
|
||||
access = AccessMode.DEFAULT;
|
||||
api = this;
|
||||
}
|
||||
|
||||
@ -107,6 +110,26 @@ public final class SubAPI extends ClientAPI {
|
||||
return new LinkedHashMap<>(plugin.lang.value().get(channel.toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin's access mode
|
||||
*
|
||||
* @return Access Mode
|
||||
*/
|
||||
public AccessMode getAccessMode() {
|
||||
return access;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the plugin's access mode
|
||||
*
|
||||
* @param mode Access Mode
|
||||
*/
|
||||
public void setAccessMode(AccessMode mode) {
|
||||
if (mode.value <= access.value && !plugin.isEnabled()) {
|
||||
access = mode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Graphics Handler
|
||||
*
|
||||
|
@ -23,7 +23,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -35,7 +35,7 @@ import java.util.*;
|
||||
|
||||
import static net.ME1312.SubServers.Client.Bukkit.Library.ObjectPermission.permits;
|
||||
|
||||
public final class SubCommand extends BukkitCommand {
|
||||
public final class SubCommand extends Command {
|
||||
private SubPlugin plugin;
|
||||
|
||||
public SubCommand(SubPlugin plugin, String name) {
|
||||
|
@ -11,7 +11,6 @@ import net.ME1312.SubData.Client.DataClient;
|
||||
import net.ME1312.SubData.Client.Encryption.AES;
|
||||
import net.ME1312.SubData.Client.Encryption.DHE;
|
||||
import net.ME1312.SubData.Client.Encryption.RSA;
|
||||
import net.ME1312.SubData.Client.Library.DataSize;
|
||||
import net.ME1312.SubData.Client.Library.DisconnectReason;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Graphic.DefaultUIHandler;
|
||||
@ -35,6 +34,8 @@ import java.nio.file.StandardCopyOption;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static net.ME1312.SubServers.Client.Bukkit.Library.AccessMode.*;
|
||||
|
||||
/**
|
||||
* SubServers Client Plugin Class
|
||||
*/
|
||||
@ -116,16 +117,16 @@ public final class SubPlugin extends JavaPlugin {
|
||||
System.out.println("SubData > Connecting to /" + config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391"));
|
||||
connect(null);
|
||||
|
||||
if (!config.get().getMap("Settings").getBoolean("API-Only-Mode", false)) {
|
||||
gui = new DefaultUIHandler(this);
|
||||
if (api.access.value > NO_COMMANDS.value && !config.get().getMap("Settings").getBoolean("API-Only-Mode", false)) {
|
||||
CommandMap cmd = Util.reflect(Bukkit.getServer().getClass().getDeclaredField("commandMap"), Bukkit.getServer());
|
||||
gui = new DefaultUIHandler(this);
|
||||
|
||||
cmd.register("subservers", new SubCommand(this, "subservers"));
|
||||
cmd.register("subservers", new SubCommand(this, "subserver"));
|
||||
cmd.register("subservers", new SubCommand(this, "sub"));
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
if (api.access.value > NO_INTEGRATIONS.value && Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.PlaceholderImpl(this).register();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package net.ME1312.SubServers.Client.Sponge.Library;
|
||||
|
||||
/**
|
||||
* SubServers.Client Access Mode Enum
|
||||
*/
|
||||
public enum AccessMode {
|
||||
DEFAULT(0),
|
||||
NO_COMMANDS(-1),
|
||||
NO_INTEGRATIONS(-2),
|
||||
;
|
||||
public final byte value;
|
||||
AccessMode(int value) {
|
||||
this.value = (byte) value;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import net.ME1312.SubData.Client.DataProtocol;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubServers.Client.Common.ClientAPI;
|
||||
import net.ME1312.SubServers.Client.Sponge.Graphic.UIHandler;
|
||||
import net.ME1312.SubServers.Client.Sponge.Library.AccessMode;
|
||||
|
||||
import org.spongepowered.api.Platform;
|
||||
import org.spongepowered.api.Sponge;
|
||||
@ -21,11 +22,13 @@ public final class SubAPI extends ClientAPI {
|
||||
LinkedList<Runnable> reloadListeners = new LinkedList<Runnable>();
|
||||
private final SubPlugin plugin;
|
||||
private static SubAPI api;
|
||||
AccessMode access;
|
||||
String name;
|
||||
|
||||
SubAPI(SubPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
GAME_VERSION = getGameVersion();
|
||||
access = AccessMode.DEFAULT;
|
||||
api = this;
|
||||
}
|
||||
|
||||
@ -109,6 +112,26 @@ public final class SubAPI extends ClientAPI {
|
||||
return new LinkedHashMap<>(plugin.lang.value().get(channel.toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin's access mode
|
||||
*
|
||||
* @return Access Mode
|
||||
*/
|
||||
public AccessMode getAccessMode() {
|
||||
return access;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the plugin's access mode
|
||||
*
|
||||
* @param mode Access Mode
|
||||
*/
|
||||
public void setAccessMode(AccessMode mode) {
|
||||
if (mode.value <= access.value && !plugin.running) {
|
||||
access = mode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Graphics Handler
|
||||
*
|
||||
|
@ -44,6 +44,8 @@ import java.nio.file.StandardCopyOption;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static net.ME1312.SubServers.Client.Sponge.Library.AccessMode.NO_COMMANDS;
|
||||
|
||||
/**
|
||||
* SubServers Client Plugin Class
|
||||
*/
|
||||
@ -63,7 +65,7 @@ public final class SubPlugin {
|
||||
@Inject public PluginContainer plugin;
|
||||
@Inject public Game game;
|
||||
|
||||
private boolean running = false;
|
||||
boolean running = false;
|
||||
private long resetDate = 0;
|
||||
private boolean reconnect = false;
|
||||
|
||||
@ -136,8 +138,8 @@ public final class SubPlugin {
|
||||
log.info("Connecting to /" + config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391"));
|
||||
connect(null);
|
||||
|
||||
if (!config.get().getMap("Settings").getBoolean("API-Only-Mode", false)) {
|
||||
//gui = new InternalUIHandler(this);
|
||||
//gui = new InternalUIHandler(this);
|
||||
if (api.access.value > NO_COMMANDS.value && !config.get().getMap("Settings").getBoolean("API-Only-Mode", false)) {
|
||||
Sponge.getCommandManager().register(plugin, new SubCommand(this).spec(), "sub", "subserver", "subservers");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user