mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-27 19:47:56 +01:00
It now runs
This commit is contained in:
parent
2e8d14c995
commit
b10cf6adbc
@ -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 @@ public interface WorldGuardPlatform {
|
||||
*/
|
||||
void broadcastNotification(String message);
|
||||
|
||||
/**
|
||||
* Load the platform
|
||||
*/
|
||||
void load();
|
||||
|
||||
/**
|
||||
* Unload the platform
|
||||
*/
|
||||
|
@ -43,6 +43,7 @@ public class BukkitConfigurationManager extends YamlConfigurationManager {
|
||||
*/
|
||||
public BukkitConfigurationManager(WorldGuardPlugin plugin) {
|
||||
super();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,8 +66,6 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
||||
@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 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
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,9 +106,8 @@ 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) {
|
||||
@ -116,6 +115,7 @@ public void onUseBlock(final UseBlockEvent event) {
|
||||
}
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user