Merge remote-tracking branch 'upstream/master' into merge

This commit is contained in:
Jesse Boyd 2019-11-19 21:25:36 +00:00
parent 2c9f192baf
commit 5d8adbc10c
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
10 changed files with 54 additions and 61 deletions

View File

@ -26,9 +26,9 @@ configurations.all {
resolutionStrategy { resolutionStrategy {
// Fabric needs this. // Fabric needs this.
force( force(
"commons-io:commons-io:2.5", "commons-io:commons-io:2.5",
"org.ow2.asm:asm:7.1", "org.ow2.asm:asm:7.1",
"org.ow2.asm:asm-commons:7.1" "org.ow2.asm:asm-commons:7.1"
) )
} }
} }
@ -53,4 +53,4 @@ dependencies {
implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143") implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143")
implementation("net.fabricmc:fabric-loom:$loomVersion") implementation("net.fabricmc:fabric-loom:$loomVersion")
implementation("net.fabricmc:sponge-mixin:$mixinVersion") implementation("net.fabricmc:sponge-mixin:$mixinVersion")
} }

View File

@ -104,6 +104,7 @@ fun Project.applyShadowConfiguration() {
exclude("GradleStart**") exclude("GradleStart**")
exclude(".cache") exclude(".cache")
exclude("LICENSE*") exclude("LICENSE*")
exclude("META-INF/maven/**")
minimize() minimize()
} }
} }

View File

@ -7,3 +7,7 @@ org.gradle.daemon=true
org.gradle.configureondemand=true org.gradle.configureondemand=true
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.caching=true org.gradle.caching=true
loom.version=0.2.5-20190906.190953-30
mixin.version=0.7.11.38

View File

