com.sk89q.worldedit.WorldEdit Java Examples

The following examples show how to use com.sk89q.worldedit.WorldEdit. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchematicHelper.java    From FunnyGuilds with Apache License 2.0 8 votes vote down vote up
public static boolean pasteSchematic(File schematicFile, Location location, boolean withAir) {
    try {
        Vector pasteLocation = new Vector(location.getX(), location.getY(), location.getZ());
        World pasteWorld = new BukkitWorld(location.getWorld());
        WorldData pasteWorldData = pasteWorld.getWorldData();

        Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(schematicFile)).read(pasteWorldData);
        ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard, pasteWorldData);

        EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(pasteWorld, -1);

        Operation operation = clipboardHolder
                .createPaste(editSession, pasteWorldData)
                .to(pasteLocation)
                .ignoreAirBlocks(!withAir)
                .build();

        Operations.completeLegacy(operation);
        return true;
    }
    catch (IOException | MaxChangedBlocksException e) {
        FunnyGuilds.getInstance().getPluginLogger().error("Could not paste schematic: " + schematicFile.getAbsolutePath(), e);
        return false;
    }
}
 
Example #2
Source File: WorldEditListener.java    From FastAsyncWorldedit with GNU General Public License v3.0 7 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
    final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
    final World world = player.getWorld();
    final WorldEdit we = WorldEdit.getInstance();
    final Block clickedBlock = event.getBlock();
    final WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
    if (we.handleBlockLeftClick(player, pos)) {
        event.setCancelled(true);
    }
    if (we.handleArmSwing(player)) {
        event.setCancelled(true);
    }
}
 
Example #3
Source File: VisualQueue.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void operate(FawePlayer fp) {
    LocalSession session = fp.getSession();
    Player player = fp.getPlayer();
    Tool tool = session.getTool(player);
    Brush brush;
    if (tool instanceof BrushTool) {
        BrushTool brushTool = (BrushTool) tool;
        if (brushTool.getVisualMode() != VisualMode.NONE) {
            try {
                brushTool.visualize(BrushTool.BrushAction.PRIMARY, player);
            } catch (Throwable e) {
                WorldEdit.getInstance().getPlatformManager().handleThrowable(e, player);
            }
        }
    }
}
 
Example #4
Source File: FaweAPI.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public static <T> T getParser(Class<T> parserClass) {
    try {
        Field field = AbstractFactory.class.getDeclaredField("parsers");
        field.setAccessible(true);
        ArrayList<InputParser> parsers = new ArrayList<>();
        parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getMaskFactory()));
        parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getBlockFactory()));
        parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getItemFactory()));
        parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getPatternFactory()));
        for (InputParser parser : parsers) {
            if (parserClass.isAssignableFrom(parser.getClass())) {
                return (T) parser;
            }
        }
        return null;
    } catch (Throwable e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
 
Example #5
Source File: FawePrimitiveBinding.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@BindingMatch(
        type = {Extent.class},
        behavior = BindingBehavior.PROVIDES
)
public Extent getExtent(ArgumentStack context) throws ParameterException {
    Extent extent = context.getContext().getLocals().get(EditSession.class);
    if (extent != null) return extent;
    extent = Request.request().getExtent();
    if (extent != null) return extent;
    Actor actor = context.getContext().getLocals().get(Actor.class);
    if (actor == null) throw new ParameterException("No player to get a session for");
    if (!(actor instanceof Player)) throw new ParameterException("Caller is not a player");
    LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
    EditSession editSession = session.createEditSession((Player) actor);
    editSession.enableQueue();
    context.getContext().getLocals().put(EditSession.class, editSession);
    session.tellVersion(actor);
    return editSession;
}
 
Example #6
Source File: FawePrimitiveBinding.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets an {@link com.sk89q.worldedit.extent.Extent} from a {@link ArgumentStack}.
 *
 * @param context the context
 * @return an extent
 * @throws ParameterException on other error
 */
@BindingMatch(type = ResettableExtent.class,
        behavior = BindingBehavior.PROVIDES)
public ResettableExtent getResettableExtent(ArgumentStack context) throws ParameterException, InputParseException {
    String input = context.next();
    if (input.equalsIgnoreCase("#null")) return new NullExtent();
    DefaultTransformParser parser = Fawe.get().getTransformParser();
    Actor actor = context.getContext().getLocals().get(Actor.class);
    ParserContext parserContext = new ParserContext();
    parserContext.setActor(context.getContext().getLocals().get(Actor.class));
    if (actor instanceof Entity) {
        Extent extent = ((Entity) actor).getExtent();
        if (extent instanceof World) {
            parserContext.setWorld((World) extent);
        }
    }
    parserContext.setSession(WorldEdit.getInstance().getSessionManager().get(actor));
    return parser.parseFromInput(input, parserContext);
}
 
Example #7
Source File: CuboidRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
    checkNotNull(player);
    checkNotNull(session);
    checkNotNull(pos);

    Message msg;
    if (position1 != null && position2 != null) {
        msg = BBC.SELECTOR_POS.m(1, position1, region.getArea());
    } else {
        msg = BBC.SELECTOR_POS.m(1, position1, "");
    }
    String prefix = WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/";
    String cmd = prefix + Commands.getAlias(SelectionCommands.class, "/pos1") + " " + pos.getBlockX() + "," + pos.getBlockY() + "," + pos.getBlockZ();
    msg.suggestTip(cmd).send(player);

    session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getArea()));
}
 
Example #8
Source File: WorldEditListener.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true,priority = EventPriority.LOWEST)
public void onPlayerChat(PlayerChatEvent event) {
    String message = event.getMessage();
    if (message.charAt(0) == '.') {
        String[] split = event.getMessage().split(" ");
        if (split.length > 0) {
            split[0] = split[0].substring(1).replace('.', '/');
            CommandManager cmdMan = WorldEdit.getInstance().getPlatformManager().getCommandManager();
            split = cmdMan.commandDetection(split);
            CommandEvent cmdEvent = new CommandEvent(plugin.wrapCommandSender(event.getPlayer()), Joiner.on(" ").join(Arrays.asList(split)));
            if (cmdMan.getDispatcher().contains(split[0])) {
                WorldEdit.getInstance().getEventBus().post(cmdEvent);
                event.setCancelled(true);
            }
        }
    }
}
 
Example #9
Source File: WorldEditListener.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Called when a player attempts to use a command
 *
 * @param event Relevant event details
 */
@EventHandler(ignoreCancelled = true,priority = EventPriority.MONITOR)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    String[] split = event.getMessage().split(" ");

    if (split.length > 0) {
        split[0] = split[0].substring(1);
        split = WorldEdit.getInstance().getPlatformManager().getCommandManager().commandDetection(split);
    }
    final String newMessage = "/" + StringUtil.joinString(split, " ");

    if (!newMessage.equals(event.getMessage())) {
        event.setMessage(newMessage);
        plugin.getServer().getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            if (!event.getMessage().isEmpty()) {
                plugin.getServer().dispatchCommand(event.getPlayer(), event.getMessage().substring(1));
            }

            event.setCancelled(true);
        }
    }
}
 
Example #10
Source File: CuboidRegionSelector.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
    checkNotNull(player);
    checkNotNull(session);
    checkNotNull(pos);

    Message msg;
    if (position1 != null && position2 != null) {
        msg = BBC.SELECTOR_POS.m(2, position2, region.getArea());
    } else {
        msg = BBC.SELECTOR_POS.m(2, position2, "");
    }
    String prefix = WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/";
    String cmd = prefix + Commands.getAlias(SelectionCommands.class, "/pos2") + " " + pos.getBlockX() + "," + pos.getBlockY() + "," + pos.getBlockZ();
    msg.suggestTip(cmd).send(player);

    session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea()));
}
 
Example #11
Source File: SpongePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public com.sk89q.worldedit.entity.Player toWorldEditPlayer() {
    if (WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS) != null) {
        for (Platform platform : WorldEdit.getInstance().getPlatformManager().getPlatforms()) {
            return platform.matchPlayer(new FakePlayer(getName(), getUUID(), null));
        }
    }
    try {
        Class<?> clazz = Class.forName("com.sk89q.worldedit.sponge.SpongeWorldEdit");
        Object spongeWorldEdit = clazz.getDeclaredMethod("inst").invoke(null);
        Method methodGetPlayer = clazz.getMethod("wrapPlayer", org.spongepowered.api.entity.living.player.Player.class);
        return (com.sk89q.worldedit.entity.Player) methodGetPlayer.invoke(spongeWorldEdit, this.parent);
    } catch (Throwable e) {
        e.printStackTrace();
        return null;
    }
}
 
