@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onGamemode(PlayerGameModeChangeEvent event) { if (!plugin.getInternalPlatform().isHookingEvents()) { return; } // this will automatically refresh their session, we don't have to do anything WorldEdit.getInstance().getSessionManager().get(plugin.wrapPlayer(event.getPlayer())); }
/** * Convert any WorldEdit world into an equivalent wrapped Bukkit world. * * <p>If a matching world cannot be found, a {@link RuntimeException} * will be thrown.</p> * * @param world the world * @return a wrapped Bukkit world */ public static BukkitWorld asBukkitWorld(World world) { if (world instanceof BukkitWorld) { return (BukkitWorld) world; } else { BukkitWorld bukkitWorld = WorldEditPlugin.getInstance().getInternalPlatform().matchWorld(world); if (bukkitWorld == null) { throw new RuntimeException("World '" + world.getName() + "' has no matching version in Bukkit"); } return bukkitWorld; } }
/** * Called on plugin disable. */ @Override public void onDisable() { WorldEdit worldEdit = WorldEdit.getInstance(); worldEdit.getSessionManager().unload(); worldEdit.getPlatformManager().unregister(server); if (config != null) { config.unload(); } if (server != null) { server.unregisterCommands(); } this.getServer().getScheduler().cancelTasks(this); }
/** * Called on plugin enable. */ @SuppressWarnings("AccessStaticViaInstance") @Override public void onEnable() { this.INSTANCE = this; //noinspection ResultOfMethodCallIgnored getDataFolder().mkdirs(); WorldEdit worldEdit = WorldEdit.getInstance(); // Setup platform server = new BukkitServerInterface(this, getServer()); worldEdit.getPlatformManager().register(server); loadAdapter(); // Need an adapter to work with special blocks with NBT data worldEdit.loadMappings(); loadConfig(); // Load configuration PermissionsResolverManager.initialize(this); // Setup permission resolver // Register CUI getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this)); getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL); // Now we can register events getServer().getPluginManager().registerEvents(new WorldEditListener(this), this); // If we are on MCPC+/Cauldron, then Forge will have already loaded // Forge WorldEdit and there's (probably) not going to be any other // platforms to be worried about... at the current time of writing WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); // Enable metrics new Metrics(this); }
if (!plugin.getInternalPlatform().isHookingEvents()) { return;