com.sk89q.worldedit.bukkit.WorldEditPlugin Java Examples

The following examples show how to use com.sk89q.worldedit.bukkit.WorldEditPlugin. 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: SchematicHandler8.java    From UhcCore with GNU General Public License v3.0 6 votes vote down vote up
public static ArrayList<Integer> pasteSchematic(Location loc, String path) throws Exception{
	WorldEditPlugin we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
	Bukkit.getLogger().info("[UhcCore] Pasting "+path);
	File schematic = new File(path);
	EditSession session = we.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(loc.getWorld()), -1);
	
	CuboidClipboard clipboard = MCEditSchematicFormat.getFormat(schematic).load(schematic);
	clipboard.paste(session, new Vector(loc.getBlockX(),loc.getBlockY(),loc.getBlockZ()), false);

	ArrayList<Integer> dimensions = new ArrayList<>();
	dimensions.add(clipboard.getHeight());
	dimensions.add(clipboard.getLength());
	dimensions.add(clipboard.getWidth());
	
	Bukkit.getLogger().info("[UhcCore] Successfully pasted '"+path+"' at "+loc.getBlockX()+" "+loc.getBlockY()+" "+loc.getBlockZ());
	return dimensions;
}
 
Example #2
Source File: AsyncWorld.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @deprecated use {@link #wrap(org.bukkit.World)} instead
 * @param parent
 * @param queue
 */
@Deprecated
public AsyncWorld(World parent, FaweQueue queue) {
    super(queue);
    this.parent = parent;
    this.queue = queue;
    if (queue instanceof BukkitQueue_0) {
        this.adapter = (BukkitImplAdapter) ((BukkitQueue_0) queue).getAdapter();
    } else {
        try {
            WorldEditPlugin instance = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
            Field fieldAdapter = WorldEditPlugin.class.getDeclaredField("bukkitAdapter");
            fieldAdapter.setAccessible(true);
            this.adapter = (BukkitImplAdapter) fieldAdapter.get(instance);
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
 
Example #3
Source File: WorldEditBridge.java    From BungeePerms with GNU General Public License v3.0 6 votes vote down vote up
public void inject(Plugin plugin)
{
    BungeePerms.getLogger().info("Injection of Bungeeperms into WorldEdit"); //todo even more lang support
    try
    {
        WorldEditPlugin we = (WorldEditPlugin) plugin;

        if (!we.isEnabled())
        {
            return;
        }

        //inject BungeePerms
        Field f = we.getPermissionsResolver().getClass().getDeclaredField("enabledResolvers");
        f.setAccessible(true);
        ((List) f.get(we.getPermissionsResolver())).add(BungeePermsResolver.class);

        we.getPermissionsResolver().findResolver();
    }
    catch (Exception ex)
    {
    }
}
 
Example #4
Source File: WorldEditBridge.java    From BungeePerms with GNU General Public License v3.0 6 votes vote down vote up
public void uninject(Plugin plugin)
{
    BungeePerms.getLogger().info("Uninjection of Bungeeperms into WorldEdit");
    try
    {
        WorldEditPlugin we = (WorldEditPlugin) plugin;

        //inject BungeePerms
        Field f = we.getPermissionsResolver().getClass().getDeclaredField("enabledResolvers");
        f.setAccessible(true);
        ((List) f.get(we.getPermissionsResolver())).remove(BungeePermsResolver.class);

        we.getPermissionsResolver().findResolver();
    }
    catch (Exception ex)//todo report error
    {
    }
}
 
Example #5
Source File: SurvivalGames.java    From Survival-Games with GNU General Public License v3.0 5 votes vote down vote up
public WorldEditPlugin getWorldEdit() {
	Plugin worldEdit = getServer().getPluginManager().getPlugin("WorldEdit");
	if (worldEdit instanceof WorldEditPlugin) {
		return (WorldEditPlugin) worldEdit;
	} else {
		return null;
	}
}
 
Example #6
Source File: ReflectionUtils.java    From Survival-Games with GNU General Public License v3.0 5 votes vote down vote up
private static Method getSelectionMethod() {
	if(!SurvivalGames.PRE1_13) return null;
	try {
		return WorldEditPlugin.class.getMethod("getSelection", Player.class);
	} catch (NoSuchMethodException | SecurityException e) {
		e.printStackTrace();
	}
	return getBlockX;	
}
 
Example #7
Source File: BukkitQueue_0.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public static void setupAdapter(BukkitImplAdapter adapter) {
    try {
        if (adapter == null && setupAdapter == (setupAdapter = true)) {
            return;
        }
        WorldEditPlugin instance = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
        Field fieldAdapter = WorldEditPlugin.class.getDeclaredField("bukkitAdapter");
        fieldAdapter.setAccessible(true);
        if (adapter != null) {
            BukkitQueue_0.adapter = adapter;
            fieldAdapter.set(instance, adapter);
        } else {
            BukkitQueue_0.adapter = adapter = (BukkitImplAdapter) fieldAdapter.get(instance);
            if (adapter == null) {
                BukkitQueue_0.adapter = adapter = new FaweAdapter_All();
                fieldAdapter.set(instance, adapter);
            }
        }
        if (adapter != null) {
            for (Method method : adapter.getClass().getDeclaredMethods()) {
                switch (method.getName()) {
                    case "toNative":
                        methodToNative = method;
                        methodToNative.setAccessible(true);
                        break;
                    case "fromNative":
                        methodFromNative = method;
                        methodFromNative.setAccessible(true);
                        break;
                }
            }
        }
        return;
    } catch (Throwable ignore) {
        ignore.printStackTrace();
    }
}
 
Example #8
Source File: WEHook.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
private static void setSelection(BukkitWorld ws, Player p, Location pos1, Location pos2) {
    WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
    RegionSelector regs = worldEdit.getSession(p).getRegionSelector(ws);
    regs.selectPrimary(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), null);
    regs.selectSecondary(BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()), null);
    worldEdit.getSession(p).setRegionSelector(ws, regs);
    worldEdit.getSession(p).dispatchCUISelection(worldEdit.wrapPlayer(p));
}
 
Example #9
Source File: WEHook.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public static void setSelectionFromRP(Player p, Location pos1, Location pos2) {
    WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
    BukkitWorld ws = new BukkitWorld(p.getWorld());
    if (worldEdit.getSession(p) == null || !worldEdit.getSession(p).isSelectionDefined(ws)) {
        setSelection(ws, p, pos1, pos2);
    } else {
        worldEdit.getSession(p).getRegionSelector(ws).clear();
        RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("cmdmanager.region.select-we.hide"));
    }
    worldEdit.getSession(p).dispatchCUISelection(worldEdit.wrapPlayer(p));
}
 
Example #10
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();
}
 
