Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-16 13:00:06 +01:00
Add ability to register commands
Dieser Commit ist enthalten in:
Ursprung
1d3a0f7488
Commit
257cc9648d
@ -1,4 +1,4 @@
|
||||
From c1770b3e3510e19c075d5e21902fe348b73508fb Mon Sep 17 00:00:00 2001
|
||||
From c623ae16ce7c29abf83a755cff088df3542e73a0 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Thu, 20 Jun 2013 17:35:57 +1000
|
||||
Subject: [PATCH] Spigot Configuration
|
||||
@ -37,9 +37,18 @@ index 3a4ddea..de052bd 100644
|
||||
this.world = new CraftWorld((WorldServer) this, gen, env);
|
||||
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 00326c1..814baa1 100644
|
||||
index 00326c1..92c6c88 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -213,7 +213,7 @@ public final class CraftServer implements Server {
|
||||
updater.getOnBroken().addAll(configuration.getStringList("auto-updater.on-broken"));
|
||||
updater.getOnUpdate().addAll(configuration.getStringList("auto-updater.on-update"));
|
||||
updater.check(serverVersion);
|
||||
-
|
||||
+ org.spigotmc.SpigotConfig.registerCommands( commandMap ); // Spigot
|
||||
loadPlugins();
|
||||
enablePlugins(PluginLoadOrder.STARTUP);
|
||||
}
|
||||
@@ -556,6 +556,7 @@ public final class CraftServer implements Server {
|
||||
playerList.getIPBans().load();
|
||||
playerList.getNameBans().load();
|
||||
@ -48,7 +57,7 @@ index 00326c1..814baa1 100644
|
||||
for (WorldServer world : console.worlds) {
|
||||
world.difficulty = difficulty;
|
||||
world.setSpawnFlags(monsters, animals);
|
||||
@@ -570,6 +571,7 @@ public final class CraftServer implements Server {
|
||||
@@ -570,12 +571,14 @@ public final class CraftServer implements Server {
|
||||
} else {
|
||||
world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns();
|
||||
}
|
||||
@ -56,12 +65,19 @@ index 00326c1..814baa1 100644
|
||||
}
|
||||
|
||||
pluginManager.clearPlugins();
|
||||
commandMap.clearCommands();
|
||||
resetRecipes();
|
||||
|
||||
+ org.spigotmc.SpigotConfig.registerCommands( commandMap ); // Spigot
|
||||
int pollCount = 0;
|
||||
|
||||
// Wait for at most 2.5 seconds for plugins to close their threads
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
new file mode 100644
|
||||
index 0000000..43d94fe
|
||||
index 0000000..933500d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -0,0 +1,98 @@
|
||||
@@ -0,0 +1,113 @@
|
||||
+package org.spigotmc;
|
||||
+
|
||||
+import com.google.common.base.Throwables;
|
||||
@ -70,9 +86,13 @@ index 0000000..43d94fe
|
||||
+import java.lang.reflect.InvocationTargetException;
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.logging.Level;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.SimpleCommandMap;
|
||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||
+
|
||||
+public class SpigotConfig
|
||||
@ -93,6 +113,7 @@ index 0000000..43d94fe
|
||||
+ /*========================================================================*/
|
||||
+ static YamlConfiguration config;
|
||||
+ static int version;
|
||||
+ static Map<String, Command> commands;
|
||||
+ /*========================================================================*/
|
||||
+
|
||||
+ public static void init()
|
||||
@ -101,10 +122,20 @@ index 0000000..43d94fe
|
||||
+ config.options().header( HEADER );
|
||||
+ config.options().copyDefaults( true );
|
||||
+
|
||||
+ commands = new HashMap<String, Command>();
|
||||
+
|
||||
+ version = getInt( "config-version", 1 );
|
||||
+ readConfig( SpigotConfig.class, null );
|
||||
+ }
|
||||
+
|
||||
+ public static void registerCommands(SimpleCommandMap commandMap)
|
||||
+ {
|
||||
+ for ( Map.Entry<String, Command> entry : commands.entrySet() )
|
||||
+ {
|
||||
+ commandMap.register( entry.getKey(), "Spigot", entry.getValue() );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ static void readConfig(Class<?> clazz, Object instance)
|
||||
+ {
|
||||
+ for ( Method method : SpigotConfig.class.getDeclaredMethods() )
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren