Fire spreads in Nether. Possible fix

Started by coladict, September 17, 2018, 08:33:19 am

previous topic - next topic

0 Members and 1 Guest are viewing this topic.

Go Down

coladict

September 17, 2018, 08:33:19 am Last Edit: September 17, 2018, 09:04:20 am by coladict
Due to a bug, the doFireTick gamerule only works in the Overworld. I've implemented a tiny plugin that should potentially fix it, but setting-up a spigot server to test it is harder than learning to write a plugin (given I'm already a master in Java).

Attaching zip file containing the source code and compiled jar file

15:05 UTC edit: forgot one line, so replaced archive.

ButtMan3K


rev_xpurple

Tried it, but the jar won't load as a plugin.

coladict

Managed to fix it, and test it. There's just one draw-back, that if you load it at server start-up it doesn't take effect, because the game worlds aren't loaded yet. You have to call reload, or `gamerule doFireTick false` or `gamerule doFireTick true` to equalize the setting everywhere.

Code is pretty straight-forward.

Code Select
package net.jarjar;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class FireTickDisablerPlugin extends JavaPlugin implements Listener {

@Override
public void onLoad() {
Logger log = getLogger();
List<World> worlds = getServer().getWorlds();
if (worlds.isEmpty()) {
log.info("FireTickDisablerPlugin: no worlds");
// worlds not loaded yet
return;
}
World first = worlds.get(0);
Boolean val = first.getGameRuleValue(GameRule.DO_FIRE_TICK);
for (int i = 1; i < worlds.size(); i++) {
World w = worlds.get(i);
log.log(Level.INFO, "FireTickDisablerPlugin: setting doFireTick to {0} in {1}", new Object[]{val, w.getName()});
w.setGameRule(GameRule.DO_FIRE_TICK, val);
}
}

@EventHandler
public void onServerCommand(ServerCommandEvent sce) {
if (sce.getCommand().equals("gamerule doFireTick true")) {
for (World w : getServer().getWorlds()) {
w.setGameRule(GameRule.DO_FIRE_TICK, Boolean.TRUE);
}
getLogger().info("fire ticking enabled");
sce.setCancelled(true);
}
else if (sce.getCommand().equals("gamerule doFireTick false")) {
for (World w : getServer().getWorlds()) {
w.setGameRule(GameRule.DO_FIRE_TICK, Boolean.FALSE);
}
getLogger().info("fire ticking disabled");
sce.setCancelled(true);
}
}

@Override
public void onEnable() {
super.onEnable();
getServer().getPluginManager().registerEvents(this, this);
}

}

rev_xpurple


Go Up