3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 02:50:06 +01:00

Update & Fix TownyFeature support. (#2279)

Dieser Commit ist enthalten in:
LlmDl 2023-06-11 16:55:11 -05:00 committet von GitHub
Ursprung 71c172cced
Commit ca4080eea7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -2,9 +2,7 @@ package com.fastasyncworldedit.bukkit.regions;
import com.fastasyncworldedit.core.regions.FaweMask; import com.fastasyncworldedit.core.regions.FaweMask;
import com.palmergames.bukkit.towny.Towny; import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyUniverse; import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.PlayerCache;
import com.palmergames.bukkit.towny.object.Resident; import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town; import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownBlock; import com.palmergames.bukkit.towny.object.TownBlock;
@ -36,17 +34,15 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
if (block == null) { if (block == null) {
return false; return false;
} }
Resident resident; Resident resident = TownyAPI.getInstance().getResident(player);
try { if (resident == null) {
resident = TownyUniverse.getInstance().getResident(player.getName()); return false;
try { }
if (block.getResident().equals(resident)) { if (block.hasResident(resident) || block.hasTrustedResident(resident)) {
return true; return true;
} }
} catch (NotRegisteredException ignored) { Town town = block.getTownOrNull(); // Will not be null, because block is not null.
} if (town.isMayor(resident) || town.hasTrustedResident(resident)) {
Town town = block.getTown();
if (town.isMayor(resident)) {
return true; return true;
} }
if (!town.hasResident(resident)) { if (!town.hasResident(resident)) {
@ -60,8 +56,6 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
return true; return true;
} }
} }
} catch (NotRegisteredException ignored) {
}
return false; return false;
} }
@ -69,24 +63,17 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
public FaweMask getMask(final com.sk89q.worldedit.entity.Player wePlayer, MaskType type, boolean isWhitelist) { public FaweMask getMask(final com.sk89q.worldedit.entity.Player wePlayer, MaskType type, boolean isWhitelist) {
final Player player = BukkitAdapter.adapt(wePlayer); final Player player = BukkitAdapter.adapt(wePlayer);
final Location location = player.getLocation(); final Location location = player.getLocation();
try { final WorldCoord mycoord = WorldCoord.parseWorldCoord(location);
final PlayerCache cache = ((Towny) this.towny).getCache(player); if (mycoord.isWilderness()) {
final WorldCoord mycoord = cache.getLastTownBlock();
if (mycoord == null) {
return null;
}
final TownBlock myplot = mycoord.getTownBlock();
if (myplot == null) {
return null; return null;
} }
final TownBlock myplot = mycoord.getTownBlockOrNull(); // Will not be null, because of the isWilderness() test above.
boolean isMember = isAllowed(player, myplot); boolean isMember = isAllowed(player, myplot);
if (isMember) { if (isMember) {
final Chunk chunk = location.getChunk(); final Location loc1 = mycoord.getLowerMostCornerLocation();
final BlockVector3 pos1 = BlockVector3 final Location loc2 = mycoord.getUpperMostCornerLocation();
.at(chunk.getX() * 16, 0, chunk.getZ() * 16); final BlockVector3 pos1 = BlockVector3.at(loc1.getX(), loc1.getY(), loc1.getZ());
final BlockVector3 pos2 = BlockVector3.at( final BlockVector3 pos2 = BlockVector3.at(loc2.getX(), loc2.getY(), loc2.getZ());
chunk.getX() * 16 + 15, 156, chunk.getZ() * 16
+ 15);
return new FaweMask(new CuboidRegion(pos1, pos2)) { return new FaweMask(new CuboidRegion(pos1, pos2)) {
@Override @Override
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
@ -94,8 +81,6 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
} }
}; };
} }
} catch (Exception ignored) {
}
return null; return null;
} }