Updated WorldEdit and WorldGuard to 7.0.0

It doesn't work without them atm because it tries to load a class from them
This commit is contained in:
Norbi Peti 2019-08-28 23:29:40 +02:00
parent 24ed3393d3
commit 14bdf0ebe0
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
6 changed files with 1093 additions and 1089 deletions

34
pom.xml
View file

@ -49,7 +49,7 @@
<!-- Official WorldGuard and WorldEdit repository -->
<repository>
<id>sk89q-mvn2</id>
<url>http://maven.sk89q.com/repo</url>
<url>https://maven.enginehub.org/repo/</url>
</repository>
<!-- Official Multiverse repository -->
<repository>
@ -81,23 +81,29 @@
<artifactId>plib</artifactId>
<version>${plib.version}</version>
</dependency>
<dependency>
<!-- http://dl.bukkit.org/ -->
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>${bukkit.version}</version>
</dependency>
<dependency>
<!-- http://dl.bukkit.org/ -->
<groupId>org.bukkit.</groupId> <!-- Needed for WE integration -->
<artifactId>bukkit</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<!-- http://dl.bukkit.org/ -->
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>${bukkit.version}</version>
<!-- http://dev.bukkit.org/server-mods/worldguard/ -->
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<!-- http://dev.bukkit.org/server-mods/worldguard/ -->
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>6.1</version>
</dependency>
<dependency>
<!-- http://dev.bukkit.org/server-mods/worldguard/ -->
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>6.0.0-SNAPSHOT</version>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<!-- http://dev.bukkit.org/server-mods/authme-reloaded/ -->

View file