Example #12
Source File: PatternUtil.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public static Pattern parsePattern(Player player, SnipeData snipeData, String arg) {
    ParserContext context = new ParserContext();
    FawePlayer<Object> fp = FawePlayer.wrap(player);
    context.setActor(fp.getPlayer());
    context.setWorld(fp.getWorld());
    context.setSession(fp.getSession());
    try {
        Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(arg, context);
        snipeData.setPattern(pattern, arg);
        snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + arg);
        return pattern;
    } catch (InputParseException e) {
        fp.sendMessage(BBC.getPrefix() + e.getMessage());
        return null;
    }
}
 
Example #13
Source File: SpongePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public com.sk89q.worldedit.entity.Player toWorldEditPlayer() {
    if (WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS) != null) {
        for (Platform platform : WorldEdit.getInstance().getPlatformManager().getPlatforms()) {
            return platform.matchPlayer(new FakePlayer(getName(), getUUID(), null));
        }
    }
    try {
        Class<?> clazz = Class.forName("com.sk89q.worldedit.sponge.SpongeWorldEdit");
        Object spongeWorldEdit = clazz.getDeclaredMethod("inst").invoke(null);
        Method methodGetPlayer = clazz.getMethod("wrapPlayer", org.spongepowered.api.entity.living.player.Player.class);
        return (com.sk89q.worldedit.entity.Player) methodGetPlayer.invoke(spongeWorldEdit, this.parent);
    } catch (Throwable e) {
        e.printStackTrace();
        return null;
    }
}
 
Example #14
Source File: ScrollSize.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean increment(Player player, int amount) {
    int max = WorldEdit.getInstance().getConfiguration().maxRadius;
    double newSize = Math.max(0, Math.min(max == -1 ? 4095 : max, getTool().getSize() + amount));
    getTool().setSize(newSize);
    return true;
}
 
Example #15
Source File: NukkitWorldEdit.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onEnable() {
    try {
        { // Defaults
            Settings.IMP.WEB.SHORTEN_URLS = true;
        }

        Fawe.set(new FaweNukkit(this));
        Fawe.setupInjector();

        Settings.IMP.HISTORY.COMBINE_STAGES = false;
        logger = Logger.getLogger(NukkitWorldEdit.class.getCanonicalName());
        createDefaultConfiguration("config-basic.yml");
        config = new NukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-basic.yml"), true), this);
        config.load();
        this.platform = new NukkitPlatform(this);
        getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);
        WorldEdit.getInstance().getPlatformManager().register(platform);
        {
            CommandManager cmdMan = CommandManager.getInstance();
            cmdMan.registerCommands(new ConvertCommands(WorldEdit.getInstance()));
        }
        logger.info("WorldEdit for Nukkit (version " + getInternalVersion() + ") is loaded");
        WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
Example #16
Source File: CFIPacketListener.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
private boolean sendBlockChange(Player plr, VirtualWorld gen, Vector pt, Interaction action) {
    PlatformManager platform = WorldEdit.getInstance().getPlatformManager();
    com.sk89q.worldedit.entity.Player actor = FawePlayer.wrap(plr).getPlayer();
    com.sk89q.worldedit.util.Location location = new com.sk89q.worldedit.util.Location(actor.getWorld(), pt);
    BlockInteractEvent toCall = new BlockInteractEvent(actor, location, action);
    platform.handleBlockInteract(toCall);
    if (toCall.isCancelled() || action == Interaction.OPEN) {
        Vector realPos = pt.add(gen.getOrigin());
        BaseBlock block = gen.getBlock(pt);
        sendBlockChange(plr, realPos, block);
        return true;
    }
    return false;
}
 
Example #17
Source File: ScrollRange.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean increment(Player player, int amount) {
    int max = WorldEdit.getInstance().getConfiguration().maxBrushRadius;
    int newSize = MathMan.wrap(getTool().getRange() + amount, (int) (getTool().getSize() + 1), max);
    getTool().setRange(newSize);
    return true;
}
 
Example #18
Source File: FakePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public FakePlayer(String name, UUID uuid, Actor parent) {
    this.name = name;
    this.uuid = uuid == null ? UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)) : uuid;
    try {
        this.world = WorldEdit.getInstance().getServer().getWorlds().get(0);
    } catch (NoCapablePlatformException e) {
        this.world = NullWorld.getInstance();
    }
    this.pos = new Location(world, 0, 0, 0);
    this.parent = parent;
}
 
Example #19
Source File: SnipeData.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param voxelId the voxelId to set
 */
