mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-22 10:15:52 +01:00
SubServers 2 Beta 5
This commit is contained in:
parent
b50452b93a
commit
83415cb873
Binary file not shown.
Binary file not shown.
@ -1,67 +0,0 @@
|
|||||||
package net.ME1312.SubServers.Bungee.Event;
|
|
||||||
|
|
||||||
import net.ME1312.SubServers.Bungee.Host.Server;
|
|
||||||
import net.ME1312.SubServers.Bungee.Host.SubServer;
|
|
||||||
import net.ME1312.SubServers.Bungee.Library.NamedContainer;
|
|
||||||
import net.ME1312.SubServers.Bungee.Library.SubEvent;
|
|
||||||
import net.md_5.bungee.api.plugin.Cancellable;
|
|
||||||
import net.md_5.bungee.api.plugin.Event;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class SubEditServerEvent extends Event implements SubEvent, Cancellable {
|
|
||||||
private boolean cancelled = false;
|
|
||||||
private UUID player;
|
|
||||||
private SubServer server;
|
|
||||||
private List<NamedContainer<String, ?>> changes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Server Edit Event
|
|
||||||
*
|
|
||||||
* @param player Player Starting Server
|
|
||||||
* @param server Server Being Changed
|
|
||||||
* @param change Pending Changes
|
|
||||||
*/
|
|
||||||
public SubEditServerEvent(UUID player, SubServer server, NamedContainer<String, ?>... change) {
|
|
||||||
this.player = player;
|
|
||||||
this.server = server;
|
|
||||||
this.changes = Arrays.asList(change);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Server to be Added
|
|
||||||
* @return The Server to be Added
|
|
||||||
*/
|
|
||||||
public Server getServer() { return server; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the player that triggered the Event
|
|
||||||
* @return The Player that triggered this Event or null if Console
|
|
||||||
*/
|
|
||||||
public UUID getPlayer() { return player; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Changes to made by this Edit
|
|
||||||
* @return Pending Changes
|
|
||||||
*/
|
|
||||||
public List<NamedContainer<String, ?>> getChanges() {
|
|
||||||
return changes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Cancelled Status
|
|
||||||
* @return Cancelled Status
|
|
||||||
*/
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Cancelled Status
|
|
||||||
*/
|
|
||||||
public void setCancelled(boolean value) {
|
|
||||||
cancelled = value;
|
|
||||||
}
|
|
||||||
}
|
|
@ -58,13 +58,6 @@ public abstract class Host {
|
|||||||
*/
|
*/
|
||||||
public abstract String getDirectory();
|
public abstract String getDirectory();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get if the Host can be Edited
|
|
||||||
*
|
|
||||||
* @return Editable Status
|
|
||||||
*/
|
|
||||||
public abstract boolean isEditable();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Name of this Host
|
* Get the Name of this Host
|
||||||
*
|
*
|
||||||
@ -150,25 +143,6 @@ public abstract class Host {
|
|||||||
*/
|
*/
|
||||||
public abstract int command(UUID player, String command, String... servers);
|
public abstract int command(UUID player, String command, String... servers);
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies edits to the Host
|
|
||||||
*
|
|
||||||
* @param player Player Editing
|
|
||||||
* @param change Change(s) to be applied
|
|
||||||
* @return Success Status
|
|
||||||
*/
|
|
||||||
public abstract int edit(UUID player, NamedContainer<String, ?>... change);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies edits to the SubServer
|
|
||||||
*
|
|
||||||
* @param change Change(s) to be applied
|
|
||||||
* @return Success Status
|
|
||||||
*/
|
|
||||||
public int edit(NamedContainer<String, ?>... change) {
|
|
||||||
return edit(null, change);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the SubCreator Instance for this Host
|
* Gets the SubCreator Instance for this Host
|
||||||
*
|
*
|
||||||
|
@ -56,11 +56,6 @@ public class InternalHost extends Host {
|
|||||||
return directory;
|
return directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEditable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@ -102,17 +97,6 @@ public class InternalHost extends Host {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int edit(UUID player, NamedContainer<String, ?>... changes) {
|
|
||||||
int i = 0;
|
|
||||||
for (NamedContainer<String, ?> change : changes) {
|
|
||||||
switch (change.name().toLowerCase()) {
|
|
||||||
// TODO SubEditor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCreator getCreator() {
|
public SubCreator getCreator() {
|
||||||
return creator;
|
return creator;
|
||||||
|
@ -471,7 +471,7 @@ public class InternalSubCreator extends SubCreator {
|
|||||||
|
|
||||||
if (process2.exitValue() == 0) {
|
if (process2.exitValue() == 0) {
|
||||||
if (host.plugin.exServers.keySet().contains(name.toLowerCase())) host.plugin.exServers.remove(name.toLowerCase());
|
if (host.plugin.exServers.keySet().contains(name.toLowerCase())) host.plugin.exServers.remove(name.toLowerCase());
|
||||||
host.addSubServer(player, name, true, port, "&aThis is a SubServer", true, dir.getPath(), exec, "stop", true, false, false, false, false);
|
host.addSubServer(player, name, true, port, "&aThis is a SubServer", true, new UniversalFile(".:" + name).getPath(), exec, "stop", true, false, false, false, false);
|
||||||
|
|
||||||
YAMLSection server = new YAMLSection();
|
YAMLSection server = new YAMLSection();
|
||||||
server.set("Enabled", true);
|
server.set("Enabled", true);
|
||||||
@ -479,7 +479,7 @@ public class InternalSubCreator extends SubCreator {
|
|||||||
server.set("Port", port);
|
server.set("Port", port);
|
||||||
server.set("Motd", "&aThis is a SubServer");
|
server.set("Motd", "&aThis is a SubServer");
|
||||||
server.set("Log", true);
|
server.set("Log", true);
|
||||||
server.set("Directory", dir.getPath());
|
server.set("Directory", new UniversalFile(".:" + name));
|
||||||
server.set("Executable", exec.toString());
|
server.set("Executable", exec.toString());
|
||||||
server.set("Stop-Command", "stop");
|
server.set("Stop-Command", "stop");
|
||||||
server.set("Run-On-Launch", false);
|
server.set("Run-On-Launch", false);
|
||||||
|
@ -16,7 +16,6 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class InternalSubServer extends SubServer {
|
public class InternalSubServer extends SubServer {
|
||||||
private InternalHost host;
|
private InternalHost host;
|
||||||
private String name;
|
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private Container<Boolean> log;
|
private Container<Boolean> log;
|
||||||
private File directory;
|
private File directory;
|
||||||
@ -32,7 +31,6 @@ public class InternalSubServer extends SubServer {
|
|||||||
public InternalSubServer(Host host, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean start, boolean restart, boolean hidden, boolean restricted, boolean temporary) throws InvalidServerException {
|
public InternalSubServer(Host host, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean start, boolean restart, boolean hidden, boolean restricted, boolean temporary) throws InvalidServerException {
|
||||||
super(host, name, port, motd, hidden, restricted);
|
super(host, name, port, motd, hidden, restricted);
|
||||||
this.host = (InternalHost) host;
|
this.host = (InternalHost) host;
|
||||||
this.name = name;
|
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.log = new Container<Boolean>(log);
|
this.log = new Container<Boolean>(log);
|
||||||
this.directory = new File(host.getDirectory(), directory);
|
this.directory = new File(host.getDirectory(), directory);
|
||||||
@ -157,182 +155,6 @@ public class InternalSubServer extends SubServer {
|
|||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int edit(UUID player, NamedContainer<String, ?>... changes) {
|
|
||||||
int i = 0;
|
|
||||||
SubEditServerEvent eEvent = new SubEditServerEvent(player, this, changes);
|
|
||||||
host.plugin.getPluginManager().callEvent(eEvent);
|
|
||||||
if (!eEvent.isCancelled()) {
|
|
||||||
for (NamedContainer<String, ?> change : changes) {
|
|
||||||
try {
|
|
||||||
boolean running = isRunning();
|
|
||||||
switch (change.name().toLowerCase()) {
|
|
||||||
case "host":
|
|
||||||
if (change.get() instanceof String) {
|
|
||||||
InternalHost oldhost = host;
|
|
||||||
Host newhost = host.plugin.hosts.get(((String) change.get()).toLowerCase());
|
|
||||||
if (newhost != null) {
|
|
||||||
if (running) allowrestart = false;
|
|
||||||
if (host.removeSubServer(player, getName())) {
|
|
||||||
if (newhost.addSubServer(player, getName(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), directory.getPath(), executable, getStopCommand(), running, willAutoRestart(), isHidden(), isRestricted(), isTemporary()) != null) {
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Host", newhost.getName());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
oldhost.servers.put(getName().toLowerCase(), this);
|
|
||||||
if (running) start(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "name":
|
|
||||||
if (change.get() instanceof String) {
|
|
||||||
host.servers.remove(getName().toLowerCase());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").set((String) change.get(), host.plugin.config.get().getSection("Servers").getSection(getName()));
|
|
||||||
host.plugin.config.get().getSection("Servers").remove(getName());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
name = (String) change.get();
|
|
||||||
host.servers.put(((String) change.get()).toLowerCase(), this);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "enabled":
|
|
||||||
if (change.get() instanceof Boolean) {
|
|
||||||
setEnabled((Boolean) change.get());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Enabled", isEnabled());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "log":
|
|
||||||
if (change.get() instanceof Boolean) {
|
|
||||||
setLogging((Boolean) change.get());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Log", isLogging());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "dir":
|
|
||||||
if (change.get() instanceof String) {
|
|
||||||
directory = new File((String) change.get());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Directory", directory.getPath());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
} else if (change.get() instanceof File) {
|
|
||||||
directory = (File) change.get();
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Directory", directory.getPath());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "exec":
|
|
||||||
if (change.get() instanceof String) {
|
|
||||||
executable = new Executable((String) change.get());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Executable", executable.toString());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
} else if (change.get() instanceof Executable) {
|
|
||||||
executable = (Executable) change.get();
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Executable", executable.toString());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "running":
|
|
||||||
if (change.get() instanceof Boolean) {
|
|
||||||
if (running) {
|
|
||||||
if (!((Boolean) change.get())) stop(player);
|
|
||||||
} else {
|
|
||||||
if (((Boolean) change.get())) start(player);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "stop-cmd":
|
|
||||||
if (change.get() instanceof String) {
|
|
||||||
setStopCommand((String) change.get());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Stop-Command", getStopCommand());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "auto-run":
|
|
||||||
if (change.get() instanceof Boolean) {
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Run-On-Launch", change.get());
|
|
||||||
host.plugin.config.save();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "auto-restart":
|
|
||||||
if (change.get() instanceof Boolean) {
|
|
||||||
setAutoRestart((Boolean) change.get());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Auto-Restart", willAutoRestart());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "restricted":
|
|
||||||
if (change.get() instanceof Boolean) {
|
|
||||||
setRestricted((Boolean) change.get());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Restricted", isRestricted());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "hidden":
|
|
||||||
if (change.get() instanceof Boolean) {
|
|
||||||
setHidden((Boolean) change.get());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Hidden", isHidden());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "motd":
|
|
||||||
if (change.get() instanceof String) {
|
|
||||||
setMotd((String) change.get());
|
|
||||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
|
||||||
host.plugin.config.get().getSection("Servers").getSection(getName()).set("Motd", getMotd());
|
|
||||||
host.plugin.config.save();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void waitFor() throws InterruptedException {
|
public void waitFor() throws InterruptedException {
|
||||||
while (thread != null && thread.isAlive()) {
|
while (thread != null && thread.isAlive()) {
|
||||||
@ -340,11 +162,6 @@ public class InternalSubServer extends SubServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRunning() {
|
public boolean isRunning() {
|
||||||
return process != null && process.isAlive();
|
return process != null && process.isAlive();
|
||||||
@ -365,11 +182,6 @@ public class InternalSubServer extends SubServer {
|
|||||||
enabled = value;
|
enabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEditable() {
|
|
||||||
return host.isEditable() && !isRunning();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLogging() {
|
public boolean isLogging() {
|
||||||
return log.get();
|
return log.get();
|
||||||
|
@ -97,25 +97,6 @@ public abstract class SubServer extends Server {
|
|||||||
return command(null, command);
|
return command(null, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies edits to the SubServer
|
|
||||||
*
|
|
||||||
* @param player Player Editing
|
|
||||||
* @param change Change(s) to be applied
|
|
||||||
* @return Success Status
|
|
||||||
*/
|
|
||||||
public abstract int edit(UUID player, NamedContainer<String, ?>... change);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies edits to the SubServer
|
|
||||||
*
|
|
||||||
* @param change Change(s) to be applied
|
|
||||||
* @return Success Status
|
|
||||||
*/
|
|
||||||
public int edit(NamedContainer<String, ?>... change) {
|
|
||||||
return edit(null, change);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits for the Server to Stop
|
* Waits for the Server to Stop
|
||||||
*
|
*
|
||||||
@ -151,13 +132,6 @@ public abstract class SubServer extends Server {
|
|||||||
*/
|
*/
|
||||||
public abstract void setEnabled(boolean value);
|
public abstract void setEnabled(boolean value);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get if the SubServer can be Edited
|
|
||||||
*
|
|
||||||
* @return Editable Status
|
|
||||||
*/
|
|
||||||
public abstract boolean isEditable();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the Server is Logging
|
* If the Server is Logging
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
ip_forward: true
|
ip_forward: true
|
||||||
network_compression_threshold: 256
|
network_compression_threshold: 256
|
||||||
stats: undefined
|
stats: 'undefined'
|
||||||
permissions:
|
permissions:
|
||||||
default:
|
default:
|
||||||
- bungeecord.command.server
|
- bungeecord.command.server
|
||||||
|
@ -3,11 +3,11 @@ Settings:
|
|||||||
Log-Creator: true
|
Log-Creator: true
|
||||||
SubData:
|
SubData:
|
||||||
Address: '127.0.0.1:4391'
|
Address: '127.0.0.1:4391'
|
||||||
Password: 'password123'
|
Password: ''
|
||||||
Allowed-Connections: []
|
Allowed-Connections: []
|
||||||
|
|
||||||
Hosts:
|
Hosts:
|
||||||
'~Built-In':
|
'~':
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Driver: 'BUILT-IN'
|
Driver: 'BUILT-IN'
|
||||||
Address: '127.0.0.1'
|
Address: '127.0.0.1'
|
||||||
@ -15,13 +15,13 @@ Hosts:
|
|||||||
Git-Bash: 'C:\Program Files\Git'
|
Git-Bash: 'C:\Program Files\Git'
|
||||||
|
|
||||||
Servers:
|
Servers:
|
||||||
'Server_1':
|
'Example':
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Host: '~Built-In'
|
Host: '~'
|
||||||
Port: 25566
|
Port: 25567
|
||||||
Motd: '&aThis is a SubServer'
|
Motd: '&aThis is a SubServer'
|
||||||
Log: true
|
Log: true
|
||||||
Directory: './Server_1'
|
Directory: './Example'
|
||||||
Executable: 'java -Djline.terminal=jline.UnsupportedTerminal -jar Spigot.jar'
|
Executable: 'java -Djline.terminal=jline.UnsupportedTerminal -jar Spigot.jar'
|
||||||
Stop-Command: 'stop'
|
Stop-Command: 'stop'
|
||||||
Run-On-Launch: false
|
Run-On-Launch: false
|
||||||
|
@ -78,8 +78,7 @@ Lang:
|
|||||||
'Interface.Host-Admin.Creator': '&eCreate a SubServer'
|
'Interface.Host-Admin.Creator': '&eCreate a SubServer'
|
||||||
'Interface.Host-Admin.Creator-Busy': '&4SubCreator is already running'
|
'Interface.Host-Admin.Creator-Busy': '&4SubCreator is already running'
|
||||||
'Interface.Host-Admin.SubServers': '&aView SubServers'
|
'Interface.Host-Admin.SubServers': '&aView SubServers'
|
||||||
'Interface.Host-Admin.Editor': '&eEdit Host'
|
'Interface.Host-Admin.Plugins': '&bPlugins...'
|
||||||
'Interface.Host-Admin.Editor-Unavailable': '&4This Host cannot be edited'
|
|
||||||
'Interface.Host-Creator.Title': 'Host/$str$/Create'
|
'Interface.Host-Creator.Title': 'Host/$str$/Create'
|
||||||
'Interface.Host-Creator.Edit-Name': 'Change Name'
|
'Interface.Host-Creator.Edit-Name': 'Change Name'
|
||||||
'Interface.Host-Creator.Edit-Name.Title': '&eSubCreator\n&6Enter a Name for this Server'
|
'Interface.Host-Creator.Edit-Name.Title': '&eSubCreator\n&6Enter a Name for this Server'
|
||||||
@ -110,7 +109,8 @@ Lang:
|
|||||||
'Interface.Host-Creator.Edit-RAM.Invalid-Title': '&eSubCreator\n&cInvalid Ram Amount'
|
'Interface.Host-Creator.Edit-RAM.Invalid-Title': '&eSubCreator\n&cInvalid Ram Amount'
|
||||||
'Interface.Host-Creator.Submit': '&eCreate SubServer'
|
'Interface.Host-Creator.Submit': '&eCreate SubServer'
|
||||||
'Interface.Host-Creator.Form-Incomplete': '&4Buttons above must be green'
|
'Interface.Host-Creator.Form-Incomplete': '&4Buttons above must be green'
|
||||||
'Interface.Host-Editor.Title': 'Host/$str$/Edit'
|
'Interface.Host-Plugin.Title': 'Host/$str$/Plugins'
|
||||||
|
'Interface.Host-Plugin.No-Plugins': '&c&oThere are No Plugins Available'
|
||||||
'Interface.Host-SubServer.Title': 'Host/$str$/SubServers'
|
'Interface.Host-SubServer.Title': 'Host/$str$/SubServers'
|
||||||
'Interface.SubServer-Menu.Title': 'SubServer Menu'
|
'Interface.SubServer-Menu.Title': 'SubServer Menu'
|
||||||
'Interface.SubServer-Menu.SubServer-Player-Count': '&2$int$ Player(s) Online'
|
'Interface.SubServer-Menu.SubServer-Player-Count': '&2$int$ Player(s) Online'
|
||||||
@ -130,7 +130,6 @@ Lang:
|
|||||||
'Interface.SubServer-Admin.Command': '&eSend a Command to the SubServer'
|
'Interface.SubServer-Admin.Command': '&eSend a Command to the SubServer'
|
||||||
'Interface.SubServer-Admin.Command.Title': '&eSubServers\n&6Enter a Command to send via Chat'
|
'Interface.SubServer-Admin.Command.Title': '&eSubServers\n&6Enter a Command to send via Chat'
|
||||||
'Interface.SubServer-Admin.Command.Message': '&eSubServers \u00BB Enter a Command to send via Chat'
|
'Interface.SubServer-Admin.Command.Message': '&eSubServers \u00BB Enter a Command to send via Chat'
|
||||||
'Interface.SubServer-Admin.Teleport': '&bTeleport to Server'
|
'Interface.SubServer-Admin.Plugins': '&bPlugins...'
|
||||||
'Interface.SubServer-Admin.Editor': '&eEdit SubServer'
|
'Interface.SubServer-Plugin.Title': 'SubServer/$str$/Plugins'
|
||||||
'Interface.SubServer-Admin.Editor-Unavailable': '&4This SubServer cannot be edited'
|
'Interface.SubServer-Plugin.No-Plugins': '&c&oThere are No Plugins Available'
|
||||||
'Interface.SubServer-Editor.Title': 'SubServer/$str$/Edit'
|
|
@ -36,7 +36,6 @@ public class PacketDownloadHostInfo implements PacketIn, PacketOut {
|
|||||||
|
|
||||||
info.put("name", host.getName());
|
info.put("name", host.getName());
|
||||||
info.put("enabled", host.isEnabled());
|
info.put("enabled", host.isEnabled());
|
||||||
info.put("editable", host.isEditable());
|
|
||||||
info.put("address", host.getAddress().toString());
|
info.put("address", host.getAddress().toString());
|
||||||
info.put("dir", host.getDirectory());
|
info.put("dir", host.getDirectory());
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ public class PacketDownloadServerInfo implements PacketIn, PacketOut {
|
|||||||
if (server != null && server instanceof SubServer) {
|
if (server != null && server instanceof SubServer) {
|
||||||
info.put("host", ((SubServer) server).getHost().getName());
|
info.put("host", ((SubServer) server).getHost().getName());
|
||||||
info.put("enabled", ((SubServer) server).isEnabled() && ((SubServer) server).getHost().isEnabled());
|
info.put("enabled", ((SubServer) server).isEnabled() && ((SubServer) server).getHost().isEnabled());
|
||||||
info.put("editable", ((SubServer) server).isEditable());
|
|
||||||
info.put("log", ((SubServer) server).isLogging());
|
info.put("log", ((SubServer) server).isLogging());
|
||||||
info.put("dir", plugin.config.get().getSection("Servers").getSection(server.getName()).getString("Directory"));
|
info.put("dir", plugin.config.get().getSection("Servers").getSection(server.getName()).getString("Directory"));
|
||||||
info.put("exec", plugin.config.get().getSection("Servers").getSection(server.getName()).getString("Executable"));
|
info.put("exec", plugin.config.get().getSection("Servers").getSection(server.getName()).getString("Executable"));
|
||||||
|
@ -37,7 +37,7 @@ public final class SubPlugin extends BungeeCord {
|
|||||||
public HashMap<String, String> exLang = new HashMap<String, String>();
|
public HashMap<String, String> exLang = new HashMap<String, String>();
|
||||||
public SubDataServer subdata = null;
|
public SubDataServer subdata = null;
|
||||||
public final Version version = new Version("2.11.2a");
|
public final Version version = new Version("2.11.2a");
|
||||||
protected Version bversion = new Version(4);
|
protected Version bversion = new Version(5);
|
||||||
|
|
||||||
protected boolean running = false;
|
protected boolean running = false;
|
||||||
public final SubAPI api = new SubAPI(this);
|
public final SubAPI api = new SubAPI(this);
|
||||||
@ -98,7 +98,7 @@ public final class SubPlugin extends BungeeCord {
|
|||||||
} catch (NullPointerException e) {}
|
} catch (NullPointerException e) {}
|
||||||
brText.close();
|
brText.close();
|
||||||
|
|
||||||
if (!Version.equalsIgnoreCase("2.11.0a+")) {
|
if (!Version.equalsIgnoreCase("2.11.2a+")) {
|
||||||
Files.move(new UniversalFile(dir, "build.sh").toPath(), new UniversalFile(dir, "build.old" + Math.round(Math.random() * 100000) + ".sh").toPath());
|
Files.move(new UniversalFile(dir, "build.sh").toPath(), new UniversalFile(dir, "build.old" + Math.round(Math.random() * 100000) + ".sh").toPath());
|
||||||
Util.copyFromJar(SubPlugin.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/build.sh", new UniversalFile(dir, "build.sh").getPath());
|
Util.copyFromJar(SubPlugin.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/build.sh", new UniversalFile(dir, "build.sh").getPath());
|
||||||
System.out.println("SubServers > Updated ~/SubServers/build.sh");
|
System.out.println("SubServers > Updated ~/SubServers/build.sh");
|
||||||
|
@ -2,6 +2,6 @@ Settings:
|
|||||||
Version: '2.11.2a+'
|
Version: '2.11.2a+'
|
||||||
Use-Title-Messages: true
|
Use-Title-Messages: true
|
||||||
SubData:
|
SubData:
|
||||||
Name: 'Server_1'
|
Name: 'undefined'
|
||||||
Address: '127.0.0.1:4391'
|
Address: '127.0.0.1:4391'
|
||||||
Password: 'password123'
|
Password: ''
|
@ -0,0 +1,10 @@
|
|||||||
|
package net.ME1312.SubServers.Client.Bukkit.Graphic;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public interface Renderer {
|
||||||
|
void open(Player player, String object);
|
||||||
|
ItemStack getIcon();
|
||||||
|
boolean isEnabled(String object);
|
||||||
|
}
|
@ -181,7 +181,33 @@ public class UIListener implements Listener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else if (event.getClickedInventory().getTitle().startsWith(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Plugin.Title", '&').split("\\$str\\$")[0]) && // Host Plugin
|
||||||
|
(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Plugin.Title", '&').split("\\$str\\$").length == 1 ||
|
||||||
|
event.getClickedInventory().getTitle().endsWith(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Plugin.Title", '&').split("\\$str\\$")[1]))) {
|
||||||
|
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR && event.getCurrentItem().hasItemMeta()) {
|
||||||
|
String item = event.getCurrentItem().getItemMeta().getDisplayName();
|
||||||
|
if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'))) {
|
||||||
|
player.closeInventory();
|
||||||
|
gui.hostPlugin(gui.lastPage - 1, gui.lastVistedObject);
|
||||||
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'))) {
|
||||||
|
player.closeInventory();
|
||||||
|
gui.hostPlugin(gui.lastPage + 1, gui.lastVistedObject);
|
||||||
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'))) {
|
||||||
|
player.closeInventory();
|
||||||
|
gui.back();
|
||||||
|
} else {
|
||||||
|
player.closeInventory();
|
||||||
|
Renderer plugin = null;
|
||||||
|
for (Renderer renderer : UIRenderer.hostPlugins.values()) {
|
||||||
|
if (item.equals(renderer.getIcon().getItemMeta().getDisplayName())) plugin = renderer;
|
||||||
|
}
|
||||||
|
if (plugin == null) {
|
||||||
|
gui.reopen();
|
||||||
|
} else {
|
||||||
|
plugin.open(player, gui.lastVistedObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (event.getClickedInventory().getTitle().equals(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Menu.Title", '&')) || // SubServer Menu
|
} else if (event.getClickedInventory().getTitle().equals(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Menu.Title", '&')) || // SubServer Menu
|
||||||
event.getClickedInventory().getTitle().startsWith(plugin.lang.getSection("Lang").getColoredString("Interface.Host-SubServer.Title", '&').split("\\$str\\$")[0]) &&
|
event.getClickedInventory().getTitle().startsWith(plugin.lang.getSection("Lang").getColoredString("Interface.Host-SubServer.Title", '&').split("\\$str\\$")[0]) &&
|
||||||
@ -192,10 +218,10 @@ public class UIListener implements Listener {
|
|||||||
|
|
||||||
if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'))) {
|
if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'))) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
gui.subserverMenu(gui.lastPage - 1, null);
|
gui.subserverMenu(gui.lastPage - 1, gui.lastVistedObject);
|
||||||
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'))) {
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'))) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
gui.subserverMenu(gui.lastPage + 1, null);
|
gui.subserverMenu(gui.lastPage + 1, gui.lastVistedObject);
|
||||||
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Menu.Host-Menu", '&'))) {
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Menu.Host-Menu", '&'))) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
gui.hostMenu(1);
|
gui.hostMenu(1);
|
||||||
@ -221,14 +247,12 @@ public class UIListener implements Listener {
|
|||||||
if (player.hasPermission("subservers.host.create.*") || player.hasPermission("subservers.host.create." + gui.lastVistedObject.toLowerCase())) {
|
if (player.hasPermission("subservers.host.create.*") || player.hasPermission("subservers.host.create." + gui.lastVistedObject.toLowerCase())) {
|
||||||
gui.hostCreator(new UIRenderer.CreatorOptions(gui.lastVistedObject));
|
gui.hostCreator(new UIRenderer.CreatorOptions(gui.lastVistedObject));
|
||||||
} else gui.reopen();
|
} else gui.reopen();
|
||||||
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Editor", '&'))) {
|
|
||||||
player.closeInventory();
|
|
||||||
if (player.hasPermission("subservers.host.edit.*") || player.hasPermission("subservers.host.edit." + gui.lastVistedObject.toLowerCase())) {
|
|
||||||
gui.hostEditor(new UIRenderer.HostEditorOptions(gui.lastVistedObject));
|
|
||||||
} else gui.reopen();
|
|
||||||
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.SubServers", '&'))) {
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.SubServers", '&'))) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
gui.subserverMenu(1, gui.lastVistedObject);
|
gui.subserverMenu(1, gui.lastVistedObject);
|
||||||
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Plugins", '&'))) {
|
||||||
|
player.closeInventory();
|
||||||
|
gui.hostPlugin(1, gui.lastVistedObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event.getClickedInventory().getTitle().startsWith(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Title", '&').split("\\$str\\$")[0]) && // SubServer Admin
|
} else if (event.getClickedInventory().getTitle().startsWith(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Title", '&').split("\\$str\\$")[0]) && // SubServer Admin
|
||||||
@ -240,11 +264,6 @@ public class UIListener implements Listener {
|
|||||||
if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'))) {
|
if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'))) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
gui.back();
|
gui.back();
|
||||||
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Editor", '&'))) {
|
|
||||||
player.closeInventory();
|
|
||||||
if (player.hasPermission("subservers.subserver.edit.*") || player.hasPermission("subservers.subserver.edit." + gui.lastVistedObject.toLowerCase())) {
|
|
||||||
gui.subserverEditor(new UIRenderer.SubServerEditorOptions(gui.lastVistedObject));
|
|
||||||
} else gui.reopen();
|
|
||||||
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Start", '&'))) {
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Start", '&'))) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
if (player.hasPermission("subservers.subserver.start.*") || player.hasPermission("subservers.subserver.start." + gui.lastVistedObject.toLowerCase())) {
|
if (player.hasPermission("subservers.subserver.start.*") || player.hasPermission("subservers.subserver.start." + gui.lastVistedObject.toLowerCase())) {
|
||||||
@ -314,14 +333,36 @@ public class UIListener implements Listener {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
} else gui.reopen();
|
} else gui.reopen();
|
||||||
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Teleport", '&'))) {
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Plugins", '&'))) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
if (player.hasPermission("subservers.server.teleport.*") || player.hasPermission("subservers.server.teleport." + gui.lastVistedObject.toLowerCase())) {
|
gui.subserverPlugin(1, gui.lastVistedObject);
|
||||||
gui.setDownloading(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Downloading.Response", '&'));
|
}
|
||||||
plugin.subdata.sendPacket(new PacketTeleportPlayer(player.getUniqueId(), gui.lastVistedObject, UUID.randomUUID().toString(), json -> {
|
}
|
||||||
if (json.getInt("r") != 0) gui.reopen();
|
} else if (event.getClickedInventory().getTitle().startsWith(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Plugin.Title", '&').split("\\$str\\$")[0]) && // SubServer Plugin
|
||||||
}));
|
(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Plugin.Title", '&').split("\\$str\\$").length == 1 ||
|
||||||
} else gui.reopen();
|
event.getClickedInventory().getTitle().endsWith(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Plugin.Title", '&').split("\\$str\\$")[1]))) {
|
||||||
|
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR && event.getCurrentItem().hasItemMeta()) {
|
||||||
|
String item = event.getCurrentItem().getItemMeta().getDisplayName();
|
||||||
|
if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'))) {
|
||||||
|
player.closeInventory();
|
||||||
|
gui.subserverPlugin(gui.lastPage - 1, gui.lastVistedObject);
|
||||||
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'))) {
|
||||||
|
player.closeInventory();
|
||||||
|
gui.subserverPlugin(gui.lastPage + 1, gui.lastVistedObject);
|
||||||
|
} else if (item.equals(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'))) {
|
||||||
|
player.closeInventory();
|
||||||
|
gui.back();
|
||||||
|
} else {
|
||||||
|
player.closeInventory();
|
||||||
|
Renderer plugin = null;
|
||||||
|
for (Renderer renderer : UIRenderer.subserverPlugins.values()) {
|
||||||
|
if (item.equals(renderer.getIcon().getItemMeta().getDisplayName())) plugin = renderer;
|
||||||
|
}
|
||||||
|
if (plugin == null) {
|
||||||
|
gui.reopen();
|
||||||
|
} else {
|
||||||
|
plugin.open(player, gui.lastVistedObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ import java.text.DecimalFormat;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class UIRenderer {
|
public class UIRenderer {
|
||||||
|
protected static HashMap<String, Renderer> hostPlugins = new HashMap<String, Renderer>();
|
||||||
|
protected static HashMap<String, Renderer> subserverPlugins = new HashMap<String, Renderer>();
|
||||||
private List<Runnable> windowHistory = new LinkedList<Runnable>();
|
private List<Runnable> windowHistory = new LinkedList<Runnable>();
|
||||||
protected Options lastUsedOptions = null;
|
protected Options lastUsedOptions = null;
|
||||||
protected String lastVistedObject = null;
|
protected String lastVistedObject = null;
|
||||||
@ -216,6 +218,26 @@ public class UIRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add Host Plugin
|
||||||
|
*
|
||||||
|
* @param handle Handle to bind
|
||||||
|
* @param renderer Renderer
|
||||||
|
*/
|
||||||
|
public static void addHostPlugin(String handle, Renderer renderer) {
|
||||||
|
hostPlugins.put(handle, renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add SubServer Plugin
|
||||||
|
*
|
||||||
|
* @param handle Handle to bind
|
||||||
|
* @param renderer Renderer
|
||||||
|
*/
|
||||||
|
public static void addSubServerPlugin(String handle, Renderer renderer) {
|
||||||
|
subserverPlugins.put(handle, renderer);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the Host Menu
|
* Opens the Host Menu
|
||||||
*
|
*
|
||||||
@ -384,34 +406,16 @@ public class UIRenderer {
|
|||||||
}
|
}
|
||||||
block.setItemMeta(blockMeta);
|
block.setItemMeta(blockMeta);
|
||||||
inv.setItem(1, block);
|
inv.setItem(1, block);
|
||||||
|
inv.setItem(2, block);
|
||||||
|
inv.setItem(3, block);
|
||||||
inv.setItem(10, block);
|
inv.setItem(10, block);
|
||||||
|
inv.setItem(11, block);
|
||||||
|
inv.setItem(12, block);
|
||||||
|
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
|
||||||
blockMeta = block.getItemMeta();
|
blockMeta = block.getItemMeta();
|
||||||
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.SubServers", '&'));
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.SubServers", '&'));
|
||||||
block.setItemMeta(blockMeta);
|
block.setItemMeta(blockMeta);
|
||||||
inv.setItem(2, block);
|
|
||||||
inv.setItem(3, block);
|
|
||||||
inv.setItem(11, block);
|
|
||||||
inv.setItem(12, block);
|
|
||||||
|
|
||||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.host.edit.*") || Bukkit.getPlayer(player).hasPermission("subservers.host.edit." + host.toLowerCase()))) {
|
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
|
||||||
blockMeta = block.getItemMeta();
|
|
||||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Editor", '&')));
|
|
||||||
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Invalid-Permission", '&').replace("$str$", "subservers.host.edit." + host.toLowerCase())));
|
|
||||||
} else if (!json.getJSONObject("host").getBoolean("editable")) {
|
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
|
||||||
blockMeta = block.getItemMeta();
|
|
||||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Editor", '&')));
|
|
||||||
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Editor-Unavailable", '&')));
|
|
||||||
} else {
|
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 1);
|
|
||||||
blockMeta = block.getItemMeta();
|
|
||||||
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Editor", '&'));
|
|
||||||
|
|
||||||
}
|
|
||||||
block.setItemMeta(blockMeta);
|
|
||||||
inv.setItem(5, block);
|
inv.setItem(5, block);
|
||||||
inv.setItem(6, block);
|
inv.setItem(6, block);
|
||||||
inv.setItem(7, block);
|
inv.setItem(7, block);
|
||||||
@ -419,6 +423,17 @@ public class UIRenderer {
|
|||||||
inv.setItem(15, block);
|
inv.setItem(15, block);
|
||||||
inv.setItem(16, block);
|
inv.setItem(16, block);
|
||||||
|
|
||||||
|
if (!json.getJSONObject("host").getBoolean("enabled")) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Plugins", '&')));
|
||||||
|
} else {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Admin.Plugins", '&'));
|
||||||
|
}
|
||||||
|
inv.setItem(27, block);
|
||||||
|
inv.setItem(28, block);
|
||||||
|
|
||||||
if (json.getJSONObject("host").getBoolean("enabled")) {
|
if (json.getJSONObject("host").getBoolean("enabled")) {
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
|
||||||
@ -731,37 +746,116 @@ public class UIRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens Host/<name>/Edit
|
* Opens Host/<name>/Plugins
|
||||||
*
|
*
|
||||||
* @param options Host Editor Options
|
* @param host Host Name
|
||||||
*/
|
*/
|
||||||
public void hostEditor(final HostEditorOptions options) {
|
public void hostPlugin(final Integer page, final String host) {
|
||||||
lastUsedOptions = options;
|
setDownloading(ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Plugin.Title", '&').replace("$str$", host)));
|
||||||
if (!options.init()) {
|
plugin.subdata.sendPacket(new PacketDownloadHostInfo(host, UUID.randomUUID().toString(), (json) -> {
|
||||||
windowHistory.add(() -> hostEditor(options));
|
windowHistory.add(() -> hostPlugin(page, host));
|
||||||
lastVistedObject = options.getHost();
|
if (!json.getBoolean("valid")) {
|
||||||
}
|
if (hasHistory()) back();
|
||||||
}
|
} else {
|
||||||
public static class HostEditorOptions extends Options {
|
setDownloading(null);
|
||||||
private String host;
|
lastVistedObject = host;
|
||||||
|
lastPage = page;
|
||||||
|
List<String> renderers = new ArrayList<String>();
|
||||||
|
for (String renderer : renderers) {
|
||||||
|
if (subserverPlugins.get(renderer).isEnabled(host)) renderers.add(renderer);
|
||||||
|
}
|
||||||
|
Collections.sort(renderers);
|
||||||
|
|
||||||
/**
|
ItemStack block;
|
||||||
* Grabs a raw HostCreatorOptions instance
|
ItemMeta blockMeta;
|
||||||
*
|
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
|
||||||
* @param host Host Name
|
ItemMeta divMeta = div.getItemMeta();
|
||||||
*/
|
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||||
public HostEditorOptions(String host) {
|
div.setItemMeta(divMeta);
|
||||||
this.host = host;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
int i = 0;
|
||||||
* Gets the Host Name
|
int min = ((page - 1) * 36);
|
||||||
*
|
int max = (min + 35);
|
||||||
* @return Host Name
|
int count = (renderers.size() == 0)?27:((renderers.size() - min - 1 >= max)?36:renderers.size() - min);
|
||||||
*/
|
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
|
||||||
public String getHost() {
|
|
||||||
return this.host;
|
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.lang.getSection("Lang").getColoredString("Interface.Host-Plugin.Title", '&').replace("$str$", host));
|
||||||
}
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
||||||
|
block.setItemMeta(divMeta);
|
||||||
|
while (i < area) {
|
||||||
|
inv.setItem(i, block);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
ItemStack adiv = block;
|
||||||
|
i = (int) ((count < 9) ? Math.floor((9 - count) / 2) : 0);
|
||||||
|
|
||||||
|
boolean even = (count & 1) == 0 && count < 9;
|
||||||
|
|
||||||
|
for (String renderer : renderers) {
|
||||||
|
if (renderers.indexOf(renderer) >= min && renderers.indexOf(renderer) <= max) {
|
||||||
|
if (even && (i == 4 || i == 13 || i == 22 || i == 31)) inv.setItem(i++, adiv);
|
||||||
|
|
||||||
|
inv.setItem(i, hostPlugins.get(renderer).getIcon());
|
||||||
|
|
||||||
|
count--;
|
||||||
|
if (count < 9 && (i == 8 || i == 17 || i == 26)) {
|
||||||
|
i += (int) Math.floor((9 - count) / 2) + 1;
|
||||||
|
even = (count & 1) == 0;
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderers.size() == 0) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Host-Plugin.No-Plugins", '&'));
|
||||||
|
block.setItemMeta(blockMeta);
|
||||||
|
inv.setItem(12, block);
|
||||||
|
inv.setItem(13, block);
|
||||||
|
inv.setItem(14, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
i = inv.getSize() - 18;
|
||||||
|
while (i < inv.getSize()) {
|
||||||
|
inv.setItem(i, div);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i = inv.getSize() - 9;
|
||||||
|
|
||||||
|
if (min != 0) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'));
|
||||||
|
block.setItemMeta(blockMeta);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
} else i += 2;
|
||||||
|
i++;
|
||||||
|
if (hasHistory()) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'));
|
||||||
|
block.setItemMeta(blockMeta);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (renderers.size() - 1 > max) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'));
|
||||||
|
block.setItemMeta(blockMeta);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
inv.setItem(i, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getPlayer(player).openInventory(inv);
|
||||||
|
open = true;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -994,20 +1088,6 @@ public class UIRenderer {
|
|||||||
inv.setItem(14, block);
|
inv.setItem(14, block);
|
||||||
inv.setItem(15, block);
|
inv.setItem(15, block);
|
||||||
inv.setItem(16, block);
|
inv.setItem(16, block);
|
||||||
|
|
||||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.server.teleport.*") || Bukkit.getPlayer(player).hasPermission("subservers.server.teleport." + subserver.toLowerCase()))) {
|
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
|
||||||
blockMeta = block.getItemMeta();
|
|
||||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Teleport", '&')));
|
|
||||||
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Invalid-Permission", '&').replace("$str$", "subservers.server.teleport." + subserver.toLowerCase())));
|
|
||||||
} else {
|
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
|
|
||||||
blockMeta = block.getItemMeta();
|
|
||||||
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Teleport", '&'));
|
|
||||||
}
|
|
||||||
block.setItemMeta(blockMeta);
|
|
||||||
inv.setItem(27, block);
|
|
||||||
inv.setItem(28, block);
|
|
||||||
} else {
|
} else {
|
||||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.start.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.start." + subserver.toLowerCase()))) {
|
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.start.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.start." + subserver.toLowerCase()))) {
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
||||||
@ -1024,38 +1104,27 @@ public class UIRenderer {
|
|||||||
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Start", '&'));
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Start", '&'));
|
||||||
}
|
}
|
||||||
block.setItemMeta(blockMeta);
|
block.setItemMeta(blockMeta);
|
||||||
inv.setItem(1, block);
|
|
||||||
inv.setItem(2, block);
|
|
||||||
inv.setItem(3, block);
|
inv.setItem(3, block);
|
||||||
inv.setItem(10, block);
|
inv.setItem(4, block);
|
||||||
inv.setItem(11, block);
|
|
||||||
inv.setItem(12, block);
|
|
||||||
|
|
||||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.edit.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.edit." + subserver.toLowerCase()))) {
|
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
|
||||||
blockMeta = block.getItemMeta();
|
|
||||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Editor", '&')));
|
|
||||||
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Invalid-Permission", '&').replace("$str$", "subservers.subserver.edit." + subserver.toLowerCase())));
|
|
||||||
} else if (!json.getJSONObject("server").getBoolean("editable")) {
|
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
|
||||||
blockMeta = block.getItemMeta();
|
|
||||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Editor", '&')));
|
|
||||||
blockMeta.setLore(Arrays.asList(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Editor-Unavailable", '&')));
|
|
||||||
} else {
|
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 1);
|
|
||||||
blockMeta = block.getItemMeta();
|
|
||||||
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Editor", '&'));
|
|
||||||
|
|
||||||
}
|
|
||||||
block.setItemMeta(blockMeta);
|
|
||||||
inv.setItem(5, block);
|
inv.setItem(5, block);
|
||||||
inv.setItem(6, block);
|
inv.setItem(12, block);
|
||||||
inv.setItem(7, block);
|
inv.setItem(13, block);
|
||||||
inv.setItem(14, block);
|
inv.setItem(14, block);
|
||||||
inv.setItem(15, block);
|
|
||||||
inv.setItem(16, block);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!json.getJSONObject("server").getBoolean("enabled")) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Plugins", '&')));
|
||||||
|
} else {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Admin.Plugins", '&'));
|
||||||
|
}
|
||||||
|
block.setItemMeta(blockMeta);
|
||||||
|
inv.setItem(27, block);
|
||||||
|
inv.setItem(28, block);
|
||||||
|
|
||||||
if (json.getJSONObject("server").getBoolean("temp")) {
|
if (json.getJSONObject("server").getBoolean("temp")) {
|
||||||
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 11);
|
||||||
blockMeta = block.getItemMeta();
|
blockMeta = block.getItemMeta();
|
||||||
@ -1099,38 +1168,115 @@ public class UIRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens SubServer/<name>/Edit
|
* Opens SubServer/<name>/Plugins
|
||||||
*
|
*
|
||||||
* @param options SubServerEditorOptions
|
* @param subserver SubServer Name
|
||||||
*/
|
*/
|
||||||
public void subserverEditor(final SubServerEditorOptions options) {
|
public void subserverPlugin(final Integer page, final String subserver) {
|
||||||
lastUsedOptions = options;
|
setDownloading(ChatColor.stripColor(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Plugin.Title", '&').replace("$str$", subserver)));
|
||||||
if (!options.init()) {
|
plugin.subdata.sendPacket(new PacketDownloadServerInfo(subserver, UUID.randomUUID().toString(), json -> {
|
||||||
windowHistory.add(() -> subserverEditor(options));
|
windowHistory.add(() -> subserverPlugin(page, subserver));
|
||||||
lastVistedObject = options.getSubserver();
|
if (!json.getString("type").equals("subserver")) {
|
||||||
}
|
if (hasHistory()) back();
|
||||||
}
|
} else {
|
||||||
public static class SubServerEditorOptions extends Options {
|
setDownloading(null);
|
||||||
private List<Runnable> history = new LinkedList<Runnable>();
|
lastVistedObject = subserver;
|
||||||
private String subserver;
|
lastPage = page;
|
||||||
private boolean init = false;
|
List<String> renderers = new ArrayList<String>();
|
||||||
|
for (String renderer : renderers) {
|
||||||
|
if (subserverPlugins.get(renderer).isEnabled(subserver)) renderers.add(renderer);
|
||||||
|
}
|
||||||
|
Collections.sort(renderers);
|
||||||
|
|
||||||
/**
|
ItemStack block;
|
||||||
* Grabs a raw SubServerEditorOptions instance
|
ItemMeta blockMeta;
|
||||||
*
|
ItemStack div = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
|
||||||
* @param subserver SubServer Name
|
ItemMeta divMeta = div.getItemMeta();
|
||||||
*/
|
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||||
public SubServerEditorOptions(String subserver) {
|
div.setItemMeta(divMeta);
|
||||||
this.subserver = subserver;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
int i = 0;
|
||||||
* Gets the SubServer Name
|
int min = ((page - 1) * 36);
|
||||||
*
|
int max = (min + 35);
|
||||||
* @return SubServer Name
|
int count = (renderers.size() == 0)?27:((renderers.size() - min - 1 >= max)?36:renderers.size() - min);
|
||||||
*/
|
int area = (count % 9 == 0) ? count : (int) (Math.floor(count / 9) + 1) * 9;
|
||||||
public String getSubserver() {
|
|
||||||
return this.subserver;
|
Inventory inv = Bukkit.createInventory(null, 18 + area, plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Plugin.Title", '&').replace("$str$", subserver));
|
||||||
}
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
||||||
|
block.setItemMeta(divMeta);
|
||||||
|
while (i < area) {
|
||||||
|
inv.setItem(i, block);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
ItemStack adiv = block;
|
||||||
|
i = (int) ((count < 9) ? Math.floor((9 - count) / 2) : 0);
|
||||||
|
|
||||||
|
boolean even = (count & 1) == 0 && count < 9;
|
||||||
|
|
||||||
|
for (String renderer : renderers) {
|
||||||
|
if (renderers.indexOf(renderer) >= min && renderers.indexOf(renderer) <= max) {
|
||||||
|
if (even && (i == 4 || i == 13 || i == 22 || i == 31)) inv.setItem(i++, adiv);
|
||||||
|
|
||||||
|
inv.setItem(i, subserverPlugins.get(renderer).getIcon());
|
||||||
|
|
||||||
|
count--;
|
||||||
|
if (count < 9 && (i == 8 || i == 17 || i == 26)) {
|
||||||
|
i += (int) Math.floor((9 - count) / 2) + 1;
|
||||||
|
even = (count & 1) == 0;
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderers.size() == 0) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.SubServer-Plugin.No-Plugins", '&'));
|
||||||
|
block.setItemMeta(blockMeta);
|
||||||
|
inv.setItem(12, block);
|
||||||
|
inv.setItem(13, block);
|
||||||
|
inv.setItem(14, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
i = inv.getSize() - 18;
|
||||||
|
while (i < inv.getSize()) {
|
||||||
|
inv.setItem(i, div);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i = inv.getSize() - 9;
|
||||||
|
|
||||||
|
if (min != 0) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back-Arrow", '&'));
|
||||||
|
block.setItemMeta(blockMeta);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
} else i += 2;
|
||||||
|
i++;
|
||||||
|
if (hasHistory()) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Back", '&'));
|
||||||
|
block.setItemMeta(blockMeta);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (renderers.size() - 1 > max) {
|
||||||
|
block = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 4);
|
||||||
|
blockMeta = block.getItemMeta();
|
||||||
|
blockMeta.setDisplayName(plugin.lang.getSection("Lang").getColoredString("Interface.Generic.Next-Arrow", '&'));
|
||||||
|
block.setItemMeta(blockMeta);
|
||||||
|
inv.setItem(i++, block);
|
||||||
|
inv.setItem(i, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getPlayer(player).openInventory(inv);
|
||||||
|
open = true;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -181,6 +181,7 @@ public final class SubCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Start.Running", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Start.Running", '&'));
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
|
case 1:
|
||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Start", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Start", '&'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -211,6 +212,7 @@ public final class SubCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Stop.Not-Running", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Stop.Not-Running", '&'));
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
|
case 1:
|
||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Stop", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Stop", '&'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -240,6 +242,7 @@ public final class SubCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Terminate.Not-Running", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Terminate.Not-Running", '&'));
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
|
case 1:
|
||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Terminate", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Terminate", '&'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -278,6 +281,7 @@ public final class SubCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Command.Not-Running", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Command.Not-Running", '&'));
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
|
case 1:
|
||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Command", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Command", '&'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -326,6 +330,7 @@ public final class SubCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Creator.Invalid-Memory", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Creator.Invalid-Memory", '&'));
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
|
case 1:
|
||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Creator", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Creator", '&'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -356,8 +361,8 @@ public final class SubCommand implements CommandExecutor {
|
|||||||
case "host/creator":
|
case "host/creator":
|
||||||
if (sender.hasPermission("subservers.host.create.*") || sender.hasPermission("subservers.host.create." + args[2].toLowerCase())) plugin.gui.getRenderer((Player) sender).hostCreator(new UIRenderer.CreatorOptions(args[2]));
|
if (sender.hasPermission("subservers.host.create.*") || sender.hasPermission("subservers.host.create." + args[2].toLowerCase())) plugin.gui.getRenderer((Player) sender).hostCreator(new UIRenderer.CreatorOptions(args[2]));
|
||||||
break;
|
break;
|
||||||
case "host/editor":
|
case "host/plugins":
|
||||||
if (sender.hasPermission("subservers.host.edit.*") || sender.hasPermission("subservers.host.edit." + args[2].toLowerCase())) plugin.gui.getRenderer((Player) sender).hostEditor(new UIRenderer.HostEditorOptions(args[2]));
|
plugin.gui.getRenderer((Player) sender).hostPlugin(Integer.parseInt(args[2]), args[3]);
|
||||||
break;
|
break;
|
||||||
case "subserver":
|
case "subserver":
|
||||||
if (args.length > 3) plugin.gui.getRenderer((Player) sender).subserverMenu(Integer.parseInt(args[2]), args[3]);
|
if (args.length > 3) plugin.gui.getRenderer((Player) sender).subserverMenu(Integer.parseInt(args[2]), args[3]);
|
||||||
@ -367,8 +372,8 @@ public final class SubCommand implements CommandExecutor {
|
|||||||
case "subserver/":
|
case "subserver/":
|
||||||
plugin.gui.getRenderer((Player) sender).subserverAdmin(args[2]);
|
plugin.gui.getRenderer((Player) sender).subserverAdmin(args[2]);
|
||||||
break;
|
break;
|
||||||
case "subserver/editor":
|
case "subserver/plugins":
|
||||||
if (sender.hasPermission("subservers.subserver.edit.*") || sender.hasPermission("subservers.subserver.edit." + args[2].toLowerCase())) plugin.gui.getRenderer((Player) sender).subserverEditor(new UIRenderer.SubServerEditorOptions(args[2]));
|
plugin.gui.getRenderer((Player) sender).subserverPlugin(Integer.parseInt(args[2]), args[3]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {}
|
} catch (Throwable e) {}
|
||||||
@ -398,6 +403,7 @@ public final class SubCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Teleport.Offline", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Teleport.Offline", '&'));
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
|
case 1:
|
||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Teleport", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Teleport", '&'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -425,6 +431,7 @@ public final class SubCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Teleport.Offline", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Teleport.Offline", '&'));
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
|
case 1:
|
||||||
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Teleport", '&'));
|
sender.sendMessage(plugin.lang.getSection("Lang").getColoredString("Command.Teleport", '&'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -4,6 +4,7 @@ import net.ME1312.SubServers.Client.Bukkit.Graphic.UIListener;
|
|||||||
import net.ME1312.SubServers.Client.Bukkit.Library.Config.YAMLConfig;
|
import net.ME1312.SubServers.Client.Bukkit.Library.Config.YAMLConfig;
|
||||||
import net.ME1312.SubServers.Client.Bukkit.Library.Config.YAMLSection;
|
import net.ME1312.SubServers.Client.Bukkit.Library.Config.YAMLSection;
|
||||||
import net.ME1312.SubServers.Client.Bukkit.Library.UniversalFile;
|
import net.ME1312.SubServers.Client.Bukkit.Library.UniversalFile;
|
||||||
|
import net.ME1312.SubServers.Client.Bukkit.Library.Util;
|
||||||
import net.ME1312.SubServers.Client.Bukkit.Library.Version.Version;
|
import net.ME1312.SubServers.Client.Bukkit.Library.Version.Version;
|
||||||
import net.ME1312.SubServers.Client.Bukkit.Network.SubDataClient;
|
import net.ME1312.SubServers.Client.Bukkit.Network.SubDataClient;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -21,7 +22,7 @@ public final class SubPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
public UIListener gui = null;
|
public UIListener gui = null;
|
||||||
public Version version;
|
public Version version;
|
||||||
protected Version bversion = new Version(4);
|
protected Version bversion = new Version(5);
|
||||||
|
|
||||||
//public final SubAPI api = new SubAPI(this);
|
//public final SubAPI api = new SubAPI(this);
|
||||||
|
|
||||||
@ -32,12 +33,12 @@ public final class SubPlugin extends JavaPlugin {
|
|||||||
Bukkit.getLogger().info("SubServers > Loading SubServers v" + version.toString() + " Libraries... ");
|
Bukkit.getLogger().info("SubServers > Loading SubServers v" + version.toString() + " Libraries... ");
|
||||||
getDataFolder().mkdirs();
|
getDataFolder().mkdirs();
|
||||||
if (!(new UniversalFile(getDataFolder(), "config.yml").exists())) {
|
if (!(new UniversalFile(getDataFolder(), "config.yml").exists())) {
|
||||||
copyFromJar("config.yml", new UniversalFile(getDataFolder(), "config.yml").getPath());
|
Util.copyFromJar(SubPlugin.class.getClassLoader(), "config.yml", new UniversalFile(getDataFolder(), "config.yml").getPath());
|
||||||
Bukkit.getLogger().info("SubServers > Created ~/plugins/SubServers/config.yml");
|
Bukkit.getLogger().info("SubServers > Created ~/plugins/SubServers/config.yml");
|
||||||
} else if ((new Version((new YAMLConfig(new UniversalFile(getDataFolder(), "config.yml"))).get().getSection("Settings").getString("Version", "0")).compareTo(new Version("2.11.0a+"))) != 0) {
|
} else if ((new Version((new YAMLConfig(new UniversalFile(getDataFolder(), "config.yml"))).get().getSection("Settings").getString("Version", "0")).compareTo(new Version("2.11.0a+"))) != 0) {
|
||||||
Files.move(new UniversalFile(getDataFolder(), "config.yml").toPath(), new UniversalFile(getDataFolder(), "config.old" + Math.round(Math.random() * 100000) + ".yml").toPath());
|
Files.move(new UniversalFile(getDataFolder(), "config.yml").toPath(), new UniversalFile(getDataFolder(), "config.old" + Math.round(Math.random() * 100000) + ".yml").toPath());
|
||||||
|
|
||||||
copyFromJar("config.yml", new UniversalFile(getDataFolder(), "config.yml").getPath());
|
Util.copyFromJar(SubPlugin.class.getClassLoader(), "config.yml", new UniversalFile(getDataFolder(), "config.yml").getPath());
|
||||||
Bukkit.getLogger().info("SubServers > Updated ~/plugins/SubServers/config.yml");
|
Bukkit.getLogger().info("SubServers > Updated ~/plugins/SubServers/config.yml");
|
||||||
}
|
}
|
||||||
pluginconf = new YAMLConfig(new UniversalFile(getDataFolder(), "config.yml"));
|
pluginconf = new YAMLConfig(new UniversalFile(getDataFolder(), "config.yml"));
|
||||||
@ -65,21 +66,4 @@ public final class SubPlugin extends JavaPlugin {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyFromJar(String resource, String destination) {
|
|
||||||
InputStream resStreamIn = SubPlugin.class.getClassLoader().getResourceAsStream(resource);
|
|
||||||
File resDestFile = new File(destination);
|
|
||||||
try {
|
|
||||||
OutputStream resStreamOut = new FileOutputStream(resDestFile);
|
|
||||||
int readBytes;
|
|
||||||
byte[] buffer = new byte[4096];
|
|
||||||
while ((readBytes = resStreamIn.read(buffer)) > 0) {
|
|
||||||
resStreamOut.write(buffer, 0, readBytes);
|
|
||||||
}
|
|
||||||
resStreamOut.close();
|
|
||||||
resStreamIn.close();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user