diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 1d3389b09..9ea58be60 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -26,9 +26,9 @@ configurations.all { resolutionStrategy { // Fabric needs this. force( - "commons-io:commons-io:2.5", - "org.ow2.asm:asm:7.1", - "org.ow2.asm:asm-commons:7.1" + "commons-io:commons-io:2.5", + "org.ow2.asm:asm:7.1", + "org.ow2.asm:asm-commons:7.1" ) } } @@ -53,4 +53,4 @@ dependencies { implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143") implementation("net.fabricmc:fabric-loom:$loomVersion") implementation("net.fabricmc:sponge-mixin:$mixinVersion") -} +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index 02459931e..f7a39851a 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -104,6 +104,7 @@ fun Project.applyShadowConfiguration() { exclude("GradleStart**") exclude(".cache") exclude("LICENSE*") + exclude("META-INF/maven/**") minimize() } } diff --git a/gradle.properties b/gradle.properties index 15c5a2370..71ec96729 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,3 +7,7 @@ org.gradle.daemon=true org.gradle.configureondemand=true org.gradle.parallel=true org.gradle.caching=true + + +loom.version=0.2.5-20190906.190953-30 +mixin.version=0.7.11.38 \ No newline at end of file diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 2fdabbcca..09b6db88c 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -82,11 +82,13 @@ tasks.named("shadowJar") { dependencies { relocate("org.slf4j", "com.sk89q.worldedit.slf4j") relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge") + relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4") include(dependency(":worldedit-core")) include(dependency(":worldedit-libs:core")) include(dependency(":worldedit-libs:bukkit")) include(dependency("org.slf4j:slf4j-api")) include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) + include(dependency("org.antlr:antlr4-runtime")) relocate("org.bstats", "com.sk89q.worldedit.bukkit.bstats") { include(dependency("org.bstats:bstats-bukkit:1.5")) } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 0cd61ca33..8cd06e0ca 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -104,16 +104,16 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public BaseItemStack getItemInHand(HandSide handSide) { ItemStack itemStack = handSide == HandSide.MAIN_HAND - ? getPlayer().getInventory().getItemInMainHand() - : getPlayer().getInventory().getItemInOffHand(); + ? player.getInventory().getItemInMainHand() + : player.getInventory().getItemInOffHand(); return BukkitAdapter.adapt(itemStack); } @Override public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { ItemStack itemStack = handSide == HandSide.MAIN_HAND - ? getPlayer().getInventory().getItemInMainHand() - : getPlayer().getInventory().getItemInOffHand(); + ? player.getInventory().getItemInMainHand() + : player.getInventory().getItemInOffHand(); return BukkitAdapter.asBlockState(itemStack).toBaseBlock(); } @@ -124,18 +124,18 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public String getDisplayName() { - return getPlayer().getDisplayName(); + return player.getDisplayName(); } @Override public void giveItem(BaseItemStack itemStack) { - final PlayerInventory inv = getPlayer().getInventory(); + final PlayerInventory inv = player.getInventory(); ItemStack newItem = BukkitAdapter.adapt(itemStack); if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) { inv.remove(newItem); } - final ItemStack item = getPlayer().getInventory().getItemInMainHand(); - getPlayer().getInventory().setItemInMainHand(newItem); + final ItemStack item = player.getInventory().getItemInMainHand(); + player.getInventory().setItemInMainHand(newItem); HashMap overflow = inv.addItem(item); if (!overflow.isEmpty()) { TaskManager.IMP.sync(new RunnableVal() { @@ -145,7 +145,7 @@ public class BukkitPlayer extends AbstractPlayerActor { ItemStack stack = entry.getValue(); if (stack.getType() != Material.AIR && stack.getAmount() > 0) { Item - dropped = getPlayer().getWorld().dropItem(getPlayer().getLocation(), stack); + dropped = player.getWorld().dropItem(player.getLocation(), stack); PlayerDropItemEvent event = new PlayerDropItemEvent(player, dropped); if (event.isCancelled()) { dropped.remove(); @@ -155,45 +155,45 @@ public class BukkitPlayer extends AbstractPlayerActor { } }); } - getPlayer().updateInventory(); + player.updateInventory(); } @Override public void printRaw(String msg) { for (String part : msg.split("\n")) { - getPlayer().sendMessage(part); + player.sendMessage(part); } } @Override public void print(String msg) { for (String part : msg.split("\n")) { - getPlayer().sendMessage("\u00A7d" + part); + player.sendMessage("\u00A7d" + part); } } @Override public void printDebug(String msg) { for (String part : msg.split("\n")) { - getPlayer().sendMessage("\u00A77" + part); + player.sendMessage("\u00A77" + part); } } @Override public void printError(String msg) { for (String part : msg.split("\n")) { - getPlayer().sendMessage("§c" + part); + player.sendMessage("§c" + part); } } @Override public void print(Component component) { - TextAdapter.sendComponent(getPlayer(), WorldEditText.format(component)); + TextAdapter.sendComponent(player, WorldEditText.format(component)); } @Override public void setPosition(Vector3 pos, float pitch, float yaw) { - org.bukkit.World world = getPlayer().getWorld(); + org.bukkit.World world = player.getWorld(); if (pos instanceof com.sk89q.worldedit.util.Location) { com.sk89q.worldedit.util.Location loc = (com.sk89q.worldedit.util.Location) pos; Extent extent = loc.getExtent(); @@ -201,17 +201,17 @@ public class BukkitPlayer extends AbstractPlayerActor { world = Bukkit.getWorld(((World) extent).getName()); } } - getPlayer().teleport(new Location(world, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch)); + player.teleport(new Location(world, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch)); } @Override public String[] getGroups() { - return plugin.getPermissionsResolver().getGroups(getPlayer()); + return plugin.getPermissionsResolver().getGroups(player); } @Override public BlockBag getInventoryBlockBag() { - return new BukkitPlayerBlockBag(getPlayer()); + return new BukkitPlayerBlockBag(player); } @Override @@ -232,10 +232,10 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public boolean togglePermission(String permission) { if (this.hasPermission(permission)) { - getPlayer().addAttachment(plugin).setPermission(permission, false); + player.addAttachment(plugin).setPermission(permission, false); return false; } else { - getPlayer().addAttachment(plugin).setPermission(permission, true); + player.addAttachment(plugin).setPermission(permission, true); return true; } } @@ -257,19 +257,19 @@ public class BukkitPlayer extends AbstractPlayerActor { * - The `/wea` command will give/remove the required bypass permission */ if (Fawe.imp().getVault() == null || Fawe. imp().getVault().permission == null) { - getPlayer().addAttachment(Fawe. imp().getPlugin()).setPermission(permission, value); + player.addAttachment(Fawe. imp().getPlugin()).setPermission(permission, value); } else if (value) { if (!Fawe. imp().getVault().permission.playerAdd(player, permission)) { - getPlayer().addAttachment(Fawe. imp().getPlugin()).setPermission(permission, value); + player.addAttachment(Fawe. imp().getPlugin()).setPermission(permission, value); } } else if (!Fawe.imp().getVault().permission.playerRemove(player, permission)) { - getPlayer().addAttachment(Fawe.imp().getPlugin()).setPermission(permission, value); + player.addAttachment(Fawe.imp().getPlugin()).setPermission(permission, value); } } @Override public World getWorld() { - return BukkitAdapter.adapt(getPlayer().getWorld()); + return BukkitAdapter.adapt(player.getWorld()); } @Override @@ -279,7 +279,7 @@ public class BukkitPlayer extends AbstractPlayerActor { if (params.length > 0) { send = send + "|" + StringUtil.joinString(params, "|"); } - getPlayer().sendPluginMessage(plugin, WorldEditPlugin.CUI_PLUGIN_CHANNEL, send.getBytes(CUIChannelListener.UTF_8_CHARSET)); + player.sendPluginMessage(plugin, WorldEditPlugin.CUI_PLUGIN_CHANNEL, send.getBytes(CUIChannelListener.UTF_8_CHARSET)); } public Player getPlayer() { @@ -299,7 +299,7 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public com.sk89q.worldedit.util.Location getLocation() { - Location nativeLocation = getPlayer().getLocation(); + Location nativeLocation = player.getLocation(); Vector3 position = BukkitAdapter.asVector(nativeLocation); return new com.sk89q.worldedit.util.Location( getWorld(), @@ -310,7 +310,7 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public boolean setLocation(com.sk89q.worldedit.util.Location location) { - return getPlayer().teleport(BukkitAdapter.adapt(location)); + return player.teleport(BukkitAdapter.adapt(location)); } @Nullable @@ -364,11 +364,11 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public > void sendFakeBlock(BlockVector3 pos, B block) { - Location loc = new Location(getPlayer().getWorld(), pos.getX(), pos.getY(), pos.getZ()); + Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()); if (block == null) { - getPlayer().sendBlockChange(loc, getPlayer().getWorld().getBlockAt(loc).getBlockData()); + player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData()); } else { - getPlayer().sendBlockChange(loc, BukkitAdapter.adapt(block)); + player.sendBlockChange(loc, BukkitAdapter.adapt(block)); if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { @@ -383,13 +383,13 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public void sendTitle(String title, String sub) { - getPlayer().sendTitle(ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20); + player.sendTitle(ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20); Bukkit.getServer().dispatchCommand(player, "title " + getName() + " subtitle [{\"text\":\"" + sub + "\",\"color\":\"gold\"}]"); Bukkit.getServer().dispatchCommand(player, "title " + getName() + " title [{\"text\":\"" + title + "\",\"color\":\"gold\"}]"); } @Override public void unregister() { - getPlayer().removeMetadata("WE", WorldEditPlugin.getInstance()); + player.removeMetadata("WE", WorldEditPlugin.getInstance()); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index eac42c71c..5ba9d3789 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -330,12 +330,6 @@ public class BukkitWorld extends AbstractWorld { @Override public void checkLoadedChunk(BlockVector3 pt) { World world = getWorld(); - - world.getChunkAt(pt.getBlockX() >> 4, pt.getBlockZ() >> 4); - - if (!world.isChunkLoaded(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)) { - world.loadChunk(pt.getBlockX() >> 4, pt.getBlockZ() >> 4); - } if (!world.isChunkLoaded(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)) { int X = pt.getBlockX() >> 4; int Z = pt.getBlockZ() >> 4; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 572a7fe4a..1b4ab8472 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -347,7 +347,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // code of WorldEdit expects it String[] split = new String[args.length + 1]; System.arraycopy(args, 0, split, 1, args.length); - split[0] = "/" + commandLabel; + split[0] = commandLabel; String arguments = Joiner.on(" ").join(split); CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments); @@ -485,22 +485,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter return true; } -/* - @Override - public List onTabComplete(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] = "/" + commandLabel; - - String arguments = Joiner.on(" ").join(split); - CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments); - getWorldEdit().getEventBus().post(event); - return CommandUtil.fixSuggestions(arguments, event.getSuggestions()); - } -*/ - /** * Gets the session for the player. * diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index f134bf1f0..e4f65dd27 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -1,9 +1,11 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.gradle.plugins.ide.idea.model.IdeaModel plugins { id("java-library") id("net.ltgt.apt-eclipse") id("net.ltgt.apt-idea") + id("antlr") } repositories { @@ -28,6 +30,11 @@ dependencies { "compile"("com.google.code.gson:gson:2.8.0") "compile"("org.slf4j:slf4j-api:1.7.26") "compile"("it.unimi.dsi:fastutil:8.2.1") + + val antlrVersion = "4.7.2" + "antlr"("org.antlr:antlr4:$antlrVersion") + "implementation"("org.antlr:antlr4-runtime:$antlrVersion") + "compile"("com.googlecode.json-simple:json-simple:1.3.9") { isTransitive = false } "compileOnly"(project(":worldedit-libs:core:ap")) "annotationProcessor"(project(":worldedit-libs:core:ap")) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index b6e452d24..961982248 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -145,7 +145,7 @@ public class ToolCommands { public void selwand(Player player, LocalSession session) throws WorldEditException { final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType(); - session.setTool(itemType, new SelectionWand()); + session.setTool(itemType, SelectionWand.INSTANCE); player.print("Selection wand bound to " + itemType.getName() + "."); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index f29f2be08..86b7a6b43 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -70,6 +70,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockType;