Skip to content

Commit

Permalink
Update SubServers.Console
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed Oct 24, 2018
1 parent dfa37c9 commit f4a78fc
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 34 deletions.
Expand Up @@ -59,12 +59,12 @@ public void onEnable() {
}
if (!(new UniversalFile(getDataFolder(), "config.yml").exists())) {
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-Client-Bukkit/config.yml");
} else if ((new Version((new YAMLConfig(new UniversalFile(getDataFolder(), "config.yml"))).get().getSection("Settings").getString("Version", "0")).compareTo(new Version("2.11.2a+"))) != 0) {
Files.move(new UniversalFile(getDataFolder(), "config.yml").toPath(), new UniversalFile(getDataFolder(), "config.old" + Math.round(Math.random() * 100000) + ".yml").toPath());

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-Client-Bukkit/config.yml");
}
config = new YAMLConfig(new UniversalFile(getDataFolder(), "config.yml"));
if (new UniversalFile(new File(System.getProperty("user.dir")), "subservers.client").exists()) {
Expand Down
Expand Up @@ -84,12 +84,12 @@ public void enable(GameInitializationEvent event) {
}
if (!(new UniversalFile(dir, "config.yml").exists())) {
Util.copyFromJar(SubPlugin.class.getClassLoader(), "config.yml", new UniversalFile(dir, "config.yml").getPath());
logger.info("Created ~/plugins/SubServers/config.yml");
logger.info("Created ~/config/subservers-client-sponge/config.yml");
} else if ((new Version((new YAMLConfig(new UniversalFile(dir, "config.yml"))).get().getSection("Settings").getString("Version", "0")).compareTo(new Version("2.11.2a+"))) != 0) {
Files.move(new UniversalFile(dir, "config.yml").toPath(), new UniversalFile(dir, "config.old" + Math.round(Math.random() * 100000) + ".yml").toPath());

Util.copyFromJar(SubPlugin.class.getClassLoader(), "config.yml", new UniversalFile(dir, "config.yml").getPath());
logger.info("Updated ~/plugins/SubServers/config.yml");
logger.info("Updated ~/config/subservers-client-sponge/config.yml");
}
config = new YAMLConfig(new UniversalFile(dir, "config.yml"));
if (new UniversalFile(new File(System.getProperty("user.dir")), "subservers.client").exists()) {
Expand Down
18 changes: 9 additions & 9 deletions SubServers.Console/pom.xml
Expand Up @@ -49,6 +49,15 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>ideauidesigner-maven-plugin</artifactId>
Expand All @@ -66,15 +75,6 @@
<failOnError>true</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion SubServers.Console/src/bungee.yml
@@ -1,4 +1,4 @@
name: SubServers-Console
main: net.ME1312.SubServers.Console.ConsolePlugin
version: 2.12.1a
version: 2.13.2a
author: ME1312
Expand Up @@ -356,8 +356,6 @@ public void actionPerformed(ActionEvent event) {
if (logger.getHandler() instanceof SubServer && input.getText().length() > 0 && !input.getText().equals(">")) {
if (((SubServer) logger.getHandler()).command((input.getText().startsWith(">")) ? input.getText().substring(1) : input.getText())) {
popup.commands.add((input.getText().startsWith(">")) ? input.getText().substring(1) : input.getText());
popup.current = 0;
popup.last = true;
input.setText("");
}
}
Expand All @@ -376,9 +374,21 @@ public void insertString(FilterBypass fb, int offset, String string, AttributeSe
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
if (offset < 1) {
length = Math.max(0, length - 1);
offset = 1;
offset = input.getDocument().getLength();
input.setCaretPosition(offset);
}

if (popup.history == Boolean.TRUE) {
popup.history = null;
} else if (popup.history == null) {
popup.history = false;
}

try {
super.replace(fb, offset, length, text, attrs);
} catch (BadLocationException e) {
super.replace(fb, 1, length, text, attrs);
}
super.replace(fb, offset, length, text, attrs);
}

@Override
Expand Down Expand Up @@ -664,8 +674,9 @@ private void find(boolean direction) {

private class TextFieldPopup extends JPanel {
protected LinkedList<String> commands = new LinkedList<String>();
protected int current = 0;
protected boolean last = true;
protected Boolean history = false;
protected int hpos = -1;
protected String hcache = "";

public TextFieldPopup(JTextComponent field, boolean command) {
JPopupMenu menu = new JPopupMenu();
Expand Down Expand Up @@ -738,11 +749,17 @@ public void next(JTextComponent field) {
if (field.isEditable()) {
LinkedList<String> list = new LinkedList<String>(commands);
Collections.reverse(list);
if (current > 0) {
if (last && current != 1) current--;
last = false;
field.setText(list.get(--current));
} else field.setText("");
if (history == Boolean.FALSE) {
hcache = (field.getText().startsWith(">"))?field.getText().substring(1):field.getText();
hpos = -1;
} else {
hpos--;
if (hpos < -1) hpos = -1;
}
if (hpos >= 0) {
history = true;
field.setText(list.get(hpos));
} else field.setText(hcache);
field.setCaretPosition(field.getText().length());
}
}
Expand All @@ -751,11 +768,16 @@ public void prev(JTextComponent field) {
if (field.isEditable()) {
LinkedList<String> list = new LinkedList<String>(commands);
Collections.reverse(list);
if (list.size() > current) {
if (!last) current++;
last = true;
field.setText(list.get(current++));
field.setCaretPosition(field.getText().length());
if (history == Boolean.FALSE) {
hcache = (field.getText().startsWith(">"))?field.getText().substring(1):field.getText();
hpos = 0;
} else {
hpos++;
}
if (hpos >= list.size()) hpos = list.size() - 1;
if (hpos >= 0) {
history = true;
field.setText(list.get(hpos));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion SubServers.Host/pom.xml
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>18w43b</version>
<version>18w43d</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
3 changes: 2 additions & 1 deletion SubServers.Host/src/net/ME1312/SubServers/Host/ExHost.java
Expand Up @@ -132,6 +132,7 @@ private ExHost(joptsimple.OptionSet options) {
try {
info = PluginInfo.getPluginInfo(this);
info.setLogger(log);
info.setIcon(ExHost.class.getResourceAsStream("/net/ME1312/SubServers/Host/Library/Files/icon.png"));
engine = GalaxiEngine.init(info);
log.info.println("Loading SubServers.Host v" + info.getVersion().toString() + " Libraries");
if (!(new UniversalFile(engine.getRuntimeDirectory(), "config.yml").exists())) {
Expand Down Expand Up @@ -242,7 +243,7 @@ private ExHost(joptsimple.OptionSet options) {
}
} catch (Exception e) {
log.error.println(e);
stop();
engine.stop();
}
}

Expand Down
@@ -1,5 +1,6 @@
package net.ME1312.SubServers.Host.Executable;

import net.ME1312.Galaxi.Library.Config.YAMLSection;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.Log.LogStream;
import net.ME1312.Galaxi.Library.Log.Logger;
Expand Down Expand Up @@ -104,10 +105,11 @@ private void start(InputStream in, boolean isErr) {
}

// Log to NETWORK
if (log.get() && SubAPI.getInstance().getInternals().config.get().getSection("Settings").getBoolean("Network-Log", true)) SubAPI.getInstance().getSubDataNetwork().sendPacket(new PacketOutExLogMessage(address, line));
YAMLSection yaml = SubAPI.getInstance().getInternals().config.get().getSection("Settings");
if (log.get() && yaml.getBoolean("Network-Log", true)) SubAPI.getInstance().getSubDataNetwork().sendPacket(new PacketOutExLogMessage(address, line));

// Log to CONSOLE
if (log.get() && SubAPI.getInstance().getInternals().config.get().getSection("Settings").getBoolean("Console-Log", true)) level.println(TextColor.convertColor(msg));
if (log.get() && yaml.getBoolean("Console-Log", true)) level.println(TextColor.convertColor(msg));

// Log to FILE
if (writer != null) {
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f4a78fc

Please sign in to comment.