Propagate FAWE diff annotations down the bukkit module

- Minor upstream merge
This commit is contained in:
NotMyFault
2021-07-14 14:40:20 +02:00
parent d7763c8542
commit bcceadee6b
34 changed files with 450 additions and 159 deletions

View File

@ -16,7 +16,7 @@ import com.fastasyncworldedit.bukkit.regions.GriefPreventionFeature;
import com.fastasyncworldedit.bukkit.regions.GriefDefenderFeature;
import com.fastasyncworldedit.bukkit.regions.ResidenceFeature;
import com.fastasyncworldedit.bukkit.regions.TownyFeature;
import com.fastasyncworldedit.bukkit.regions.Worldguard;
import com.fastasyncworldedit.bukkit.regions.WorldGuardFeature;
import com.fastasyncworldedit.bukkit.util.BukkitTaskManager;
import com.fastasyncworldedit.bukkit.util.ItemUtil;
import com.fastasyncworldedit.bukkit.util.MinecraftVersion;
@ -190,7 +190,7 @@ public class FaweBukkit implements IFawe, Listener {
final ArrayList<FaweMaskManager> managers = new ArrayList<>();
if (worldguardPlugin != null && worldguardPlugin.isEnabled()) {
try {
managers.add(new Worldguard(worldguardPlugin));
managers.add(new WorldGuardFeature(worldguardPlugin));
LOGGER.info("Attempting to use plugin 'WorldGuard'");
} catch (Throwable ignored) {
}

View File

@ -1,7 +1,5 @@
package com.fastasyncworldedit.bukkit.adapter;
import com.destroystokyo.paper.util.ReentrantLockWithGetOwner;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;

View File

@ -5,7 +5,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitEntity;
import com.sk89q.worldedit.bukkit.BukkitItemStack;
import com.fastasyncworldedit.bukkit.util.BukkitItemStack;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;

View File

@ -0,0 +1,11 @@
package com.fastasyncworldedit.bukkit.adapter;
import java.util.concurrent.locks.ReentrantLock;
public class ReentrantLockWithGetOwner extends ReentrantLock {
@Override
public Thread getOwner() {
return super.getOwner();
}
}

View File

@ -37,7 +37,7 @@ public class WorldGuardFilter extends CuboidRegionFilter {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
if (max.getBlockX() - min.getBlockX() > 1024 || max.getBlockZ() - min.getBlockZ() > 1024) {
LOGGER.debug("Large or complex region shapes cannot be optimized. Filtering will be slower");
LOGGER.info("Large or complex region shapes cannot be optimized. Filtering will be slower");
large = true;
break;
}

View File

@ -25,7 +25,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
super(residencePlugin.getName());
this.residence = residencePlugin;
this.plugin = p3;
LOGGER.debug("Plugin 'Residence' found. Using it now.");
LOGGER.info("Plugin 'Residence' found. Using it now.");
}
public boolean isAllowed(Player player, ClaimedResidence residence, MaskType type) {

View File

@ -29,7 +29,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
public TownyFeature(Plugin townyPlugin) {
super(townyPlugin.getName());
this.towny = townyPlugin;
LOGGER.debug("Plugin 'Towny' found. Using it now.");
LOGGER.info("Plugin 'Towny' found. Using it now.");
}
public boolean isAllowed(Player player, TownBlock block) {

View File

@ -30,7 +30,7 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import java.util.Locale;
public class Worldguard extends BukkitMaskManager implements Listener {
public class WorldGuardFeature extends BukkitMaskManager implements Listener {
private final WorldGuardPlugin worldguard;
private static final Logger LOGGER = LogManagerCompat.getLogger();
@ -45,10 +45,10 @@ public class Worldguard extends BukkitMaskManager implements Listener {
return (WorldGuardPlugin) plugin;
}
public Worldguard(Plugin p2) {
public WorldGuardFeature(Plugin p2) {
super(p2.getName());
this.worldguard = this.getWorldGuard();
LOGGER.debug("Plugin 'WorldGuard' found. Using it now.");
LOGGER.info("Plugin 'WorldGuard' found. Using it now.");
}

View File

@ -0,0 +1,78 @@
package com.fastasyncworldedit.bukkit.util;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.bukkit.FaweBukkit;
import com.fastasyncworldedit.bukkit.util.ItemUtil;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.item.ItemType;
import org.bukkit.inventory.ItemStack;
import javax.annotation.Nullable;
public class BukkitItemStack extends BaseItemStack {
private ItemStack stack;
private Object nativeItem;
private boolean loadedNBT;
public BukkitItemStack(ItemStack stack) {
super(BukkitAdapter.asItemType(stack.getType()));
this.stack = stack;
}
public BukkitItemStack(ItemType type, ItemStack stack) {
super(type);
this.stack = stack;
}
@Override
public int getAmount() {
return stack.getAmount();
}
@Nullable
@Override
public Object getNativeItem() {
ItemUtil util = Fawe.<FaweBukkit>imp().getItemUtil();
if (util != null && nativeItem == null) {
return nativeItem = util.getNMSItem(stack);
}
return nativeItem;
}
public ItemStack getBukkitItemStack() {
return stack;
}
@Override
public boolean hasNbtData() {
if (!loadedNBT) {
return stack.hasItemMeta();
}
return super.hasNbtData();
}
@Nullable
@Override
public CompoundTag getNbtData() {
if (!loadedNBT) {
loadedNBT = true;
ItemUtil util = Fawe.<FaweBukkit>imp().getItemUtil();
if (util != null) {
super.setNbtData(util.getNBT(stack));
}
}
return super.getNbtData();
}
@Override
public void setNbtData(@Nullable CompoundTag nbtData) {
ItemUtil util = Fawe.<FaweBukkit>imp().getItemUtil();
if (util != null) {
stack = util.setNBT(stack, nbtData);
nativeItem = null;
}
super.setNbtData(nbtData);
}
}

View File

@ -0,0 +1,36 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.fastasyncworldedit.bukkit.util;
import com.fastasyncworldedit.core.configuration.Caption;
import com.sk89q.worldedit.WorldEditException;
/**
* Thrown if the world has been unloaded.
*/
public class WorldUnloadedException extends WorldEditException {
/**
* Create a new instance.
*/
public WorldUnloadedException() {
super(Caption.of("worldedit.error.world-unloaded"));
}
}