@ -82,11 +82,13 @@ tasks.named<ShadowJar>("shadowJar") {
dependencies { dependencies {
relocate("org.slf4j", "com.sk89q.worldedit.slf4j") relocate("org.slf4j", "com.sk89q.worldedit.slf4j")
relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge") relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge")
relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4")
include(dependency(":worldedit-core")) include(dependency(":worldedit-core"))
include(dependency(":worldedit-libs:core")) include(dependency(":worldedit-libs:core"))
include(dependency(":worldedit-libs:bukkit")) include(dependency(":worldedit-libs:bukkit"))
include(dependency("org.slf4j:slf4j-api")) include(dependency("org.slf4j:slf4j-api"))
include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) include(dependency("org.apache.logging.log4j:log4j-slf4j-impl"))
include(dependency("org.antlr:antlr4-runtime"))
relocate("org.bstats", "com.sk89q.worldedit.bukkit.bstats") { relocate("org.bstats", "com.sk89q.worldedit.bukkit.bstats") {
include(dependency("org.bstats:bstats-bukkit:1.5")) include(dependency("org.bstats:bstats-bukkit:1.5"))
} }

View File

@ -104,16 +104,16 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public BaseItemStack getItemInHand(HandSide handSide) { public BaseItemStack getItemInHand(HandSide handSide) {
ItemStack itemStack = handSide == HandSide.MAIN_HAND ItemStack itemStack = handSide == HandSide.MAIN_HAND
? getPlayer().getInventory().getItemInMainHand() ? player.getInventory().getItemInMainHand()
: getPlayer().getInventory().getItemInOffHand(); : player.getInventory().getItemInOffHand();
return BukkitAdapter.adapt(itemStack); return BukkitAdapter.adapt(itemStack);
} }
@Override @Override
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
ItemStack itemStack = handSide == HandSide.MAIN_HAND ItemStack itemStack = handSide == HandSide.MAIN_HAND
? getPlayer().getInventory().getItemInMainHand() ? player.getInventory().getItemInMainHand()
: getPlayer().getInventory().getItemInOffHand(); : player.getInventory().getItemInOffHand();
return BukkitAdapter.asBlockState(itemStack).toBaseBlock(); return BukkitAdapter.asBlockState(itemStack).toBaseBlock();
} }
@ -124,18 +124,18 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public String getDisplayName() { public String getDisplayName() {
return getPlayer().getDisplayName(); return player.getDisplayName();
} }
@Override @Override
public void giveItem(BaseItemStack itemStack) { public void giveItem(BaseItemStack itemStack) {
final PlayerInventory inv = getPlayer().getInventory(); final PlayerInventory inv = player.getInventory();
ItemStack newItem = BukkitAdapter.adapt(itemStack); ItemStack newItem = BukkitAdapter.adapt(itemStack);
if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) { if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
inv.remove(newItem); inv.remove(newItem);
} }
final ItemStack item = getPlayer().getInventory().getItemInMainHand(); final ItemStack item = player.getInventory().getItemInMainHand();
getPlayer().getInventory().setItemInMainHand(newItem); player.getInventory().setItemInMainHand(newItem);
HashMap<Integer, ItemStack> overflow = inv.addItem(item); HashMap<Integer, ItemStack> overflow = inv.addItem(item);
if (!overflow.isEmpty()) { if (!overflow.isEmpty()) {
TaskManager.IMP.sync(new RunnableVal<Object>() { TaskManager.IMP.sync(new RunnableVal<Object>() {
@ -145,7 +145,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
ItemStack stack = entry.getValue(); ItemStack stack = entry.getValue();
if (stack.getType() != Material.AIR && stack.getAmount() > 0) { if (stack.getType() != Material.AIR && stack.getAmount() > 0) {
Item Item
dropped = getPlayer().getWorld().dropItem(getPlayer().getLocation(), stack); dropped = player.getWorld().dropItem(player.getLocation(), stack);
PlayerDropItemEvent event = new PlayerDropItemEvent(player, dropped); PlayerDropItemEvent event = new PlayerDropItemEvent(player, dropped);
if (event.isCancelled()) { if (event.isCancelled()) {
dropped.remove(); dropped.remove();
@ -155,45 +155,45 @@ public class BukkitPlayer extends AbstractPlayerActor {
} }
}); });
} }
getPlayer().updateInventory(); player.updateInventory();
} }
@Override @Override
public void printRaw(String msg) { public void printRaw(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
getPlayer().sendMessage(part); player.sendMessage(part);
} }
} }
@Override @Override
public void print(String msg) { public void print(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
getPlayer().sendMessage("\u00A7d" + part); player.sendMessage("\u00A7d" + part);
} }
} }
@Override @Override
public void printDebug(String msg) { public void printDebug(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
getPlayer().sendMessage("\u00A77" + part); player.sendMessage("\u00A77" + part);
} }
} }
@Override @Override
public void printError(String msg) { public void printError(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
getPlayer().sendMessage("§c" + part); player.sendMessage("§c" + part);
} }
} }
@Override @Override
public void print(Component component) { public void print(Component component) {
TextAdapter.sendComponent(getPlayer(), WorldEditText.format(component)); TextAdapter.sendComponent(player, WorldEditText.format(component));
} }
@Override @Override
public void setPosition(Vector3 pos, float pitch, float yaw) { 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) { if (pos instanceof com.sk89q.worldedit.util.Location) {
com.sk89q.worldedit.util.Location loc = (com.sk89q.worldedit.util.Location) pos; com.sk89q.worldedit.util.Location loc = (com.sk89q.worldedit.util.Location) pos;
Extent extent = loc.getExtent(); Extent extent = loc.getExtent();
@ -201,17 +201,17 @@ public class BukkitPlayer extends AbstractPlayerActor {
world = Bukkit.getWorld(((World) extent).getName()); 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 @Override
public String[] getGroups() { public String[] getGroups() {
return plugin.getPermissionsResolver().getGroups(getPlayer()); return plugin.getPermissionsResolver().getGroups(player);
} }
@Override @Override
public BlockBag getInventoryBlockBag() { public BlockBag getInventoryBlockBag() {
return new BukkitPlayerBlockBag(getPlayer()); return new BukkitPlayerBlockBag(player);
} }
@Override @Override
@ -232,10 +232,10 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override public boolean togglePermission(String permission) { @Override public boolean togglePermission(String permission) {
if (this.hasPermission(permission)) { if (this.hasPermission(permission)) {
getPlayer().addAttachment(plugin).setPermission(permission, false); player.addAttachment(plugin).setPermission(permission, false);
return false; return false;
} else { } else {
getPlayer().addAttachment(plugin).setPermission(permission, true); player.addAttachment(plugin).setPermission(permission, true);
return true; return true;
} }
} }
@ -257,19 +257,19 @@ public class BukkitPlayer extends AbstractPlayerActor {
* - The `/wea` command will give/remove the required bypass permission * - The `/wea` command will give/remove the required bypass permission
*/ */
if (Fawe.<FaweBukkit>imp().getVault() == null || Fawe.<FaweBukkit> imp().getVault().permission == null) { if (Fawe.<FaweBukkit>imp().getVault() == null || Fawe.<FaweBukkit> imp().getVault().permission == null) {
getPlayer().addAttachment(Fawe.<FaweBukkit> imp().getPlugin()).setPermission(permission, value); player.addAttachment(Fawe.<FaweBukkit> imp().getPlugin()).setPermission(permission, value);
} else if (value) { } else if (value) {
if (!Fawe.<FaweBukkit> imp().getVault().permission.playerAdd(player, permission)) { if (!Fawe.<FaweBukkit> imp().getVault().permission.playerAdd(player, permission)) {
getPlayer().addAttachment(Fawe.<FaweBukkit> imp().getPlugin()).setPermission(permission, value); player.addAttachment(Fawe.<FaweBukkit> imp().getPlugin()).setPermission(permission, value);
} }
} else if (!Fawe.<FaweBukkit>imp().getVault().permission.playerRemove(player, permission)) { } else if (!Fawe.<FaweBukkit>imp().getVault().permission.playerRemove(player, permission)) {
getPlayer().addAttachment(Fawe.<FaweBukkit>imp().getPlugin()).setPermission(permission, value); player.addAttachment(Fawe.<FaweBukkit>imp().getPlugin()).setPermission(permission, value);
} }
} }
@Override @Override
public World getWorld() { public World getWorld() {
return BukkitAdapter.adapt(getPlayer().getWorld()); return BukkitAdapter.adapt(player.getWorld());
} }
@Override @Override
@ -279,7 +279,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
if (params.length > 0) { if (params.length > 0) {
send = send + "|" + StringUtil.joinString(params, "|"); 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() { public Player getPlayer() {
@ -299,7 +299,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public com.sk89q.worldedit.util.Location getLocation() { public com.sk89q.worldedit.util.Location getLocation() {
Location nativeLocation = getPlayer().getLocation(); Location nativeLocation = player.getLocation();
Vector3 position = BukkitAdapter.asVector(nativeLocation); Vector3 position = BukkitAdapter.asVector(nativeLocation);
return new com.sk89q.worldedit.util.Location( return new com.sk89q.worldedit.util.Location(
getWorld(), getWorld(),
@ -310,7 +310,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public boolean setLocation(com.sk89q.worldedit.util.Location location) { public boolean setLocation(com.sk89q.worldedit.util.Location location) {
return getPlayer().teleport(BukkitAdapter.adapt(location)); return player.teleport(BukkitAdapter.adapt(location));
} }
@Nullable @Nullable
@ -364,11 +364,11 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) { public <B extends BlockStateHolder<B>> 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) { if (block == null) {
getPlayer().sendBlockChange(loc, getPlayer().getWorld().getBlockAt(loc).getBlockData()); player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());
} else { } else {
getPlayer().sendBlockChange(loc, BukkitAdapter.adapt(block)); player.sendBlockChange(loc, BukkitAdapter.adapt(block));
if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) { if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) { if (adapter != null) {
@ -383,13 +383,13 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public void sendTitle(String title, String sub) { 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() + " subtitle [{\"text\":\"" + sub + "\",\"color\":\"gold\"}]");
Bukkit.getServer().dispatchCommand(player, "title " + getName() + " title [{\"text\":\"" + title + "\",\"color\":\"gold\"}]"); Bukkit.getServer().dispatchCommand(player, "title " + getName() + " title [{\"text\":\"" + title + "\",\"color\":\"gold\"}]");
} }
@Override @Override
public void unregister() { public void unregister() {
getPlayer().removeMetadata("WE", WorldEditPlugin.getInstance()); player.removeMetadata("WE", WorldEditPlugin.getInstance());
} }
} }

View File

@ -330,12 +330,6 @@ public class BukkitWorld extends AbstractWorld {
@Override @Override
public void checkLoadedChunk(BlockVector3 pt) { public void checkLoadedChunk(BlockVector3 pt) {
World world = getWorld(); 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)) { if (!world.isChunkLoaded(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)) {
int X = pt.getBlockX() >> 4; int X = pt.getBlockX() >> 4;
int Z = pt.getBlockZ() >> 4; int Z = pt.getBlockZ() >> 4;

View File

@ -347,7 +347,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
// code of WorldEdit expects it // code of WorldEdit expects it
String[] split = new String[args.length + 1]; String[] split = new String[args.length + 1];
System.arraycopy(args, 0, split, 1, args.length); System.arraycopy(args, 0, split, 1, args.length);
split[0] = "/" + commandLabel; split[0] = commandLabel;
String arguments = Joiner.on(" ").join(split); String arguments = Joiner.on(" ").join(split);
CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments); CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments);
@ -485,22 +485,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
return true; return true;
} }
/*
@Override
public List<String> 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. * Gets the session for the player.
* *

View File

@ -1,9 +1,11 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.plugins.ide.idea.model.IdeaModel
plugins { plugins {
id("java-library") id("java-library")
id("net.ltgt.apt-eclipse") id("net.ltgt.apt-eclipse")
id("net.ltgt.apt-idea") id("net.ltgt.apt-idea")
id("antlr")
} }
repositories { repositories {
@ -28,6 +30,11 @@ dependencies {
"compile"("com.google.code.gson:gson:2.8.0") "compile"("com.google.code.gson:gson:2.8.0")
"compile"("org.slf4j:slf4j-api:1.7.26") "compile"("org.slf4j:slf4j-api:1.7.26")
"compile"("it.unimi.dsi:fastutil:8.2.1") "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 } "compile"("com.googlecode.json-simple:json-simple:1.3.9") { isTransitive = false }
"compileOnly"(project(":worldedit-libs:core:ap")) "compileOnly"(project(":worldedit-libs:core:ap"))
"annotationProcessor"(project(":worldedit-libs:core:ap")) "annotationProcessor"(project(":worldedit-libs:core:ap"))

View File

@ -145,7 +145,7 @@ public class ToolCommands {
public void selwand(Player player, LocalSession session) throws WorldEditException { public void selwand(Player player, LocalSession session) throws WorldEditException {
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType(); 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() + "."); player.print("Selection wand bound to " + itemType.getName() + ".");
} }

View File

@ -70,6 +70,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;