Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to run with incompatible NMS #589

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public void onEnable() {
// Read in config
Settings.LOCALE = getConfig().getString("Locale");
Settings.Debug = getConfig().getBoolean("Debug", false);
Settings.DisableNMSCompatibilityCheck = getConfig().getBoolean("IReallyKnowWhatIAmDoing", false);
Settings.DisableSpillProtection = getConfig().getBoolean("DisableSpillProtection", false);
Settings.DisableIceForm = getConfig().getBoolean("DisableIceForm", true);

Expand All @@ -126,20 +127,20 @@ public void onEnable() {
if (pilotTool != null) {
Material material = Material.getMaterial(pilotTool);
if (material != null) {
logger.info(I18nSupport.getInternationalisedString("Startup - Recognized Pilot Tool")
+ pilotTool);
logger.info("Recognized PilotTool setting of: " + pilotTool);
Settings.PilotTool = material;
}
else {
logger.info(I18nSupport.getInternationalisedString("Startup - No Pilot Tool"));
logger.info("No PilotTool setting, using default of stick");
}
}
else {
logger.info(I18nSupport.getInternationalisedString("Startup - No Pilot Tool"));
logger.info("No PilotTool setting, using default of stick");
}

String packageName = getServer().getClass().getPackage().getName();
String version = packageName.substring(packageName.lastIndexOf('.') + 1);
getLogger().info("Loading support for " + version);
try {
final Class<?> worldHandlerClazz = Class.forName("net.countercraft.movecraft.compat." + version + ".IWorldHandler");
// Check if we have a NMSHandler class at that location.
Expand All @@ -157,9 +158,9 @@ public void onEnable() {
getLogger().warning("Did not find smooth teleport, falling back to bukkit teleportation provider.");
}
}
catch (ReflectiveOperationException ignored) {
catch (final ReflectiveOperationException e) {
if (Settings.Debug) {
ignored.printStackTrace();
e.printStackTrace();
}
smoothTeleport = new BukkitTeleport(); // Fall back to bukkit teleportation
getLogger().warning("Falling back to bukkit teleportation provider.");
Expand All @@ -168,11 +169,19 @@ public void onEnable() {
}
catch (final Exception e) {
e.printStackTrace();
getLogger().severe(I18nSupport.getInternationalisedString("Startup - Version Not Supported"));
setEnabled(false);
return;
getLogger().severe("Could not find support for this version.");
if (!Settings.DisableNMSCompatibilityCheck) {
// Disable ourselves and exit
setEnabled(false);
return;
}
else {
// Server owner claims to know what they are doing, warn them of the possible consequences
getLogger().severe("WARNING!\n\t"
+ "Running Movecraft on an incompatible version can corrupt your world and break EVERYTHING!\n\t"
+ "We provide no support for any issues.");
}
}
getLogger().info(I18nSupport.getInternationalisedString("Startup - Loading Support") + " " + version);


Settings.SinkCheckTicks = getConfig().getDouble("SinkCheckTicks", 100.0);
Expand Down Expand Up @@ -218,8 +227,8 @@ public void onEnable() {
adventure = BukkitAudiences.create(this);

if(shuttingDown && Settings.IGNORE_RESET) {
logger.severe(I18nSupport.getInternationalisedString("Startup - Error - Reload error"));
logger.severe(I18nSupport.getInternationalisedString("Startup - Error - Disable warning for reload"));
logger.severe("Movecraft is incompatible with the reload command. Movecraft has shut down and will restart when the server is restarted.");
logger.severe("If you wish to use the reload command and Movecraft, you may disable this check inside the config.yml by setting 'safeReload: false'");
getPluginLoader().disablePlugin(this);
return;
}
Expand Down Expand Up @@ -270,9 +279,7 @@ public void onEnable() {
getServer().getPluginManager().registerEvents(new TeleportSign(), this);
getServer().getPluginManager().registerEvents(new ScuttleSign(), this);

logger.info(String.format(
I18nSupport.getInternationalisedString("Startup - Enabled message"),
getDescription().getVersion()));
logger.info("[V " + getDescription().getVersion() + "] has been enabled.");
}

@Override
Expand All @@ -295,21 +302,19 @@ private boolean initializeDatapack() {
break;
}
if(datapackDirectory == null) {
logger.severe(I18nSupport.getInternationalisedString("Startup - Datapack World Error"));
logger.severe("Failed to initialize Movecraft data pack due to first time world initialization.");
return false;
}
if(!datapackDirectory.exists()) {
logger.info(I18nSupport.getInternationalisedString("Startup - Datapack Directory") + datapackDirectory.getPath());
logger.info("Creating a datapack directory at " + datapackDirectory.getPath());
if(!datapackDirectory.mkdir()) {
logger.severe(I18nSupport.getInternationalisedString("Startup - Datapack Directory Error"));
logger.severe("Failed to create datapack directory!");
return false;
}
}
else if(new File(datapackDirectory, "movecraft-data.zip").exists()) {
logger.warning(String.format(
I18nSupport.getInternationalisedString("Startup - Datapack Conflict"),
datapackDirectory.getPath())
);
logger.warning("Conflicting datapack already exists in " + datapackDirectory.getPath()
+ ". If you would like to regenerate the datapack, delete the existing one and set the GeneratedDatapack config option to false.");
getConfig().set("GeneratedDatapack", true);
saveConfig();
return false;
Expand All @@ -331,20 +336,20 @@ else if(new File(datapackDirectory, "movecraft-data.zip").exists()) {
e.printStackTrace();
return false;
}
logger.info(I18nSupport.getInternationalisedString("Startup - Datapack Saved"));
logger.info("Saved default Movecraft datapack.");
getConfig().set("GeneratedDatapack", true);
saveConfig();

logger.info(I18nSupport.getInternationalisedString("Startup - Datapack First Boot"));
logger.info("It is expected that your crafts are not loaded during startup on the first boot. They will be loaded after startup.");

getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
logger.info(I18nSupport.getInternationalisedString("Startup - Datapack Enabling"));
logger.info("Enabling datapack and reloading craft types.");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "datapack list"); // required for some reason
if (!Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "datapack enable \"file/movecraft-data.zip\""))
logger.severe(I18nSupport.getInternationalisedString("Startup - Datapack Enable Error"));
logger.severe("Failed to automatically load movecraft datapack. Check if it exists.");

CraftManager.getInstance().reloadCraftTypes();
}, 200); // Wait 10 seconds before reloading. Needed to prevent Paper from running this during startup.
}, 600); // Wait 30 seconds before reloading. Needed to prevent Paper from running this during startup.
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ private Set<CraftType> loadCraftTypes() {
}
}
if (craftTypes.isEmpty()) {
Movecraft.getInstance().getLogger().log(Level.SEVERE, ERROR_PREFIX + I18nSupport.getInternationalisedString("Startup - No Crafts Found"));
Movecraft.getInstance().getLogger().log(Level.SEVERE, ERROR_PREFIX + "NO CRAFT FILES FOUND!");
return craftTypes;
}
Movecraft.getInstance().getLogger().log(Level.INFO, String.format(I18nSupport.getInternationalisedString("Startup - Number of craft files loaded"), craftTypes.size()));
Movecraft.getInstance().getLogger().log(Level.INFO, "Loaded " + craftTypes.size() + " Craft files");
return craftTypes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ Translation\ -\ Failed\ Craft\ is\ obstructed=Stroj se nemuze pohnout, protoze j
Translation\ -\ Failed\ Craft\ out\ of\ fuel=Stroji doslo palivo\!
Translation\ -\ Failed\ Craft\ hit\ minimum\ height\ limit=Stroj dosahl minimalniho limitu vysky
Internal\ -\ Error\ -\ Processor\ thread\ encountered\ an\ error=Async uloha vygenerovala vyjimku.
Startup\ -\ Number\ of\ craft\ files\ loaded=Nacteno %d souboru stroju
Startup\ -\ Error\ -\ Reload\ error=Movecraft je nekompatibilni s prikazem reload. Movecraft se vypnul a bude restartovan az s restartem serveru.
Startup\ -\ Error\ -\ Disable\ warning\ for\ reload=Pokud chcete pouzit prikaz reload a Movecraft, muzete tuto kontrolu vypnout v config.yml nastavenim 'safeReload: false'
Startup\ -\ Enabled\ message=[V %S] byl nacten.
Player\ -\ Craft\ is\ sinking=Vas stroj je prilis poskozen a potapi se\! OPUSTIT PALUBU\!
Player\ -\ Error\ -\ You\ do\ not\ have\ a\ craft\ to\ release!=Nemas zadny stroj, ktery by jsi mohl opustit\!
Release\ -\ Player\ has\ left\ craft=Opustil jsi svuj stroj\! Mas 15 vterin na navrat do stroje, jinak automaticky pustis ovladani.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,6 @@ Scuttle\ -\ Must\ Be\ Online=Player supplied must be online.
Scuttle\ -\ Must\ Be\ Player=You must be a player to scuttle your craft.
Scuttle\ -\ Craft\ Already\ Sinking=The craft is already sinking\!
Scuttle\ -\ Scuttle\ Activated=Scuttle was activated. Abandon Ship\!
Startup\ -\ Number\ of\ craft\ files\ loaded=Loaded %d Craft files
Startup\ -\ No\ Crafts\ Found=NO CRAFT FILES FOUND\!
Startup\ -\ Datapack\ Conflict=Conflicting datapack already exists in %s. If you would like to regenerate the datapack, delete the existing one and set the GeneratedDatapack config option to false.
Startup\ -\ Datapack\ Directory=Creating a datapack directory at
Startup\ -\ Datapack\ Directory\ Error=Failed to create datapack directory!
Startup\ -\ Datapack\ Enabling=Enabling datapack and reloading craft types.
Startup\ -\ Datapack\ Enable\ Error=Failed to automatically load movecraft datapack. Check if it exists.
Startup\ -\ Datapack\ First\ Boot=It is expected that your crafts are not loaded during startup on the first boot. They will be loaded after startup.
Startup\ -\ Datapack\ Saved=Saved default movecraft datapack.
Startup\ -\ Datapack\ World\ Error=Failed to initialize movecraft data pack due to first time world initialization.
Startup\ -\ Error\ -\ Reload\ error=Movecraft is incompatible with the reload command. Movecraft has shut down and will restart when the server is restarted.
Startup\ -\ Error\ -\ Disable\ warning\ for\ reload=If you wish to use the reload command and Movecraft, you may disable this check inside the config.yml by setting 'safeReload \: false'
Startup\ -\ Enabled\ message=[V %S] has been enabled.
Startup\ -\ Recognized\ Pilot\ Tool=Recognized PilotTool setting of\:
Startup\ -\ No\ Pilot\ Tool=No PilotTool setting, using default of stick
Startup\ -\ Version\ Not\ Supported=Could not find support for this version.
Startup\ -\ Loading\ Support=Loading support for
Teleportation\ -\ Cooldown\ active=Teleportation cooldown is active. You need to wait %d seconds
Translation\ -\ Failed\ Craft\ cannot\ pass\ world\ border=Translation Failed: You cannot move the craft past the world border
Translation\ -\ Failed\ Craft\ hit\ height\ limit=Craft has hit the height limit
Expand Down
Loading