Example #11
Source File: GameManager.java    From Survival-Games with GNU General Public License v3.0 4 votes vote down vote up
public WorldEditPlugin getWorldEdit() {
	return p.getWorldEdit();
}
 
Example #12
Source File: FaweBukkit.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public WorldEditPlugin getWorldEditPlugin() {
    if (this.worldedit == null) {
        this.worldedit = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
    }
    return this.worldedit;
}
 
Example #13
Source File: AreaShop.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Function to get the WorldEdit plugin.
 * @return WorldEditPlugin
 */
@Override
public WorldEditPlugin getWorldEdit() {
	return worldEdit;
}
 
Example #14
Source File: DeathzoneCommands.java    From HeavySpleef with GNU General Public License v3.0 4 votes vote down vote up
@Command(name = "adddeathzone", permission = Permissions.PERMISSION_ADD_DEATHZONE, minArgs = 1,
		descref = Messages.Help.Description.ADDDEATHZONE,
		usage = "/spleef adddeathzone <Game> [Deathzone-Name]")
@PlayerOnly
public void onCommandAddDeathzone(CommandContext context, HeavySpleef heavySpleef) throws CommandException {
	SpleefPlayer player = heavySpleef.getSpleefPlayer(context.getSender());
	
	String gameName = context.getString(0);
	GameManager manager = heavySpleef.getGameManager();
	
	CommandValidate.isTrue(manager.hasGame(gameName), i18n.getVarString(Messages.Command.GAME_DOESNT_EXIST)
			.setVariable("game", gameName)
			.toString());
	Game game = manager.getGame(gameName);
	
	WorldEditPlugin plugin = (WorldEditPlugin) heavySpleef.getHookManager().getHook(HookReference.WORLDEDIT).getPlugin();
	com.sk89q.worldedit.entity.Player bukkitPlayer = plugin.wrapPlayer(player.getBukkitPlayer());
	World world = new BukkitWorld(player.getBukkitPlayer().getWorld());
	
	LocalSession session = plugin.getWorldEdit().getSessionManager().get(bukkitPlayer);
	RegionSelector selector = session.getRegionSelector(world);
	
	Region region;
	
	try {
		region = selector.getRegion().clone();
	} catch (IncompleteRegionException e) {
		player.sendMessage(i18n.getString(Messages.Command.DEFINE_FULL_WORLDEDIT_REGION));
		return;
	}
	
	validateSelectedRegion(region);
	
	String deathzoneName = context.argsLength() > 1 ? context.getString(1) : generateUniqueDeathzoneName(game);
	
	game.addDeathzone(deathzoneName, region);
	player.sendMessage(i18n.getVarString(Messages.Command.DEATHZONE_ADDED)
			.setVariable("deathzonename", deathzoneName)
			.toString());
	
	//Save the game
	heavySpleef.getDatabaseHandler().saveGame(game, null);
}
 
Example #15
Source File: WorldEditHelper.java    From WorldEditSelectionVisualizer with MIT License 3 votes vote down vote up
public WorldEditHelper(WorldEditSelectionVisualizer plugin) {
    this.plugin = plugin;

    registerShapeProcessors();

    worldEditPlugin = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");

    if (worldEditPlugin == null) {
        throw new IllegalStateException("WorldEditPlugin not found");
    }

    runTaskTimer(plugin, 20, plugin.getConfig().getInt("selection-update-interval"));
}
 
Example #16
Source File: AreaShopInterface.java    From AreaShop with GNU General Public License v3.0 votes vote down vote up
WorldEditPlugin getWorldEdit();