public final void setVoxelId(final int voxelId) {
    if (WorldEdit.getInstance().getConfiguration().disallowedBlocks.contains(voxelId)) {
        if (owner != null) {
            Player plr = owner.getPlayer();
            if (plr != null) {
                plr.sendMessage(ChatColor.RED + "You are not allowed to use '" + voxelId + "'");
                return;
            }
        }
    }
    this.voxelId = voxelId;
}
 
Example #20
Source File: NukkitWorldEdit.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    // Add the command to the array because the underlying command handling
    // code of WorldEdit expects it
    String[] split = new String[args.length + 1];
    System.arraycopy(args, 0, split, 1, args.length);
    split[0] = cmd.getName();
    CommandEvent event = new CommandEvent(wrapCommandSender(sender), Joiner.on(" ").join(Arrays.asList(split)));
    WorldEdit.getInstance().getEventBus().post(event);

    return true;
}
 
Example #21
Source File: CompatibilityHelper.java    From WorldEditSelectionVisualizer with MIT License 5 votes vote down vote up
public boolean isSelectionItem(ItemStack item) {
    if (item == null || item.getType() == Material.AIR) {
        return false;
    }

    if (wandItemField == null) {
        return true;
    }

    try {
        if (wandItemField.getType() == int.class) { // WorldEdit under 1.13
            //noinspection deprecation
            return item.getType().getId() == wandItemField.getInt(WorldEdit.getInstance().getConfiguration());
        }

        if (wandItemField.getType() == String.class) { // WorldEdit 1.13+
            String wandItem = (String) wandItemField.get(WorldEdit.getInstance().getConfiguration());

            return BukkitAdapter.adapt(item).getType().getId().equals(wandItem);
        }

    } catch (ReflectiveOperationException e) {
        plugin.getLogger().log(Level.WARNING, "An error occurred on isHoldingSelectionItem", e);
    }

    return true;
}
 
Example #22
Source File: FawePrimitiveBinding.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@BindingMatch(
        type = {TextureUtil.class},
        behavior = BindingBehavior.PROVIDES
)
public TextureUtil getTexture(ArgumentStack context) {
    Actor actor = context.getContext().getLocals().get(Actor.class);
    if (actor == null) return Fawe.get().getCachedTextureUtil(true, 0, 100);
    LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
    return session.getTextureUtil();
}
 
Example #23
Source File: PlatformManager.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new platform manager.
 *
 * @param worldEdit the WorldEdit instance
 */
public PlatformManager(WorldEdit worldEdit) {
    checkNotNull(worldEdit);
    this.worldEdit = worldEdit;
    this.commandManager = new CommandManager(worldEdit, this);

    // Register this instance for events
    worldEdit.getEventBus().register(this);
}
 
Example #24
Source File: SessionManager.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new session manager.
 *
 * @param worldEdit a WorldEdit instance
 */
public SessionManager(WorldEdit worldEdit) {
    checkNotNull(worldEdit);
    this.worldEdit = worldEdit;

    worldEdit.getEventBus().register(this);
}
 
Example #25
Source File: HelpBuilder.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public HelpBuilder(CommandCallable callable, CommandContext args, final String prefix, int perPage) {
    if (callable == null) {
        callable = WorldEdit.getInstance().getPlatformManager().getCommandManager().getDispatcher();
    }
    this.callable = callable;
    this.args = args;
    this.prefix = prefix;
    this.perPage = perPage;
}
 
Example #26
Source File: WorldEditHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static void loadIslandSchematic(final File file, final Location origin, PlayerPerk playerPerk) {
    log.finer("Trying to load schematic " + file);
    if (file == null || !file.exists() || !file.canRead()) {
        LogUtil.log(Level.WARNING, "Unable to load schematic " + file);
    }
    boolean noAir = false;
    BlockVector3 to = BlockVector3.at(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
    EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(origin.getWorld()), -1);
    editSession.setFastMode(true);
    ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(origin);
    if (region != null) {
        editSession.setMask(new RegionMask(getRegion(origin.getWorld(), region)));
    }
    try {
        ClipboardFormat clipboardFormat = ClipboardFormats.findByFile(file);
        try (InputStream in = new FileInputStream(file)) {
            Clipboard clipboard = clipboardFormat.getReader(in).read();
            Operation operation = new ClipboardHolder(clipboard)
                    .createPaste(editSession)
                    .to(to)
                    .ignoreAirBlocks(noAir)
                    .build();
            Operations.completeBlindly(operation);
        }
        editSession.flushSession();
    } catch (IOException e) {
        log.log(Level.INFO, "Unable to paste schematic " + file, e);
    }
}
 
