Permalink
Browse files

It now runs

  • Loading branch information...
me4502 committed Jul 22, 2018
1 parent 2e8d14c commit b10cf6adbcd3dbbd9c66616ed6ef8b1add2315b2
@@ -40,7 +40,11 @@ public static WorldGuard getInstance() {
return instance;
}
public WorldGuard() {
private WorldGuard() {
}
public void setup() {
getPlatform().load();
Flags.registerAll();
}
@@ -27,8 +27,8 @@
public abstract class YamlWorldConfiguration extends WorldConfiguration {
@Unreported private YAMLProcessor parentConfig;
@Unreported private YAMLProcessor config;
@Unreported protected YAMLProcessor parentConfig;
@Unreported protected YAMLProcessor config;
public boolean getBoolean(String node, boolean def) {
boolean val = parentConfig.getBoolean(node, def);
@@ -96,6 +96,11 @@
*/
void broadcastNotification(String message);
/**
* Load the platform
*/
void load();
/**
* Unload the platform
*/
@@ -43,6 +43,7 @@
*/
public BukkitConfigurationManager(WorldGuardPlugin plugin) {
super();
this.plugin = plugin;
}
@Override
@@ -66,8 +66,6 @@
@Unreported private WorldGuardPlugin plugin;
@Unreported private String worldName;
@Unreported private YAMLProcessor parentConfig;
@Unreported private YAMLProcessor config;
@Unreported private ChestProtection chestProtection = new SignChestProtection();
@@ -42,14 +42,10 @@
public class BukkitWorldGuardPlatform implements WorldGuardPlatform {
private SessionManager sessionManager;
private final BukkitConfigurationManager configuration;
private final BukkitRegionContainer regionContainer;
private BukkitConfigurationManager configuration;
private BukkitRegionContainer regionContainer;
public BukkitWorldGuardPlatform() {
sessionManager = new BukkitSessionManager(WorldGuardPlugin.inst());
configuration = new BukkitConfigurationManager(WorldGuardPlugin.inst());
regionContainer = new BukkitRegionContainer(WorldGuardPlugin.inst());
regionContainer.initialize();
}
@Override
@@ -108,6 +104,15 @@ public void broadcastNotification(String message) {
WorldGuard.logger.info(message);
}
@Override
public void load() {
sessionManager = new BukkitSessionManager(WorldGuardPlugin.inst());
configuration = new BukkitConfigurationManager(WorldGuardPlugin.inst());
configuration.load();
regionContainer = new BukkitRegionContainer(WorldGuardPlugin.inst());
regionContainer.initialize();
}
@Override
public void unload() {
configuration.unload();
@@ -126,7 +126,7 @@
private static WorldGuardPlugin inst;
private static BukkitWorldGuardPlatform platform;
private final CommandsManager<CommandSender> commands;
private final GlobalRegionManager globalRegionManager = new GlobalRegionManager((BukkitRegionContainer) WorldGuard.getInstance().getPlatform().getRegionContainer());
private GlobalRegionManager globalRegionManager;
private final Supervisor supervisor = new SimpleSupervisor();
private ListeningExecutorService executorService;
private ProfileService profileService;
@@ -168,7 +168,9 @@ public void onEnable() {
executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20));
WorldGuard.getInstance().setPlatform(platform = new BukkitWorldGuardPlatform()); // Initialise WorldGuard
WorldGuard.getInstance().setup();
BukkitSessionManager sessionManager = (BukkitSessionManager) platform.getSessionManager();
globalRegionManager = new GlobalRegionManager(WorldGuard.getInstance().getPlatform().getRegionContainer());
// Set the proper command injector
commands.setInjector(new SimpleInjector(this));
@@ -106,16 +106,16 @@ public void onBreakBlock(final BreakBlockEvent event) {
@EventHandler(ignoreCancelled = true)
public void onUseBlock(final UseBlockEvent event) {
final Player player = event.getCause().getFirstPlayer();
final LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
final BukkitWorldConfiguration wcfg = getWorldConfig(localPlayer);
final BukkitWorldConfiguration wcfg = getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
// Early guard
if (!wcfg.signChestProtection) {
return;
}
if (player != null) {
final LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
event.filter(target -> {
if (wcfg.isChestProtected(BukkitAdapter.adapt(target.getBlock().getLocation()), localPlayer)) {
sendMessage(event, player, ChatColor.DARK_RED + "This chest is protected.");
@@ -80,9 +80,10 @@ public void onPlayerMove(PlayerMoveEvent event) {
LocalPlayer localPlayer = plugin.wrapPlayer(player);
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer);
final Location override = BukkitAdapter.adapt(session.testMoveTo(localPlayer, BukkitAdapter.adapt(event.getTo()), MoveType.MOVE));
com.sk89q.worldedit.util.Location weLocation = session.testMoveTo(localPlayer, BukkitAdapter.adapt(event.getTo()), MoveType.MOVE);
if (override != null) {
if (weLocation != null) {
final Location override = BukkitAdapter.adapt(weLocation);
override.setX(override.getBlockX() + 0.5);
override.setY(override.getBlockY());
override.setZ(override.getBlockZ() + 0.5);

0 comments on commit b10cf6a

Please sign in to comment.