This commit is contained in:
Telesphoreo 2020-11-08 21:08:44 -06:00
parent 08bfd73eec
commit 0adee3582b
2 changed files with 6 additions and 11 deletions

View File

@ -10,7 +10,6 @@ import org.bukkit.World;
public class GameRuleHandler extends FreedomService public class GameRuleHandler extends FreedomService
{ {
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class); private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
public GameRuleHandler() public GameRuleHandler()
@ -61,11 +60,8 @@ public class GameRuleHandler extends FreedomService
public void commitGameRules() public void commitGameRules()
{ {
List<World> worlds = Bukkit.getWorlds(); List<World> worlds = Bukkit.getWorlds();
Iterator<Map.Entry<GameRule, Boolean>> it = rules.entrySet().iterator(); for (Map.Entry<GameRule, Boolean> gameRuleEntry : rules.entrySet())
while (it.hasNext())
{ {
Map.Entry<GameRule, Boolean> gameRuleEntry = it.next();
String gameRuleName = gameRuleEntry.getKey().getGameRuleName(); String gameRuleName = gameRuleEntry.getKey().getGameRuleName();
String gameRuleValue = gameRuleEntry.getValue().toString(); String gameRuleValue = gameRuleEntry.getValue().toString();
@ -79,13 +75,11 @@ public class GameRuleHandler extends FreedomService
world.setTime(time + 24000 + 6000); world.setTime(time + 24000 + 6000);
} }
} }
} }
} }
public static enum GameRule public enum GameRule
{ {
DO_FIRE_TICK("doFireTick", true), DO_FIRE_TICK("doFireTick", true),
MOB_GRIEFING("mobGriefing", true), MOB_GRIEFING("mobGriefing", true),
KEEP_INVENTORY("keepInventory", false), KEEP_INVENTORY("keepInventory", false),
@ -98,7 +92,7 @@ public class GameRuleHandler extends FreedomService
ANNOUNCE_ADVANCEMENTS("announceAdvancements", false), ANNOUNCE_ADVANCEMENTS("announceAdvancements", false),
SHOW_DEATH_MESSAGES("showDeathMessages", false), SHOW_DEATH_MESSAGES("showDeathMessages", false),
SEND_COMMAND_FEEDBACK("sendCommandFeedback", false); SEND_COMMAND_FEEDBACK("sendCommandFeedback", false);
//
private final String gameRuleName; private final String gameRuleName;
private final boolean defaultValue; private final boolean defaultValue;
@ -118,5 +112,4 @@ public class GameRuleHandler extends FreedomService
return defaultValue; return defaultValue;
} }
} }
} }

View File

@ -214,13 +214,14 @@ public class EventBlocker extends FreedomService
// TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper. // TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
private ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP)); private ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
@EventHandler @EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) public void onBlockPhysics(BlockPhysicsEvent event)
{ {
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean()) if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{ {
// Check if the block is involved with redstone. // Check if the block is involved with redstone.
if(event.getBlock().getBlockData() instanceof AnaloguePowerable || event.getBlock().getBlockData() instanceof Powerable || redstoneBlocks.contains(event.getBlock().getType())) if (event.getBlock().getBlockData() instanceof AnaloguePowerable || event.getBlock().getBlockData() instanceof Powerable || redstoneBlocks.contains(event.getBlock().getType()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -239,6 +240,7 @@ public class EventBlocker extends FreedomService
} }
} }
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onBlockDispense(BlockDispenseEvent event) public void onBlockDispense(BlockDispenseEvent event)
{ {