mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Handle running multiple platforms at a time better.
This commit is contained in:
parent
d1a69fd985
commit
f3e107da90
@ -61,6 +61,9 @@ sourceSets {
|
|||||||
minecraft {
|
minecraft {
|
||||||
version = "1.6.4-9.11.1.964"
|
version = "1.6.4-9.11.1.964"
|
||||||
forgeVersion = "9.11.1.964"
|
forgeVersion = "9.11.1.964"
|
||||||
|
|
||||||
|
replaceIn "com/sk89q/worldedit/forge/WorldEditMod.java"
|
||||||
|
replace "%VERSION%", project.version
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
@ -119,6 +119,21 @@ public class BukkitServerInterface extends ServerInterface {
|
|||||||
return plugin.getLocalConfiguration();
|
return plugin.getLocalConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return plugin.getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlatformName() {
|
||||||
|
return "Bukkit-Official";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlatformVersion() {
|
||||||
|
return plugin.getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
public void unregisterCommands() {
|
public void unregisterCommands() {
|
||||||
dynamicCommands.unregisterCommands();
|
dynamicCommands.unregisterCommands();
|
||||||
}
|
}
|
||||||
|
@ -130,4 +130,19 @@ public class ForgeServerInterface extends ServerInterface {
|
|||||||
public LocalConfiguration getConfiguration() {
|
public LocalConfiguration getConfiguration() {
|
||||||
return mod.getConfig();
|
return mod.getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return mod.getInternalVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlatformName() {
|
||||||
|
return "Forge-Official";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlatformVersion() {
|
||||||
|
return mod.getInternalVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class WorldEditMod {
|
|||||||
logger.setParent(FMLLog.getLogger());
|
logger.setParent(FMLLog.getLogger());
|
||||||
Logger.getLogger("com.sk89q").setParent(FMLLog.getLogger());
|
Logger.getLogger("com.sk89q").setParent(FMLLog.getLogger());
|
||||||
|
|
||||||
String modVersion = WorldEditMod.class.getAnnotation(Mod.class).version();
|
String modVersion = getInternalVersion();
|
||||||
String manifestVersion = WorldEdit.getVersion();
|
String manifestVersion = WorldEdit.getVersion();
|
||||||
if (!manifestVersion.equalsIgnoreCase(modVersion) && !modVersion.equals("%VERSION%")) {
|
if (!manifestVersion.equalsIgnoreCase(modVersion) && !modVersion.equals("%VERSION%")) {
|
||||||
WorldEdit.setVersion(manifestVersion + " (" + modVersion + ")");
|
WorldEdit.setVersion(manifestVersion + " (" + modVersion + ")");
|
||||||
@ -176,4 +176,9 @@ public class WorldEditMod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getInternalVersion() {
|
||||||
|
return WorldEditMod.class.getAnnotation(Mod.class).version();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1042,12 +1042,10 @@ public class WorldEdit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the version of WorldEdit.
|
* @deprecated Declare your platform version with {@link Platform#getPlatformVersion()}
|
||||||
*
|
|
||||||
* @param version the version
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void setVersion(String version) {
|
public static void setVersion(String version) {
|
||||||
WorldEdit.version = version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,19 +19,18 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Console;
|
import com.sk89q.minecraft.util.commands.Console;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class WorldEditCommands {
|
public class WorldEditCommands {
|
||||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||||
@ -54,7 +53,23 @@ public class WorldEditCommands {
|
|||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
player.print("WorldEdit version " + WorldEdit.getVersion());
|
player.print("WorldEdit version " + WorldEdit.getVersion());
|
||||||
player.print("http://www.sk89q.com/projects/worldedit/");
|
player.print("https://github.com/sk89q/worldedit/");
|
||||||
|
|
||||||
|
PlatformManager pm = we.getPlatformManager();
|
||||||
|
Platform primary = pm.getPrimaryPlatform();
|
||||||
|
|
||||||
|
player.printDebug("");
|
||||||
|
player.printDebug("Platforms:");
|
||||||
|
for (Platform platform : pm.getPlatforms()) {
|
||||||
|
String prefix = "";
|
||||||
|
|
||||||
|
if (primary != null && primary.equals(platform)) {
|
||||||
|
prefix = "[PRIMARY] ";
|
||||||
|
}
|
||||||
|
|
||||||
|
player.printDebug(String.format("- %s%s v%s (WE v%s)",
|
||||||
|
prefix, platform.getPlatformName(), platform.getPlatformVersion(), platform.getVersion()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -89,4 +89,31 @@ public interface Platform {
|
|||||||
*/
|
*/
|
||||||
LocalConfiguration getConfiguration();
|
LocalConfiguration getConfiguration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of WorldEdit that this platform provides.
|
||||||
|
* </p>
|
||||||
|
* This version should match WorldEdit releases because it may be
|
||||||
|
* checked to match.
|
||||||
|
*
|
||||||
|
* @return the version
|
||||||
|
*/
|
||||||
|
String getVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a friendly name of the platform.
|
||||||
|
* </p>
|
||||||
|
* The name can be anything (reasonable). An example name may be
|
||||||
|
* "Bukkit" or "Forge".
|
||||||
|
*
|
||||||
|
* @return the platform name
|
||||||
|
*/
|
||||||
|
String getPlatformName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of the platform, which can be anything.
|
||||||
|
*
|
||||||
|
* @return the platform version
|
||||||
|
*/
|
||||||
|
String getPlatformVersion();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,11 +64,30 @@ public class PlatformManager {
|
|||||||
*/
|
*/
|
||||||
public synchronized void register(Platform platform) throws PlatformRejectionException {
|
public synchronized void register(Platform platform) throws PlatformRejectionException {
|
||||||
checkNotNull(platform);
|
checkNotNull(platform);
|
||||||
logger.log(Level.INFO, "Got request to register " + platform.getClass() + " with WorldEdit [" + super.toString() + "]");
|
logger.log(Level.FINE, "Got request to register " + platform.getClass() + " with WorldEdit [" + super.toString() + "]");
|
||||||
platforms.add(platform);
|
platforms.add(platform);
|
||||||
|
|
||||||
|
// Register primary platform
|
||||||
if (this.primary == null) {
|
if (this.primary == null) {
|
||||||
commandManager.register(platform);
|
commandManager.register(platform);
|
||||||
this.primary = platform;
|
this.primary = platform;
|
||||||
|
} else {
|
||||||
|
// Make sure that versions are in sync
|
||||||
|
if (!primary.getVersion().equals(platform.getVersion())) {
|
||||||
|
logger.log(Level.WARNING,
|
||||||
|
"\n**********************************************\n" +
|
||||||
|
"** There is a mismatch in available WorldEdit platforms!\n" +
|
||||||
|
"**\n" +
|
||||||
|
"** {0} v{1} is trying to register WE version v{2}\n" +
|
||||||
|
"** but the primary platform, {3} v{4}, uses WE version v{5}\n" +
|
||||||
|
"**\n" +
|
||||||
|
"** Things may break! Please make sure that your WE versions are in sync.\n" +
|
||||||
|
"**********************************************\n",
|
||||||
|
new Object[]{
|
||||||
|
platform.getClass(), platform.getPlatformVersion(), platform.getVersion(),
|
||||||
|
primary.getClass(), primary.getPlatformVersion(), primary.getVersion()
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +110,26 @@ public class PlatformManager {
|
|||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of loaded platforms.
|
||||||
|
* </p>
|
||||||
|
* The returned list is a copy of the original and is mutable.
|
||||||
|
*
|
||||||
|
* @return a list of platforms
|
||||||
|
*/
|
||||||
|
public synchronized List<Platform> getPlatforms() {
|
||||||
|
return new ArrayList<Platform>(platforms);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the primary platform.
|
||||||
|
*
|
||||||
|
* @return the primary platform (may be null)
|
||||||
|
*/
|
||||||
|
public @Nullable Platform getPrimaryPlatform() {
|
||||||
|
return primary;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the command manager.
|
* Get the command manager.
|
||||||
*
|
*
|
||||||
|
@ -91,4 +91,19 @@ class ServerInterfaceAdapter extends ServerInterface {
|
|||||||
return platform.getConfiguration();
|
return platform.getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return platform.getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlatformName() {
|
||||||
|
return platform.getPlatformName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlatformVersion() {
|
||||||
|
return platform.getPlatformVersion();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user