Fix claim visuals not reverting properly. Fixes #1

* Fix version.
* Ignore '_nextClaimID' file during GP Bukkit migration.
This commit is contained in:
bloodshot 2019-07-24 00:04:02 -04:00
parent 8a8d4dd08c
commit 83b4596690
6 changed files with 21 additions and 12 deletions

View File

@ -180,8 +180,9 @@ public void revertActiveVisual(Player player) {
this.visualRevertTask = null; this.visualRevertTask = null;
} }
GDClaim claim = null;
if (this.visualClaimId != null) { if (this.visualClaimId != null) {
GDClaim claim = (GDClaim) GriefDefenderPlugin.getInstance().dataStore.getClaim(this.worldUniqueId, this.visualClaimId); claim = (GDClaim) GriefDefenderPlugin.getInstance().dataStore.getClaim(this.worldUniqueId, this.visualClaimId);
if (claim != null) { if (claim != null) {
claim.playersWatching.remove(this.playerID); claim.playersWatching.remove(this.playerID);
} }
@ -193,6 +194,13 @@ public void revertActiveVisual(Player player) {
for (int i = 0; i < this.visualBlocks.size(); i++) { for (int i = 0; i < this.visualBlocks.size(); i++) {
BlockSnapshot snapshot = this.visualBlocks.get(i).getOriginal(); BlockSnapshot snapshot = this.visualBlocks.get(i).getOriginal();
// If original block does not exist, do not send to player
if (NMSUtil.getInstance().getBlockData(snapshot.getLocation().getBlock()) != snapshot.getState()) {
if (claim != null) {
claim.markVisualDirty = true;
}
continue;
}
NMSUtil.getInstance().sendBlockChange(player, snapshot); NMSUtil.getInstance().sendBlockChange(player, snapshot);
} }
} }

View File

@ -189,15 +189,14 @@ public class GriefDefenderPlugin {
public static final String MOD_ID = "GriefDefender"; public static final String MOD_ID = "GriefDefender";
public static final String API_VERSION = GriefDefenderPlugin.class.getPackage().getSpecificationVersion(); public static final String API_VERSION = GriefDefenderPlugin.class.getPackage().getSpecificationVersion();
public static final String IMPLEMENTATION_NAME = GriefDefenderPlugin.class.getPackage().getImplementationTitle(); public static final String IMPLEMENTATION_NAME = GriefDefenderPlugin.class.getPackage().getImplementationTitle();
public static final String IMPLEMENTATION_VERSION = GriefDefenderPlugin.class.getPackage().getImplementationVersion(); public static final String IMPLEMENTATION_VERSION = GriefDefenderPlugin.class.getPackage().getImplementationVersion() == null ? "unknown" : GriefDefenderPlugin.class.getPackage().getImplementationVersion();
public static String VERSION = "1.0.0";
private Path configPath = Paths.get(".", "plugins", "GriefDefender"); private Path configPath = Paths.get(".", "plugins", "GriefDefender");
public MessageStorage messageStorage; public MessageStorage messageStorage;
public MessageDataConfig messageData; public MessageDataConfig messageData;
public Map<UUID, Random> worldGeneratorRandoms = new HashMap<>(); public Map<UUID, Random> worldGeneratorRandoms = new HashMap<>();
public static ClaimBlockSystem CLAIM_BLOCK_SYSTEM; public static ClaimBlockSystem CLAIM_BLOCK_SYSTEM;
public static final String CONFIG_HEADER = "1.0.0\n" public static final String CONFIG_HEADER = IMPLEMENTATION_VERSION + "\n"
+ "# If you need help with the configuration or have any issues related to GriefDefender,\n" + "# If you need help with the configuration or have any issues related to GriefDefender,\n"
+ "# create a ticket on https://github.com/bloodmc/GriefDefender/issues.\n" + "# create a ticket on https://github.com/bloodmc/GriefDefender/issues.\n"
+ "# Note: If you have not purchased GriefDefender, please consider doing so to get \n" + "# Note: If you have not purchased GriefDefender, please consider doing so to get \n"

View File

@ -131,6 +131,7 @@ public class GDClaim implements Claim {
private UUID ownerUniqueId; private UUID ownerUniqueId;
public boolean cuboid = false; public boolean cuboid = false;
public boolean markVisualDirty = false;
protected ClaimStorageData claimStorage; protected ClaimStorageData claimStorage;
protected IClaimData claimData; protected IClaimData claimData;
@ -243,8 +244,9 @@ public void setType(ClaimType type) {
} }
public ClaimVisual getVisualizer() { public ClaimVisual getVisualizer() {
if (this.claimVisual == null) { if (this.claimVisual == null || this.markVisualDirty) {
this.claimVisual = new ClaimVisual(this, ClaimVisual.getClaimVisualType(this)); this.claimVisual = new ClaimVisual(this, ClaimVisual.getClaimVisualType(this));
this.markVisualDirty = false;
} }
return this.claimVisual; return this.claimVisual;
} }

View File

@ -47,16 +47,10 @@ public class CommandGDVersion extends BaseCommand {
@Subcommand("version") @Subcommand("version")
public void execute(CommandSender src) { public void execute(CommandSender src) {
String version = GriefDefenderPlugin.IMPLEMENTATION_VERSION;
if (version == null) {
version = "unknown";
}
Component gpVersion = TextComponent.builder("") Component gpVersion = TextComponent.builder("")
.append(GriefDefenderPlugin.GD_TEXT) .append(GriefDefenderPlugin.GD_TEXT)
.append("Running ") .append("Running ")
// TODO : Use version from manifest .append("GriefDefender " + GriefDefenderPlugin.IMPLEMENTATION_VERSION, TextColor.AQUA)
.append("GriefDefender " + GriefDefenderPlugin.VERSION, TextColor.AQUA)
.build(); .build();
Component bukkitVersion = TextComponent.builder("") Component bukkitVersion = TextComponent.builder("")
.append(GriefDefenderPlugin.GD_TEXT) .append(GriefDefenderPlugin.GD_TEXT)

View File

@ -526,6 +526,8 @@ public void onBlockBreak(BlockBreakEvent event) {
GriefDefenderPlugin.sendClaimDenyMessage(targetClaim, player, message); GriefDefenderPlugin.sendClaimDenyMessage(targetClaim, player, message);
} }
event.setCancelled(true); event.setCancelled(true);
} else {
targetClaim.markVisualDirty = true;
} }
GDTimings.BLOCK_BREAK_EVENT.stopTiming(); GDTimings.BLOCK_BREAK_EVENT.stopTiming();

View File

@ -76,6 +76,10 @@ public static void migrate(World world, Path gpClassicDataPath) throws FileNotFo
int claimId = Integer.parseInt(file.getName().replaceFirst("[.][^.]+$", "")); int claimId = Integer.parseInt(file.getName().replaceFirst("[.][^.]+$", ""));
idToUUID.put(claimId, UUID.randomUUID()); idToUUID.put(claimId, UUID.randomUUID());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
if (file.getName().equalsIgnoreCase("_nextClaimID")) {
// GP keeps track of next claim ID in this file so we can safely ignore the exception
continue;
}
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }