Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed GUI-console issued commands not working, closes 13 in CanaryLib

Additional changes according to API changes
  • Loading branch information...
commit fef41fa52ac55a3c560528b36b87e02287e721af 1 parent 0342f22
@damagefilter damagefilter authored
View
16 src/main/java/net/canarymod/CanaryServer.java
@@ -70,39 +70,39 @@ public WorldManager getWorldManager() {
}
@Override
- public void consoleCommand(String command) {
+ public boolean consoleCommand(String command) {
ConsoleCommandHook hook = (ConsoleCommandHook) Canary.hooks()
.callCancelableHook(new ConsoleCommandHook(null, command));
if (hook.isCanceled()) {
- return;
+ return true;
}
String[] args = command.split(" ");
CanaryCommand toExecute = CanaryCommand.fromString(args[0].replace("/", ""));
if(toExecute != null) {
- toExecute.execute(null, args);
+ return toExecute.execute(null, args);
}
else{
server.a(command, server);
+ return false;
}
- Logman.logInfo("Console issued server command: " + command);
}
@Override
- public void consoleCommand(String command, Player player) {
+ public boolean consoleCommand(String command, Player player) {
ConsoleCommandHook hook = (ConsoleCommandHook) Canary.hooks()
.callCancelableHook(new ConsoleCommandHook(player, command));
if (hook.isCanceled()) {
- return;
+ return true;
}
String[] args = command.split(" ");
CanaryCommand toExecute = CanaryCommand.fromString(args[0].replace("/", ""));
if(toExecute != null) {
- toExecute.execute(null, args);
+ return toExecute.execute(null, args);
}
else{
server.a(command, ((CanaryPlayer) player).getHandle().a);
+ return false;
}
- Logman.logInfo(player.getName() + " issued server command: " + command);
}
@SuppressWarnings("unchecked")
View
14 src/main/java/net/canarymod/api/world/CanaryWorld.java
@@ -126,6 +126,20 @@ public void setNanoTick(Dimension.Type dimension, int tickIndex, long tick) {
break;
}
}
+
+ @Override
+ public long getNanoTick(Dimension.Type dimension, int tickIndex) {
+ switch(dimension) {
+ case NORMAL:
+ return nanoTicks[0][tickIndex];
+ case NETHER:
+ return nanoTicks[1][tickIndex];
+ case END:
+ return nanoTicks[2][tickIndex];
+ default:
+ return 0L;
+ }
+ }
@Override
public void setEnabled(boolean enabled) {
View
22 src/main/java/net/minecraft/server/OGuiStatsComponent.java
@@ -9,6 +9,7 @@
import net.canarymod.Canary;
import net.canarymod.api.world.CanaryWorld;
+import net.canarymod.api.world.World;
import net.minecraft.server.OGuiStatsListener;
import net.minecraft.server.OMinecraftServer;
import net.minecraft.server.ONetworkManager;
@@ -39,16 +40,23 @@ private void a() {
this.d[2] = "Avg tick: " + a.format(this.a(this.e.f) * 1.0E-6D) + " ms";
this.d[3] = "Avg sent: " + (int) this.a(this.e.u) + ", Avg size: " + (int) this.a(this.e.v);
this.d[4] = "Avg rec: " + (int) this.a(this.e.w) + ", Avg size: " + (int) this.a(this.e.x);
- OWorldServer[] level = ((CanaryWorld)Canary.getServer().getWorldManager().getWorld(Canary.getServer().getDefaultWorldName())).getDimensionArray();
- if (level != null) {
- for (int var3 = 0; var3 < level.length; ++var3) {
- this.d[5 + var3] = "Lvl " + var3 + " tick: " + a.format(this.a(this.e.g[var3]) * 1.0E-6D) + " ms";
- if (level[var3] != null && level[var3].G != null) {
- this.d[5 + var3] = this.d[5 + var3] + ", " + level[var3].G.d();
+
+ //CanaryMod Multiworld:
+ World[] worlds = Canary.getServer().getWorldManager().getAllWorlds();
+ if(worlds != null) {
+ for(World w : worlds) {
+ String worldName = w.getName();
+ OWorldServer[] level = ((CanaryWorld)w).getDimensionArray();
+ for (int i = 0; i < level.length; i++) {
+ net.canarymod.api.world.Dimension dim = w.getDimensions()[i];
+ this.d[5 + i] = "World " + worldName + " lvl " + i + " tick " + a.format(w.getNanoTick(dim.getType(), i) * 1.0E-6D) + " ms";
+ if(level[i] != null && level[i].G != null) {
+ this.d[5 + i] += ", " + level[i].G.d();
+ }
}
}
}
-
+ //CanaryMod end
this.b[this.c++ & 255] = (int) (this.a(this.e.v) * 100.0D / 12500.0D);
this.repaint();
}
View
10 src/main/java/net/minecraft/server/OServerGuiCommandListener.java
@@ -3,6 +3,8 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JTextField;
+
+import net.canarymod.Canary;
import net.minecraft.server.OServerGUI;
class OServerGuiCommandListener implements ActionListener {
@@ -21,9 +23,13 @@
@Override
public void actionPerformed(ActionEvent var1) {
String var2 = this.a.getText().trim();
- if (var2.length() > 0) {
- OServerGUI.a(this.b).a(var2, this.b);
+ //CanaryMod: Parse console commands from GUI
+ if (var2.length() > 0 && Canary.instance() != null) {
+ //CanaryMod we parse that command instead
+ Canary.getServer().consoleCommand(var2);
+// OServerGUI.a(this.b).a(var2, this.b);
}
+ //CanaryMod end
this.a.setText("");
}
Please sign in to comment.
Something went wrong with that request. Please try again.