mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Merge from upstream
This commit is contained in:
@ -1,21 +1,33 @@
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'java-library'
|
||||
|
||||
repositories {
|
||||
maven { url "https://hub.spigotmc.org/nexus/content/groups/public" }
|
||||
maven { url "https://repo.codemc.org/repository/maven-public" }
|
||||
maven { url 'https://papermc.io/repo/repository/maven-public/' }
|
||||
maven { url "https://papermc.io/repo/repository/maven-public/" }
|
||||
flatDir {
|
||||
dirs 'lib'
|
||||
}
|
||||
}
|
||||
|
||||
configurations.all { Configuration it ->
|
||||
it.resolutionStrategy { ResolutionStrategy rs ->
|
||||
rs.force("com.google.guava:guava:21.0")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':worldedit-core')
|
||||
compile 'org.bukkit:craftbukkit-1.14:pre5'
|
||||
api project(':worldedit-core')
|
||||
api project(':worldedit-libs:bukkit')
|
||||
compile 'net.milkbowl.vault:VaultAPI:1.7'
|
||||
compile 'com.sk89q:dummypermscompat:1.10'
|
||||
compile 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT'
|
||||
compile 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT'
|
||||
compile 'org.slf4j:slf4j-jdk14:1.7.26'
|
||||
compile 'com.destroystokyo.paper:paper-api:1.14.3-R0.1-SNAPSHOT'
|
||||
implementation 'io.papermc:paperlib:1.0.2'
|
||||
compileOnly 'com.sk89q:dummypermscompat:1.10'
|
||||
// compile 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT'
|
||||
compile name: 'spigot-1.14.3'
|
||||
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.8.1'
|
||||
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
||||
compile 'com.massivecraft:factions:2.8.0'
|
||||
compile 'com.drtshock:factions:1.6.9.5'
|
||||
@ -81,9 +93,13 @@ task copyFiles {
|
||||
shadowJar {
|
||||
dependencies {
|
||||
relocate "org.slf4j", "com.sk89q.worldedit.slf4j"
|
||||
relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge"
|
||||
include(dependency(':worldedit-core'))
|
||||
include(dependency('org.slf4j:slf4j-api'))
|
||||
include(dependency("org.slf4j:slf4j-jdk14"))
|
||||
include(dependency("org.apache.logging.log4j:log4j-slf4j-impl"))
|
||||
relocate ("io.papermc.lib", "com.sk89q.worldedit.bukkit.paperlib") {
|
||||
include(dependency("io.papermc:paperlib:1.0.2"))
|
||||
}
|
||||
}
|
||||
archiveName = "${parent.name}-${project.name.replaceAll("worldedit-", "")}-${parent.version}.jar"
|
||||
destinationDir = file '../target'
|
||||
|
@ -7,6 +7,7 @@ import com.boydti.fawe.object.FawePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BukkitCommand implements CommandExecutor {
|
||||
|
||||
@ -17,7 +18,7 @@ public class BukkitCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
public boolean onCommand(@NotNull final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
final FawePlayer plr = Fawe.imp().wrap(sender);
|
||||
if (!sender.hasPermission(this.cmd.getPerm()) && !sender.isOp()) {
|
||||
BBC.NO_PERM.send(plr, this.cmd.getPerm());
|
||||
|
@ -2,20 +2,15 @@ package com.boydti.fawe.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FaweLocation;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.wrappers.PlayerWrapper;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitPlayer extends FawePlayer<Player> {
|
||||
|
||||
private static ConsoleCommandSender console;
|
||||
@ -66,21 +61,11 @@ public class BukkitPlayer extends FawePlayer<Player> {
|
||||
|
||||
@Override
|
||||
public void resetTitle() {
|
||||
sendTitle("","");
|
||||
parent.resetTitle();
|
||||
}
|
||||
|
||||
public void sendTitle(String title, String sub) {
|
||||
try {
|
||||
Method methodSendTitle = Player.class.getDeclaredMethod("sendTitle", String.class, String.class, int.class, int.class, int.class);
|
||||
methodSendTitle.invoke(parent, ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20);
|
||||
return;
|
||||
} catch (Throwable ignore) {
|
||||
try {
|
||||
Method methodSendTitle = Player.class.getDeclaredMethod("sendTitle", String.class, String.class);
|
||||
methodSendTitle.invoke(parent, ChatColor.GOLD + title, ChatColor.GOLD + sub);
|
||||
return;
|
||||
} catch (Throwable ignore2) {}
|
||||
}
|
||||
parent.sendTitle(ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20);
|
||||
if (console == null) {
|
||||
console = Bukkit.getConsoleSender();
|
||||
Bukkit.getServer().dispatchCommand(console, "gamerule sendCommandFeedback false");
|
||||
@ -95,15 +80,13 @@ public class BukkitPlayer extends FawePlayer<Player> {
|
||||
this.parent.sendMessage(BBC.color(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(final String cmd) {
|
||||
Bukkit.getServer().dispatchCommand(this.parent, cmd);
|
||||
@Override public void printError(String msg) {
|
||||
this.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweLocation getLocation() {
|
||||
final Location loc = this.parent.getLocation();
|
||||
return new FaweLocation(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
public void executeCommand(final String cmd) {
|
||||
Bukkit.getServer().dispatchCommand(this.parent, cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +61,6 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FaweBukkit implements IFawe, Listener {
|
||||
@ -73,9 +72,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
|
||||
private boolean listeningImages;
|
||||
private BukkitImageListener imageListener;
|
||||
private CFIPacketListener packetListener;
|
||||
|
||||
private boolean listeningCui;
|
||||
//private CFIPacketListener packetListener;
|
||||
|
||||
public VaultUtil getVault() {
|
||||
return this.vault;
|
||||
@ -106,11 +103,11 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
try {
|
||||
Fawe.get().setChatManager(new BukkitChatManager());
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
Bukkit.getServer().shutdown();
|
||||
}
|
||||
|
||||
@ -131,29 +128,34 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent");
|
||||
Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent");
|
||||
Bukkit.getPluginManager().registerEvents(new AsyncTabCompleteListener(WorldEditPlugin.getInstance()), plugin);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
debug("====== USE PAPER ======");
|
||||
debug("DOWNLOAD: https://papermc.io/ci/job/Paper-1.13/");
|
||||
debug("GUIDE: https://www.spigotmc.org/threads/21726/");
|
||||
debug(" - This is only a recommendation");
|
||||
debug(" - Allows the use of Async Tab Completetion as provided by Paper");
|
||||
debug("==============================");
|
||||
Bukkit.getPluginManager().registerEvents(new SyncTabCompleteListener(WorldEditPlugin.getInstance()), plugin);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPacketListener() {
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
if (packetListener == null && manager.getPlugin("ProtocolLib") != null) {
|
||||
packetListener = new CFIPacketListener(plugin);
|
||||
}
|
||||
}
|
||||
// @Override // Please don't delete this again, it's WIP
|
||||
// public void registerPacketListener() {
|
||||
// PluginManager manager = Bukkit.getPluginManager();
|
||||
// if (packetListener == null && manager.getPlugin("ProtocolLib") != null) {
|
||||
// packetListener = new CFIPacketListener(plugin);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public synchronized ImageViewer getImageViewer(FawePlayer fp) {
|
||||
if (listeningImages && imageListener == null) return null;
|
||||
try {
|
||||
listeningImages = true;
|
||||
registerPacketListener();
|
||||
//registerPacketListener();
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
|
||||
if (manager.getPlugin("PacketListenerApi") == null) {
|
||||
@ -197,13 +199,9 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(final String s) {
|
||||
public void debug(final String message) {
|
||||
ConsoleCommandSender console = Bukkit.getConsoleSender();
|
||||
if (console != null) {
|
||||
console.sendMessage(BBC.color(s));
|
||||
} else {
|
||||
Bukkit.getLogger().info(BBC.color(s));
|
||||
}
|
||||
console.sendMessage(BBC.color(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -239,7 +237,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
Player player = (Player) obj;
|
||||
FawePlayer existing = Fawe.get().getCachedPlayer(player.getName());
|
||||
return existing != null ? existing : new BukkitPlayer(player);
|
||||
} else if (obj != null && obj.getClass().getName().contains("EntityPlayer")) {
|
||||
} else if (obj.getClass().getName().contains("EntityPlayer")) {
|
||||
try {
|
||||
Method method = obj.getClass().getDeclaredMethod("getBukkitEntity");
|
||||
return wrap(method.invoke(obj));
|
||||
@ -280,14 +278,13 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
try {
|
||||
this.vault = new VaultUtil();
|
||||
} catch (final Throwable e) {
|
||||
this.debug(BBC.getPrefix() + "&dVault is used for persistent `/wea` toggles.");
|
||||
this.debug("&dVault is used for persistent `/wea` toggles.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDebugInfo() {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
List<String> pl = new ArrayList<>();
|
||||
msg.append("server.version: " + Bukkit.getVersion() + "\n");
|
||||
msg.append("Plugins: \n");
|
||||
for (Plugin p : Bukkit.getPluginManager().getPlugins()) {
|
||||
@ -323,7 +320,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
try {
|
||||
return getQueue(world);
|
||||
} catch (Throwable ignore) {
|
||||
} catch (Throwable throwable) {
|
||||
// Disable incompatible settings
|
||||
Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
|
||||
Settings.IMP.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI
|
||||
@ -338,7 +335,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
debug("Download the version of FAWE for your platform");
|
||||
debug(" - http://ci.athion.net/job/FastAsyncWorldEdit/lastSuccessfulBuild/artifact/target");
|
||||
debug("=======================================");
|
||||
ignore.printStackTrace();
|
||||
throwable.printStackTrace();
|
||||
debug("=======================================");
|
||||
TaskManager.IMP.laterAsync(
|
||||
() -> MainUtil.sendAdmin("&cNo NMS placer found, see console!"), 1);
|
||||
@ -371,11 +368,11 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
}
|
||||
Throwable error = null;
|
||||
Throwable error;
|
||||
try {
|
||||
return getQueue(world);
|
||||
} catch (Throwable ignore) {
|
||||
error = ignore;
|
||||
} catch (Throwable throwable) {
|
||||
error = throwable;
|
||||
}
|
||||
// Disable incompatible settings
|
||||
Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
|
||||
@ -422,7 +419,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
managers.add(new WorldguardFlag(worldguardPlugin, this));
|
||||
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
|
||||
@ -431,13 +428,13 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
managers.add(new TownyFeature(townyPlugin, this));
|
||||
Fawe.debug("Plugin 'Towny' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
final Plugin factionsPlugin = Bukkit.getServer().getPluginManager().getPlugin("Factions");
|
||||
if ((factionsPlugin != null) && factionsPlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new FactionsFeature(factionsPlugin, this));
|
||||
managers.add(new FactionsFeature(factionsPlugin));
|
||||
Fawe.debug("Plugin 'Factions' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
try {
|
||||
@ -445,10 +442,10 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
Fawe.debug("Plugin 'FactionsUUID' found. Using it now.");
|
||||
} catch (Throwable e2) {
|
||||
try {
|
||||
managers.add(new FactionsOneFeature(factionsPlugin, this));
|
||||
managers.add(new FactionsOneFeature(factionsPlugin));
|
||||
Fawe.debug("Plugin 'FactionsUUID' found. Using it now.");
|
||||
} catch (Throwable e3) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
@ -460,16 +457,16 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
managers.add(new ResidenceFeature(residencePlugin, this));
|
||||
Fawe.debug("Plugin 'Residence' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
|
||||
if ((griefpreventionPlugin != null) && griefpreventionPlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new GriefPreventionFeature(griefpreventionPlugin, this));
|
||||
managers.add(new GriefPreventionFeature(griefpreventionPlugin));
|
||||
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
|
||||
@ -478,7 +475,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
|
||||
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -486,10 +483,10 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
final Plugin aSkyBlock = Bukkit.getServer().getPluginManager().getPlugin("ASkyBlock");
|
||||
if ((aSkyBlock != null) && aSkyBlock.isEnabled()) {
|
||||
try {
|
||||
managers.add(new ASkyBlockHook(aSkyBlock, this));
|
||||
managers.add(new ASkyBlockHook(aSkyBlock));
|
||||
Fawe.debug("Plugin 'ASkyBlock' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (Settings.IMP.EXPERIMENTAL.FREEBUILD) {
|
||||
@ -497,7 +494,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
managers.add(new FreeBuildRegion());
|
||||
Fawe.debug("Plugin '<internal.freebuild>' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -571,7 +568,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
BukkitQueue_0.checkVersion(v.name());
|
||||
this.version = tmp = v;
|
||||
break;
|
||||
} catch (IllegalStateException e) {}
|
||||
} catch (IllegalStateException ignored) {}
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.boydti.fawe.bukkit.adapter.v1_13_1;
|
||||
|
||||
import com.sk89q.util.ReflectionUtil;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
|
||||
import net.minecraft.server.v1_13_R2.*;
|
||||
import net.minecraft.server.v1_13_R2.Block;
|
||||
import net.minecraft.server.v1_13_R2.EnumPistonReaction;
|
||||
import net.minecraft.server.v1_13_R2.IBlockData;
|
||||
import net.minecraft.server.v1_13_R2.ITileEntity;
|
||||
import net.minecraft.server.v1_13_R2.Material;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
|
||||
|
||||
public class BlockMaterial_1_13 implements BlockMaterial {
|
||||
@ -22,7 +24,7 @@ public class BlockMaterial_1_13 implements BlockMaterial {
|
||||
this.defaultState = defaultState;
|
||||
this.material = defaultState.getMaterial();
|
||||
this.craftBlockData = CraftBlockData.fromData(defaultState);
|
||||
this.isTranslucent = ReflectionUtil.getField(Block.class, block, "n");
|
||||
this.isTranslucent = block.f(defaultState); //isSolid
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
|
@ -20,7 +20,6 @@
|
||||
package com.boydti.fawe.bukkit.adapter.v1_13_1;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.collection.ObjObjMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
@ -33,42 +32,50 @@ import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.LazyBaseEntity;
|
||||
import com.sk89q.worldedit.internal.Constants;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.*;
|
||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||
import com.sk89q.worldedit.registry.state.EnumProperty;
|
||||
import com.sk89q.worldedit.registry.state.IntegerProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.*;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import net.minecraft.server.v1_13_R2.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements BukkitImplAdapter<NBTBase>{
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private final Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
||||
|
||||
private final Field nbtListTagListField;
|
||||
private final Method nbtCreateTagMethod;
|
||||
@ -83,6 +90,9 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
public Spigot_v1_13_R2() throws NoSuchFieldException, NoSuchMethodException {
|
||||
// A simple test
|
||||
CraftServer.class.cast(Bukkit.getServer());
|
||||
|
||||
// The list of tags on an NBTTagList
|
||||
nbtListTagListField = NBTTagList.class.getDeclaredField("list");
|
||||
nbtListTagListField.setAccessible(true);
|
||||
@ -139,6 +149,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
@Nullable
|
||||
private static String getEntityId(Entity entity) {
|
||||
MinecraftKey minecraftkey = EntityTypes.getName(entity.getBukkitEntity().getHandle().P());
|
||||
|
||||
return minecraftkey == null ? null : minecraftkey.toString();
|
||||
}
|
||||
|
||||
@ -189,11 +200,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
return IRegistry.BLOCK.getOrDefault(new MinecraftKey(blockType.getNamespace(), blockType.getResource()));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Code that is less likely to break
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public BaseBlock getBlock(Location location) {
|
||||
checkNotNull(location);
|
||||
@ -247,7 +253,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
|
||||
nmsChunk.d(pos); // Force delete the old tile entity
|
||||
|
||||
CompoundTag nativeTag = state instanceof BaseBlock ? ((BaseBlock)state).getNbtData() : null;
|
||||
CompoundTag nativeTag = state instanceof BaseBlock ? state.getNbtData() : null;
|
||||
if (nativeTag != null || existing instanceof TileEntityBlock) {
|
||||
nmsWorld.setTypeAndData(pos, blockData, 0);
|
||||
// remove tile
|
||||
@ -348,7 +354,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
if (block == null) {
|
||||
logger.warn("Failed to find properties for " + blockType.getId());
|
||||
logger.warning("Failed to find properties for " + blockType.getId());
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, Property<?>> properties = Maps.newLinkedHashMap();
|
||||
@ -414,7 +420,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
try {
|
||||
return toNativeList((NBTTagList) foreign);
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Failed to convert NBTTagList", e);
|
||||
logger.log(Level.WARNING, "Failed to convert NBTTagList", e);
|
||||
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
|
||||
}
|
||||
} else if (foreign instanceof NBTTagLong) {
|
||||
@ -440,7 +446,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
* @throws IllegalArgumentException on error
|
||||
* @throws IllegalAccessException on error
|
||||
*/
|
||||
public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
private ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
List<Tag> values = new ArrayList<>();
|
||||
int type = foreign.d();
|
||||
|
||||
@ -541,7 +547,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
@Override
|
||||
public void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -557,6 +563,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
@Override
|
||||
public void sendFakeOP(Player player) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ public final class ArrayWrapper<E> {
|
||||
*
|
||||
* @param elements The elements of the array.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public ArrayWrapper(E... elements) {
|
||||
setArray(elements);
|
||||
}
|
||||
|
@ -12,27 +12,17 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Achievement;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.Statistic.Type;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
import static com.boydti.fawe.bukkit.chat.TextualComponent.rawText;
|
||||
@ -271,162 +261,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display information about an achievement when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
*
|
||||
* @param name The name of the achievement to display, excluding the "achievement." prefix.
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage achievementTooltip(final String name) {
|
||||
onHover("show_achievement", new JsonString("achievement." + name));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display information about an achievement when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
*
|
||||
* @param which The achievement to display.
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage achievementTooltip(final Achievement which) {
|
||||
try {
|
||||
Object achievement = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement", Achievement.class).invoke(null, which);
|
||||
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Achievement"), "name").get(achievement));
|
||||
} catch (IllegalAccessException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||
return this;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display information about a parameterless statistic when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
*
|
||||
* @param which The statistic to display.
|
||||
* @return This builder instance.
|
||||
* @throws IllegalArgumentException If the statistic requires a parameter which was not supplied.
|
||||
*/
|
||||
public FancyMessage statisticTooltip(final Statistic which) {
|
||||
Type type = which.getType();
|
||||
if (type != Type.UNTYPED) {
|
||||
throw new IllegalArgumentException("That statistic requires an additional " + type + " parameter!");
|
||||
}
|
||||
try {
|
||||
Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSStatistic", Statistic.class).invoke(null, which);
|
||||
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||
} catch (IllegalAccessException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||
return this;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display information about a statistic parameter with a material when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
*
|
||||
* @param which The statistic to display.
|
||||
* @param item The sole material parameter to the statistic.
|
||||
* @return This builder instance.
|
||||
* @throws IllegalArgumentException If the statistic requires a parameter which was not supplied, or was supplied a parameter that was not required.
|
||||
*/
|
||||
public FancyMessage statisticTooltip(final Statistic which, Material item) {
|
||||
Type type = which.getType();
|
||||
if (type == Type.UNTYPED) {
|
||||
throw new IllegalArgumentException("That statistic needs no additional parameter!");
|
||||
}
|
||||
if ((type == Type.BLOCK && item.isBlock()) || type == Type.ENTITY) {
|
||||
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
||||
}
|
||||
try {
|
||||
Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getMaterialStatistic", Statistic.class, Material.class).invoke(null, which, item);
|
||||
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||
} catch (IllegalAccessException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||
return this;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display information about a statistic parameter with an entity type when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
*
|
||||
* @param which The statistic to display.
|
||||
* @param entity The sole entity type parameter to the statistic.
|
||||
* @return This builder instance.
|
||||
* @throws IllegalArgumentException If the statistic requires a parameter which was not supplied, or was supplied a parameter that was not required.
|
||||
*/
|
||||
public FancyMessage statisticTooltip(final Statistic which, EntityType entity) {
|
||||
Type type = which.getType();
|
||||
if (type == Type.UNTYPED) {
|
||||
throw new IllegalArgumentException("That statistic needs no additional parameter!");
|
||||
}
|
||||
if (type != Type.ENTITY) {
|
||||
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
||||
}
|
||||
try {
|
||||
Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getEntityStatistic", Statistic.class, EntityType.class).invoke(null, which, entity);
|
||||
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||
} catch (IllegalAccessException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||
return this;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display information about an item when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
*
|
||||
* @param itemJSON A string representing the JSON-serialized NBT data tag of an {@link ItemStack}.
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage itemTooltip(final String itemJSON) {
|
||||
onHover("show_item", new JsonString(itemJSON)); // Seems a bit hacky, considering we have a JSON object as a parameter
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display information about an item when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
*
|
||||
* @param itemStack The stack for which to display information.
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage itemTooltip(final ItemStack itemStack) {
|
||||
try {
|
||||
Object nmsItem = Reflection.getMethod(Reflection.getOBCClass("inventory.CraftItemStack"), "asNMSCopy", ItemStack.class).invoke(null, itemStack);
|
||||
return itemTooltip(Reflection.getMethod(Reflection.getNMSClass("ItemStack"), "save", Reflection.getNMSClass("NBTTagCompound")).invoke(nmsItem, Reflection.getNMSClass("NBTTagCompound").newInstance()).toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display raw text when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
@ -579,9 +413,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage translationReplacements(final FancyMessage... replacements) {
|
||||
for (FancyMessage str : replacements) {
|
||||
latest().translationReplacements.add(str);
|
||||
}
|
||||
Collections.addAll(latest().translationReplacements, replacements);
|
||||
|
||||
dirty = true;
|
||||
|
||||
@ -873,6 +705,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
/**
|
||||
* <b>Internally called method. Not for API consumption.</b>
|
||||
*/
|
||||
@NotNull
|
||||
public Iterator<MessagePart> iterator() {
|
||||
return messageParts.iterator();
|
||||
}
|
||||
|
@ -40,10 +40,6 @@ public final class Reflection {
|
||||
*/
|
||||
public synchronized static String getVersion() {
|
||||
if (_versionString == null) {
|
||||
if (Bukkit.getServer() == null) {
|
||||
// The server hasn't started, static initializer call?
|
||||
return null;
|
||||
}
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
_versionString = name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe.bukkit.chat;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@ -75,48 +74,6 @@ public abstract class TextualComponent implements Cloneable {
|
||||
throw new UnsupportedOperationException("This feature is only supported in snapshot releases.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a scoreboard value.
|
||||
* The client will see their own score for the specified objective as the text represented by this component.
|
||||
* <p>
|
||||
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b>
|
||||
* </p>
|
||||
*
|
||||
* @param scoreboardObjective The name of the objective for which to display the score.
|
||||
* @return The text component representing the specified scoreboard score (for the viewing player), or {@code null} if an error occurs during
|
||||
* JSON serialization.
|
||||
*/
|
||||
public static TextualComponent objectiveScore(String scoreboardObjective) {
|
||||
return objectiveScore("*", scoreboardObjective);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a scoreboard value.
|
||||
* The client will see the score of the specified player for the specified objective as the text represented by this component.
|
||||
*
|
||||
* <p><b>This method is currently guaranteed to throw an {@code UnsupportedOperationException}
|
||||
* as it is only supported on snapshot clients.</b>
|
||||
*
|
||||
* @param playerName The name of the player whos score will be shown. If
|
||||
* this string represents the single-character sequence
|
||||
* "*", the viewing player's score will be displayed.
|
||||
* Standard minecraft selectors (@a, @p, etc)
|
||||
* are <em>not</em> supported.
|
||||
* @param scoreboardObjective The name of the objective for
|
||||
* which to display the score.
|
||||
* @return The text component representing the specified scoreboard score
|
||||
* for the specified player, or {@code null} if an error occurs during JSON serialization.
|
||||
*/
|
||||
public static TextualComponent objectiveScore(String playerName, String scoreboardObjective) {
|
||||
throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE
|
||||
// OVERLOADS documentation accordingly
|
||||
|
||||
return new ComplexTextTypeComponent("score", ImmutableMap.<String, String>builder()
|
||||
.put("name", playerName)
|
||||
.put("objective", scoreboardObjective)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a player name, retrievable by using a standard minecraft selector.
|
||||
* The client will see the players or entities captured by the specified selector as the text represented by this component.
|
||||
|
@ -4,13 +4,12 @@ import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -23,7 +22,7 @@ public class GriefPreventionFilter extends CuboidRegionFilter {
|
||||
this.claims = TaskManager.IMP.sync(new RunnableVal<Collection<Claim>>() {
|
||||
@Override
|
||||
public void run(Collection<Claim> claims) {
|
||||
this.value = new ArrayDeque(GriefPrevention.instance.dataStore.getClaims());
|
||||
this.value = new ArrayDeque<>(GriefPrevention.instance.dataStore.getClaims());
|
||||
}
|
||||
});
|
||||
this.world = world;
|
||||
|
@ -7,7 +7,6 @@ import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
@ -65,4 +64,4 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
|
||||
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class ATabCompleteListener implements Listener {
|
||||
Dispatcher dispatcher = CommandManager.getInstance().getDispatcher();
|
||||
CommandMapping weCommand = dispatcher.get(label);
|
||||
if (weCommand != null) {
|
||||
CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer.substring(index, buffer.length()));
|
||||
CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer.substring(index));
|
||||
worldEdit.getWorldEdit().getEventBus().post(event);
|
||||
List<String> suggestions = event.getSuggestions();
|
||||
if (suggestions != null && !suggestions.isEmpty()) {
|
||||
|
@ -10,22 +10,15 @@ import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.image.ImageViewer;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Rotation;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -48,6 +41,13 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitImageListener implements Listener {
|
||||
private Location mutable = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
|
||||
|
||||
@ -153,8 +153,7 @@ public class BukkitImageListener implements Listener {
|
||||
ImageViewer viewer = generator.getImageViewer();
|
||||
if (!(viewer instanceof BukkitImageViewer)) return null;
|
||||
|
||||
BukkitImageViewer biv = (BukkitImageViewer) viewer;
|
||||
return biv;
|
||||
return (BukkitImageViewer) viewer;
|
||||
}
|
||||
|
||||
private void handleInteract(PlayerEvent event, Entity entity, boolean primary) {
|
||||
@ -189,7 +188,6 @@ public class BukkitImageListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tool == null) return;
|
||||
BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
|
||||
Brush brush = context.getBrush();
|
||||
if (brush == null) return;
|
||||
@ -210,7 +208,7 @@ public class BukkitImageListener implements Listener {
|
||||
double zRat = Math.sin(yawRad) * a;
|
||||
|
||||
BlockFace facing = itemFrame.getFacing();
|
||||
double thickness = 1/32d + 1/128d;
|
||||
double thickness = 1/32D + 1/128D;
|
||||
double modX = facing.getModX();
|
||||
double modZ = facing.getModZ();
|
||||
double dx = source.getX() - target.getX() - modX * thickness;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.listener;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.command.CFICommands;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
@ -15,30 +14,25 @@ import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.injector.netty.WirePacket;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.event.platform.BlockInteractEvent;
|
||||
import com.sk89q.worldedit.event.platform.Interaction;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -70,7 +64,7 @@ public class CFIPacketListener implements Listener {
|
||||
Player plr = event.getPlayer();
|
||||
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
|
||||
if (!sendBlockChange(plr, gen, pt, Interaction.HIT)) {
|
||||
gen.setBlock(pt, EditSession.nullBlock);
|
||||
gen.setBlock(pt, BlockTypes.AIR.getDefaultState());
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
@ -89,7 +83,7 @@ public class CFIPacketListener implements Listener {
|
||||
EnumWrappers.Hand enumHand = hands.isEmpty() ? EnumWrappers.Hand.MAIN_HAND : hands.get(0);
|
||||
PlayerInventory inv = plr.getInventory();
|
||||
ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand();
|
||||
if (hand != null && hand.getType().isBlock()) {
|
||||
if (hand.getType().isBlock()) {
|
||||
Material type = hand.getType();
|
||||
switch (type) {
|
||||
case AIR:
|
||||
@ -287,8 +281,7 @@ public class CFIPacketListener implements Listener {
|
||||
BlockPosition loc = position.readSafely(0);
|
||||
if (loc == null) return null;
|
||||
BlockVector3 origin = generator.getOrigin().toBlockPoint();
|
||||
BlockVector3 pt = BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
|
||||
return pt;
|
||||
return BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
|
||||
}
|
||||
|
||||
private void handleBlockEvent(PacketEvent event, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> task) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
import com.wasteofplastic.askyblock.Island;
|
||||
import org.bukkit.Location;
|
||||
@ -12,13 +12,9 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class ASkyBlockHook extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
Plugin aSkyBlock;
|
||||
|
||||
public ASkyBlockHook(final Plugin aSkyBlock, final FaweBukkit p3) {
|
||||
public ASkyBlockHook(final Plugin aSkyBlock) {
|
||||
super(aSkyBlock.getName());
|
||||
this.aSkyBlock = aSkyBlock;
|
||||
this.plugin = p3;
|
||||
|
||||
}
|
||||
|
||||
@ -33,8 +29,6 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener {
|
||||
|
||||
Island island = ASkyBlockAPI.getInstance().getIslandAt(location);
|
||||
if (island != null && isAllowed(player, island, type)) {
|
||||
int minX = island.getMinProtectedX();
|
||||
int minZ = island.getMinProtectedZ();
|
||||
|
||||
World world = location.getWorld();
|
||||
Location center = island.getCenter();
|
||||
@ -42,7 +36,7 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener {
|
||||
Location pos2 = center.add(center.subtract(pos1));
|
||||
pos2.setY(255);
|
||||
|
||||
return new BukkitMask(pos1, pos2, "ISLAND: " + minX + "," + minZ) {
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
return isAllowed((Player) player.parent, island, type);
|
||||
@ -52,4 +46,4 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class BukkitMask extends FaweMask {
|
||||
|
||||
public BukkitMask(Location pos1, Location pos2) {
|
||||
this(pos1, pos2, null);
|
||||
}
|
||||
|
||||
public BukkitMask(Location pos1, Location pos2, String name) {
|
||||
super(BlockVector3.at(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), BlockVector3.at(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name);
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -13,18 +14,13 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class FactionsFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
Plugin factions;
|
||||
|
||||
public FactionsFeature(final Plugin factionsPlugin, final FaweBukkit p3) {
|
||||
public FactionsFeature(final Plugin factionsPlugin) {
|
||||
super(factionsPlugin.getName());
|
||||
this.factions = factionsPlugin;
|
||||
this.plugin = p3;
|
||||
BoardColl.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
final Player player = fp.parent;
|
||||
final Location loc = player.getLocation();
|
||||
final PS ps = PS.valueOf(loc);
|
||||
@ -36,25 +32,14 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
|
||||
final Chunk chunk = loc.getChunk();
|
||||
final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
|
||||
final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CHUNK:" + loc.getChunk().getX() + "," + loc.getChunk().getZ();
|
||||
}
|
||||
};
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint());
|
||||
}
|
||||
}
|
||||
else if (fac.getOnlinePlayers().contains(player)) {
|
||||
if (fac.getComparisonName().equals("wilderness") == false) {
|
||||
} else if (fac.getOnlinePlayers().contains(player)) {
|
||||
if (!fac.getComparisonName().equals("wilderness")) {
|
||||
final Chunk chunk = loc.getChunk();
|
||||
final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
|
||||
final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CHUNK:" + loc.getChunk().getX() + "," + loc.getChunk().getZ();
|
||||
}
|
||||
};
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.util.Perm;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -15,19 +13,21 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
public class FactionsOneFeature extends BukkitMaskManager implements Listener {
|
||||
|
||||
private final Class clazzBoard;
|
||||
private final Method methodGetFactionAt;
|
||||
|
||||
public FactionsOneFeature(final Plugin factionsPlugin, final FaweBukkit p3) throws Throwable {
|
||||
public FactionsOneFeature(final Plugin factionsPlugin) throws Throwable {
|
||||
super(factionsPlugin.getName());
|
||||
this.clazzBoard = Class.forName("com.massivecraft.factions.Board");
|
||||
Class clazzBoard = Class.forName("com.massivecraft.factions.Board");
|
||||
this.methodGetFactionAt = clazzBoard.getDeclaredMethod("getFactionAt", FLocation.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
final Player player = fp.parent;
|
||||
final Chunk chunk = player.getLocation().getChunk();
|
||||
final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness");
|
||||
@ -40,13 +40,12 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
|
||||
if (this.isAdded(locs, world, player, perm, type)) {
|
||||
boolean hasPerm = true;
|
||||
|
||||
RegionWrapper chunkSelection;
|
||||
while (hasPerm && (count > 0)) {
|
||||
count--;
|
||||
|
||||
hasPerm = false;
|
||||
|
||||
chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ);
|
||||
RegionWrapper chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ);
|
||||
|
||||
if (this.isAdded(chunkSelection, world, player, perm, type)) {
|
||||
locs = new RegionWrapper(locs.minX, locs.maxX + 1, locs.minZ, locs.maxZ);
|
||||
@ -77,12 +76,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
|
||||
|
||||
final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4);
|
||||
final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CHUNK:" + pos1.getChunk().getX() + "," + pos1.getChunk().getZ();
|
||||
}
|
||||
};
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -112,7 +106,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,12 @@ package com.boydti.fawe.bukkit.regions;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.util.Perm;
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -23,7 +25,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
final Player player = fp.parent;
|
||||
final Chunk chunk = player.getLocation().getChunk();
|
||||
final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness");
|
||||
@ -36,13 +38,12 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
||||
if (this.isAdded(locs, world, player, perm, type)) {
|
||||
boolean hasPerm = true;
|
||||
|
||||
RegionWrapper chunkSelection;
|
||||
while (hasPerm && (count > 0)) {
|
||||
count--;
|
||||
|
||||
hasPerm = false;
|
||||
|
||||
chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ);
|
||||
RegionWrapper chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ);
|
||||
|
||||
if (this.isAdded(chunkSelection, world, player, perm, type)) {
|
||||
locs = new RegionWrapper(locs.minX, locs.maxX + 1, locs.minZ, locs.maxZ);
|
||||
@ -73,12 +74,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
||||
|
||||
final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4);
|
||||
final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CHUNK:" + pos1.getChunk().getX() + "," + pos1.getChunk().getZ();
|
||||
}
|
||||
};
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -50,33 +50,27 @@ public class FreeBuildRegion extends BukkitMaskManager {
|
||||
currRegList.add(listener);
|
||||
}
|
||||
if (currRegList.isEmpty()) return null;
|
||||
RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[currRegList.size()]);
|
||||
RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]);
|
||||
|
||||
World bukkitWorld = player.parent.getWorld();
|
||||
AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld);
|
||||
|
||||
BlockVector3 vec1 = BlockVector3.at(0, 0, 0);
|
||||
BlockVector3 vec2 = vec1;
|
||||
Location pos1 = BukkitAdapter.adapt(bukkitWorld, vec1);
|
||||
Location pos2 = BukkitAdapter.adapt(bukkitWorld, vec2);
|
||||
Location pos1 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO);
|
||||
Location pos2 = BukkitAdapter.adapt(bukkitWorld, BlockVector3.ZERO);
|
||||
|
||||
AsyncBlock block = new AsyncBlock(asyncWorld, new NullFaweQueue(asyncWorld.getWorldName(), BlockTypes.STONE.getDefaultState()), 0, 0, 0);
|
||||
BlockBreakEvent event = new BlockBreakEvent(block, player.parent);
|
||||
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "freebuild-global";
|
||||
}
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
return bukkitWorld == ((FawePlayer<Player>)player).parent.getWorld() && type == MaskType.MEMBER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region getRegion() {
|
||||
return new CuboidRegion(vec1, vec2) {
|
||||
return new CuboidRegion(BlockVector3.ZERO, BlockVector3.ZERO) {
|
||||
|
||||
@Override
|
||||
public boolean contains(int x, int z) {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.bukkit.filter.GriefPreventionFilter;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.general.RegionFilter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -14,13 +15,9 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class GriefPreventionFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
Plugin griefprevention;
|
||||
|
||||
public GriefPreventionFeature(final Plugin griefpreventionPlugin, final FaweBukkit p3) {
|
||||
public GriefPreventionFeature(final Plugin griefpreventionPlugin) {
|
||||
super(griefpreventionPlugin.getName());
|
||||
this.griefprevention = griefpreventionPlugin;
|
||||
this.plugin = p3;
|
||||
}
|
||||
|
||||
public boolean isAllowed(Player player, Claim claim, MaskType type) {
|
||||
@ -28,21 +25,16 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null);
|
||||
if (claim != null) {
|
||||
final String uuid = player.getUniqueId().toString();
|
||||
if (isAllowed(player, claim, type)) {
|
||||
claim.getGreaterBoundaryCorner().getBlockX();
|
||||
final Location pos1 = new Location(location.getWorld(), claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ());
|
||||
final Location pos2 = new Location(location.getWorld(), claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ());
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CLAIM:" + claim.toString();
|
||||
}
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
|
||||
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
|
@ -43,7 +43,7 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener
|
||||
if (isAllowed(player, myField, type, member)) {
|
||||
BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz());
|
||||
BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz());
|
||||
return new FaweMask(pos1, pos2, "FIELD: " + myField) {
|
||||
return new FaweMask(pos1, pos2) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
return isAllowed((Player) player.parent, myField, type, fp.hasPermission("fawe.preciousstones.member"));
|
||||
|
@ -5,6 +5,8 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
import com.bekvon.bukkit.residence.protection.CuboidArea;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -26,7 +28,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp, final MaskType type) {
|
||||
public FaweMask getMask(final FawePlayer<Player> fp, final MaskType type) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location);
|
||||
@ -40,13 +42,8 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
||||
final Location pos1 = area.getLowLoc();
|
||||
final Location pos2 = area.getHighLoc();
|
||||
final ClaimedResidence finalResidence = residence;
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RESIDENCE: " + finalResidence.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
return isAllowed((Player) player.parent, finalResidence, type);
|
||||
}
|
||||
|
@ -2,9 +2,11 @@ package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.object.*;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -53,7 +55,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
try {
|
||||
@ -71,12 +73,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
final Chunk chunk = location.getChunk();
|
||||
final Location pos1 = new Location(location.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
|
||||
final Location pos2 = new Location(location.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PLOT:" + location.getChunk().getX() + "," + location.getChunk().getZ();
|
||||
}
|
||||
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
return isAllowed((Player) player.parent, myplot);
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.bukkit.filter.WorldGuardFilter;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.general.RegionFilter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
@ -18,7 +17,11 @@ import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.*;
|
||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -26,14 +29,14 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
WorldGuardPlugin worldguard;
|
||||
private WorldGuardPlugin worldguard;
|
||||
FaweBukkit plugin;
|
||||
|
||||
private WorldGuardPlugin getWorldGuard() {
|
||||
final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
|
||||
// WorldGuard may not be loaded
|
||||
if ((plugin == null) || !(plugin instanceof WorldGuardPlugin)) {
|
||||
if (!(plugin instanceof WorldGuardPlugin)) {
|
||||
return null; // Maybe you want throw an exception instead
|
||||
}
|
||||
|
||||
@ -46,13 +49,13 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
this.plugin = p3;
|
||||
}
|
||||
|
||||
public ProtectedRegion getRegion(final com.sk89q.worldguard.LocalPlayer player, final Location loc) {
|
||||
public ProtectedRegion getRegion(final LocalPlayer player, final Location location) {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
if (container == null) {
|
||||
System.out.println("Region capability is not enabled for WorldGuard.");
|
||||
return null;
|
||||
}
|
||||
RegionManager manager = container.get(FaweAPI.getWorld(loc.getWorld().getName()));
|
||||
RegionManager manager = container.get(BukkitAdapter.adapt(location.getWorld()));
|
||||
if (manager == null) {
|
||||
System.out.println("Region capability is not enabled for that world.");
|
||||
return null;
|
||||
@ -61,7 +64,7 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
if (global != null && isAllowed(player, global)) {
|
||||
return global;
|
||||
}
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ()));
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(location.getX(), location.getY(), location.getZ()));
|
||||
for (final ProtectedRegion region : regions) {
|
||||
if (isAllowed(player, region)) {
|
||||
return region;
|
||||
@ -93,7 +96,7 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
@Override
|
||||
public FaweMask getMask(FawePlayer<Player> fp, MaskType type) {
|
||||
final Player player = fp.parent;
|
||||
final com.sk89q.worldguard.LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||
final Location location = player.getLocation();
|
||||
final ProtectedRegion myregion = this.getRegion(localplayer, location);
|
||||
if (myregion != null) {
|
||||
@ -107,7 +110,7 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
|
||||
pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
|
||||
} else {
|
||||
return new FaweMask(adapt(myregion), myregion.getId()) {
|
||||
return new FaweMask(adapt(myregion)) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion);
|
||||
@ -115,20 +118,15 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
};
|
||||
}
|
||||
}
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return myregion.getId();
|
||||
}
|
||||
return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
|
||||
final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
final RegionManager manager = container.get(fp.getWorld());
|
||||
|
||||
return new FaweMask(new ManagerRegion(manager, localplayer), null) {
|
||||
return new FaweMask(new ManagerRegion(manager, localplayer)) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
// We rely on the region mask instead of this
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.boydti.fawe.bukkit.util;
|
||||
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class BukkitReflectionUtils {
|
||||
/**
|
||||
* prefix of bukkit classes
|
||||
@ -15,49 +15,33 @@ public class BukkitReflectionUtils {
|
||||
* prefix of minecraft classes
|
||||
*/
|
||||
private static volatile String preClassM = null;
|
||||
/**
|
||||
* boolean value, TRUE if server uses forge or MCPC+
|
||||
*/
|
||||
private static boolean forge = false;
|
||||
|
||||
/**
|
||||
* check server version and class names
|
||||
*/
|
||||
public static void init() {
|
||||
if (Bukkit.getServer() != null) {
|
||||
if (Bukkit.getVersion().contains("MCPC") || Bukkit.getVersion().contains("Forge")) {
|
||||
forge = true;
|
||||
}
|
||||
final Server server = Bukkit.getServer();
|
||||
final Class<?> bukkitServerClass = server.getClass();
|
||||
String[] pas = bukkitServerClass.getName().split("\\.");
|
||||
final Server server = Bukkit.getServer();
|
||||
final Class<?> bukkitServerClass = server.getClass();
|
||||
String[] pas = bukkitServerClass.getName().split("\\.");
|
||||
if (pas.length == 5) {
|
||||
final String verB = pas[3];
|
||||
preClassB = "org.bukkit.craftbukkit." + verB;
|
||||
}
|
||||
try {
|
||||
final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
|
||||
final Object handle = getHandle.invoke(server);
|
||||
final Class handleServerClass = handle.getClass();
|
||||
pas = handleServerClass.getName().split("\\.");
|
||||
if (pas.length == 5) {
|
||||
final String verB = pas[3];
|
||||
preClassB = "org.bukkit.craftbukkit." + verB;
|
||||
}
|
||||
try {
|
||||
final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
|
||||
final Object handle = getHandle.invoke(server);
|
||||
final Class handleServerClass = handle.getClass();
|
||||
pas = handleServerClass.getName().split("\\.");
|
||||
if (pas.length == 5) {
|
||||
final String verM = pas[3];
|
||||
preClassM = "net.minecraft.server." + verM;
|
||||
}
|
||||
} catch (final Exception ignored) {
|
||||
MainUtil.handleError(ignored);
|
||||
final String verM = pas[3];
|
||||
preClassM = "net.minecraft.server." + verM;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return true if server has forge classes
|
||||
*/
|
||||
public static boolean isForge() {
|
||||
return forge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace
|
||||
* {nm} to net.minecraft
|
||||
@ -90,18 +74,6 @@ public class BukkitReflectionUtils {
|
||||
return ReflectionUtils.getClass(className);
|
||||
}
|
||||
|
||||
public static Class<?> getUtilClass(final String name) {
|
||||
try {
|
||||
return Class.forName(name); //Try before 1.8 first
|
||||
} catch (final ClassNotFoundException ex) {
|
||||
try {
|
||||
return Class.forName("net.minecraft.util." + name); //Not 1.8
|
||||
} catch (final ClassNotFoundException ex2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.util.TaskManager;
|
||||
import org.apache.commons.lang.mutable.MutableInt;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BukkitTaskMan extends TaskManager {
|
||||
|
||||
@ -14,44 +15,35 @@ public class BukkitTaskMan extends TaskManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int repeat(final Runnable r, final int interval) {
|
||||
return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, r, interval, interval);
|
||||
public int repeat(@NotNull final Runnable runnable, final int interval) {
|
||||
return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, runnable, interval, interval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int repeatAsync(final Runnable r, final int interval) {
|
||||
return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, r, interval, interval);
|
||||
public int repeatAsync(@NotNull final Runnable runnable, final int interval) {
|
||||
return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, runnable, interval, interval);
|
||||
}
|
||||
|
||||
public MutableInt index = new MutableInt(0);
|
||||
|
||||
@Override
|
||||
public void async(final Runnable r) {
|
||||
if (r == null) {
|
||||
return;
|
||||
}
|
||||
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, r).getTaskId();
|
||||
public void async(@NotNull final Runnable runnable) {
|
||||
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, runnable).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void task(final Runnable r) {
|
||||
if (r == null) {
|
||||
return;
|
||||
}
|
||||
this.plugin.getServer().getScheduler().runTask(this.plugin, r).getTaskId();
|
||||
public void task(@NotNull final Runnable runnable) {
|
||||
this.plugin.getServer().getScheduler().runTask(this.plugin, runnable).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void later(final Runnable r, final int delay) {
|
||||
if (r == null) {
|
||||
return;
|
||||
}
|
||||
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, r, delay).getTaskId();
|
||||
public void later(@NotNull final Runnable runnable, final int delay) {
|
||||
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, runnable, delay).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void laterAsync(final Runnable r, final int delay) {
|
||||
this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, r, delay);
|
||||
public void laterAsync(@NotNull final Runnable runnable, final int delay) {
|
||||
this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, runnable, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,20 +2,20 @@ package com.boydti.fawe.bukkit.util;
|
||||
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemUtil {
|
||||
|
||||
private final Class<?> classCraftItemStack;
|
||||
private final Method methodAsNMSCopy;
|
||||
private final Class<?> classNMSItem;
|
||||
private final Method methodGetTag;
|
||||
private final Method methodHasTag;
|
||||
private final Method methodSetTag;
|
||||
@ -25,8 +25,8 @@ public class ItemUtil {
|
||||
private SoftReference<Int2ObjectOpenHashMap<WeakReference<Tag>>> hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>());
|
||||
|
||||
public ItemUtil() throws Exception {
|
||||
this.classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack");
|
||||
this.classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack");
|
||||
Class<?> classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack");
|
||||
Class<?> classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack");
|
||||
this.methodAsNMSCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class));
|
||||
this.methodHasTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("hasTag"));
|
||||
this.methodGetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("getTag"));
|
||||
@ -61,7 +61,7 @@ public class ItemUtil {
|
||||
Int2ObjectOpenHashMap<WeakReference<Tag>> map = hashToNMSTag.get();
|
||||
if (map == null) {
|
||||
map = new Int2ObjectOpenHashMap<>();
|
||||
hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>(map));
|
||||
hashToNMSTag = new SoftReference<>(new Int2ObjectOpenHashMap<>(map));
|
||||
}
|
||||
WeakReference<Tag> nativeTagRef = map.get(nmsTag.hashCode());
|
||||
if (nativeTagRef != null) {
|
||||
|
@ -334,7 +334,7 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
index = 0;
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
} while (System.currentTimeMillis() - start < recommended);
|
||||
if (more || place) {
|
||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.bukkit.BukkitPlayer;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
|
||||
import com.boydti.fawe.example.IntFaweChunk;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
@ -22,16 +21,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -46,6 +35,12 @@ import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMappedFaweQueue<World, CHUNK, CHUNKSECTIONS, SECTION> implements Listener {
|
||||
|
||||
protected static boolean PAPER = true;
|
||||
@ -259,7 +254,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
}
|
||||
|
||||
public World createWorld(final WorldCreator creator) {
|
||||
World world = TaskManager.IMP.sync(new RunnableVal<World>() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<World>() {
|
||||
@Override
|
||||
public void run(World value) {
|
||||
disableChunkLoad = true;
|
||||
@ -267,7 +262,6 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
disableChunkLoad = false;
|
||||
}
|
||||
});
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -289,8 +283,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
@Override
|
||||
public boolean regenerateChunk(World world, int x, int z, BiomeType biome, Long seed) {
|
||||
if (!keepLoaded.isEmpty()) keepLoaded.remove(MathMan.pairInt(x, z));
|
||||
boolean result = world.regenerateChunk(x, z);
|
||||
return result;
|
||||
return world.regenerateChunk(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,20 +11,12 @@ import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
@ -33,6 +25,14 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot, ChunkSnapshot> {
|
||||
|
||||
private ConcurrentMap<Long, ChunkSnapshot> chunkCache = new MapMaker()
|
||||
@ -78,15 +78,6 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
}
|
||||
|
||||
private static Class<?> classRegionFileCache;
|
||||
private static Class<?> classRegionFile;
|
||||
private static Class<?> classCraftChunk;
|
||||
private static Class<?> classCraftWorld;
|
||||
private static Class<?> classNMSChunk;
|
||||
private static Class<?> classNMSWorld;
|
||||
private static Class<?> classChunkProviderServer;
|
||||
private static Class<?> classIChunkLoader;
|
||||
private static Class<?> classChunkRegionLoader;
|
||||
private static Class<?> classIChunkProvider;
|
||||
private static Method methodGetHandleChunk;
|
||||
private static Method methodGetHandleWorld;
|
||||
private static Method methodFlush;
|
||||
@ -100,15 +91,15 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
try {
|
||||
BukkitReflectionUtils.init();
|
||||
classRegionFileCache = BukkitReflectionUtils.getNmsClass("RegionFileCache");
|
||||
classRegionFile = BukkitReflectionUtils.getNmsClass("RegionFile");
|
||||
classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk");
|
||||
classNMSChunk = BukkitReflectionUtils.getNmsClass("Chunk");
|
||||
classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld");
|
||||
classNMSWorld = BukkitReflectionUtils.getNmsClass("World");
|
||||
classChunkProviderServer = BukkitReflectionUtils.getNmsClass("ChunkProviderServer");
|
||||
classIChunkProvider = BukkitReflectionUtils.getNmsClass("IChunkProvider");
|
||||
classIChunkLoader = BukkitReflectionUtils.getNmsClass("IChunkLoader");
|
||||
classChunkRegionLoader = BukkitReflectionUtils.getNmsClass("ChunkRegionLoader");
|
||||
Class<?> classRegionFile = BukkitReflectionUtils.getNmsClass("RegionFile");
|
||||
Class<?> classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk");
|
||||
Class<?> classNMSChunk = BukkitReflectionUtils.getNmsClass("Chunk");
|
||||
Class<?> classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld");
|
||||
Class<?> classNMSWorld = BukkitReflectionUtils.getNmsClass("World");
|
||||
Class<?> classChunkProviderServer = BukkitReflectionUtils.getNmsClass("ChunkProviderServer");
|
||||
Class<?> classIChunkProvider = BukkitReflectionUtils.getNmsClass("IChunkProvider");
|
||||
Class<?> classIChunkLoader = BukkitReflectionUtils.getNmsClass("IChunkLoader");
|
||||
Class<?> classChunkRegionLoader = BukkitReflectionUtils.getNmsClass("ChunkRegionLoader");
|
||||
|
||||
methodGetHandleChunk = ReflectionUtils.setAccessible(classCraftChunk.getDeclaredMethod("getHandle"));
|
||||
methodGetHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle"));
|
||||
@ -120,8 +111,8 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
|
||||
fieldRegionMap = ReflectionUtils.findField(classRegionFileCache, Map.class);
|
||||
fieldRegionRAF = ReflectionUtils.findField(classRegionFile, RandomAccessFile.class);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,15 +280,15 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
private ChunkSnapshot tryGetSnasphot(Chunk chunk) {
|
||||
try {
|
||||
return chunk.getChunkSnapshot(false, true, false);
|
||||
} catch (Throwable ignore) {
|
||||
Throwable cause = ignore;
|
||||
} catch (Throwable throwable) {
|
||||
Throwable cause = throwable;
|
||||
while (cause.getCause() != null) {
|
||||
cause = cause.getCause();
|
||||
}
|
||||
if (cause instanceof IllegalStateException) {
|
||||
return null;
|
||||
}
|
||||
throw ignore;
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,8 +382,8 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
if (disableResult != null) {
|
||||
try {
|
||||
fieldNeighbors.set(disableResult[0], disableResult[1]);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -337,16 +337,14 @@ public abstract class ChunkListener implements Listener {
|
||||
if (elem == null) return;
|
||||
String className = elem.getClassName();
|
||||
int len = className.length();
|
||||
if (className != null) {
|
||||
if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) {
|
||||
for (Entity ent : world.getEntities()) {
|
||||
if (ent.getType() == EntityType.FIREWORK) {
|
||||
Vector velocity = ent.getVelocity();
|
||||
double vertical = Math.abs(velocity.getY());
|
||||
if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) {
|
||||
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation());
|
||||
ent.remove();
|
||||
}
|
||||
if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) {
|
||||
for (Entity ent : world.getEntities()) {
|
||||
if (ent.getType() == EntityType.FIREWORK) {
|
||||
Vector velocity = ent.getVelocity();
|
||||
double vertical = Math.abs(velocity.getY());
|
||||
if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) {
|
||||
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation());
|
||||
ent.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
copy.sectionPalettes[i] = copy(current);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
@ -296,7 +296,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
|
||||
@Override
|
||||
public Chunk getNewChunk() {
|
||||
return ((BukkitQueue_1_13) getParent()).getWorld().getChunkAt(getX(), getZ());
|
||||
return getParent().getWorld().getChunkAt(getX(), getZ());
|
||||
}
|
||||
|
||||
public void optimize() {
|
||||
@ -348,8 +348,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
// Remove entities
|
||||
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
||||
if (!entsToRemove.isEmpty()) {
|
||||
for (int i = 0; i < entities.length; i++) {
|
||||
Collection<Entity> ents = entities[i];
|
||||
for (Collection<Entity> ents : entities) {
|
||||
if (!ents.isEmpty()) {
|
||||
Iterator<Entity> iter = ents.iterator();
|
||||
while (iter.hasNext()) {
|
||||
@ -445,13 +444,11 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
UUID uuid = entity.getUniqueID();
|
||||
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
|
||||
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
|
||||
if (nativeTag != null) {
|
||||
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_13.fromNative(nativeTag);
|
||||
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
||||
tag.remove(name);
|
||||
}
|
||||
entity.f(tag);
|
||||
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_13.fromNative(nativeTag);
|
||||
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
||||
tag.remove(name);
|
||||
}
|
||||
entity.f(tag);
|
||||
entity.setLocation(x, y, z, yaw, pitch);
|
||||
synchronized (BukkitQueue_0.class) {
|
||||
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
@ -547,9 +544,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
// Trim tiles
|
||||
HashMap<BlockPosition, TileEntity> toRemove = null;
|
||||
if (!tiles.isEmpty()) {
|
||||
Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<BlockPosition, TileEntity> tile = iterator.next();
|
||||
for (Map.Entry<BlockPosition, TileEntity> tile : tiles.entrySet()) {
|
||||
BlockPosition pos = tile.getKey();
|
||||
int lx = pos.getX() & 15;
|
||||
int ly = pos.getY();
|
||||
@ -625,8 +620,8 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
getParent().getChangeTask().run(copy, this);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.v1_13;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.BukkitPlayer;
|
||||
import com.boydti.fawe.bukkit.adapter.v1_13_1.BlockMaterial_1_13;
|
||||
@ -14,10 +13,9 @@ import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualChunk;
|
||||
import com.boydti.fawe.object.visitor.FaweChunkVisitor;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
@ -25,32 +23,7 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import net.minecraft.server.v1_13_R2.BiomeBase;
|
||||
import net.minecraft.server.v1_13_R2.Block;
|
||||
import net.minecraft.server.v1_13_R2.BlockPosition;
|
||||
import net.minecraft.server.v1_13_R2.ChunkProviderServer;
|
||||
import net.minecraft.server.v1_13_R2.ChunkSection;
|
||||
import net.minecraft.server.v1_13_R2.DataBits;
|
||||
import net.minecraft.server.v1_13_R2.DataPalette;
|
||||
import net.minecraft.server.v1_13_R2.DataPaletteBlock;
|
||||
import net.minecraft.server.v1_13_R2.DataPaletteHash;
|
||||
import net.minecraft.server.v1_13_R2.DataPaletteLinear;
|
||||
import net.minecraft.server.v1_13_R2.Entity;
|
||||
import net.minecraft.server.v1_13_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_13_R2.EnumSkyBlock;
|
||||
import net.minecraft.server.v1_13_R2.GameProfileSerializer;
|
||||
import net.minecraft.server.v1_13_R2.IBlockData;
|
||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R2.Packet;
|
||||
import net.minecraft.server.v1_13_R2.PacketDataSerializer;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutMultiBlockChange;
|
||||
import net.minecraft.server.v1_13_R2.PlayerChunk;
|
||||
import net.minecraft.server.v1_13_R2.PlayerChunkMap;
|
||||
import net.minecraft.server.v1_13_R2.RegistryID;
|
||||
import net.minecraft.server.v1_13_R2.TileEntity;
|
||||
import net.minecraft.server.v1_13_R2.WorldChunkManager;
|
||||
import net.minecraft.server.v1_13_R2.WorldData;
|
||||
import net.minecraft.server.v1_13_R2.WorldServer;
|
||||
import net.minecraft.server.v1_13_R2.*;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftChunk;
|
||||
@ -64,51 +37,34 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R2.Chunk, ChunkSection[], ChunkSection> {
|
||||
|
||||
protected final static Field fieldBits;
|
||||
protected final static Field fieldPalette;
|
||||
protected final static Field fieldSize;
|
||||
final static Field fieldPalette;
|
||||
final static Field fieldSize;
|
||||
|
||||
protected final static Field fieldHashBlocks;
|
||||
protected final static Field fieldLinearBlocks;
|
||||
protected final static Field fieldHashIndex;
|
||||
protected final static Field fieldRegistryb;
|
||||
protected final static Field fieldRegistryc;
|
||||
protected final static Field fieldRegistryd;
|
||||
protected final static Field fieldRegistrye;
|
||||
protected final static Field fieldRegistryf;
|
||||
final static Field fieldHashBlocks;
|
||||
final static Field fieldLinearBlocks;
|
||||
private final static Field fieldHashIndex;
|
||||
final static Field fieldRegistryb;
|
||||
final static Field fieldRegistryc;
|
||||
final static Field fieldRegistryd;
|
||||
final static Field fieldRegistrye;
|
||||
final static Field fieldRegistryf;
|
||||
|
||||
protected final static Field fieldLinearIndex;
|
||||
protected final static Field fieldDefaultBlock;
|
||||
final static Field fieldLinearIndex;
|
||||
final static Field fieldDefaultBlock;
|
||||
|
||||
protected final static Field fieldFluidCount;
|
||||
protected final static Field fieldTickingBlockCount;
|
||||
protected final static Field fieldNonEmptyBlockCount;
|
||||
protected final static Field fieldSection;
|
||||
protected final static Field fieldLiquidCount;
|
||||
protected final static Field fieldEmittedLight;
|
||||
protected final static Field fieldSkyLight;
|
||||
private final static Field fieldFluidCount;
|
||||
final static Field fieldTickingBlockCount;
|
||||
final static Field fieldNonEmptyBlockCount;
|
||||
final static Field fieldSection;
|
||||
final static Field fieldLiquidCount;
|
||||
private final static ChunkSection emptySection;
|
||||
|
||||
|
||||
// protected final static Field fieldBiomes;
|
||||
|
||||
protected final static Field fieldChunkGenerator;
|
||||
protected final static Field fieldSeed;
|
||||
// protected final static Field fieldBiomeCache;
|
||||
// protected final static Field fieldBiomes2;
|
||||
protected final static Field fieldGenLayer1;
|
||||
protected final static Field fieldGenLayer2;
|
||||
protected final static Field fieldSave;
|
||||
// protected final static MutableGenLayer genLayer;
|
||||
protected final static ChunkSection emptySection;
|
||||
|
||||
// protected static final Method methodResize;
|
||||
|
||||
protected final static Field fieldDirtyCount;
|
||||
protected final static Field fieldDirtyBits;
|
||||
private final static Field fieldDirtyCount;
|
||||
private final static Field fieldDirtyBits;
|
||||
|
||||
static {
|
||||
try {
|
||||
@ -116,12 +72,8 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
Arrays.fill(emptySection.getSkyLightArray().asBytes(), (byte) 255);
|
||||
fieldSection = ChunkSection.class.getDeclaredField("blockIds");
|
||||
fieldLiquidCount = ChunkSection.class.getDeclaredField("e");
|
||||
fieldEmittedLight = ChunkSection.class.getDeclaredField("emittedLight");
|
||||
fieldSkyLight = ChunkSection.class.getDeclaredField("skyLight");
|
||||
fieldSection.setAccessible(true);
|
||||
fieldLiquidCount.setAccessible(true);
|
||||
fieldEmittedLight.setAccessible(true);
|
||||
fieldSkyLight.setAccessible(true);
|
||||
|
||||
fieldFluidCount = ChunkSection.class.getDeclaredField("e");
|
||||
fieldTickingBlockCount = ChunkSection.class.getDeclaredField("tickingBlockCount");
|
||||
@ -130,27 +82,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
fieldTickingBlockCount.setAccessible(true);
|
||||
fieldNonEmptyBlockCount.setAccessible(true);
|
||||
|
||||
|
||||
|
||||
// fieldBiomes = ChunkProviderGenerate.class.getDeclaredField("D"); // *
|
||||
// fieldBiomes.setAccessible(true);
|
||||
|
||||
fieldChunkGenerator = ChunkProviderServer.class.getDeclaredField("chunkGenerator");
|
||||
fieldChunkGenerator.setAccessible(true);
|
||||
fieldSeed = WorldData.class.getDeclaredField("e");
|
||||
fieldSeed.setAccessible(true);
|
||||
|
||||
// fieldBiomeCache = WorldChunkManager.class.getDeclaredField("d"); // *
|
||||
// fieldBiomeCache.setAccessible(true);
|
||||
// fieldBiomes2 = WorldChunkManager.class.getDeclaredField("e"); // *
|
||||
// fieldBiomes2.setAccessible(true);
|
||||
fieldGenLayer1 = WorldChunkManager.class.getDeclaredField("b") ;
|
||||
fieldGenLayer2 = WorldChunkManager.class.getDeclaredField("c") ;
|
||||
fieldGenLayer1.setAccessible(true);
|
||||
fieldGenLayer2.setAccessible(true);
|
||||
|
||||
fieldSave = ReflectionUtils.setAccessible(net.minecraft.server.v1_13_R2.Chunk.class.getDeclaredField("s")); //*
|
||||
|
||||
fieldHashBlocks = DataPaletteHash.class.getDeclaredField("b");
|
||||
fieldHashBlocks.setAccessible(true);
|
||||
fieldLinearBlocks = DataPaletteLinear.class.getDeclaredField("b");
|
||||
@ -185,16 +116,13 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
fieldPalette = DataPaletteBlock.class.getDeclaredField("h");
|
||||
fieldPalette.setAccessible(true);
|
||||
|
||||
// methodResize = DataPaletteBlock.class.getDeclaredMethod("b", int.class);
|
||||
// methodResize.setAccessible(true);
|
||||
|
||||
fieldDirtyCount = PlayerChunk.class.getDeclaredField("dirtyCount");
|
||||
fieldDirtyBits = PlayerChunk.class.getDeclaredField("h");
|
||||
fieldDirtyCount.setAccessible(true);
|
||||
fieldDirtyBits.setAccessible(true);
|
||||
|
||||
Fawe.debug("Using adapter: " + getAdapter());
|
||||
Fawe.debug("=========================================");
|
||||
System.out.println("Using adapter: " + getAdapter());
|
||||
System.out.println("=========================================");
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -258,54 +186,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(World world, int x, int z, BiomeType biome, Long seed) {
|
||||
// if (biome != null) {
|
||||
// try {
|
||||
// if (seed == null) {
|
||||
// seed = world.getSeed();
|
||||
// }
|
||||
// nmsWorld.worldData.getSeed();
|
||||
// boolean result;
|
||||
// ChunkProviderGenerate generator = new ChunkProviderGenerate(nmsWorld, seed, false, "");
|
||||
// Biome bukkitBiome = getAdapter().getBiome(biome.getId());
|
||||
// BiomeBase base = BiomeBase.getBiome(biome.getId());
|
||||
// fieldBiomes.set(generator, new BiomeBase[]{base});
|
||||
// boolean cold = base.getTemperature() <= 1;
|
||||
// net.minecraft.server.v1_13_R2.ChunkGenerator existingGenerator = nmsWorld.getChunkProvider().chunkGenerator;
|
||||
// long existingSeed = world.getSeed();
|
||||
// {
|
||||
// if (genLayer == null) genLayer = new MutableGenLayer(seed);
|
||||
// genLayer.set(biome.getId());
|
||||
// Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager());
|
||||
// Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager());
|
||||
// fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer);
|
||||
// fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer);
|
||||
//
|
||||
// fieldSeed.set(nmsWorld.worldData, seed);
|
||||
//
|
||||
// ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new BiomeCache(this.nmsWorld.getWorldChunkManager()));
|
||||
//
|
||||
// ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), generator);
|
||||
//
|
||||
// keepLoaded.remove(MathMan.pairInt(x, z));
|
||||
// result = getWorld().regenerateChunk(x, z);
|
||||
// net.minecraft.server.v1_13_R2.Chunk nmsChunk = getCachedChunk(world, x, z);
|
||||
// if (nmsChunk != null) {
|
||||
// nmsChunk.f(true); // Set Modified
|
||||
// nmsChunk.mustSave = true;
|
||||
// }
|
||||
//
|
||||
// ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), existingGenerator);
|
||||
//
|
||||
// fieldSeed.set(nmsWorld.worldData, existingSeed);
|
||||
//
|
||||
// fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1);
|
||||
// fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2);
|
||||
// }
|
||||
// return result;
|
||||
// } catch (Throwable e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
return super.regenerateChunk(world, x, z, biome, seed);
|
||||
}
|
||||
|
||||
@ -438,89 +318,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public World createWorld(final WorldCreator creator) {
|
||||
// final String name = creator.name();
|
||||
// ChunkGenerator generator = creator.generator();
|
||||
// final CraftServer server = (CraftServer) Bukkit.getServer();
|
||||
// final MinecraftServer console = server.getServer();
|
||||
// final File folder = new File(server.getWorldContainer(), name);
|
||||
// final World world = server.getWorld(name);
|
||||
// final WorldType type = WorldType.getType(creator.type().getName());
|
||||
// final boolean generateStructures = creator.generateStructures();
|
||||
// if (world != null) {
|
||||
// return world;
|
||||
// }
|
||||
// if (folder.exists() && !folder.isDirectory()) {
|
||||
// throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
||||
// }
|
||||
// TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
// @Override
|
||||
// public void run(Object value) {
|
||||
// try {
|
||||
// Field field = CraftServer.class.getDeclaredField("worlds");
|
||||
// field.setAccessible(true);
|
||||
// Map<Object, Object> existing = (Map<Object, Object>) field.get(server);
|
||||
// if (!existing.getClass().getName().contains("SynchronizedMap")) {
|
||||
// field.set(server, Collections.synchronizedMap(existing));
|
||||
// }
|
||||
// } catch (Throwable e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// if (generator == null) {
|
||||
// generator = server.getGenerator(name);
|
||||
// }
|
||||
// int dimension = 10 + console.worlds.size();
|
||||
// boolean used = false;
|
||||
// do {
|
||||
// for (final WorldServer ws : console.worlds) {
|
||||
// used = (ws.dimension == dimension);
|
||||
// if (used) {
|
||||
// ++dimension;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// } while (used);
|
||||
// final boolean hardcore = false;
|
||||
// final IDataManager sdm = new ServerNBTManager(server.getWorldContainer(), name, true, server.getHandle().getServer().dataConverterManager);
|
||||
// WorldData worlddata = sdm.getWorldData();
|
||||
// final WorldSettings worldSettings;
|
||||
// if (worlddata == null) {
|
||||
// worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById(server.getDefaultGameMode().getValue()), generateStructures, hardcore, type);
|
||||
// worldSettings.setGeneratorSettings(creator.generatorSettings());
|
||||
// worlddata = new WorldData(worldSettings, name);
|
||||
// } else {
|
||||
// worldSettings = null;
|
||||
// }
|
||||
// worlddata.checkName(name);
|
||||
// final WorldServer internal = (WorldServer)new WorldServer(console, sdm, worlddata, dimension, console.methodProfiler, creator.environment(), generator).b();
|
||||
// startSet(true); // Temporarily allow async chunk load since the world isn't added yet
|
||||
// if (worldSettings != null) {
|
||||
// internal.a(worldSettings);
|
||||
// }
|
||||
// endSet(true);
|
||||
// internal.scoreboard = server.getScoreboardManager().getMainScoreboard().getHandle();
|
||||
// internal.tracker = new EntityTracker(internal);
|
||||
// internal.addIWorldAccess(new WorldManager(console, internal));
|
||||
// internal.worldData.setDifficulty(EnumDifficulty.EASY);
|
||||
// internal.setSpawnFlags(true, true);
|
||||
// if (generator != null) {
|
||||
// internal.getWorld().getPopulators().addAll(generator.getDefaultPopulators(internal.getWorld()));
|
||||
// }
|
||||
// // Add the world
|
||||
// return TaskManager.IMP.sync(new RunnableVal<World>() {
|
||||
// @Override
|
||||
// public void run(World value) {
|
||||
// console.worlds.add(internal);
|
||||
// server.getPluginManager().callEvent(new WorldInitEvent(internal.getWorld()));
|
||||
// server.getPluginManager().callEvent(new WorldLoadEvent(internal.getWorld()));
|
||||
// this.value = internal.getWorld();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int getCombinedId4Data(ChunkSection lastSection, int x, int y, int z) {
|
||||
DataPaletteBlock<IBlockData> dataPalette = lastSection.getBlocks();
|
||||
@ -679,7 +476,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
return playerChunk;
|
||||
}
|
||||
|
||||
public boolean sendChunk(PlayerChunk playerChunk, net.minecraft.server.v1_13_R2.Chunk nmsChunk, int mask) {
|
||||
private boolean sendChunk(PlayerChunk playerChunk, net.minecraft.server.v1_13_R2.Chunk nmsChunk, int mask) {
|
||||
if (playerChunk == null) {
|
||||
return false;
|
||||
}
|
||||
@ -690,71 +487,33 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
sections[layer] = new ChunkSection(layer << 4, nmsWorld.worldProvider.g());
|
||||
}
|
||||
}
|
||||
TaskManager.IMP.sync(new Supplier<Object>() {
|
||||
@Override
|
||||
public Object get() {
|
||||
try {
|
||||
int dirtyBits = fieldDirtyBits.getInt(playerChunk);
|
||||
if (dirtyBits == 0) {
|
||||
((CraftWorld) getWorld()).getHandle().getPlayerChunkMap().a(playerChunk);
|
||||
}
|
||||
if (mask == 0) {
|
||||
dirtyBits = 65535;
|
||||
} else {
|
||||
dirtyBits |= mask;
|
||||
}
|
||||
|
||||
fieldDirtyBits.set(playerChunk, dirtyBits);
|
||||
fieldDirtyCount.set(playerChunk, 64);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
TaskManager.IMP.sync(() -> {
|
||||
try {
|
||||
int dirtyBits = fieldDirtyBits.getInt(playerChunk);
|
||||
if (dirtyBits == 0) {
|
||||
((CraftWorld) getWorld()).getHandle().getPlayerChunkMap().a(playerChunk);
|
||||
}
|
||||
return null;
|
||||
if (mask == 0) {
|
||||
dirtyBits = 65535;
|
||||
} else {
|
||||
dirtyBits |= mask;
|
||||
}
|
||||
|
||||
fieldDirtyBits.set(playerChunk, dirtyBits);
|
||||
fieldDirtyCount.set(playerChunk, 64);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
// if (mask == 0) {
|
||||
// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65535);
|
||||
// for (EntityPlayer player : playerChunk.players) {
|
||||
// player.playerConnection.sendPacket(packet);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// // Send chunks
|
||||
// boolean empty = false;
|
||||
// ChunkSection[] sections = nmsChunk.getSections();
|
||||
// for (int i = 0; i < sections.length; i++) {
|
||||
// if (sections[i] == null) {
|
||||
// sections[i] = emptySection;
|
||||
// empty = true;
|
||||
// }
|
||||
// }
|
||||
// if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
||||
// for (EntityPlayer player : playerChunk.players) {
|
||||
// player.playerConnection.sendPacket(packet);
|
||||
// }
|
||||
// mask = 255;
|
||||
// }
|
||||
// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, mask);
|
||||
// for (EntityPlayer player : playerChunk.players) {
|
||||
// player.playerConnection.sendPacket(packet);
|
||||
// }
|
||||
// if (empty) {
|
||||
// for (int i = 0; i < sections.length; i++) {
|
||||
// if (sections[i] == emptySection) {
|
||||
// sections[i] = null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEntities(net.minecraft.server.v1_13_R2.Chunk nmsChunk) {
|
||||
try {
|
||||
final Collection<Entity>[] entities = nmsChunk.entitySlices;
|
||||
for (int i = 0; i < entities.length; i++) {
|
||||
Collection<Entity> slice = entities[i];
|
||||
for (Collection<Entity> slice : entities) {
|
||||
if (slice != null && !slice.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
@ -780,8 +539,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
|
||||
@Override
|
||||
public void setFullbright(ChunkSection[] sections) {
|
||||
for (int i = 0; i < sections.length; i++) {
|
||||
ChunkSection section = sections[i];
|
||||
for (ChunkSection section : sections) {
|
||||
if (section != null) {
|
||||
byte[] bytes = section.getSkyLightArray().asBytes();
|
||||
Arrays.fill(bytes, (byte) 255);
|
||||
@ -817,7 +575,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
nmsWorld.r(pos);
|
||||
}
|
||||
|
||||
protected WorldServer nmsWorld;
|
||||
private WorldServer nmsWorld;
|
||||
|
||||
@Override
|
||||
public World getImpWorld() {
|
||||
@ -830,13 +588,13 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCount(int tickingBlockCount, int nonEmptyBlockCount, ChunkSection section) throws NoSuchFieldException, IllegalAccessException {
|
||||
static void setCount(int tickingBlockCount, int nonEmptyBlockCount, ChunkSection section) throws NoSuchFieldException, IllegalAccessException {
|
||||
fieldFluidCount.set(section, 0); // TODO FIXME
|
||||
fieldTickingBlockCount.set(section, tickingBlockCount);
|
||||
fieldNonEmptyBlockCount.set(section, nonEmptyBlockCount);
|
||||
}
|
||||
|
||||
public int getNonEmptyBlockCount(ChunkSection section) throws IllegalAccessException {
|
||||
int getNonEmptyBlockCount(ChunkSection section) throws IllegalAccessException {
|
||||
return (int) fieldNonEmptyBlockCount.get(section);
|
||||
}
|
||||
|
||||
@ -845,7 +603,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
Arrays.fill(section.getEmittedLightArray().asBytes(), (byte) 0);
|
||||
}
|
||||
|
||||
public static ChunkSection newChunkSection(int y2, boolean flag, int[] blocks) {
|
||||
static ChunkSection newChunkSection(int y2, boolean flag, int[] blocks) {
|
||||
if (blocks == null) {
|
||||
return new ChunkSection(y2 << 4, flag);
|
||||
} else {
|
||||
@ -899,9 +657,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
// protected DataBits a;
|
||||
long[] bits = Arrays.copyOfRange(blockstates, 0, blockBitArrayEnd);
|
||||
DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
|
||||
DataPalette<IBlockData> palette;
|
||||
// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a);
|
||||
palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d);
|
||||
DataPalette<IBlockData> palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d);
|
||||
|
||||
// set palette
|
||||
for (int i = 0; i < num_palette; i++) {
|
||||
@ -938,13 +694,13 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
return tile != null ? getTag(tile) : null;
|
||||
}
|
||||
|
||||
public CompoundTag getTag(TileEntity tile) {
|
||||
CompoundTag getTag(TileEntity tile) {
|
||||
try {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tile.save(tag); // readTagIntoEntity
|
||||
return (CompoundTag) toNative(tag);
|
||||
} catch (Exception e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ public class BukkitChunk_1_14 extends IntFaweChunk<Chunk, BukkitQueue_1_14> {
|
||||
copy.sectionPalettes[i] = copy(current);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
@ -611,7 +611,7 @@ public class BukkitChunk_1_14 extends IntFaweChunk<Chunk, BukkitQueue_1_14> {
|
||||
getParent().getChangeTask().run(copy, this);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -905,7 +905,7 @@ public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R
|
||||
tile.save(tag); // readTagIntoEntity
|
||||
return (CompoundTag) toNative(tag);
|
||||
} catch (Exception e) {
|
||||
MainUtil.handleError(e);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ import net.minecraft.server.v1_14_R1.NBTTagLong;
|
||||
import net.minecraft.server.v1_14_R1.NBTTagLongArray;
|
||||
import net.minecraft.server.v1_14_R1.NBTTagShort;
|
||||
import net.minecraft.server.v1_14_R1.NBTTagString;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityStatus;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutTileEntityData;
|
||||
import net.minecraft.server.v1_14_R1.PlayerChunkMap;
|
||||
import net.minecraft.server.v1_14_R1.TileEntity;
|
||||
import net.minecraft.server.v1_14_R1.World;
|
||||
@ -101,6 +103,7 @@ import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.slf4j.Logger;
|
||||
@ -590,8 +593,11 @@ public final class Spigot_v1_14_R1 extends CachedBukkitAdapter implements Bukkit
|
||||
|
||||
@Override
|
||||
public void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTileEntityData(
|
||||
new BlockPosition(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()),
|
||||
7,
|
||||
(NBTTagCompound) fromNative(nbtData)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -606,7 +612,8 @@ public final class Spigot_v1_14_R1 extends CachedBukkitAdapter implements Bukkit
|
||||
|
||||
@Override
|
||||
public void sendFakeOP(Player player) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityStatus(
|
||||
((CraftPlayer) player).getHandle(), (byte) 28
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,15 @@
|
||||
package com.boydti.fawe.bukkit.wrapper;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.wrapper.state.AsyncSign;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.destroystokyo.paper.block.BlockSoundGroup;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -28,6 +24,10 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class AsyncBlock implements Block {
|
||||
|
||||
@ -70,27 +70,27 @@ public class AsyncBlock implements Block {
|
||||
return BlockTypes.getFromStateId(id).getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public AsyncBlock getRelative(int modX, int modY, int modZ) {
|
||||
return new AsyncBlock(world, queue, x + modX, y + modY, z + modZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public AsyncBlock getRelative(BlockFace face) {
|
||||
return this.getRelative(face.getModX(), face.getModY(), face.getModZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public AsyncBlock getRelative(BlockFace face, int distance) {
|
||||
return this.getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public Material getType() {
|
||||
return getBlockData().getMaterial();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public BlockData getBlockData() {
|
||||
return BukkitAdapter.getBlockData(queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId()));
|
||||
}
|
||||
@ -135,7 +135,7 @@ public class AsyncBlock implements Block {
|
||||
return (byte) queue.getEmmittedLight(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public AsyncWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
@ -155,7 +155,7 @@ public class AsyncBlock implements Block {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public Location getLocation() {
|
||||
return new Location(world, x, y, z);
|
||||
}
|
||||
@ -164,20 +164,20 @@ public class AsyncBlock implements Block {
|
||||
public Location getLocation(Location loc) {
|
||||
if(loc != null) {
|
||||
loc.setWorld(this.getWorld());
|
||||
loc.setX((double)this.x);
|
||||
loc.setY((double)this.y);
|
||||
loc.setZ((double)this.z);
|
||||
loc.setX(this.x);
|
||||
loc.setY(this.y);
|
||||
loc.setZ(this.z);
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public AsyncChunk getChunk() {
|
||||
return world.getChunkAt(x >> 4, z >> 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(BlockData blockData) {
|
||||
public void setBlockData(@NotNull BlockData blockData) {
|
||||
try {
|
||||
queue.setBlock(x, y, z, BukkitAdapter.adapt(blockData));
|
||||
} catch (WorldEditException e) {
|
||||
@ -186,12 +186,12 @@ public class AsyncBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(BlockData blockData, boolean b) {
|
||||
public void setBlockData(@NotNull BlockData blockData, boolean b) {
|
||||
setBlockData(blockData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Material type) {
|
||||
public void setType(@NotNull Material type) {
|
||||
try {
|
||||
queue.setBlock(x, y, z, BukkitAdapter.adapt(type).getDefaultState());
|
||||
} catch (WorldEditException e) {
|
||||
@ -200,12 +200,12 @@ public class AsyncBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Material type, boolean applyPhysics) {
|
||||
public void setType(@NotNull Material type, boolean applyPhysics) {
|
||||
setType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFace getFace(Block block) {
|
||||
public BlockFace getFace(@NotNull Block block) {
|
||||
BlockFace[] directions = BlockFace.values();
|
||||
for (BlockFace face : directions) {
|
||||
if (this.getX() + face.getModX() == block.getX()
|
||||
@ -217,7 +217,7 @@ public class AsyncBlock implements Block {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public AsyncBlockState getState() {
|
||||
int combined = queue.getCombinedId4Data(x, y, z, 0);
|
||||
BlockType type = BlockTypes.getFromStateId(combined);
|
||||
@ -231,12 +231,18 @@ public class AsyncBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public AsyncBlockState getState(boolean useSnapshot) {
|
||||
return getState();
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
public Biome getBiome() {
|
||||
return world.getAdapter().adapt(queue.getBiomeType(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(Biome bio) {
|
||||
public void setBiome(@NotNull Biome bio) {
|
||||
BiomeType biome = world.getAdapter().adapt(bio);
|
||||
queue.setBiome(x, z, biome);
|
||||
}
|
||||
@ -252,17 +258,17 @@ public class AsyncBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockFacePowered(BlockFace face) {
|
||||
public boolean isBlockFacePowered(@NotNull BlockFace face) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
|
||||
public boolean isBlockFaceIndirectlyPowered(@NotNull BlockFace face) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(BlockFace face) {
|
||||
public int getBlockPower(@NotNull BlockFace face) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -316,37 +322,37 @@ public class AsyncBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean breakNaturally(ItemStack tool) {
|
||||
public boolean breakNaturally(@NotNull ItemStack tool) {
|
||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public Collection<ItemStack> getDrops() {
|
||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops(ItemStack tool) {
|
||||
@NotNull @Override
|
||||
public Collection<ItemStack> getDrops(@NotNull ItemStack tool) {
|
||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops(tool));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) {
|
||||
this.getUnsafeBlock().setMetadata(metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||
@NotNull @Override
|
||||
public List<MetadataValue> getMetadata(@NotNull String metadataKey) {
|
||||
return this.getUnsafeBlock().getMetadata(metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
public boolean hasMetadata(@NotNull String metadataKey) {
|
||||
return this.getUnsafeBlock().hasMetadata(metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
|
||||
public void removeMetadata(@NotNull String metadataKey, @NotNull Plugin owningPlugin) {
|
||||
this.getUnsafeBlock().removeMetadata(metadataKey, owningPlugin);
|
||||
}
|
||||
|
||||
@ -356,12 +362,17 @@ public class AsyncBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTrace(Location arg0, Vector arg1, double arg2, FluidCollisionMode arg3) {
|
||||
public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2, @NotNull FluidCollisionMode arg3) {
|
||||
return this.getUnsafeBlock().rayTrace(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @Override
|
||||
public BoundingBox getBoundingBox() {
|
||||
return this.getUnsafeBlock().getBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull BlockSoundGroup getSoundGroup() {
|
||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getSoundGroup());
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import com.boydti.fawe.util.TaskManager;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AsyncChunk implements Chunk {
|
||||
|
||||
@ -130,18 +130,18 @@ public class AsyncChunk implements Chunk {
|
||||
});
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public BlockState[] getTileEntities(boolean b) {
|
||||
// if (!isLoaded()) {
|
||||
// return new BlockState[0];
|
||||
// }
|
||||
// return TaskManager.IMP.sync(new RunnableVal<BlockState[]>() {
|
||||
// @Override
|
||||
// public void run(BlockState[] value) {
|
||||
// this.value = world.getChunkAt(x, z).getTileEntities(b);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
@Override
|
||||
public @NotNull BlockState[] getTileEntities(boolean useSnapshot) {
|
||||
if (!isLoaded()) {
|
||||
return new BlockState[0];
|
||||
}
|
||||
return TaskManager.IMP.sync(new RunnableVal<BlockState[]>() {
|
||||
@Override
|
||||
public void run(BlockState[] value) {
|
||||
this.value = world.getChunkAt(x, z).getTileEntities(useSnapshot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
@ -163,7 +163,6 @@ public class AsyncChunk implements Chunk {
|
||||
return load(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unload(boolean save) {
|
||||
return world.unloadChunk(x, z, save);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import org.bukkit.OfflinePlayer;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -58,7 +59,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
Map<String, Set<String>> userGroupPermissions = new HashMap<>();
|
||||
|
||||
List<String> groupKeys = config.getStringList("permissions.groups", null);
|
||||
List<String> groupKeys = config.getKeys("permissions.groups");
|
||||
|
||||
if (groupKeys != null) {
|
||||
for (String key : groupKeys) {
|
||||
@ -76,7 +77,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> userKeys = config.getStringList("permissions.users", null);
|
||||
List<String> userKeys = config.getKeys("permissions.users");
|
||||
|
||||
if (userKeys != null) {
|
||||
for (String key : userKeys) {
|
||||
@ -102,8 +103,8 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
}
|
||||
|
||||
userPermissionsCache.put(key.toLowerCase(), permsCache);
|
||||
userGroups.put(key.toLowerCase(), new HashSet<>(groups));
|
||||
userPermissionsCache.put(key.toLowerCase(Locale.ROOT), permsCache);
|
||||
userGroups.put(key.toLowerCase(Locale.ROOT), new HashSet<>(groups));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,7 +118,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> perms = userPermissionsCache.get(player.toLowerCase());
|
||||
Set<String> perms = userPermissionsCache.get(player.toLowerCase(Locale.ROOT));
|
||||
if (perms == null) {
|
||||
return defaultPermissionsCache.contains(permission)
|
||||
|| defaultPermissionsCache.contains("*");
|
||||
@ -134,7 +135,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
@Override
|
||||
public boolean inGroup(String player, String group) {
|
||||
Set<String> groups = userGroups.get(player.toLowerCase());
|
||||
Set<String> groups = userGroups.get(player.toLowerCase(Locale.ROOT));
|
||||
if (groups == null) {
|
||||
return false;
|
||||
}
|
||||
@ -144,12 +145,12 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
@Override
|
||||
public String[] getGroups(String player) {
|
||||
Set<String> groups = userGroups.get(player.toLowerCase());
|
||||
Set<String> groups = userGroups.get(player.toLowerCase(Locale.ROOT));
|
||||
if (groups == null) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
return groups.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,13 +51,14 @@ import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Adapts between Bukkit and WorldEdit equivalent objects.
|
||||
*/
|
||||
public enum BukkitAdapter {
|
||||
INSTANCE
|
||||
;
|
||||
INSTANCE;
|
||||
|
||||
private final IBukkitAdapter adapter;
|
||||
|
||||
BukkitAdapter() {
|
||||
@ -73,14 +74,36 @@ public enum BukkitAdapter {
|
||||
return INSTANCE.adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks equality between a WorldEdit BlockType and a Bukkit Material
|
||||
*
|
||||
* @param blockType The WorldEdit BlockType
|
||||
* @param type The Bukkit Material
|
||||
* @return If they are equal
|
||||
*/
|
||||
public static boolean equals(BlockType blockType, Material type) {
|
||||
return getAdapter().equals(blockType, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert any WorldEdit world into an equivalent wrapped Bukkit world.
|
||||
*
|
||||
* <p>If a matching world cannot be found, a {@link RuntimeException}
|
||||
* will be thrown.</p>
|
||||
*
|
||||
* @param world the world
|
||||
* @return a wrapped Bukkit world
|
||||
*/
|
||||
public static BukkitWorld asBukkitWorld(World world) {
|
||||
return getAdapter().asBukkitWorld(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit world from a Bukkit world.
|
||||
*
|
||||
* @param world the Bukkit world
|
||||
* @return a WorldEdit world
|
||||
*/
|
||||
public static World adapt(org.bukkit.World world) {
|
||||
return getAdapter().adapt(world);
|
||||
}
|
||||
@ -89,23 +112,48 @@ public enum BukkitAdapter {
|
||||
return getAdapter().adapt(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit location from a Bukkit location.
|
||||
*
|
||||
* @param location the Bukkit location
|
||||
* @return a WorldEdit location
|
||||
*/
|
||||
public static Location adapt(org.bukkit.Location location) {
|
||||
checkNotNull(location);
|
||||
return getAdapter().adapt(location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit location from a WorldEdit location.
|
||||
*
|
||||
* @param location the WorldEdit location
|
||||
* @return a Bukkit location
|
||||
*/
|
||||
public static org.bukkit.Location adapt(Location location) {
|
||||
checkNotNull(location);
|
||||
return getAdapter().adapt(location);
|
||||
}
|
||||
|
||||
public static org.bukkit.Location adapt(org.bukkit.World world, Vector3 position) {
|
||||
return getAdapter().adapt(world, position);
|
||||
}
|
||||
|
||||
|
||||
public static org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) {
|
||||
checkNotNull(world);
|
||||
checkNotNull(position);
|
||||
return getAdapter().adapt(world, position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit location from a WorldEdit location with a Bukkit world.
|
||||
*
|
||||
* @param world the Bukkit world
|
||||
* @param location the WorldEdit location
|
||||
* @return a Bukkit location
|
||||
*/
|
||||
public static org.bukkit.Location adapt(org.bukkit.World world, Location location) {
|
||||
checkNotNull(world);
|
||||
checkNotNull(location);
|
||||
return getAdapter().adapt(world, location);
|
||||
}
|
||||
|
||||
@ -113,23 +161,57 @@ public enum BukkitAdapter {
|
||||
return getAdapter().asVector(location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit Vector from a Bukkit location.
|
||||
*
|
||||
* @param location The Bukkit location
|
||||
* @return a WorldEdit vector
|
||||
*/
|
||||
public static BlockVector3 asBlockVector(org.bukkit.Location location) {
|
||||
checkNotNull(location);
|
||||
return getAdapter().asBlockVector(location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit entity from a Bukkit entity.
|
||||
*
|
||||
* @param entity the Bukkit entity
|
||||
* @return a WorldEdit entity
|
||||
*/
|
||||
public static Entity adapt(org.bukkit.entity.Entity entity) {
|
||||
checkNotNull(entity);
|
||||
return getAdapter().adapt(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit Material form a WorldEdit ItemType
|
||||
*
|
||||
* @param itemType The WorldEdit ItemType
|
||||
* @return The Bukkit Material
|
||||
*/
|
||||
public static Material adapt(ItemType itemType) {
|
||||
checkNotNull(itemType);
|
||||
return getAdapter().adapt(itemType);
|
||||
}
|
||||
|
||||
public static Material adapt(BlockType blockType) {
|
||||
/**
|
||||
* Create a Bukkit Material form a WorldEdit BlockType
|
||||
*
|
||||
* @param blockType The WorldEdit BlockType
|
||||
* @return The Bukkit Material
|
||||
*/
|
||||
public static Material adapt(@NotNull BlockType blockType) {
|
||||
return getAdapter().adapt(blockType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit GameMode from a Bukkit one.
|
||||
*
|
||||
* @param gameMode Bukkit GameMode
|
||||
* @return WorldEdit GameMode
|
||||
*/
|
||||
public static GameMode adapt(org.bukkit.GameMode gameMode) {
|
||||
checkNotNull(gameMode);
|
||||
return getAdapter().adapt(gameMode);
|
||||
}
|
||||
|
||||
@ -161,15 +243,35 @@ public enum BukkitAdapter {
|
||||
return getAdapter().adapt(entityType);
|
||||
}
|
||||
|
||||
public static BlockType asBlockType(Material material) {
|
||||
/**
|
||||
* Converts a Material to a BlockType
|
||||
*
|
||||
* @param material The material
|
||||
* @return The blocktype
|
||||
*/
|
||||
public static BlockType asBlockType(@NotNull Material material) {
|
||||
return getAdapter().asBlockType(material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Material to a ItemType
|
||||
*
|
||||
* @param material The material
|
||||
* @return The itemtype
|
||||
*/
|
||||
public static ItemType asItemType(Material material) {
|
||||
checkNotNull(material);
|
||||
return getAdapter().asItemType(material);
|
||||
}
|
||||
|
||||
public static BlockState adapt(BlockData blockData) {
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BlockState from a Bukkit BlockData
|
||||
*
|
||||
* @param blockData The Bukkit BlockData
|
||||
* @return The WorldEdit BlockState
|
||||
*/
|
||||
public static BlockState adapt(@NotNull BlockData blockData) {
|
||||
return getAdapter().adapt(blockData);
|
||||
}
|
||||
|
||||
@ -183,7 +285,7 @@ public enum BukkitAdapter {
|
||||
* @param block The WorldEdit BlockStateHolder
|
||||
* @return The Bukkit BlockData
|
||||
*/
|
||||
public static <B extends BlockStateHolder<B>> BlockData adapt(B block) {
|
||||
public static BlockData adapt(@NotNull BlockStateHolder block) {
|
||||
return getAdapter().adapt(block);
|
||||
}
|
||||
|
||||
@ -191,15 +293,40 @@ public enum BukkitAdapter {
|
||||
return getAdapter().getBlockData(combinedId);
|
||||
}
|
||||
|
||||
public static BlockState asBlockState(ItemStack itemStack) {
|
||||
return getAdapter().asBlockState(itemStack);
|
||||
/**
|
||||
* Create a WorldEdit BlockState from a Bukkit ItemStack
|
||||
*
|
||||
* @param itemStack The Bukkit ItemStack
|
||||
* @return The WorldEdit BlockState
|
||||
*/
|
||||
public static BlockState asBlockState(ItemStack itemStack) throws WorldEditException {
|
||||
checkNotNull(itemStack);
|
||||
if (itemStack.getType().isBlock()) {
|
||||
return getAdapter().asBlockState(itemStack);
|
||||
} else {
|
||||
throw new NotABlockException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BaseItemStack from a Bukkit ItemStack
|
||||
*
|
||||
* @param itemStack The Bukkit ItemStack
|
||||
* @return The WorldEdit BaseItemStack
|
||||
*/
|
||||
public static BaseItemStack adapt(ItemStack itemStack) {
|
||||
checkNotNull(itemStack);
|
||||
return getAdapter().adapt(itemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit ItemStack from a WorldEdit BaseItemStack
|
||||
*
|
||||
* @param item The WorldEdit BaseItemStack
|
||||
* @return The Bukkit ItemStack
|
||||
*/
|
||||
public static ItemStack adapt(BaseItemStack item) {
|
||||
checkNotNull(item);
|
||||
return getAdapter().adapt(item);
|
||||
}
|
||||
|
||||
|
@ -19,28 +19,21 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.bekvon.bukkit.residence.commands.material;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.command.tool.BlockDataCyler;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
|
||||
|
@ -1,18 +1,6 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.world.registry.BundledItemRegistry;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class BukkitItemRegistry extends BundledItemRegistry {
|
||||
@Override
|
||||
public Collection<String> registerItems() {
|
||||
ArrayList<String> items = new ArrayList<>();
|
||||
for (Material m : Material.values()) {
|
||||
if (!m.isLegacy() && m.isItem()) items.add(m.getKey().getNamespace() + ":" + m.getKey().getKey());
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -41,7 +42,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -51,12 +51,11 @@ import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
private Player player;
|
||||
@ -109,8 +108,8 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
|
||||
inv.remove(newItem);
|
||||
}
|
||||
final ItemStack item = player.getItemInHand();
|
||||
player.setItemInHand(newItem);
|
||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
||||
player.getInventory().setItemInMainHand(newItem);
|
||||
HashMap<Integer, ItemStack> overflow = inv.addItem(item);
|
||||
if (!overflow.isEmpty()) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@ -168,13 +167,10 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
Extent extent = loc.getExtent();
|
||||
if (extent instanceof World) {
|
||||
org.bukkit.World world = Bukkit.getWorld(((World) extent).getName());
|
||||
// System.out.println("Teleport to world " + world);
|
||||
player.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));
|
||||
}
|
||||
}
|
||||
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),
|
||||
pos.getZ(), yaw, pitch));
|
||||
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw, pitch));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -216,7 +212,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
if (params.length > 0) {
|
||||
send = send + "|" + StringUtil.joinString(params, "|");
|
||||
}
|
||||
player.sendPluginMessage(plugin, WorldEditPlugin.getCuiPluginChannel(), send.getBytes(CUIChannelListener.UTF_8_CHARSET));
|
||||
player.sendPluginMessage(plugin, WorldEditPlugin.CUI_PLUGIN_CHANNEL, send.getBytes(CUIChannelListener.UTF_8_CHARSET));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
@ -305,7 +301,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
|
||||
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
|
||||
Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
|
||||
if (block == null) {
|
||||
player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());
|
||||
|
@ -38,7 +38,7 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
public BukkitPlayerBlockBag(Player player) {
|
||||
@ -56,13 +56,26 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
|
||||
|
||||
/**
|
||||
* Get the player.
|
||||
*
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseItem getItem(int slot) {
|
||||
loadInventory();
|
||||
return BukkitAdapter.adapt(items[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int slot, BaseItem block) {
|
||||
loadInventory();
|
||||
BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1);
|
||||
items[slot] = BukkitAdapter.adapt(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchBlock(BlockState blockState) throws BlockBagException {
|
||||
if (blockState.getBlockType().getMaterial().isAir()) {
|
||||
@ -182,16 +195,4 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
|
||||
public void addSingleSourcePosition(Location pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseItem getItem(int slot) {
|
||||
loadInventory();
|
||||
return BukkitAdapter.adapt(items[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int slot, BaseItem block) {
|
||||
loadInventory();
|
||||
BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1);
|
||||
items[slot] = BukkitAdapter.adapt(stack);
|
||||
}
|
||||
}
|
||||
|
@ -36,14 +36,13 @@ import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitServerInterface implements MultiUserPlatform {
|
||||
public Server server;
|
||||
public WorldEditPlugin plugin;
|
||||
@ -100,7 +99,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
return player;
|
||||
} else {
|
||||
org.bukkit.entity.Player bukkitPlayer = server.getPlayerExact(player.getName());
|
||||
return bukkitPlayer != null ? plugin.wrapPlayer(bukkitPlayer) : null;
|
||||
return bukkitPlayer != null ? WorldEditPlugin.getInstance().wrapPlayer(bukkitPlayer) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +118,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
public void registerCommands(Dispatcher dispatcher) {
|
||||
List<CommandInfo> toRegister = new ArrayList<>();
|
||||
BukkitCommandInspector inspector = new BukkitCommandInspector(plugin, dispatcher);
|
||||
|
||||
|
||||
for (CommandMapping command : dispatcher.getCommands()) {
|
||||
Description description = command.getDescription();
|
||||
List<String> permissions = description.getPermissions();
|
||||
@ -177,7 +176,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
public Collection<Actor> getConnectedUsers() {
|
||||
List<Actor> users = new ArrayList<>();
|
||||
for (org.bukkit.entity.Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
users.add(plugin.wrapPlayer(player));
|
||||
users.add(WorldEditPlugin.getInstance().wrapPlayer(player));
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
@ -18,11 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -38,7 +38,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
@ -57,7 +56,6 @@ import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
|
@ -24,13 +24,14 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* Handles incoming WorldEditCui init message.
|
||||
*/
|
||||
public class CUIChannelListener implements PluginMessageListener {
|
||||
|
||||
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
|
||||
public static final Charset UTF_8_CHARSET = StandardCharsets.UTF_8;
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public CUIChannelListener(WorldEditPlugin plugin) {
|
||||
|
@ -1,52 +0,0 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DelegateEntity implements Entity {
|
||||
private final Entity parent;
|
||||
|
||||
public DelegateEntity(Entity parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Entity getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BaseEntity getState() {
|
||||
return parent.getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return parent.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extent getExtent() {
|
||||
return parent.getExtent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove() {
|
||||
return parent.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getFacet(Class<? extends T> cls) {
|
||||
return parent.getFacet(cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setLocation(Location location) {
|
||||
return parent.setLocation(location);
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
@Override
|
||||
public boolean setBlockData(int x, int y, int z, BlockData blockData) {
|
||||
try {
|
||||
editSession.setBlock(BlockVector3.at(x, y, z), BukkitAdapter.adapt(blockData));
|
||||
editSession.setBlock(x, y, z, BukkitAdapter.adapt(blockData));
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
return false;
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(int x, int y, int z) {
|
||||
return BukkitAdapter.adapt(editSession.getBlock(BlockVector3.at(x, y, z)));
|
||||
return BukkitAdapter.adapt(editSession.getBlock(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,7 +59,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(int x, int y, int z) {
|
||||
return editSession.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir();
|
||||
return editSession.getBlock(x, y, z).getBlockType().getMaterial().isAir();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -109,15 +109,15 @@ public class WorldEditListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerCommand(PlayerCommandSendEvent event) {
|
||||
CommandLocals locals = new CommandLocals();
|
||||
locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer()));
|
||||
Dispatcher dispatcher = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher();
|
||||
if (dispatcher != null) {
|
||||
Set<String> toRemove = dispatcher.getCommands().stream()
|
||||
.filter(commandMapping -> !commandMapping.getCallable().testPermission(locals))
|
||||
.map(CommandMapping::getPrimaryAlias)
|
||||
.collect(Collectors.toSet());
|
||||
event.getCommands().removeIf(toRemove::contains);
|
||||
CommandLocals locals = new CommandLocals();
|
||||
locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer()));
|
||||
Set<String> toRemove = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher().getCommands().stream()
|
||||
.filter(commandMapping -> !commandMapping.getCallable().testPermission(locals))
|
||||
.map(CommandMapping::getPrimaryAlias)
|
||||
.collect(Collectors.toSet());
|
||||
event.getCommands().removeIf(toRemove::contains);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,14 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.bekvon.bukkit.residence.commands.message;
|
||||
import com.bekvon.bukkit.residence.containers.cmd;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -34,38 +37,30 @@ import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.item.ItemCategory;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -85,8 +80,6 @@ import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Plugin for Bukkit.
|
||||
*/
|
||||
@ -102,39 +95,38 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
|
||||
private static Map<String, Plugin> lookupNames;
|
||||
static {
|
||||
{ // Disable AWE as otherwise both fail to load
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
try {
|
||||
Field pluginsField = manager.getClass().getDeclaredField("plugins");
|
||||
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
|
||||
pluginsField.setAccessible(true);
|
||||
lookupNamesField.setAccessible(true);
|
||||
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
|
||||
lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
|
||||
pluginsField.set(manager, plugins = new ArrayList<Plugin>(plugins) {
|
||||
@Override
|
||||
public boolean add(Plugin plugin) {
|
||||
if (plugin.getName().startsWith("AsyncWorldEdit")) {
|
||||
Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible");
|
||||
} else if (plugin.getName().startsWith("BetterShutdown")) {
|
||||
Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible (Improperly shaded classes from com.sk89q.minecraft.util.commands)");
|
||||
} else {
|
||||
return super.add(plugin);
|
||||
}
|
||||
return false;
|
||||
// Disable AWE as otherwise both fail to load
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
try {
|
||||
Field pluginsField = manager.getClass().getDeclaredField("plugins");
|
||||
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
|
||||
pluginsField.setAccessible(true);
|
||||
lookupNamesField.setAccessible(true);
|
||||
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
|
||||
lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
|
||||
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
|
||||
@Override
|
||||
public boolean add(Plugin plugin) {
|
||||
if (plugin.getName().startsWith("AsyncWorldEdit")) {
|
||||
Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible");
|
||||
} else if (plugin.getName().startsWith("BetterShutdown")) {
|
||||
Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible (Improperly shaded classes from com.sk89q.minecraft.util.commands)");
|
||||
} else {
|
||||
return super.add(plugin);
|
||||
}
|
||||
});
|
||||
lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap<String, Plugin>(lookupNames) {
|
||||
@Override
|
||||
public Plugin put(String key, Plugin plugin) {
|
||||
if (plugin.getName().startsWith("AsyncWorldEdit") || plugin.getName().startsWith("BetterShutdown")) {
|
||||
return null;
|
||||
}
|
||||
return super.put(key, plugin);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap<String, Plugin>(lookupNames) {
|
||||
@Override
|
||||
public Plugin put(@NotNull String key, @NotNull Plugin plugin) {
|
||||
if (plugin.getName().startsWith("AsyncWorldEdit") || plugin.getName().startsWith("BetterShutdown")) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (Throwable ignore) {}
|
||||
}
|
||||
return super.put(key, plugin);
|
||||
}
|
||||
});
|
||||
} catch (Throwable ignore) {}
|
||||
}
|
||||
|
||||
public WorldEditPlugin() {
|
||||
@ -157,15 +149,11 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
public static String getCuiPluginChannel() {
|
||||
return CUI_PLUGIN_CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
if (INSTANCE != null) return;
|
||||
rename();
|
||||
this.INSTANCE = this;
|
||||
INSTANCE = this;
|
||||
FaweBukkit imp = new FaweBukkit(this);
|
||||
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
@ -190,6 +178,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
if (INSTANCE != null) return;
|
||||
onLoad();
|
||||
setupTags(); // these have to be done post-world since they rely on MC registries. the other ones just use Bukkit enums
|
||||
//TODO: FAWE -- This needs to be moved to onLoad()
|
||||
setupRegistries();
|
||||
WorldEdit.getInstance().loadMappings();
|
||||
|
||||
@ -197,8 +186,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
|
||||
// Register CUI
|
||||
fail(() -> {
|
||||
getServer().getMessenger().registerIncomingPluginChannel(INSTANCE, CUI_PLUGIN_CHANNEL, new CUIChannelListener(INSTANCE));
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(INSTANCE, CUI_PLUGIN_CHANNEL);
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
|
||||
}, "Failed to register CUI");
|
||||
|
||||
// Now we can register events
|
||||
@ -209,12 +198,11 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
// platforms to be worried about... at the current time of writing
|
||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
||||
|
||||
{ // Register 1.13 Material ids with LegacyMapper
|
||||
LegacyMapper legacyMapper = LegacyMapper.getInstance();
|
||||
for (Material m : Material.values()) {
|
||||
if (!m.isLegacy() && m.isBlock()) {
|
||||
legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
|
||||
}
|
||||
// Register 1.13 Material ids with LegacyMapper
|
||||
LegacyMapper legacyMapper = LegacyMapper.getInstance();
|
||||
for (Material m : Material.values()) {
|
||||
if (!m.isLegacy() && m.isBlock()) {
|
||||
legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -226,28 +214,30 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
}
|
||||
// Block & Item
|
||||
for (Material material : Material.values()) {
|
||||
// if (material.isBlock() && !material.isLegacy()) {
|
||||
// BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
|
||||
// // TODO Use something way less hacky than this.
|
||||
// ParserContext context = new ParserContext();
|
||||
// context.setPreferringWildcard(true);
|
||||
// context.setTryLegacy(false);
|
||||
// context.setRestricted(false);
|
||||
// try {
|
||||
// FuzzyBlockState state = (FuzzyBlockState) WorldEdit.getInstance().getBlockFactory().parseFromInput(
|
||||
// BukkitAdapter.adapt(blockState.getBlockType()).createBlockData().getAsString(), context
|
||||
// ).toImmutableState();
|
||||
// BlockState defaultState = blockState.getBlockType().getAllStates().get(0);
|
||||
// for (Map.Entry<Property<?>, Object> propertyObjectEntry : state.getStates().entrySet()) {
|
||||
// defaultState = defaultState.with((Property) propertyObjectEntry.getKey(), propertyObjectEntry.getValue());
|
||||
// }
|
||||
// return defaultState;
|
||||
// } catch (InputParseException e) {
|
||||
// e.printStackTrace();
|
||||
// return blockState;
|
||||
// }
|
||||
// }));
|
||||
// }
|
||||
/*
|
||||
if (material.isBlock() && !material.isLegacy()) {
|
||||
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
|
||||
// TODO Use something way less hacky than this.
|
||||
ParserContext context = new ParserContext();
|
||||
context.setPreferringWildcard(true);
|
||||
context.setTryLegacy(false);
|
||||
context.setRestricted(false);
|
||||
try {
|
||||
FuzzyBlockState state = (FuzzyBlockState) WorldEdit.getInstance().getBlockFactory().parseFromInput(
|
||||
BukkitAdapter.adapt(blockState.getBlockType()).createBlockData().getAsString(), context
|
||||
).toImmutableState();
|
||||
BlockState defaultState = blockState.getBlockType().getAllStates().get(0);
|
||||
for (Map.Entry<Property<?>, Object> propertyObjectEntry : state.getStates().entrySet()) {
|
||||
defaultState = defaultState.with((Property) propertyObjectEntry.getKey(), propertyObjectEntry.getValue());
|
||||
}
|
||||
return defaultState;
|
||||
} catch (InputParseException e) {
|
||||
e.printStackTrace();
|
||||
return blockState;
|
||||
}
|
||||
}));
|
||||
}
|
||||
*/
|
||||
if (material.isItem() && !material.isLegacy()) {
|
||||
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
|
||||
}
|
||||
@ -276,63 +266,29 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
}
|
||||
|
||||
private void rename() {
|
||||
// {
|
||||
// PluginDescriptionFile desc = getDescription();
|
||||
// if (desc != null) {
|
||||
// try {
|
||||
// Field nameField = PluginDescriptionFile.class.getDeclaredField("name");
|
||||
// nameField.setAccessible(true);
|
||||
// nameField.set(desc, "FastAsyncWorldEdit");
|
||||
// Field descriptionField = JavaPlugin.class.getDeclaredField("description");
|
||||
// descriptionField.setAccessible(true);
|
||||
// descriptionField.set(this, desc);
|
||||
// } catch (Throwable ignore) {
|
||||
// ignore.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
{
|
||||
File dir = getDataFolder();
|
||||
if (dir != null) {
|
||||
dir = new File(dir.getParentFile(), "FastAsyncWorldEdit");
|
||||
try {
|
||||
Field descriptionField = JavaPlugin.class.getDeclaredField("dataFolder");
|
||||
descriptionField.setAccessible(true);
|
||||
descriptionField.set(this, dir);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
}
|
||||
File dir = new File(getDataFolder().getParentFile(), "FastAsyncWorldEdit");
|
||||
try {
|
||||
Field descriptionField = JavaPlugin.class.getDeclaredField("dataFolder");
|
||||
descriptionField.setAccessible(true);
|
||||
descriptionField.set(this, dir);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
// {
|
||||
// Logger logger = getLogger();
|
||||
// if (logger != null) {
|
||||
// try {
|
||||
// Field nameField = Logger.class.getDeclaredField("name");
|
||||
// nameField.setAccessible(true);
|
||||
// nameField.set(logger, "FastAsyncWorldEdit");
|
||||
// } catch (Throwable ignore) {
|
||||
// ignore.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
{
|
||||
File pluginsFolder = MainUtil.getJarFile().getParentFile();
|
||||
for (File file : pluginsFolder.listFiles()) {
|
||||
if (file.length() == 1988) return;
|
||||
}
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit");
|
||||
File dummy = MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "DummyFawe.jar");
|
||||
if (dummy != null && dummy.exists() && plugin == this) {
|
||||
try {
|
||||
Bukkit.getPluginManager().loadPlugin(dummy);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
getLogger().info("Please restart the server if you have any plugins which depend on FAWE.");
|
||||
} else if (dummy == null) {
|
||||
MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "update" + File.separator + "DummyFawe.jar");
|
||||
File pluginsFolder = MainUtil.getJarFile().getParentFile();
|
||||
for (File file : pluginsFolder.listFiles()) {
|
||||
if (file.length() == 2016) return;
|
||||
}
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit");
|
||||
File dummy = MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "DummyFawe.jar");
|
||||
if (dummy != null && dummy.exists() && plugin == this) {
|
||||
try {
|
||||
Bukkit.getPluginManager().loadPlugin(dummy);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
getLogger().info("Please restart the server if you have any plugins which depend on FAWE.");
|
||||
} else if (dummy == null) {
|
||||
MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "update" + File.separator + "DummyFawe.jar");
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,20 +426,20 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
return true;
|
||||
}
|
||||
|
||||
// @Deprecated Using Async tab complete (rather than main thread)
|
||||
// @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] = cmd.getName();
|
||||
//
|
||||
// CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), Joiner.on(" ").join(split));
|
||||
// getWorldEdit().getEventBus().post(event);
|
||||
//
|
||||
// return event.getSuggestions();
|
||||
// }
|
||||
/*
|
||||
@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] = cmd.getName();
|
||||
|
||||
CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), Joiner.on(" ").join(split));
|
||||
getWorldEdit().getEventBus().post(event);
|
||||
return event.getSuggestions();
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
|
@ -29,6 +29,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public interface IBukkitAdapter {
|
||||
|
||||
/**
|
||||
* Checks equality between a WorldEdit BlockType and a Bukkit Material
|
||||
*
|
||||
@ -101,7 +102,7 @@ public interface IBukkitAdapter {
|
||||
default Location adapt(org.bukkit.Location location) {
|
||||
checkNotNull(location);
|
||||
Vector3 position = asVector(location);
|
||||
return new com.sk89q.worldedit.util.Location(
|
||||
return new Location(
|
||||
adapt(location.getWorld()),
|
||||
position,
|
||||
location.getYaw(),
|
||||
@ -138,7 +139,7 @@ public interface IBukkitAdapter {
|
||||
world,
|
||||
position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
|
||||
default org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position){
|
||||
return adapt(world, position.toVector3());
|
||||
}
|
||||
@ -170,7 +171,7 @@ public interface IBukkitAdapter {
|
||||
checkNotNull(location);
|
||||
return Vector3.at(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BlockVector from a Bukkit location.
|
||||
*
|
||||
|
Binary file not shown.
@ -3,7 +3,7 @@
|
||||
#
|
||||
# About editing this file:
|
||||
# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain and post
|
||||
# errors. If you use an editor, like Notepad++ (recommended for Windows
|
||||
# errors. If you use an editor, like Notepad++ (recommended for Windows
|
||||
# users), you must configure it to "replace tabs with spaces."
|
||||
# This can be changed in Settings > Preferences > Language Menu.
|
||||
# - Don't get rid of indentations. They are indented so some entries that are
|
||||
@ -30,8 +30,6 @@ limits:
|
||||
butcher-radius:
|
||||
default: -1
|
||||
maximum: -1
|
||||
# Use either block ids, names, or regex
|
||||
# Regex supports properties as well (see FAWE mask documentation)
|
||||
disallowed-blocks: []
|
||||
|
||||
use-inventory:
|
||||
|
Reference in New Issue
Block a user