Imgurcraft | The minecraft server for Imgurians!

All Imgurcraft boards => General Discussion => Topic started by: coladict on September 17, 2018, 08:33:19 am

Title: Fire spreads in Nether. Possible fix
Post by: coladict on September 17, 2018, 08:33:19 am
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.
Title: Re: Fire spreads in Nether. Possible fix
Post by: ButtMan3K on September 18, 2018, 02:47:41 am
Ughhhh Java... great job tho :D
Title: Re: Fire spreads in Nether. Possible fix
Post by: rev_xpurple on September 19, 2018, 12:24:34 am
Tried it, but the jar won't load as a plugin.
Title: Re: Fire spreads in Nether. Possible fix
Post by: coladict on September 19, 2018, 08:46:12 am
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);
}

}
Title: Re: Fire spreads in Nether. Possible fix
Post by: rev_xpurple on September 19, 2018, 09:39:08 am
It seems to work!