@ -1,23 +1,14 @@
package de.jaschastarke.minecraft.limitedcreative.blockstate;
import java.util.Date;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.Selection;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;
import de.jaschastarke.LocaleString;
import de.jaschastarke.bukkit.lib.chat.ChatFormattings;
import de.jaschastarke.bukkit.lib.commands.BukkitCommand;
import de.jaschastarke.bukkit.lib.commands.CommandContext;
import de.jaschastarke.bukkit.lib.commands.CommandException;
import de.jaschastarke.bukkit.lib.commands.HelpCommand;
import de.jaschastarke.bukkit.lib.commands.IHelpDescribed;
import de.jaschastarke.bukkit.lib.commands.MissingPermissionCommandException;
import de.jaschastarke.bukkit.lib.commands.*;
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
@ -32,6 +23,11 @@ import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.Cuboid;
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.DBTransaction;
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import java.util.Date;
/**
* LimitedCreative-BlockState-Command: modify blockstate database to prevent drops of selected blocks (requires WorldEdit)
@ -155,16 +151,21 @@ public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
return false;
}
WorldEditPlugin we = (WorldEditPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin("WorldEdit");
final Selection selection = we.getSelection(context.getPlayer());
BukkitPlayer bp = BukkitAdapter.adapt(context.getPlayer());
Region region = null;
try {
region = WorldEdit.getInstance().getSessionManager().get(bp).getSelection(bp.getWorld());
} catch (Exception ignored) { //IncompleteRegionException
}
final Region selection = region;
if (selection == null) {
context.response(L("command.blockstate.worledit_selection_empty"));
return true;
}
final Location min = selection.getMinimumPoint();
final Location max = selection.getMaximumPoint();
final BlockVector3 min = selection.getMinimumPoint();
final BlockVector3 max = selection.getMaximumPoint();
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
@Override
@ -174,10 +175,12 @@ public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
DBTransaction update = mod.getModel().groupUpdate();
int count = 0;
World w = selection.getWorld();
assert w != null;
org.bukkit.World bw = BukkitAdapter.adapt(w);
Cuboid c = new Cuboid();
c.add(min);
c.add(max);
c.add(new Location(bw, min.getBlockX(), min.getBlockY(), min.getBlockZ()));
c.add(new Location(bw, max.getBlockX(), max.getBlockY(), max.getBlockZ()));
mod.getModel().cacheStates(c);
BlockState seed = new BlockState();
@ -188,9 +191,9 @@ public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
Location loc = new Location(w, x, y, z);
if (w.getBlockAt(loc).getType() != Material.AIR && selection.contains(loc)) {
seed.setLocation(loc);
BlockVector3 loc = BlockVector3.at(x, y, z);
if (!w.getBlock(loc).getBlockType().getMaterial().isAir() && selection.contains(loc)) {
seed.setLocation(new Location(bw, x, y, z));
update.setState(new BlockState(seed));
count++;
}

View file

@ -1,21 +1,20 @@
package de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit;
import java.util.Date;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState;
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.logging.AbstractLoggingExtent;
import java.util.Date;
import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState;
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
public class EditSessionExtent extends AbstractLoggingExtent {
public class EditSessionExtent extends AbstractDelegateExtent {
private ModBlockStates mod;
private Player player = null;
private World world;
@ -30,14 +29,15 @@ public class EditSessionExtent extends AbstractLoggingExtent {
/**
* Called when a block is being changed.
*
* @param position the position
* @param pt the position
* @param newBlock the new block to replace the old one
*/
protected void onBlockChange(Vector pt, BaseBlock newBlock) {
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pt, T newBlock) throws WorldEditException {
if (mod.isDebug())
mod.getLog().debug("WorldEdit-Integration: BlockChange: "+pt.toString()+" BB: " + newBlock.toString());
Location loc = new Location(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (newBlock.getType() == 0) {
if (newBlock.getBlockType().getMaterial().isAir()) {
mod.getModel().removeState(loc.getBlock());
} else {
BlockState s = mod.getModel().getState(loc.getBlock());
@ -54,5 +54,6 @@ public class EditSessionExtent extends AbstractLoggingExtent {
mod.getModel().setState(s);
}
return true;
}
}

View file

@ -1,12 +1,10 @@
package de.jaschastarke.minecraft.limitedcreative.regions;
import org.bukkit.GameMode;
import org.bukkit.command.CommandSender;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.FlagContext;
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
import com.sk89q.worldguard.protection.flags.RegionGroup;
import org.bukkit.GameMode;
/**
* Well, that was an interesting idea, but it doesn't work.
@ -17,7 +15,8 @@ public class GameModeFlag extends Flag<GameMode> {
}
@Override
public GameMode parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
public GameMode parseInput(FlagContext context) throws InvalidFlagFormat {
String input = context.getUserInput();
input = input.trim();
if (input.equalsIgnoreCase("creative")) {
return GameMode.CREATIVE;

View file

@ -1,31 +1,19 @@
package de.jaschastarke.minecraft.limitedcreative.regions;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.FlagContext;
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import de.jaschastarke.LocaleString;
import de.jaschastarke.bukkit.lib.chat.ChatFormattings;
import de.jaschastarke.bukkit.lib.commands.BukkitCommand;
import de.jaschastarke.bukkit.lib.commands.CommandContext;
import de.jaschastarke.bukkit.lib.commands.CommandException;
import de.jaschastarke.bukkit.lib.commands.HelpCommand;
import de.jaschastarke.bukkit.lib.commands.ICommand;
import de.jaschastarke.bukkit.lib.commands.IHelpDescribed;
import de.jaschastarke.bukkit.lib.commands.MethodCommand;
import de.jaschastarke.bukkit.lib.commands.MissingPermissionCommandException;
import de.jaschastarke.bukkit.lib.commands.*;
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
@ -40,6 +28,13 @@ import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagList;
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagValue;
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.Region;
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import java.util.ArrayList;
import java.util.List;
/**
* LimitedCreative-Region-Command: configure creative regions
@ -138,7 +133,8 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
if (idx > -1 && context.getArgument(idx) != null)
w = Bukkit.getWorld(context.getArgument(idx));
if (w != null) {
RegionManager mgr = getWorldGuard().getRegionManager(w);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionManager mgr = container.get(BukkitAdapter.adapt(w));
if (mgr != null) {
List<String> hints = new ArrayList<String>();
for (String rId : mgr.getRegions().keySet()) {
@ -174,7 +170,8 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
if (w == null)
throw new CommandException(L("command.worldguard.world_not_found"));
RegionManager mgr = getWorldGuard().getRegionManager(w);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionManager mgr = container.get(BukkitAdapter.adapt(w));
ProtectedRegion region = mgr.getRegion(params.getArgument(0));
if (region == null && params.getArgument(0).equalsIgnoreCase("__global__")) {
region = new GlobalProtectedRegion(params.getArgument(0));
@ -202,7 +199,7 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
String value = params.getValue();
try {
if (value != null && value.trim().length() > 0) {
reg.setFlag(flag, flag.parseInput(getWorldGuard(), context.getSender(), value));
reg.setFlag(flag, flag.parseInput(FlagContext.create().setInput(value).build()));
} else {
reg.setFlag(flag, null);
}
@ -237,17 +234,18 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
throw new CommandException(L("command.worldguard.world_not_found"));
ProtectedRegion region = null;
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
if (params.getArgumentCount() == 0 && context.isPlayer()) {
RegionManager mgr = getWorldGuard().getRegionManager(context.getPlayer().getWorld());
ApplicableRegionSet set = mgr.getApplicableRegions(context.getPlayer().getLocation());
RegionManager mgr = container.get(BukkitAdapter.adapt(context.getPlayer().getWorld()));
ApplicableRegionSet set = mgr.getApplicableRegions(BukkitAdapter.asBlockVector(context.getPlayer().getLocation()));
if (set.size() > 0) {
region = set.iterator().next();
} else {
region = getWorldGuard().getRegionManager(w).getRegion(GLOBAL_REGION);
region = container.get(BukkitAdapter.adapt(w)).getRegion(GLOBAL_REGION);
}
} else {
int rpc = params.getArgumentCount() > 1 ? 1 : 0;
RegionManager mgr = getWorldGuard().getRegionManager(w);
RegionManager mgr = container.get(BukkitAdapter.adapt(w));
region = mgr.getRegion(params.getArgument(rpc));
if (region == null && params.getArgument(rpc).equalsIgnoreCase(GLOBAL_REGION)) {
region = new GlobalProtectedRegion(params.getArgument(rpc));

View file

@ -17,14 +17,16 @@
*/
package de.jaschastarke.minecraft.limitedcreative.regions.worldguard;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import de.jaschastarke.minecraft.limitedcreative.ModRegions;
import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration;
import de.jaschastarke.utils.StringUtil;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
@ -32,15 +34,9 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.bukkit.BukkitUtil;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import de.jaschastarke.minecraft.limitedcreative.ModRegions;
import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration;
import de.jaschastarke.utils.StringUtil;
import java.io.File;
import java.io.IOException;
import java.util.*;
public class CustomRegionManager {
protected YamlConfiguration c;
@ -161,12 +157,13 @@ public class CustomRegionManager {
}
public RegionManager getWGManager(World world) {
return getWorldGuard().getRegionManager(world);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
return container.get(BukkitAdapter.adapt(world));
}
public String getRegionsHash(Location loc) {
StringBuilder hash = new StringBuilder(loc.getWorld().getName());
List<String> idlist = getWGManager(loc.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(loc));
List<String> idlist = getWGManager(loc.getWorld()).getApplicableRegionsIDs(BukkitAdapter.asBlockVector(loc));
if (idlist.size() > 0) {
hash.append("#");
String[] ids = idlist.toArray(new String[idlist.size()]);
@ -179,7 +176,7 @@ public class CustomRegionManager {
}
public ApplicableRegions getRegionSet(Location loc) {
return new ApplicableRegions(getWGManager(loc.getWorld()).getApplicableRegions(loc), this.world(loc.getWorld()));
return new ApplicableRegions(getWGManager(loc.getWorld()).getApplicableRegions(BukkitAdapter.asBlockVector(loc)), this.world(loc.getWorld()));
}
public ApplicableRegions getRegionSet(Block block) {