Example #27
Source File: PasteSchematicEvent.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Void execute(String playerID) throws QuestRuntimeException {
    try {
        Location location = loc.getLocation(playerID);
        ClipboardFormat format = ClipboardFormats.findByFile(file);
        if (format == null) {
            throw new IOException("Unknown Schematic Format");
        }

        Clipboard clipboard;
        try (ClipboardReader reader = format.getReader(new FileInputStream(file))) {
            clipboard = reader.read();
        }


        try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(location.getWorld()), -1)) {
            Operation operation = new ClipboardHolder(clipboard)
                    .createPaste(editSession)
                    .to(BukkitAdapter.asBlockVector(location))
                    .ignoreAirBlocks(noAir)
                    .build();

            Operations.complete(operation);
        }
    } catch (IOException | WorldEditException e) {
        LogUtils.getLogger().log(Level.WARNING, "Error while pasting a schematic: " + e.getMessage());
        LogUtils.logThrowable(e);
    }
    return null;
}
 
Example #28
Source File: BukkitServerBridge.java    From PlotMe-Core with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Setup PlotMe plugin hooks
 */
@Override
public void setupHooks() {
    PluginManager pluginManager = plotMeCorePlugin.getServer().getPluginManager();
    if (pluginManager.getPlugin("WorldEdit") != null) {
        WorldEdit.getInstance().getEventBus().register(new PlotWorldEditListener(plotMeCorePlugin.getAPI()));
    }

    setUsingLwc(pluginManager.getPlugin("LWC") != null);
}
 
Example #29
Source File: Game.java    From HeavySpleef with GNU General Public License v3.0 5 votes vote down vote up
public Game(HeavySpleef heavySpleef, String name, World world) {
	this.heavySpleef = heavySpleef;
	this.name = name;
	this.world = world;
	this.worldEditWorld = new BukkitWorld(world);
	this.i18n = I18NManager.getGlobal();
	this.ingamePlayers = Sets.newLinkedHashSet();
	this.deadPlayers = Lists.newArrayList();
	this.eventBus = heavySpleef.getGlobalEventBus().newChildBus();
	this.statisticRecorder = new StatisticRecorder(heavySpleef, heavySpleef.getLogger());
	this.regeneratorFactory = new FloorRegeneratorFactory();
	this.killedPlayers = Lists.newArrayList();
       this.killedLobbyPlayers = Lists.newArrayList();
	
	eventBus.registerListener(statisticRecorder);
	setGameState(GameState.WAITING);
	
	DefaultConfig configuration = heavySpleef.getConfiguration(ConfigType.DEFAULT_CONFIG);
	FlagManager.GamePropertyBundle defaults = new FlagManager.DefaultGamePropertyBundle(configuration.getProperties());
	
	this.flagManager = new FlagManager(heavySpleef.getPlugin(), defaults);
	this.extensionManager = heavySpleef.getExtensionRegistry().newManagerInstance(eventBus);
	this.deathzones = Maps.newHashMap();
	this.blocksBroken = HashBiMap.create();
	this.killDetector = new DefaultKillDetector();
	this.queuedPlayers = new LinkedList<SpleefPlayer>();
	this.spawnLocationQueue = new LinkedList<Location>();
	
	//Concurrent map for database schematics
	this.floors = new ConcurrentHashMap<String, Floor>();
	
	WorldEditHook hook = (WorldEditHook) heavySpleef.getHookManager().getHook(HookReference.WORLDEDIT);
	WorldEdit worldEdit = hook.getWorldEdit();
	
	this.editSessionFactory = worldEdit.getEditSessionFactory();
	
	GeneralSection generalSection = configuration.getGeneralSection();
	this.joinRequester = new JoinRequester(this, heavySpleef.getPvpTimerManager());
	this.joinRequester.setPvpTimerMode(generalSection.getPvpTimer() > 0);
}
 
Example #30
Source File: WorldEditHook.java    From HeavySpleef with GNU General Public License v3.0 5 votes vote down vote up
public WorldEdit getWorldEdit() {
	if (!isProvided()) {
		throw new IllegalStateException("The WorldEdit hook is not provided");
	}
	
	WorldEditPlugin plugin = (WorldEditPlugin) getPlugin();
	return plugin.getWorldEdit();
}