mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 19:06:41 +00:00
Merge branch 'IntellectualSites:main' into main
This commit is contained in:
@ -202,8 +202,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
}
|
||||
try {
|
||||
// Non-Paper
|
||||
SERVER_LEVEL_ENTITY_MANAGER = ServerLevel.class.getDeclaredField("entityManager");
|
||||
LEVEL_CHUNK_ENTITIES.setAccessible(true);
|
||||
SERVER_LEVEL_ENTITY_MANAGER = ServerLevel.class.getDeclaredField(Refraction.pickName("entityManager", "P"));
|
||||
SERVER_LEVEL_ENTITY_MANAGER.setAccessible(true);
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
POST_CHUNK_REWRITE = chunkRewrite;
|
||||
|
@ -199,8 +199,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
}
|
||||
try {
|
||||
// Non-Paper
|
||||
SERVER_LEVEL_ENTITY_MANAGER = ServerLevel.class.getDeclaredField("entityManager");
|
||||
LEVEL_CHUNK_ENTITIES.setAccessible(true);
|
||||
SERVER_LEVEL_ENTITY_MANAGER = ServerLevel.class.getDeclaredField(Refraction.pickName("entityManager", "P"));
|
||||
SERVER_LEVEL_ENTITY_MANAGER.setAccessible(true);
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
POST_CHUNK_REWRITE = chunkRewrite;
|
||||
|
@ -204,8 +204,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
}
|
||||
try {
|
||||
// Non-Paper
|
||||
SERVER_LEVEL_ENTITY_MANAGER = ServerLevel.class.getDeclaredField("entityManager");
|
||||
LEVEL_CHUNK_ENTITIES.setAccessible(true);
|
||||
SERVER_LEVEL_ENTITY_MANAGER = ServerLevel.class.getDeclaredField(Refraction.pickName("entityManager", "L"));
|
||||
SERVER_LEVEL_ENTITY_MANAGER.setAccessible(true);
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
POST_CHUNK_REWRITE = chunkRewrite;
|
||||
|
@ -182,8 +182,8 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
||||
CraftServer.class.cast(Bukkit.getServer());
|
||||
|
||||
int dataVersion = CraftMagicNumbers.INSTANCE.getDataVersion();
|
||||
if (dataVersion != 3463) {
|
||||
throw new UnsupportedClassVersionError("Not 1.20!");
|
||||
if (dataVersion != 3463 && dataVersion != 3465) {
|
||||
throw new UnsupportedClassVersionError("Not 1.20(.1)!");
|
||||
}
|
||||
|
||||
serverWorldsField = CraftServer.class.getDeclaredField("worlds");
|
||||
|
@ -211,7 +211,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
||||
try {
|
||||
// Non-Paper
|
||||
SERVER_LEVEL_ENTITY_MANAGER = ServerLevel.class.getDeclaredField(Refraction.pickName("entityManager", "M"));
|
||||
LEVEL_CHUNK_ENTITIES.setAccessible(true);
|
||||
SERVER_LEVEL_ENTITY_MANAGER.setAccessible(true);
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
POST_CHUNK_REWRITE = chunkRewrite;
|
||||
|
@ -2,9 +2,7 @@ package com.fastasyncworldedit.bukkit.regions;
|
||||
|
||||
import com.fastasyncworldedit.core.regions.FaweMask;
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import com.palmergames.bukkit.towny.TownyUniverse;
|
||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.object.PlayerCache;
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||
@ -36,31 +34,27 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
Resident resident;
|
||||
try {
|
||||
resident = TownyUniverse.getInstance().getResident(player.getName());
|
||||
try {
|
||||
if (block.getResident().equals(resident)) {
|
||||
return true;
|
||||
}
|
||||
} catch (NotRegisteredException ignored) {
|
||||
}
|
||||
Town town = block.getTown();
|
||||
if (town.isMayor(resident)) {
|
||||
Resident resident = TownyAPI.getInstance().getResident(player);
|
||||
if (resident == null) {
|
||||
return false;
|
||||
}
|
||||
if (block.hasResident(resident) || block.hasTrustedResident(resident)) {
|
||||
return true;
|
||||
}
|
||||
Town town = block.getTownOrNull(); // Will not be null, because block is not null.
|
||||
if (town.isMayor(resident) || town.hasTrustedResident(resident)) {
|
||||
return true;
|
||||
}
|
||||
if (!town.hasResident(resident)) {
|
||||
return false;
|
||||
}
|
||||
if (player.hasPermission("fawe.towny.*")) {
|
||||
return true;
|
||||
}
|
||||
for (String rank : resident.getTownRanks()) {
|
||||
if (player.hasPermission("fawe.towny." + rank)) {
|
||||
return true;
|
||||
}
|
||||
if (!town.hasResident(resident)) {
|
||||
return false;
|
||||
}
|
||||
if (player.hasPermission("fawe.towny.*")) {
|
||||
return true;
|
||||
}
|
||||
for (String rank : resident.getTownRanks()) {
|
||||
if (player.hasPermission("fawe.towny." + rank)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (NotRegisteredException ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -69,32 +63,23 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||
public FaweMask getMask(final com.sk89q.worldedit.entity.Player wePlayer, MaskType type, boolean isWhitelist) {
|
||||
final Player player = BukkitAdapter.adapt(wePlayer);
|
||||
final Location location = player.getLocation();
|
||||
try {
|
||||
final PlayerCache cache = ((Towny) this.towny).getCache(player);
|
||||
final WorldCoord mycoord = cache.getLastTownBlock();
|
||||
if (mycoord == null) {
|
||||
return null;
|
||||
}
|
||||
final TownBlock myplot = mycoord.getTownBlock();
|
||||
if (myplot == null) {
|
||||
return null;
|
||||
}
|
||||
boolean isMember = isAllowed(player, myplot);
|
||||
if (isMember) {
|
||||
final Chunk chunk = location.getChunk();
|
||||
final BlockVector3 pos1 = BlockVector3
|
||||
.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
|
||||
final BlockVector3 pos2 = BlockVector3.at(
|
||||
chunk.getX() * 16 + 15, 156, chunk.getZ() * 16
|
||||
+ 15);
|
||||
return new FaweMask(new CuboidRegion(pos1, pos2)) {
|
||||
@Override
|
||||
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
||||
return isAllowed(BukkitAdapter.adapt(player), myplot);
|
||||
}
|
||||
};
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
final WorldCoord mycoord = WorldCoord.parseWorldCoord(location);
|
||||
if (mycoord.isWilderness()) {
|
||||
return null;
|
||||
}
|
||||
final TownBlock myplot = mycoord.getTownBlockOrNull(); // Will not be null, because of the isWilderness() test above.
|
||||
boolean isMember = isAllowed(player, myplot);
|
||||
if (isMember) {
|
||||
final Location loc1 = mycoord.getLowerMostCornerLocation();
|
||||
final Location loc2 = mycoord.getUpperMostCornerLocation();
|
||||
final BlockVector3 pos1 = BlockVector3.at(loc1.getX(), loc1.getY(), loc1.getZ());
|
||||
final BlockVector3 pos2 = BlockVector3.at(loc2.getX(), loc2.getY(), loc2.getZ());
|
||||
return new FaweMask(new CuboidRegion(pos1, pos2)) {
|
||||
@Override
|
||||
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
||||
return isAllowed(BukkitAdapter.adapt(player), myplot);
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.util.WorldUnloadedException;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.internal.exception.FaweException;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
|
||||
@ -242,6 +244,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public int getBlockLightLevel(BlockVector3 pt) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(pt);
|
||||
//FAWE end
|
||||
return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel();
|
||||
}
|
||||
|
||||
@ -265,6 +270,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
@Override
|
||||
public boolean clearContainerBlockContents(BlockVector3 pt) {
|
||||
checkNotNull(pt);
|
||||
//FAWE start - safe edit region
|
||||
testCoords(pt);
|
||||
//FAWE end
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
try {
|
||||
@ -337,6 +345,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
@Override
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 pt) {
|
||||
//FAWE start - allow tree commands to be undone and obey region restrictions
|
||||
testCoords(pt);
|
||||
return WorldEditPlugin.getInstance().getBukkitImplAdapter().generateTree(type, editSession, pt, getWorld());
|
||||
//FAWE end
|
||||
}
|
||||
@ -349,6 +358,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public void checkLoadedChunk(BlockVector3 pt) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(pt);
|
||||
//FAWE end
|
||||
World world = getWorld();
|
||||
//FAWE start
|
||||
int X = pt.getBlockX() >> 4;
|
||||
@ -480,6 +492,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public void simulateBlockMine(BlockVector3 pt) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(pt);
|
||||
//FAWE end
|
||||
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally();
|
||||
}
|
||||
|
||||
@ -493,6 +508,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public boolean canPlaceAt(BlockVector3 position, com.sk89q.worldedit.world.block.BlockState blockState) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(position);
|
||||
//FAWE end
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
return adapter.canPlaceAt(getWorld(), position, blockState);
|
||||
@ -505,6 +523,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(position);
|
||||
//FAWE end
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
try {
|
||||
@ -526,6 +547,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(position);
|
||||
//FAWE end
|
||||
if (worldNativeAccess != null) {
|
||||
try {
|
||||
return worldNativeAccess.setBlock(position, block, sideEffects);
|
||||
@ -545,6 +569,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(position);
|
||||
//FAWE end
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
return adapter.getFullBlock(BukkitAdapter.adapt(getWorld(), position));
|
||||
@ -553,11 +580,25 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
}
|
||||
|
||||
private void testCoords(BlockVector3 position) throws FaweException {
|
||||
if (!Settings.settings().REGION_RESTRICTIONS_OPTIONS.RESTRICT_TO_SAFE_RANGE) {
|
||||
return;
|
||||
}
|
||||
int x = position.getX();
|
||||
int z = position.getZ();
|
||||
if (x > 30000000 || z > 30000000 || x < -30000000 || z < -30000000) {
|
||||
throw FaweCache.OUTSIDE_SAFE_REGION;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SideEffect> applySideEffects(
|
||||
BlockVector3 position, com.sk89q.worldedit.world.block.BlockState previousType,
|
||||
SideEffectSet sideEffectSet
|
||||
) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(position);
|
||||
//FAWE end
|
||||
if (worldNativeAccess != null) {
|
||||
worldNativeAccess.applySideEffects(position, previousType, sideEffectSet);
|
||||
return Sets.intersection(
|
||||
@ -571,6 +612,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(position);
|
||||
//FAWE end
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
return adapter.simulateItemUse(getWorld(), position, item, face);
|
||||
@ -588,6 +632,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(position);
|
||||
//FAWE end
|
||||
if (HAS_3D_BIOMES) {
|
||||
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
|
||||
} else {
|
||||
@ -598,6 +645,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
//FAWE start - safe edit region
|
||||
testCoords(position);
|
||||
//FAWE end
|
||||
if (HAS_3D_BIOMES) {
|
||||
getWorld().setBiome(position.getBlockX(), position.getBlockY(), position.getBlockZ(), BukkitAdapter.adapt(biome));
|
||||
} else {
|
||||
@ -626,11 +676,13 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public void refreshChunk(int chunkX, int chunkZ) {
|
||||
testCoords(BlockVector3.at(chunkX << 4, 0, chunkZ << 4));
|
||||
getWorld().refreshChunk(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkGet get(int chunkX, int chunkZ) {
|
||||
testCoords(BlockVector3.at(chunkX << 4, 0, chunkZ << 4));
|
||||
return WorldEditPlugin.getInstance().getBukkitImplAdapter().get(getWorldChecked(), chunkX, chunkZ);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user