reformat code

- Lots of tabs to spaces going on
- That's a lot of changes!

#63
This commit is contained in:
RoboMWM 2020-06-08 21:57:55 -07:00
parent bc05440617
commit 40f554d386
63 changed files with 12745 additions and 12750 deletions

View File

@ -1,13 +1,13 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.ArrayList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChunkSnapshot; import org.bukkit.ChunkSnapshot;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import java.util.ArrayList;
//automatically extends a claim downward based on block types detected //automatically extends a claim downward based on block types detected
class AutoExtendClaimTask implements Runnable class AutoExtendClaimTask implements Runnable
{ {

View File

@ -190,10 +190,13 @@ public class BlockEventHandler implements Listener
} }
} }
private boolean doesAllowFireProximityInWorld(World world) { private boolean doesAllowFireProximityInWorld(World world)
if (GriefPrevention.instance.pvpRulesApply(world)) { {
if (GriefPrevention.instance.pvpRulesApply(world))
{
return GriefPrevention.instance.config_pvp_allowFireNearPlayers; return GriefPrevention.instance.config_pvp_allowFireNearPlayers;
} else { } else
{
return GriefPrevention.instance.config_pvp_allowFireNearPlayers_NonPvp; return GriefPrevention.instance.config_pvp_allowFireNearPlayers_NonPvp;
} }
} }
@ -217,7 +220,8 @@ public class BlockEventHandler implements Listener
Player otherPlayer = players.get(i); Player otherPlayer = players.get(i);
// Ignore players in creative or spectator mode to avoid users from checking if someone is spectating near them // Ignore players in creative or spectator mode to avoid users from checking if someone is spectating near them
if(otherPlayer.getGameMode() == GameMode.CREATIVE || otherPlayer.getGameMode() == GameMode.SPECTATOR) { if (otherPlayer.getGameMode() == GameMode.CREATIVE || otherPlayer.getGameMode() == GameMode.SPECTATOR)
{
continue; continue;
} }
@ -660,7 +664,8 @@ public class BlockEventHandler implements Listener
//don't track in worlds where claims are not enabled //don't track in worlds where claims are not enabled
if (!GriefPrevention.instance.claimsEnabledForWorld(igniteEvent.getBlock().getWorld())) return; if (!GriefPrevention.instance.claimsEnabledForWorld(igniteEvent.getBlock().getWorld())) return;
if(igniteEvent.getCause() == IgniteCause.LIGHTNING && GriefPrevention.instance.dataStore.getClaimAt(igniteEvent.getIgnitingEntity().getLocation(), false, null) != null){ if (igniteEvent.getCause() == IgniteCause.LIGHTNING && GriefPrevention.instance.dataStore.getClaimAt(igniteEvent.getIgnitingEntity().getLocation(), false, null) != null)
{
// if(igniteEvent.getIgnitingEntity().hasMetadata("GP_TRIDENT")){ //BlockIgniteEvent is called before LightningStrikeEvent. See #532 // if(igniteEvent.getIgnitingEntity().hasMetadata("GP_TRIDENT")){ //BlockIgniteEvent is called before LightningStrikeEvent. See #532
igniteEvent.setCancelled(true); igniteEvent.setCancelled(true);
// } // }
@ -757,9 +762,9 @@ public class BlockEventHandler implements Listener
} }
//ensures fluids don't flow into land claims from outside //ensures fluids don't flow into land claims from outside
private Claim lastSpreadClaim = null; private Claim lastSpreadClaim = null;
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockFromTo(BlockFromToEvent spreadEvent) public void onBlockFromTo(BlockFromToEvent spreadEvent)
{ {

View File

@ -19,9 +19,6 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;

View File

@ -18,15 +18,26 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.*; import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.*; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
//represents a player claim //represents a player claim
//creating an instance doesn't make an effective claim //creating an instance doesn't make an effective claim
//only claims which have been added to the datastore have any effect //only claims which have been added to the datastore have any effect
@ -133,7 +144,8 @@ public class Claim
int seaLevel = 0; //clean up all fluids in the end int seaLevel = 0; //clean up all fluids in the end
//respect sea level in normal worlds //respect sea level in normal worlds
if(lesser.getWorld().getEnvironment() == Environment.NORMAL) seaLevel = GriefPrevention.instance.getSeaLevel(lesser.getWorld()); if (lesser.getWorld().getEnvironment() == Environment.NORMAL)
seaLevel = GriefPrevention.instance.getSeaLevel(lesser.getWorld());
for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++)
{ {
@ -167,7 +179,8 @@ public class Claim
int seaLevel = 0; //clean up all fluids in the end int seaLevel = 0; //clean up all fluids in the end
//respect sea level in normal worlds //respect sea level in normal worlds
if(lesser.getWorld().getEnvironment() == Environment.NORMAL) seaLevel = GriefPrevention.instance.getSeaLevel(lesser.getWorld()); if (lesser.getWorld().getEnvironment() == Environment.NORMAL)
seaLevel = GriefPrevention.instance.getSeaLevel(lesser.getWorld());
for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++)
{ {
@ -366,7 +379,8 @@ public class Claim
} }
//owners can make changes, or admins with ignore claims mode enabled //owners can make changes, or admins with ignore claims mode enabled
if(player.getUniqueId().equals(this.ownerID) || GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).ignoreClaims) return null; if (player.getUniqueId().equals(this.ownerID) || GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).ignoreClaims)
return null;
//anyone with explicit build permission can make changes //anyone with explicit build permission can make changes
if (this.hasExplicitPermission(player, ClaimPermission.Build)) return null; if (this.hasExplicitPermission(player, ClaimPermission.Build)) return null;
@ -455,12 +469,10 @@ public class Claim
if (!breakable) if (!breakable)
{ {
return GriefPrevention.instance.dataStore.getMessage(Messages.NonSiegeMaterial); return GriefPrevention.instance.dataStore.getMessage(Messages.NonSiegeMaterial);
} } else if (player.getUniqueId().equals(this.ownerID))
else if(player.getUniqueId().equals(this.ownerID))
{ {
return GriefPrevention.instance.dataStore.getMessage(Messages.NoOwnerBuildUnderSiege); return GriefPrevention.instance.dataStore.getMessage(Messages.NoOwnerBuildUnderSiege);
} } else
else
{ {
return null; return null;
} }
@ -483,7 +495,8 @@ public class Claim
} }
//claim owner and admins in ignoreclaims mode have access //claim owner and admins in ignoreclaims mode have access
if(player.getUniqueId().equals(this.ownerID) || GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).ignoreClaims) return null; if (player.getUniqueId().equals(this.ownerID) || GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).ignoreClaims)
return null;
//look for explicit individual access, inventory, or build permission //look for explicit individual access, inventory, or build permission
if (this.hasExplicitPermission(player, ClaimPermission.Access)) return null; if (this.hasExplicitPermission(player, ClaimPermission.Access)) return null;
@ -523,7 +536,8 @@ public class Claim
} }
//owner and administrators in ignoreclaims mode have access //owner and administrators in ignoreclaims mode have access
if(player.getUniqueId().equals(this.ownerID) || GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).ignoreClaims) return null; if (player.getUniqueId().equals(this.ownerID) || GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).ignoreClaims)
return null;
//admin claims need adminclaims permission only. //admin claims need adminclaims permission only.
if (this.isAdminClaim()) if (this.isAdminClaim())
@ -650,12 +664,10 @@ public class Claim
if (entry.getValue() == ClaimPermission.Build) if (entry.getValue() == ClaimPermission.Build)
{ {
builders.add(entry.getKey()); builders.add(entry.getKey());
} } else if (entry.getValue() == ClaimPermission.Inventory)
else if(entry.getValue() == ClaimPermission.Inventory)
{ {
containers.add(entry.getKey()); containers.add(entry.getKey());
} } else
else
{ {
accessors.add(entry.getKey()); accessors.add(entry.getKey());
} }
@ -753,8 +765,10 @@ public class Claim
//first, check the corners of this claim aren't inside any existing claims //first, check the corners of this claim aren't inside any existing claims
if (otherClaim.contains(this.lesserBoundaryCorner, true, false)) return true; if (otherClaim.contains(this.lesserBoundaryCorner, true, false)) return true;
if (otherClaim.contains(this.greaterBoundaryCorner, true, false)) return true; if (otherClaim.contains(this.greaterBoundaryCorner, true, false)) return true;
if(otherClaim.contains(new Location(this.lesserBoundaryCorner.getWorld(), this.lesserBoundaryCorner.getBlockX(), 0, this.greaterBoundaryCorner.getBlockZ()), true, false)) return true; if (otherClaim.contains(new Location(this.lesserBoundaryCorner.getWorld(), this.lesserBoundaryCorner.getBlockX(), 0, this.greaterBoundaryCorner.getBlockZ()), true, false))
if(otherClaim.contains(new Location(this.lesserBoundaryCorner.getWorld(), this.greaterBoundaryCorner.getBlockX(), 0, this.lesserBoundaryCorner.getBlockZ()), true, false)) return true; return true;
if (otherClaim.contains(new Location(this.lesserBoundaryCorner.getWorld(), this.greaterBoundaryCorner.getBlockX(), 0, this.lesserBoundaryCorner.getBlockZ()), true, false))
return true;
//verify that no claim's lesser boundary point is inside this new claim, to cover the "existing claim is entirely inside new claim" case //verify that no claim's lesser boundary point is inside this new claim, to cover the "existing claim is entirely inside new claim" case
if (this.contains(otherClaim.getLesserBoundaryCorner(), true, false)) return true; if (this.contains(otherClaim.getLesserBoundaryCorner(), true, false)) return true;
@ -822,7 +836,8 @@ public class Claim
} }
} }
if(totalEntities >= maxEntities) return GriefPrevention.instance.dataStore.getMessage(Messages.TooManyEntitiesInClaim); if (totalEntities >= maxEntities)
return GriefPrevention.instance.dataStore.getMessage(Messages.TooManyEntitiesInClaim);
return null; return null;
} }
@ -833,7 +848,8 @@ public class Claim
//determine maximum allowable entity count, based on claim size //determine maximum allowable entity count, based on claim size
int maxActives = this.getArea() / 100; int maxActives = this.getArea() / 100;
if(maxActives == 0) return GriefPrevention.instance.dataStore.getMessage(Messages.ClaimTooSmallForActiveBlocks); if (maxActives == 0)
return GriefPrevention.instance.dataStore.getMessage(Messages.ClaimTooSmallForActiveBlocks);
//count current actives //count current actives
int totalActives = 0; int totalActives = 0;
@ -854,7 +870,8 @@ public class Claim
} }
} }
if(totalActives >= maxActives) return GriefPrevention.instance.dataStore.getMessage(Messages.TooManyActiveBlocksInClaim); if (totalActives >= maxActives)
return GriefPrevention.instance.dataStore.getMessage(Messages.TooManyActiveBlocksInClaim);
return null; return null;
} }
@ -901,8 +918,7 @@ public class Claim
if (block.getType() == Material.CHEST && !creativeMode) if (block.getType() == Material.CHEST && !creativeMode)
{ {
score += 10; score += 10;
} } else
else
{ {
score += .5; score += .5;
} }
@ -917,12 +933,10 @@ public class Claim
if (block.getType() == Material.CHEST && !creativeMode) if (block.getType() == Material.CHEST && !creativeMode)
{ {
score += 10; score += 10;
} } else if (creativeMode && (block.getType() == Material.LAVA))
else if(creativeMode && (block.getType() == Material.LAVA))
{ {
score -= 10; score -= 10;
} } else
else
{ {
score += 1; score += 1;
} }

View File

@ -18,14 +18,13 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.Calendar; import me.ryanhamshire.GriefPrevention.events.ClaimExpirationEvent;
import java.util.Date;
import java.util.Vector;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import me.ryanhamshire.GriefPrevention.events.ClaimExpirationEvent; import java.util.Calendar;
import java.util.Date;
import java.util.Vector;
class CleanupUnusedClaimTask implements Runnable class CleanupUnusedClaimTask implements Runnable
{ {
@ -106,9 +105,7 @@ class CleanupUnusedClaimTask implements Runnable
} }
} }
} }
} } else if (GriefPrevention.instance.config_claims_unusedClaimExpirationDays > 0 && GriefPrevention.instance.creativeRulesApply(claim.getLesserBoundaryCorner()))
else if(GriefPrevention.instance.config_claims_unusedClaimExpirationDays > 0 && GriefPrevention.instance.creativeRulesApply(claim.getLesserBoundaryCorner()))
{ {
//avoid scanning large claims and administrative claims //avoid scanning large claims and administrative claims
if (claim.isAdminClaim() || claim.getWidth() > 25 || claim.getHeight() > 25) return; if (claim.isAdminClaim() || claim.getWidth() > 25 || claim.getHeight() > 25) return;

View File

@ -18,6 +18,9 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import com.google.common.io.Files;
import org.bukkit.scheduler.BukkitScheduler;
import java.io.File; import java.io.File;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -26,10 +29,6 @@ import java.util.Date;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.bukkit.scheduler.BukkitScheduler;
import com.google.common.io.Files;
class CustomLogger class CustomLogger
{ {
private final SimpleDateFormat timestampFormat = new SimpleDateFormat("HH:mm"); private final SimpleDateFormat timestampFormat = new SimpleDateFormat("HH:mm");
@ -62,6 +61,7 @@ class CustomLogger
} }
private static final Pattern inlineFormatterPattern = Pattern.compile("§."); private static final Pattern inlineFormatterPattern = Pattern.compile("§.");
void AddEntry(String entry, CustomLogEntryTypes entryType) void AddEntry(String entry, CustomLogEntryTypes entryType)
{ {
//if disabled, do nothing //if disabled, do nothing
@ -81,11 +81,15 @@ class CustomLogger
private boolean isEnabledType(CustomLogEntryTypes entryType) private boolean isEnabledType(CustomLogEntryTypes entryType)
{ {
if (entryType == CustomLogEntryTypes.Exception) return true; if (entryType == CustomLogEntryTypes.Exception) return true;
if(entryType == CustomLogEntryTypes.SocialActivity && !GriefPrevention.instance.config_logs_socialEnabled) return false; if (entryType == CustomLogEntryTypes.SocialActivity && !GriefPrevention.instance.config_logs_socialEnabled)
if(entryType == CustomLogEntryTypes.SuspiciousActivity && !GriefPrevention.instance.config_logs_suspiciousEnabled) return false; return false;
if(entryType == CustomLogEntryTypes.AdminActivity && !GriefPrevention.instance.config_logs_adminEnabled) return false; if (entryType == CustomLogEntryTypes.SuspiciousActivity && !GriefPrevention.instance.config_logs_suspiciousEnabled)
return false;
if (entryType == CustomLogEntryTypes.AdminActivity && !GriefPrevention.instance.config_logs_adminEnabled)
return false;
if (entryType == CustomLogEntryTypes.Debug && !GriefPrevention.instance.config_logs_debugEnabled) return false; if (entryType == CustomLogEntryTypes.Debug && !GriefPrevention.instance.config_logs_debugEnabled) return false;
if(entryType == CustomLogEntryTypes.MutedChat && !GriefPrevention.instance.config_logs_mutedChatEnabled) return false; if (entryType == CustomLogEntryTypes.MutedChat && !GriefPrevention.instance.config_logs_mutedChatEnabled)
return false;
return true; return true;
} }

View File

@ -95,6 +95,7 @@ public abstract class DataStore
//reading and writing the schema version to the data store //reading and writing the schema version to the data store
abstract int getSchemaVersionFromStorage(); abstract int getSchemaVersionFromStorage();
abstract void updateSchemaVersionInStorage(int versionToSet); abstract void updateSchemaVersionInStorage(int versionToSet);
//current version of the schema of data in secondary storage //current version of the schema of data in secondary storage
@ -116,8 +117,7 @@ public abstract class DataStore
if (this.currentSchemaVersion >= 0) if (this.currentSchemaVersion >= 0)
{ {
return this.currentSchemaVersion; return this.currentSchemaVersion;
} } else
else
{ {
this.currentSchemaVersion = this.getSchemaVersionFromStorage(); this.currentSchemaVersion = this.getSchemaVersionFromStorage();
return this.currentSchemaVersion; return this.currentSchemaVersion;
@ -388,6 +388,7 @@ public abstract class DataStore
super(message); super(message);
} }
} }
synchronized public void changeClaimOwner(Claim claim, UUID newOwnerID) synchronized public void changeClaimOwner(Claim claim, UUID newOwnerID)
{ {
//if it's a subdivision, throw an exception //if it's a subdivision, throw an exception
@ -467,7 +468,8 @@ public abstract class DataStore
} }
} }
private void addToChunkClaimMap(Claim claim){ private void addToChunkClaimMap(Claim claim)
{
ArrayList<Long> chunkHashes = claim.getChunkHashes(); ArrayList<Long> chunkHashes = claim.getChunkHashes();
for (Long chunkHash : chunkHashes) for (Long chunkHash : chunkHashes)
{ {
@ -481,7 +483,8 @@ public abstract class DataStore
} }
} }
private void removeFromChunkClaimMap(Claim claim) { private void removeFromChunkClaimMap(Claim claim)
{
ArrayList<Long> chunkHashes = claim.getChunkHashes(); ArrayList<Long> chunkHashes = claim.getChunkHashes();
for (Long chunkHash : chunkHashes) for (Long chunkHash : chunkHashes)
{ {
@ -497,7 +500,8 @@ public abstract class DataStore
break; break;
} }
} }
if (claimsInChunk.isEmpty()) { // if nothing's left, remove this chunk's cache if (claimsInChunk.isEmpty())
{ // if nothing's left, remove this chunk's cache
this.chunksToClaimsMap.remove(chunkHash); this.chunksToClaimsMap.remove(chunkHash);
} }
} }
@ -506,6 +510,7 @@ public abstract class DataStore
//turns a location into a string, useful in data storage //turns a location into a string, useful in data storage
private String locationStringDelimiter = ";"; private String locationStringDelimiter = ";";
String locationToString(Location location) String locationToString(Location location)
{ {
StringBuilder stringBuilder = new StringBuilder(location.getWorld().getName()); StringBuilder stringBuilder = new StringBuilder(location.getWorld().getName());
@ -568,7 +573,8 @@ public abstract class DataStore
this.writeClaimToStorage(claim); this.writeClaimToStorage(claim);
} }
private void assignClaimID(Claim claim) { private void assignClaimID(Claim claim)
{
//ensure a unique identifier for the claim which will be used to name the file on disk //ensure a unique identifier for the claim which will be used to name the file on disk
if (claim.id == null || claim.id == -1) if (claim.id == null || claim.id == -1)
{ {
@ -716,7 +722,8 @@ public abstract class DataStore
synchronized public Claim getClaimAt(Location location, boolean ignoreHeight, Claim cachedClaim) synchronized public Claim getClaimAt(Location location, boolean ignoreHeight, Claim cachedClaim)
{ {
//check cachedClaim guess first. if it's in the datastore and the location is inside it, we're done //check cachedClaim guess first. if it's in the datastore and the location is inside it, we're done
if(cachedClaim != null && cachedClaim.inDataStore && cachedClaim.contains(location, ignoreHeight, true)) return cachedClaim; if (cachedClaim != null && cachedClaim.inDataStore && cachedClaim.contains(location, ignoreHeight, true))
return cachedClaim;
//find a top level claim //find a top level claim
Long chunkID = getChunkHash(location); Long chunkID = getChunkHash(location);
@ -732,7 +739,8 @@ public abstract class DataStore
for (int j = 0; j < claim.children.size(); j++) for (int j = 0; j < claim.children.size(); j++)
{ {
Claim subdivision = claim.children.get(j); Claim subdivision = claim.children.get(j);
if(subdivision.inDataStore && subdivision.contains(location, ignoreHeight, false)) return subdivision; if (subdivision.inDataStore && subdivision.contains(location, ignoreHeight, false))
return subdivision;
} }
return claim; return claim;
@ -768,8 +776,7 @@ public abstract class DataStore
if (chunkClaims != null) if (chunkClaims != null)
{ {
return Collections.unmodifiableCollection(chunkClaims); return Collections.unmodifiableCollection(chunkClaims);
} } else
else
{ {
return Collections.unmodifiableCollection(new ArrayList<Claim>()); return Collections.unmodifiableCollection(new ArrayList<Claim>());
} }
@ -794,6 +801,7 @@ public abstract class DataStore
{ {
return createClaim(world, x1, x2, y1, y2, z1, z2, ownerID, parent, id, creatingPlayer, false); return createClaim(world, x1, x2, y1, y2, z1, z2, ownerID, parent, id, creatingPlayer, false);
} }
//creates a claim. //creates a claim.
//if the new claim would overlap an existing claim, returns a failure along with a reference to the existing claim //if the new claim would overlap an existing claim, returns a failure along with a reference to the existing claim
//if the new claim would overlap a WorldGuard region where the player doesn't have permission to build, returns a failure with NULL for claim //if the new claim would overlap a WorldGuard region where the player doesn't have permission to build, returns a failure with NULL for claim
@ -819,8 +827,7 @@ public abstract class DataStore
{ {
smallx = x1; smallx = x1;
bigx = x2; bigx = x2;
} } else
else
{ {
smallx = x2; smallx = x2;
bigx = x1; bigx = x1;
@ -830,8 +837,7 @@ public abstract class DataStore
{ {
smally = y1; smally = y1;
bigy = y2; bigy = y2;
} } else
else
{ {
smally = y2; smally = y2;
bigy = y1; bigy = y1;
@ -841,8 +847,7 @@ public abstract class DataStore
{ {
smallz = z1; smallz = z1;
bigz = z2; bigz = z2;
} } else
else
{ {
smallz = z2; smallz = z2;
bigz = z1; bigz = z1;
@ -884,8 +889,7 @@ public abstract class DataStore
if (newClaim.parent != null) if (newClaim.parent != null)
{ {
claimsToCheck = newClaim.parent.children; claimsToCheck = newClaim.parent.children;
} } else
else
{ {
claimsToCheck = this.claims; claimsToCheck = this.claims;
} }
@ -914,7 +918,8 @@ public abstract class DataStore
return result; return result;
} }
} }
if (dryRun) { if (dryRun)
{
// since this is a dry run, just return the unsaved claim as is. // since this is a dry run, just return the unsaved claim as is.
result.succeeded = true; result.succeeded = true;
result.claim = newClaim; result.claim = newClaim;
@ -923,7 +928,8 @@ public abstract class DataStore
assignClaimID(newClaim); // assign a claim ID before calling event, in case a plugin wants to know the ID. assignClaimID(newClaim); // assign a claim ID before calling event, in case a plugin wants to know the ID.
ClaimCreatedEvent event = new ClaimCreatedEvent(newClaim, creatingPlayer); ClaimCreatedEvent event = new ClaimCreatedEvent(newClaim, creatingPlayer);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled())
{
result.succeeded = false; result.succeeded = false;
result.claim = null; result.claim = null;
return result; return result;
@ -1000,7 +1006,8 @@ public abstract class DataStore
//respects the max depth config variable //respects the max depth config variable
synchronized public void extendClaim(Claim claim, int newDepth) synchronized public void extendClaim(Claim claim, int newDepth)
{ {
if(newDepth < GriefPrevention.instance.config_claims_maxDepth) newDepth = GriefPrevention.instance.config_claims_maxDepth; if (newDepth < GriefPrevention.instance.config_claims_maxDepth)
newDepth = GriefPrevention.instance.config_claims_maxDepth;
if (claim.parent != null) claim = claim.parent; if (claim.parent != null) claim = claim.parent;
@ -1051,19 +1058,16 @@ public abstract class DataStore
if (siegeData.attacker.getName().equals(loserName)) if (siegeData.attacker.getName().equals(loserName))
{ {
winnerName = siegeData.defender.getName(); winnerName = siegeData.defender.getName();
} } else
else
{ {
winnerName = siegeData.attacker.getName(); winnerName = siegeData.attacker.getName();
} }
} } else if (winnerName != null && loserName == null)
else if(winnerName != null && loserName == null)
{ {
if (siegeData.attacker.getName().equals(winnerName)) if (siegeData.attacker.getName().equals(winnerName))
{ {
loserName = siegeData.defender.getName(); loserName = siegeData.defender.getName();
} } else
else
{ {
loserName = siegeData.attacker.getName(); loserName = siegeData.attacker.getName();
} }
@ -1366,8 +1370,7 @@ public abstract class DataStore
if (ownerID == player.getUniqueId()) if (ownerID == player.getUniqueId())
{ {
claimBlocksRemaining = playerData.getRemainingClaimBlocks(); claimBlocksRemaining = playerData.getRemainingClaimBlocks();
} } else
else
{ {
PlayerData ownerData = this.getPlayerData(ownerID); PlayerData ownerData = this.getPlayerData(ownerID);
claimBlocksRemaining = ownerData.getRemainingClaimBlocks(); claimBlocksRemaining = ownerData.getRemainingClaimBlocks();
@ -1408,8 +1411,7 @@ public abstract class DataStore
//clean up //clean up
playerData.claimResizing = null; playerData.claimResizing = null;
playerData.lastShovelLocation = null; playerData.lastShovelLocation = null;
} } else
else
{ {
if (result.claim != null) if (result.claim != null)
{ {
@ -1419,8 +1421,7 @@ public abstract class DataStore
//show the player the conflicting claim //show the player the conflicting claim
Visualization visualization = Visualization.FromClaim(result.claim, player.getEyeLocation().getBlockY(), VisualizationType.ErrorClaim, player.getLocation()); Visualization visualization = Visualization.FromClaim(result.claim, player.getEyeLocation().getBlockY(), VisualizationType.ErrorClaim, player.getLocation());
Visualization.Apply(player, visualization); Visualization.Apply(player, visualization);
} } else
else
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.ResizeFailOverlapRegion); GriefPrevention.sendMessage(player, TextMode.Err, Messages.ResizeFailOverlapRegion);
} }
@ -1433,12 +1434,10 @@ public abstract class DataStore
if (player.hasPermission("griefprevention.adminclaims") && player.hasPermission("griefprevention.adjustclaimblocks")) if (player.hasPermission("griefprevention.adminclaims") && player.hasPermission("griefprevention.adjustclaimblocks"))
{ {
GriefPrevention.sendMessage(player, TextMode.Info, Messages.AdvertiseACandACB); GriefPrevention.sendMessage(player, TextMode.Info, Messages.AdvertiseACandACB);
} } else if (player.hasPermission("griefprevention.adminclaims"))
else if(player.hasPermission("griefprevention.adminclaims"))
{ {
GriefPrevention.sendMessage(player, TextMode.Info, Messages.AdvertiseAdminClaims); GriefPrevention.sendMessage(player, TextMode.Info, Messages.AdvertiseAdminClaims);
} } else if (player.hasPermission("griefprevention.adjustclaimblocks"))
else if(player.hasPermission("griefprevention.adjustclaimblocks"))
{ {
GriefPrevention.sendMessage(player, TextMode.Info, Messages.AdvertiseACB); GriefPrevention.sendMessage(player, TextMode.Info, Messages.AdvertiseACB);
} }

View File

@ -18,14 +18,27 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.sql.*; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import org.bukkit.*; import java.util.List;
import java.util.Properties;
import java.util.UUID;
//manages data stored in the file system //manages data stored in the file system
public class DatabaseDataStore extends DataStore public class DatabaseDataStore extends DataStore
@ -228,7 +241,8 @@ public class DatabaseDataStore extends DataStore
for (String name : changes.keySet()) for (String name : changes.keySet())
{ {
try (PreparedStatement updateStmnt = this.databaseConnection.prepareStatement(this.getUpdateNameSQL())) { try (PreparedStatement updateStmnt = this.databaseConnection.prepareStatement(this.getUpdateNameSQL()))
{
updateStmnt.setString(1, changes.get(name).toString()); updateStmnt.setString(1, changes.get(name).toString());
updateStmnt.setString(2, name); updateStmnt.setString(2, name);
updateStmnt.executeUpdate(); updateStmnt.executeUpdate();
@ -289,8 +303,7 @@ public class DatabaseDataStore extends DataStore
{ {
GriefPrevention.AddLogEntry("Failed to load a claim (ID:" + claimID.toString() + ") because its world isn't loaded (yet?). Please delete the claim or contact the GriefPrevention developer with information about which plugin(s) you're using to load or create worlds. " + lesserCornerString); GriefPrevention.AddLogEntry("Failed to load a claim (ID:" + claimID.toString() + ") because its world isn't loaded (yet?). Please delete the claim or contact the GriefPrevention developer with information about which plugin(s) you're using to load or create worlds. " + lesserCornerString);
continue; continue;
} } else
else
{ {
throw e; throw e;
} }
@ -301,8 +314,7 @@ public class DatabaseDataStore extends DataStore
if (ownerName.isEmpty() || ownerName.startsWith("--")) if (ownerName.isEmpty() || ownerName.startsWith("--"))
{ {
ownerID = null; //administrative land claim or subdivision ownerID = null; //administrative land claim or subdivision
} } else if (this.getSchemaVersion() < 1)
else if(this.getSchemaVersion() < 1)
{ {
try try
{ {
@ -313,8 +325,7 @@ public class DatabaseDataStore extends DataStore
GriefPrevention.AddLogEntry("This owner name did not convert to a UUID: " + ownerName + "."); GriefPrevention.AddLogEntry("This owner name did not convert to a UUID: " + ownerName + ".");
GriefPrevention.AddLogEntry(" Converted land claim to administrative @ " + lesserBoundaryCorner.toString()); GriefPrevention.AddLogEntry(" Converted land claim to administrative @ " + lesserBoundaryCorner.toString());
} }
} } else
else
{ {
try try
{ {
@ -347,13 +358,11 @@ public class DatabaseDataStore extends DataStore
if (removeClaim) if (removeClaim)
{ {
claimsToRemove.add(claim); claimsToRemove.add(claim);
} } else if (parentId == -1)
else if(parentId == -1)
{ {
//top level claim //top level claim
this.addClaim(claim, false); this.addClaim(claim, false);
} } else
else
{ {
//subdivision //subdivision
subdivisionsToLoad.add(claim); subdivisionsToLoad.add(claim);
@ -442,7 +451,8 @@ public class DatabaseDataStore extends DataStore
boolean inheritNothing = claim.getSubclaimRestrictions(); boolean inheritNothing = claim.getSubclaimRestrictions();
long parentId = claim.parent == null ? -1 : claim.parent.id; long parentId = claim.parent == null ? -1 : claim.parent.id;
try (PreparedStatement insertStmt = this.databaseConnection.prepareStatement(this.getInsertClaimSQL())) { try (PreparedStatement insertStmt = this.databaseConnection.prepareStatement(this.getInsertClaimSQL()))
{
insertStmt.setLong(1, claim.id); insertStmt.setLong(1, claim.id);
insertStmt.setString(2, owner); insertStmt.setString(2, owner);
@ -467,7 +477,8 @@ public class DatabaseDataStore extends DataStore
@Override @Override
synchronized void deleteClaimFromSecondaryStorage(Claim claim) synchronized void deleteClaimFromSecondaryStorage(Claim claim)
{ {
try(PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeleteClaimSQL())) { try (PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeleteClaimSQL()))
{
deleteStmnt.setLong(1, claim.id); deleteStmnt.setLong(1, claim.id);
deleteStmnt.executeUpdate(); deleteStmnt.executeUpdate();
} }
@ -520,7 +531,8 @@ public class DatabaseDataStore extends DataStore
private void savePlayerData(String playerID, PlayerData playerData) private void savePlayerData(String playerID, PlayerData playerData)
{ {
try (PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeletePlayerDataSQL()); try (PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeletePlayerDataSQL());
PreparedStatement insertStmnt = this.databaseConnection.prepareStatement(this.getInsertPlayerDataSQL())) { PreparedStatement insertStmnt = this.databaseConnection.prepareStatement(this.getInsertPlayerDataSQL()))
{
OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(playerID)); OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(playerID));
SimpleDateFormat sqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -554,7 +566,8 @@ public class DatabaseDataStore extends DataStore
this.nextClaimID = nextID; this.nextClaimID = nextID;
try (PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeleteNextClaimIdSQL()); try (PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeleteNextClaimIdSQL());
PreparedStatement insertStmnt = this.databaseConnection.prepareStatement(this.getInsertNextClaimIdSQL())) { PreparedStatement insertStmnt = this.databaseConnection.prepareStatement(this.getInsertNextClaimIdSQL()))
{
deleteStmnt.execute(); deleteStmnt.execute();
insertStmnt.setLong(1, nextID); insertStmnt.setLong(1, nextID);
insertStmnt.executeUpdate(); insertStmnt.executeUpdate();
@ -572,7 +585,8 @@ public class DatabaseDataStore extends DataStore
{ {
//group bonus blocks are stored in the player data table, with player name = $groupName //group bonus blocks are stored in the player data table, with player name = $groupName
try (PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeleteGroupBonusSQL()); try (PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeleteGroupBonusSQL());
PreparedStatement insertStmnt = this.databaseConnection.prepareStatement(this.getInsertPlayerDataSQL())) { PreparedStatement insertStmnt = this.databaseConnection.prepareStatement(this.getInsertPlayerDataSQL()))
{
SimpleDateFormat sqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = sqlFormat.format(new Date()); String dateString = sqlFormat.format(new Date());
deleteStmnt.setString(1, '$' + groupName); deleteStmnt.setString(1, '$' + groupName);
@ -603,7 +617,8 @@ public class DatabaseDataStore extends DataStore
this.databaseConnection.close(); this.databaseConnection.close();
} }
} }
catch(SQLException e){}; catch (SQLException e) {}
;
} }
this.databaseConnection = null; this.databaseConnection = null;
@ -633,7 +648,8 @@ public class DatabaseDataStore extends DataStore
@Override @Override
protected int getSchemaVersionFromStorage() protected int getSchemaVersionFromStorage()
{ {
try (PreparedStatement selectStmnt = this.databaseConnection.prepareStatement(this.getSelectSchemaVersionSQL())) { try (PreparedStatement selectStmnt = this.databaseConnection.prepareStatement(this.getSelectSchemaVersionSQL()))
{
ResultSet results = selectStmnt.executeQuery(); ResultSet results = selectStmnt.executeQuery();
//if there's nothing yet, assume 0 and add it //if there's nothing yet, assume 0 and add it
@ -661,7 +677,8 @@ public class DatabaseDataStore extends DataStore
protected void updateSchemaVersionInStorage(int versionToSet) protected void updateSchemaVersionInStorage(int versionToSet)
{ {
try (PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeleteSchemaVersionSQL()); try (PreparedStatement deleteStmnt = this.databaseConnection.prepareStatement(this.getDeleteSchemaVersionSQL());
PreparedStatement insertStmnt = this.databaseConnection.prepareStatement(this.getInsertSchemaVerSQL())) { PreparedStatement insertStmnt = this.databaseConnection.prepareStatement(this.getInsertSchemaVerSQL()))
{
deleteStmnt.execute(); deleteStmnt.execute();
insertStmnt.setInt(1, versionToSet); insertStmnt.setInt(1, versionToSet);
@ -676,62 +693,77 @@ public class DatabaseDataStore extends DataStore
/** /**
* Concats an array to a string divided with the ; sign * Concats an array to a string divided with the ; sign
*
* @param input Arraylist with strings to concat * @param input Arraylist with strings to concat
* @return String with all values from input array * @return String with all values from input array
*/ */
private String storageStringBuilder(ArrayList<String> input) { private String storageStringBuilder(ArrayList<String> input)
{
String output = ""; String output = "";
for(String string : input) { for (String string : input)
{
output += string + ";"; output += string + ";";
} }
return output; return output;
} }
public String getUpdateNameSQL() { public String getUpdateNameSQL()
{
return updateNameSQL; return updateNameSQL;
} }
public String getInsertClaimSQL() { public String getInsertClaimSQL()
{
return insertClaimSQL; return insertClaimSQL;
} }
public String getDeleteClaimSQL() { public String getDeleteClaimSQL()
{
return deleteClaimSQL; return deleteClaimSQL;
} }
public String getGetPlayerDataSQL() { public String getGetPlayerDataSQL()
{
return getPlayerDataSQL; return getPlayerDataSQL;
} }
public String getDeletePlayerDataSQL() { public String getDeletePlayerDataSQL()
{
return deletePlayerDataSQL; return deletePlayerDataSQL;
} }
public String getInsertPlayerDataSQL() { public String getInsertPlayerDataSQL()
{
return insertPlayerDataSQL; return insertPlayerDataSQL;
} }
public String getInsertNextClaimIdSQL() { public String getInsertNextClaimIdSQL()
{
return insertNextClaimIdSQL; return insertNextClaimIdSQL;
} }
public String getDeleteGroupBonusSQL() { public String getDeleteGroupBonusSQL()
{
return deleteGroupBonusSQL; return deleteGroupBonusSQL;
} }
public String getInsertSchemaVerSQL() { public String getInsertSchemaVerSQL()
{
return insertSchemaVerSQL; return insertSchemaVerSQL;
} }
public String getDeleteNextClaimIdSQL() { public String getDeleteNextClaimIdSQL()
{
return deleteNextClaimIdSQL; return deleteNextClaimIdSQL;
} }
public String getDeleteSchemaVersionSQL() { public String getDeleteSchemaVersionSQL()
{
return deleteSchemaVersionSQL; return deleteSchemaVersionSQL;
} }
public String getSelectSchemaVersionSQL() { public String getSelectSchemaVersionSQL()
{
return selectSchemaVersionSQL; return selectSchemaVersionSQL;
} }
} }

View File

@ -18,11 +18,11 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.Collection;
import me.ryanhamshire.GriefPrevention.events.AccrueClaimBlocksEvent; import me.ryanhamshire.GriefPrevention.events.AccrueClaimBlocksEvent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collection;
//FEATURE: give players claim blocks for playing, as long as they're not away from their computer //FEATURE: give players claim blocks for playing, as long as they're not away from their computer
//runs every 5 minutes in the main thread, grants blocks per hour / 12 to each online player who appears to be actively playing //runs every 5 minutes in the main thread, grants blocks per hour / 12 to each online player who appears to be actively playing

View File

@ -73,9 +73,7 @@ class EntityCleanupTask implements Runnable
{ {
Boat boat = (Boat) entity; Boat boat = (Boat) entity;
if (boat.isEmpty()) remove = true; if (boat.isEmpty()) remove = true;
} } else if (entity instanceof Vehicle)
else if(entity instanceof Vehicle)
{ {
Vehicle vehicle = (Vehicle) entity; Vehicle vehicle = (Vehicle) entity;
@ -106,8 +104,7 @@ class EntityCleanupTask implements Runnable
if (claim != null) if (claim != null)
{ {
cachedClaim = claim; cachedClaim = claim;
} } else
else
{ {
remove = true; remove = true;
} }

View File

@ -29,6 +29,7 @@ import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Explosive; import org.bukkit.entity.Explosive;
@ -38,7 +39,9 @@ import org.bukkit.entity.Horse;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.LightningStrike; import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Mule;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.entity.Rabbit; import org.bukkit.entity.Rabbit;
@ -46,9 +49,6 @@ import org.bukkit.entity.Tameable;
import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
import org.bukkit.entity.WaterMob; import org.bukkit.entity.WaterMob;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Mule;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.entity.minecart.ExplosiveMinecart; import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -125,7 +125,8 @@ public class EntityEventHandler implements Listener
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onLightningStrike(LightningStrikeEvent event){ public void onLightningStrike(LightningStrikeEvent event)
{
if (event.getCause() == LightningStrikeEvent.Cause.TRIDENT) if (event.getCause() == LightningStrikeEvent.Cause.TRIDENT)
event.getLightning().setMetadata("GP_TRIDENT", new FixedMetadataValue(GriefPrevention.instance, event.getLightning().getLocation())); event.getLightning().setMetadata("GP_TRIDENT", new FixedMetadataValue(GriefPrevention.instance, event.getLightning().getLocation()));
} }
@ -136,18 +137,13 @@ public class EntityEventHandler implements Listener
if (!GriefPrevention.instance.config_endermenMoveBlocks && event.getEntityType() == EntityType.ENDERMAN) if (!GriefPrevention.instance.config_endermenMoveBlocks && event.getEntityType() == EntityType.ENDERMAN)
{ {
event.setCancelled(true); event.setCancelled(true);
} } else if (!GriefPrevention.instance.config_silverfishBreakBlocks && event.getEntityType() == EntityType.SILVERFISH)
else if(!GriefPrevention.instance.config_silverfishBreakBlocks && event.getEntityType() == EntityType.SILVERFISH)
{ {
event.setCancelled(true); event.setCancelled(true);
} } else if (!GriefPrevention.instance.config_rabbitsEatCrops && event.getEntityType() == EntityType.RABBIT)
else if(!GriefPrevention.instance.config_rabbitsEatCrops && event.getEntityType() == EntityType.RABBIT)
{ {
event.setCancelled(true); event.setCancelled(true);
} } else if (GriefPrevention.instance.config_claims_worldModes.get(event.getBlock().getWorld()) != ClaimsMode.Disabled)
else if(GriefPrevention.instance.config_claims_worldModes.get(event.getBlock().getWorld()) != ClaimsMode.Disabled)
{ {
if (event.getEntityType() == EntityType.WITHER) if (event.getEntityType() == EntityType.WITHER)
{ {
@ -156,9 +152,7 @@ public class EntityEventHandler implements Listener
{ {
event.setCancelled(true); event.setCancelled(true);
} }
} } else if (!GriefPrevention.instance.config_claims_ravagersBreakBlocks && event.getEntityType() == EntityType.RAVAGER)
else if (!GriefPrevention.instance.config_claims_ravagersBreakBlocks && event.getEntityType() == EntityType.RAVAGER)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -182,11 +176,14 @@ public class EntityEventHandler implements Listener
} }
//Prevent breaking lilypads via collision with a boat. Thanks Jikoo. //Prevent breaking lilypads via collision with a boat. Thanks Jikoo.
else if (event.getEntity() instanceof Vehicle && !event.getEntity().getPassengers().isEmpty()) { else if (event.getEntity() instanceof Vehicle && !event.getEntity().getPassengers().isEmpty())
{
Entity driver = event.getEntity().getPassengers().get(0); Entity driver = event.getEntity().getPassengers().get(0);
if (driver instanceof Player) { if (driver instanceof Player)
{
Block block = event.getBlock(); Block block = event.getBlock();
if (GriefPrevention.instance.allowBreak((Player) driver, block, block.getLocation()) != null) { if (GriefPrevention.instance.allowBreak((Player) driver, block, block.getLocation()) != null)
{
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -279,8 +276,7 @@ public class EntityEventHandler implements Listener
if (!GriefPrevention.instance.config_creaturesTrampleCrops) if (!GriefPrevention.instance.config_creaturesTrampleCrops)
{ {
event.setCancelled(true); event.setCancelled(true);
} } else
else
{ {
Entity rider = event.getEntity().getPassenger(); Entity rider = event.getEntity().getPassenger();
if (rider != null && rider.getType() == EntityType.PLAYER) if (rider != null && rider.getType() == EntityType.PLAYER)
@ -655,7 +651,8 @@ public class EntityEventHandler implements Listener
if (entity instanceof Monster) return true; if (entity instanceof Monster) return true;
EntityType type = entity.getType(); EntityType type = entity.getType();
if(type == EntityType.GHAST || type == EntityType.MAGMA_CUBE || type == EntityType.SHULKER || type == EntityType.POLAR_BEAR) return true; if (type == EntityType.GHAST || type == EntityType.MAGMA_CUBE || type == EntityType.SHULKER || type == EntityType.POLAR_BEAR)
return true;
if (type == EntityType.RABBIT) if (type == EntityType.RABBIT)
{ {
@ -748,17 +745,18 @@ public class EntityEventHandler implements Listener
if (damageSource.getType() == EntityType.PLAYER) if (damageSource.getType() == EntityType.PLAYER)
{ {
attacker = (Player) damageSource; attacker = (Player) damageSource;
} } else if (damageSource instanceof Projectile)
else if(damageSource instanceof Projectile)
{ {
arrow = (Projectile) damageSource; arrow = (Projectile) damageSource;
if (arrow.getShooter() instanceof Player) if (arrow.getShooter() instanceof Player)
{ {
attacker = (Player) arrow.getShooter(); attacker = (Player) arrow.getShooter();
} }
}else if(subEvent.getDamager() instanceof Firework) { } else if (subEvent.getDamager() instanceof Firework)
{
damageSource = subEvent.getDamager(); damageSource = subEvent.getDamager();
if(damageSource.hasMetadata("GP_FIREWORK")) { if (damageSource.hasMetadata("GP_FIREWORK"))
{
List<MetadataValue> data = damageSource.getMetadata("GP_FIREWORK"); List<MetadataValue> data = damageSource.getMetadata("GP_FIREWORK");
if (data != null && data.size() > 0) if (data != null && data.size() > 0)
{ {
@ -807,7 +805,8 @@ public class EntityEventHandler implements Listener
if (firework != null && event.getEntityType() == EntityType.PLAYER && !GriefPrevention.instance.pvpRulesApply(attacker.getWorld())) if (firework != null && event.getEntityType() == EntityType.PLAYER && !GriefPrevention.instance.pvpRulesApply(attacker.getWorld()))
{ {
Player defender = (Player) (event.getEntity()); Player defender = (Player) (event.getEntity());
if(attacker != defender) { if (attacker != defender)
{
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -832,14 +831,16 @@ public class EntityEventHandler implements Listener
if (defenderData.pvpImmune) if (defenderData.pvpImmune)
{ {
event.setCancelled(true); event.setCancelled(true);
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.ThatPlayerPvPImmune); if (sendErrorMessagesToPlayers)
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.ThatPlayerPvPImmune);
return; return;
} }
if (attackerData.pvpImmune) if (attackerData.pvpImmune)
{ {
event.setCancelled(true); event.setCancelled(true);
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune); if (sendErrorMessagesToPlayers)
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune);
return; return;
} }
} }
@ -860,7 +861,8 @@ public class EntityEventHandler implements Listener
if (!pvpEvent.isCancelled()) if (!pvpEvent.isCancelled())
{ {
event.setCancelled(true); event.setCancelled(true);
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune); if (sendErrorMessagesToPlayers)
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune);
return; return;
} }
} }
@ -876,7 +878,8 @@ public class EntityEventHandler implements Listener
if (!pvpEvent.isCancelled()) if (!pvpEvent.isCancelled())
{ {
event.setCancelled(true); event.setCancelled(true);
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.PlayerInPvPSafeZone); if (sendErrorMessagesToPlayers)
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.PlayerInPvPSafeZone);
return; return;
} }
} }
@ -936,7 +939,8 @@ public class EntityEventHandler implements Listener
|| subEvent.getEntityType() == EntityType.ENDER_CRYSTAL) || subEvent.getEntityType() == EntityType.ENDER_CRYSTAL)
{ {
//allow for disabling villager protections in the config //allow for disabling villager protections in the config
if(subEvent.getEntityType() == EntityType.VILLAGER && !GriefPrevention.instance.config_claims_protectCreatures) return; if (subEvent.getEntityType() == EntityType.VILLAGER && !GriefPrevention.instance.config_claims_protectCreatures)
return;
//don't protect polar bears, they may be aggressive //don't protect polar bears, they may be aggressive
if (subEvent.getEntityType() == EntityType.POLAR_BEAR) return; if (subEvent.getEntityType() == EntityType.POLAR_BEAR) return;
@ -973,7 +977,8 @@ public class EntityEventHandler implements Listener
if (failureReason != null) if (failureReason != null)
{ {
event.setCancelled(true); event.setCancelled(true);
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, failureReason); if (sendErrorMessagesToPlayers)
GriefPrevention.sendMessage(attacker, TextMode.Err, failureReason);
return; return;
} }
} }
@ -1009,7 +1014,8 @@ public class EntityEventHandler implements Listener
String message = GriefPrevention.instance.dataStore.getMessage(Messages.NoDamageClaimedEntity, ownerName); String message = GriefPrevention.instance.dataStore.getMessage(Messages.NoDamageClaimedEntity, ownerName);
if (attacker.hasPermission("griefprevention.ignoreclaims")) if (attacker.hasPermission("griefprevention.ignoreclaims"))
message += " " + GriefPrevention.instance.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement); message += " " + GriefPrevention.instance.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement);
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, message); if (sendErrorMessagesToPlayers)
GriefPrevention.sendMessage(attacker, TextMode.Err, message);
PreventPvPEvent pvpEvent = new PreventPvPEvent(new Claim(subEvent.getEntity().getLocation(), subEvent.getEntity().getLocation(), null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), null)); PreventPvPEvent pvpEvent = new PreventPvPEvent(new Claim(subEvent.getEntity().getLocation(), subEvent.getEntity().getLocation(), null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), null));
Bukkit.getPluginManager().callEvent(pvpEvent); Bukkit.getPluginManager().callEvent(pvpEvent);
if (!pvpEvent.isCancelled()) if (!pvpEvent.isCancelled())
@ -1022,7 +1028,8 @@ public class EntityEventHandler implements Listener
else if (attackerData.pvpImmune) else if (attackerData.pvpImmune)
{ {
event.setCancelled(true); event.setCancelled(true);
if(sendErrorMessagesToPlayers) GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune); if (sendErrorMessagesToPlayers)
GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.CantFightWhileImmune);
return; return;
} }
// disallow players attacking tamed wolves (dogs) unless under attack by said wolf // disallow players attacking tamed wolves (dogs) unless under attack by said wolf
@ -1110,7 +1117,8 @@ public class EntityEventHandler implements Listener
//kill the arrow to avoid infinite bounce between crowded together animals //RoboMWM: except for tridents //kill the arrow to avoid infinite bounce between crowded together animals //RoboMWM: except for tridents
if (arrow != null && arrow.getType() != EntityType.TRIDENT) arrow.remove(); if (arrow != null && arrow.getType() != EntityType.TRIDENT) arrow.remove();
if(damageSource != null && damageSource.getType() == EntityType.FIREWORK && event.getEntity().getType() != EntityType.PLAYER) return; if (damageSource != null && damageSource.getType() == EntityType.FIREWORK && event.getEntity().getType() != EntityType.PLAYER)
return;
if (sendErrorMessagesToPlayers) if (sendErrorMessagesToPlayers)
{ {
@ -1134,8 +1142,10 @@ public class EntityEventHandler implements Listener
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onCrossbowFireWork(EntityShootBowEvent shootEvent) { public void onCrossbowFireWork(EntityShootBowEvent shootEvent)
if(shootEvent.getEntity() instanceof Player && shootEvent.getProjectile() instanceof Firework) { {
if (shootEvent.getEntity() instanceof Player && shootEvent.getProjectile() instanceof Firework)
{
shootEvent.getProjectile().setMetadata("GP_FIREWORK", new FixedMetadataValue(GriefPrevention.instance, shootEvent.getEntity())); shootEvent.getProjectile().setMetadata("GP_FIREWORK", new FixedMetadataValue(GriefPrevention.instance, shootEvent.getEntity()));
} }
} }
@ -1172,17 +1182,17 @@ public class EntityEventHandler implements Listener
if (damageSource.getType() == EntityType.PLAYER) if (damageSource.getType() == EntityType.PLAYER)
{ {
attacker = (Player) damageSource; attacker = (Player) damageSource;
} } else if (damageSource instanceof Projectile)
else if(damageSource instanceof Projectile)
{ {
arrow = (Projectile) damageSource; arrow = (Projectile) damageSource;
if (arrow.getShooter() instanceof Player) if (arrow.getShooter() instanceof Player)
{ {
attacker = (Player) arrow.getShooter(); attacker = (Player) arrow.getShooter();
} }
} } else if (damageSource instanceof Firework)
else if(damageSource instanceof Firework) { {
if(damageSource.hasMetadata("GP_FIREWORK")) { if (damageSource.hasMetadata("GP_FIREWORK"))
{
List<MetadataValue> data = damageSource.getMetadata("GP_FIREWORK"); List<MetadataValue> data = damageSource.getMetadata("GP_FIREWORK");
if (data != null && data.size() > 0) if (data != null && data.size() > 0)
{ {
@ -1234,17 +1244,17 @@ public class EntityEventHandler implements Listener
if (damageSource.getType() == EntityType.PLAYER) if (damageSource.getType() == EntityType.PLAYER)
{ {
attacker = (Player) damageSource; attacker = (Player) damageSource;
} } else if (damageSource instanceof Projectile)
else if(damageSource instanceof Projectile)
{ {
Projectile arrow = (Projectile) damageSource; Projectile arrow = (Projectile) damageSource;
if (arrow.getShooter() instanceof Player) if (arrow.getShooter() instanceof Player)
{ {
attacker = (Player) arrow.getShooter(); attacker = (Player) arrow.getShooter();
} }
} } else if (damageSource instanceof Firework)
else if(damageSource instanceof Firework) { {
if(damageSource.hasMetadata("GP_FIREWORK")) { if (damageSource.hasMetadata("GP_FIREWORK"))
{
List<MetadataValue> data = damageSource.getMetadata("GP_FIREWORK"); List<MetadataValue> data = damageSource.getMetadata("GP_FIREWORK");
if (data != null && data.size() > 0) if (data != null && data.size() > 0)
{ {

View File

@ -38,7 +38,8 @@ class EquipShovelProcessingTask implements Runnable
public void run() public void run()
{ {
//if he's not holding the golden shovel anymore, do nothing //if he's not holding the golden shovel anymore, do nothing
if(GriefPrevention.instance.getItemInHand(player, EquipmentSlot.HAND).getType() != GriefPrevention.instance.config_claims_modificationTool) return; if (GriefPrevention.instance.getItemInHand(player, EquipmentSlot.HAND).getType() != GriefPrevention.instance.config_claims_modificationTool)
return;
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()); PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId());
@ -61,8 +62,7 @@ class EquipShovelProcessingTask implements Runnable
if (GriefPrevention.instance.creativeRulesApply(player.getLocation())) if (GriefPrevention.instance.creativeRulesApply(player.getLocation()))
{ {
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL); GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL);
} } else if (GriefPrevention.instance.claimsEnabledForWorld(player.getLocation().getWorld()))
else if(GriefPrevention.instance.claimsEnabledForWorld(player.getLocation().getWorld()))
{ {
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL); GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL);
} }

View File

@ -57,12 +57,14 @@ class FindUnusedClaimsTask implements Runnable
GriefPrevention.instance.getServer().getScheduler().runTaskAsynchronously(GriefPrevention.instance, new CleanupUnusedClaimPreTask(claimOwnerIterator.next())); GriefPrevention.instance.getServer().getScheduler().runTaskAsynchronously(GriefPrevention.instance, new CleanupUnusedClaimPreTask(claimOwnerIterator.next()));
} }
public void refreshUUIDs() { public void refreshUUIDs()
{
// Fetch owner UUIDs from list of claims // Fetch owner UUIDs from list of claims
claimOwnerUUIDs = GriefPrevention.instance.dataStore.claims.stream().map(claim -> claim.ownerID) claimOwnerUUIDs = GriefPrevention.instance.dataStore.claims.stream().map(claim -> claim.ownerID)
.distinct().filter(Objects::nonNull).collect(Collectors.toList()); .distinct().filter(Objects::nonNull).collect(Collectors.toList());
if (!claimOwnerUUIDs.isEmpty()) { if (!claimOwnerUUIDs.isEmpty())
{
// Randomize order // Randomize order
Collections.shuffle(claimOwnerUUIDs); Collections.shuffle(claimOwnerUUIDs);
} }

View File

@ -206,8 +206,7 @@ public class FlatFileDataStore extends DataStore
if (this.getSchemaVersion() <= 1) if (this.getSchemaVersion() <= 1)
{ {
this.loadClaimData_Legacy(files); this.loadClaimData_Legacy(files);
} } else
else
{ {
this.loadClaimData(files); this.loadClaimData(files);
} }
@ -284,8 +283,7 @@ public class FlatFileDataStore extends DataStore
if (ownerName.isEmpty() || ownerName.startsWith("--")) if (ownerName.isEmpty() || ownerName.startsWith("--"))
{ {
ownerID = null; //administrative land claim or subdivision ownerID = null; //administrative land claim or subdivision
} } else if (this.getSchemaVersion() == 0)
else if(this.getSchemaVersion() == 0)
{ {
try try
{ {
@ -296,8 +294,7 @@ public class FlatFileDataStore extends DataStore
GriefPrevention.AddLogEntry("Couldn't resolve this name to a UUID: " + ownerName + "."); GriefPrevention.AddLogEntry("Couldn't resolve this name to a UUID: " + ownerName + ".");
GriefPrevention.AddLogEntry(" Converted land claim to administrative @ " + lesserBoundaryCorner.toString()); GriefPrevention.AddLogEntry(" Converted land claim to administrative @ " + lesserBoundaryCorner.toString());
} }
} } else
else
{ {
try try
{ {
@ -373,8 +370,7 @@ public class FlatFileDataStore extends DataStore
GriefPrevention.AddLogEntry("Failed to load a claim " + files[i].getName() + " because its world isn't loaded (yet?). Please delete the claim file or contact the GriefPrevention developer with information about which plugin(s) you're using to load or create worlds. " + lesserCornerString); GriefPrevention.AddLogEntry("Failed to load a claim " + files[i].getName() + " because its world isn't loaded (yet?). Please delete the claim file or contact the GriefPrevention developer with information about which plugin(s) you're using to load or create worlds. " + lesserCornerString);
inStream.close(); inStream.close();
} } else
else
{ {
StringWriter errors = new StringWriter(); StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors)); e.printStackTrace(new PrintWriter(errors));
@ -435,8 +431,7 @@ public class FlatFileDataStore extends DataStore
if (out_parentID.size() == 0 || out_parentID.get(0) == -1) if (out_parentID.size() == 0 || out_parentID.get(0) == -1)
{ {
this.addClaim(claim, false); this.addClaim(claim, false);
} } else
else
{ {
orphans.put(claim, out_parentID.get(0)); orphans.put(claim, out_parentID.get(0));
} }
@ -448,8 +443,7 @@ public class FlatFileDataStore extends DataStore
if (e.getMessage() != null && e.getMessage().contains("World not found")) if (e.getMessage() != null && e.getMessage().contains("World not found"))
{ {
files[i].delete(); files[i].delete();
} } else
else
{ {
StringWriter errors = new StringWriter(); StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors)); e.printStackTrace(new PrintWriter(errors));
@ -903,8 +897,7 @@ public class FlatFileDataStore extends DataStore
catch (IOException exception) {} catch (IOException exception) {}
return schemaVersion; return schemaVersion;
} } else
else
{ {
this.updateSchemaVersionInStorage(0); this.updateSchemaVersionInStorage(0);
return 0; return 0;

View File

@ -18,6 +18,42 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import me.ryanhamshire.GriefPrevention.DataStore.NoTransferException;
import me.ryanhamshire.GriefPrevention.events.PreventBlockBreakEvent;
import me.ryanhamshire.GriefPrevention.events.SaveTrappedPlayerEvent;
import me.ryanhamshire.GriefPrevention.events.TrustChangedEvent;
import me.ryanhamshire.GriefPrevention.metrics.MetricsHandler;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.BanList;
import org.bukkit.BanList.Type;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.BlockIterator;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,42 +68,6 @@ import java.util.logging.Logger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import me.ryanhamshire.GriefPrevention.DataStore.NoTransferException;
import me.ryanhamshire.GriefPrevention.events.PreventBlockBreakEvent;
import me.ryanhamshire.GriefPrevention.events.SaveTrappedPlayerEvent;
import me.ryanhamshire.GriefPrevention.events.TrustChangedEvent;
import me.ryanhamshire.GriefPrevention.metrics.MetricsHandler;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.BanList.Type;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.*;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.BlockIterator;
public class GriefPrevention extends JavaPlugin public class GriefPrevention extends JavaPlugin
{ {
//for convenience, a reference to the instance of this plugin //for convenience, a reference to the instance of this plugin
@ -301,8 +301,10 @@ public class GriefPrevention extends JavaPlugin
if (this.dataStore == null) if (this.dataStore == null)
{ {
File oldclaimdata = new File(getDataFolder(), "ClaimData"); File oldclaimdata = new File(getDataFolder(), "ClaimData");
if(oldclaimdata.exists()) { if (oldclaimdata.exists())
if(!FlatFileDataStore.hasData()) { {
if (!FlatFileDataStore.hasData())
{
File claimdata = new File("plugins" + File.separator + "GriefPreventionData" + File.separator + "ClaimData"); File claimdata = new File("plugins" + File.separator + "GriefPreventionData" + File.separator + "ClaimData");
oldclaimdata.renameTo(claimdata); oldclaimdata.renameTo(claimdata);
File oldplayerdata = new File(getDataFolder(), "PlayerData"); File oldplayerdata = new File(getDataFolder(), "PlayerData");
@ -473,8 +475,7 @@ public class GriefPrevention extends JavaPlugin
this.config_claims_worldModes.put(world, claimsMode); this.config_claims_worldModes.put(world, claimsMode);
if (claimsMode == ClaimsMode.Creative) this.config_creativeWorldsExist = true; if (claimsMode == ClaimsMode.Creative) this.config_creativeWorldsExist = true;
continue; continue;
} } else
else
{ {
GriefPrevention.AddLogEntry("Error: Invalid claim mode \"" + configSetting + "\". Options are Survival, Creative, and Disabled."); GriefPrevention.AddLogEntry("Error: Invalid claim mode \"" + configSetting + "\". Options are Survival, Creative, and Disabled.");
this.config_claims_worldModes.put(world, ClaimsMode.Creative); this.config_claims_worldModes.put(world, ClaimsMode.Creative);
@ -487,9 +488,7 @@ public class GriefPrevention extends JavaPlugin
{ {
this.config_claims_worldModes.put(world, ClaimsMode.Creative); this.config_claims_worldModes.put(world, ClaimsMode.Creative);
this.config_creativeWorldsExist = true; this.config_creativeWorldsExist = true;
} } else if (deprecated_claimsEnabledWorldNames.contains(world.getName()))
else if(deprecated_claimsEnabledWorldNames.contains(world.getName()))
{ {
this.config_claims_worldModes.put(world, ClaimsMode.Survival); this.config_claims_worldModes.put(world, ClaimsMode.Survival);
} }
@ -498,9 +497,7 @@ public class GriefPrevention extends JavaPlugin
else if (world.getName().toLowerCase().contains("survival")) else if (world.getName().toLowerCase().contains("survival"))
{ {
this.config_claims_worldModes.put(world, ClaimsMode.Survival); this.config_claims_worldModes.put(world, ClaimsMode.Survival);
} } else if (world.getName().toLowerCase().contains("creative"))
else if(world.getName().toLowerCase().contains("creative"))
{ {
this.config_claims_worldModes.put(world, ClaimsMode.Creative); this.config_claims_worldModes.put(world, ClaimsMode.Creative);
this.config_creativeWorldsExist = true; this.config_creativeWorldsExist = true;
@ -511,14 +508,10 @@ public class GriefPrevention extends JavaPlugin
{ {
this.config_claims_worldModes.put(world, ClaimsMode.Creative); this.config_claims_worldModes.put(world, ClaimsMode.Creative);
this.config_creativeWorldsExist = true; this.config_creativeWorldsExist = true;
} } else if (world.getEnvironment() == Environment.NORMAL)
else if(world.getEnvironment() == Environment.NORMAL)
{ {
this.config_claims_worldModes.put(world, ClaimsMode.Survival); this.config_claims_worldModes.put(world, ClaimsMode.Survival);
} } else
else
{ {
this.config_claims_worldModes.put(world, ClaimsMode.Disabled); this.config_claims_worldModes.put(world, ClaimsMode.Disabled);
} }
@ -695,8 +688,7 @@ public class GriefPrevention extends JavaPlugin
if (world == null) if (world == null)
{ {
AddLogEntry("Error: Siege Configuration: There's no world named \"" + worldName + "\". Please update your config.yml."); AddLogEntry("Error: Siege Configuration: There's no world named \"" + worldName + "\". Please update your config.yml.");
} } else
else
{ {
this.config_siege_enabledWorlds.add(world); this.config_siege_enabledWorlds.add(world);
} }
@ -763,8 +755,7 @@ public class GriefPrevention extends JavaPlugin
if (material == null) if (material == null)
{ {
GriefPrevention.AddLogEntry("Siege Configuration: Material not found: " + blockName + "."); GriefPrevention.AddLogEntry("Siege Configuration: Material not found: " + blockName + ".");
} } else
else
{ {
this.config_siege_blocks.add(material); this.config_siege_blocks.add(material);
} }
@ -984,20 +975,16 @@ public class GriefPrevention extends JavaPlugin
if (configSetting.equalsIgnoreCase("Survival")) if (configSetting.equalsIgnoreCase("Survival"))
{ {
return ClaimsMode.Survival; return ClaimsMode.Survival;
} } else if (configSetting.equalsIgnoreCase("Creative"))
else if(configSetting.equalsIgnoreCase("Creative"))
{ {
return ClaimsMode.Creative; return ClaimsMode.Creative;
} } else if (configSetting.equalsIgnoreCase("Disabled"))
else if(configSetting.equalsIgnoreCase("Disabled"))
{ {
return ClaimsMode.Disabled; return ClaimsMode.Disabled;
} } else if (configSetting.equalsIgnoreCase("SurvivalRequiringClaims"))
else if(configSetting.equalsIgnoreCase("SurvivalRequiringClaims"))
{ {
return ClaimsMode.SurvivalRequiringClaims; return ClaimsMode.SurvivalRequiringClaims;
} } else
else
{ {
return null; return null;
} }
@ -1005,7 +992,8 @@ public class GriefPrevention extends JavaPlugin
//handles slash commands //handles slash commands
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
{
Player player = null; Player player = null;
if (sender instanceof Player) if (sender instanceof Player)
@ -1073,8 +1061,7 @@ public class GriefPrevention extends JavaPlugin
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.MinimumRadius, String.valueOf(radius)); GriefPrevention.sendMessage(player, TextMode.Err, Messages.MinimumRadius, String.valueOf(radius));
return true; return true;
} } else
else
{ {
radius = specifiedRadius; radius = specifiedRadius;
} }
@ -1109,13 +1096,11 @@ public class GriefPrevention extends JavaPlugin
Visualization visualization = Visualization.FromClaim(result.claim, player.getEyeLocation().getBlockY(), VisualizationType.ErrorClaim, player.getLocation()); Visualization visualization = Visualization.FromClaim(result.claim, player.getEyeLocation().getBlockY(), VisualizationType.ErrorClaim, player.getLocation());
Visualization.Apply(player, visualization); Visualization.Apply(player, visualization);
} } else
else
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.CreateClaimFailOverlapRegion); GriefPrevention.sendMessage(player, TextMode.Err, Messages.CreateClaimFailOverlapRegion);
} }
} } else
else
{ {
GriefPrevention.sendMessage(player, TextMode.Success, Messages.CreateClaimSuccess); GriefPrevention.sendMessage(player, TextMode.Success, Messages.CreateClaimSuccess);
@ -1123,8 +1108,7 @@ public class GriefPrevention extends JavaPlugin
if (GriefPrevention.instance.creativeRulesApply(player.getLocation())) if (GriefPrevention.instance.creativeRulesApply(player.getLocation()))
{ {
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL); GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL);
} } else if (GriefPrevention.instance.claimsEnabledForWorld(player.getLocation().getWorld()))
else if(GriefPrevention.instance.claimsEnabledForWorld(player.getLocation().getWorld()))
{ {
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL); GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL);
} }
@ -1148,8 +1132,7 @@ public class GriefPrevention extends JavaPlugin
if (GriefPrevention.instance.creativeRulesApply(player.getLocation())) if (GriefPrevention.instance.creativeRulesApply(player.getLocation()))
{ {
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL); GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL);
} } else if (GriefPrevention.instance.claimsEnabledForWorld(player.getLocation().getWorld()))
else if(GriefPrevention.instance.claimsEnabledForWorld(player.getLocation().getWorld()))
{ {
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL); GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL);
} }
@ -1167,8 +1150,7 @@ public class GriefPrevention extends JavaPlugin
if (GriefPrevention.instance.creativeRulesApply(player.getLocation())) if (GriefPrevention.instance.creativeRulesApply(player.getLocation()))
{ {
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL); GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL);
} } else if (GriefPrevention.instance.claimsEnabledForWorld(player.getLocation().getWorld()))
else if(GriefPrevention.instance.claimsEnabledForWorld(player.getLocation().getWorld()))
{ {
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL); GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL);
} }
@ -1228,8 +1210,7 @@ public class GriefPrevention extends JavaPlugin
if (direction.getZ() > 0) if (direction.getZ() > 0)
{ {
newz2 += amount; //north newz2 += amount; //north
} } else
else
{ {
newz1 -= amount; //south newz1 -= amount; //south
} }
@ -1241,8 +1222,7 @@ public class GriefPrevention extends JavaPlugin
if (direction.getX() > 0) if (direction.getX() > 0)
{ {
newx2 += amount; //east newx2 += amount; //east
} } else
else
{ {
newx1 -= amount; //west newx1 -= amount; //west
} }
@ -1254,8 +1234,7 @@ public class GriefPrevention extends JavaPlugin
if (direction.getX() > 0) if (direction.getX() > 0)
{ {
newx2 += amount; newx2 += amount;
} } else
else
{ {
newx1 -= amount; newx1 -= amount;
} }
@ -1263,8 +1242,7 @@ public class GriefPrevention extends JavaPlugin
if (direction.getZ() > 0) if (direction.getZ() > 0)
{ {
newz2 += amount; newz2 += amount;
} } else
else
{ {
newz1 -= amount; newz1 -= amount;
} }
@ -1301,8 +1279,7 @@ public class GriefPrevention extends JavaPlugin
if (!playerData.ignoreClaims) if (!playerData.ignoreClaims)
{ {
GriefPrevention.sendMessage(player, TextMode.Success, Messages.RespectingClaims); GriefPrevention.sendMessage(player, TextMode.Success, Messages.RespectingClaims);
} } else
else
{ {
GriefPrevention.sendMessage(player, TextMode.Success, Messages.IgnoringClaims); GriefPrevention.sendMessage(player, TextMode.Success, Messages.IgnoringClaims);
} }
@ -1564,15 +1541,12 @@ public class GriefPrevention extends JavaPlugin
if (claim == null || claim.allowEdit(player) == null) if (claim == null || claim.allowEdit(player) == null)
{ {
clearPermissions = true; clearPermissions = true;
} } else
else
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.ClearPermsOwnerOnly); GriefPrevention.sendMessage(player, TextMode.Err, Messages.ClearPermsOwnerOnly);
return true; return true;
} }
} } else
else
{ {
//validate player argument or group argument //validate player argument or group argument
if (!args[0].startsWith("[") || !args[0].endsWith("]")) if (!args[0].startsWith("[") || !args[0].endsWith("]"))
@ -1605,7 +1579,8 @@ public class GriefPrevention extends JavaPlugin
TrustChangedEvent event = new TrustChangedEvent(player, playerData.getClaims(), null, false, idToDrop); TrustChangedEvent event = new TrustChangedEvent(player, playerData.getClaims(), null, false, idToDrop);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled())
{
return true; return true;
} }
@ -1641,8 +1616,7 @@ public class GriefPrevention extends JavaPlugin
if (!clearPermissions) if (!clearPermissions)
{ {
GriefPrevention.sendMessage(player, TextMode.Success, Messages.UntrustIndividualAllClaims, args[0]); GriefPrevention.sendMessage(player, TextMode.Success, Messages.UntrustIndividualAllClaims, args[0]);
} } else
else
{ {
GriefPrevention.sendMessage(player, TextMode.Success, Messages.UntrustEveryoneAllClaims); GriefPrevention.sendMessage(player, TextMode.Success, Messages.UntrustEveryoneAllClaims);
} }
@ -1653,8 +1627,7 @@ public class GriefPrevention extends JavaPlugin
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoPermissionTrust, claim.getOwnerName()); GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoPermissionTrust, claim.getOwnerName());
return true; return true;
} } else
else
{ {
//if clearing all //if clearing all
if (clearPermissions) if (clearPermissions)
@ -1670,7 +1643,8 @@ public class GriefPrevention extends JavaPlugin
TrustChangedEvent event = new TrustChangedEvent(player, claim, null, false, args[0]); TrustChangedEvent event = new TrustChangedEvent(player, claim, null, false, args[0]);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled())
{
return true; return true;
} }
@ -1691,14 +1665,14 @@ public class GriefPrevention extends JavaPlugin
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.ManagersDontUntrustManagers, claim.getOwnerName()); GriefPrevention.sendMessage(player, TextMode.Err, Messages.ManagersDontUntrustManagers, claim.getOwnerName());
return true; return true;
} } else
else
{ {
//calling the event //calling the event
TrustChangedEvent event = new TrustChangedEvent(player, claim, null, false, idToDrop); TrustChangedEvent event = new TrustChangedEvent(player, claim, null, false, idToDrop);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled())
{
return true; return true;
} }
@ -1779,8 +1753,7 @@ public class GriefPrevention extends JavaPlugin
{ {
claim.setSubclaimRestrictions(false); claim.setSubclaimRestrictions(false);
GriefPrevention.sendMessage(player, TextMode.Success, Messages.SubclaimUnrestricted); GriefPrevention.sendMessage(player, TextMode.Success, Messages.SubclaimUnrestricted);
} } else
else
{ {
claim.setSubclaimRestrictions(true); claim.setSubclaimRestrictions(true);
GriefPrevention.sendMessage(player, TextMode.Success, Messages.SubclaimRestricted); GriefPrevention.sendMessage(player, TextMode.Success, Messages.SubclaimRestricted);
@ -1817,9 +1790,7 @@ public class GriefPrevention extends JavaPlugin
{ {
GriefPrevention.sendMessage(player, TextMode.Info, Messages.BlockPurchaseCost, String.valueOf(GriefPrevention.instance.config_economy_claimBlocksPurchaseCost), String.valueOf(GriefPrevention.economy.getBalance(player.getName()))); GriefPrevention.sendMessage(player, TextMode.Info, Messages.BlockPurchaseCost, String.valueOf(GriefPrevention.instance.config_economy_claimBlocksPurchaseCost), String.valueOf(GriefPrevention.economy.getBalance(player.getName())));
return false; return false;
} } else
else
{ {
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId()); PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
@ -1991,9 +1962,7 @@ public class GriefPrevention extends JavaPlugin
if (claim == null) if (claim == null)
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.DeleteClaimMissing); GriefPrevention.sendMessage(player, TextMode.Err, Messages.DeleteClaimMissing);
} } else
else
{ {
//deleting an admin claim additionally requires the adminclaims permission //deleting an admin claim additionally requires the adminclaims permission
if (!claim.isAdminClaim() || player.hasPermission("griefprevention.adminclaims")) if (!claim.isAdminClaim() || player.hasPermission("griefprevention.adminclaims"))
@ -2003,8 +1972,7 @@ public class GriefPrevention extends JavaPlugin
{ {
GriefPrevention.sendMessage(player, TextMode.Warn, Messages.DeletionSubdivisionWarning); GriefPrevention.sendMessage(player, TextMode.Warn, Messages.DeletionSubdivisionWarning);
playerData.warnedAboutMajorDeletion = true; playerData.warnedAboutMajorDeletion = true;
} } else
else
{ {
claim.removeSurfaceFluids(null); claim.removeSurfaceFluids(null);
this.dataStore.deleteClaim(claim, true, true); this.dataStore.deleteClaim(claim, true, true);
@ -2023,17 +1991,14 @@ public class GriefPrevention extends JavaPlugin
playerData.warnedAboutMajorDeletion = false; playerData.warnedAboutMajorDeletion = false;
} }
} } else
else
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.CantDeleteAdminClaim); GriefPrevention.sendMessage(player, TextMode.Err, Messages.CantDeleteAdminClaim);
} }
} }
return true; return true;
} } else if (cmd.getName().equalsIgnoreCase("claimexplosions") && player != null)
else if(cmd.getName().equalsIgnoreCase("claimexplosions") && player != null)
{ {
//determine which claim the player is standing in //determine which claim the player is standing in
Claim claim = this.dataStore.getClaimAt(player.getLocation(), true /*ignore height*/, null); Claim claim = this.dataStore.getClaimAt(player.getLocation(), true /*ignore height*/, null);
@ -2041,9 +2006,7 @@ public class GriefPrevention extends JavaPlugin
if (claim == null) if (claim == null)
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.DeleteClaimMissing); GriefPrevention.sendMessage(player, TextMode.Err, Messages.DeleteClaimMissing);
} } else
else
{ {
String noBuildReason = claim.allowBuild(player, Material.STONE); String noBuildReason = claim.allowBuild(player, Material.STONE);
if (noBuildReason != null) if (noBuildReason != null)
@ -2056,8 +2019,7 @@ public class GriefPrevention extends JavaPlugin
{ {
claim.areExplosivesAllowed = false; claim.areExplosivesAllowed = false;
GriefPrevention.sendMessage(player, TextMode.Success, Messages.ExplosivesDisabled); GriefPrevention.sendMessage(player, TextMode.Success, Messages.ExplosivesDisabled);
} } else
else
{ {
claim.areExplosivesAllowed = true; claim.areExplosivesAllowed = true;
GriefPrevention.sendMessage(player, TextMode.Success, Messages.ExplosivesEnabled); GriefPrevention.sendMessage(player, TextMode.Success, Messages.ExplosivesEnabled);
@ -2094,9 +2056,7 @@ public class GriefPrevention extends JavaPlugin
} }
return true; return true;
} } else if (cmd.getName().equalsIgnoreCase("deleteclaimsinworld"))
else if(cmd.getName().equalsIgnoreCase("deleteclaimsinworld"))
{ {
//must be executed at the console //must be executed at the console
if (player != null) if (player != null)
@ -2120,9 +2080,7 @@ public class GriefPrevention extends JavaPlugin
this.dataStore.deleteClaimsInWorld(world, true); this.dataStore.deleteClaimsInWorld(world, true);
GriefPrevention.AddLogEntry("Deleted all claims in world: " + world.getName() + ".", CustomLogEntryTypes.AdminActivity); GriefPrevention.AddLogEntry("Deleted all claims in world: " + world.getName() + ".", CustomLogEntryTypes.AdminActivity);
return true; return true;
} } else if (cmd.getName().equalsIgnoreCase("deleteuserclaimsinworld"))
else if(cmd.getName().equalsIgnoreCase("deleteuserclaimsinworld"))
{ {
//must be executed at the console //must be executed at the console
if (player != null) if (player != null)
@ -2160,8 +2118,7 @@ public class GriefPrevention extends JavaPlugin
{ {
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2); GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2);
return true; return true;
} } else
else
{ {
WelcomeTask task = new WelcomeTask(otherPlayer); WelcomeTask task = new WelcomeTask(otherPlayer);
task.run(); task.run();
@ -2272,8 +2229,7 @@ public class GriefPrevention extends JavaPlugin
playerData = this.dataStore.getPlayerData(otherPlayer.getUniqueId()); playerData = this.dataStore.getPlayerData(otherPlayer.getUniqueId());
GriefPrevention.sendMessage(player, TextMode.Success, Messages.DropUnlockOthersConfirmation, otherPlayer.getName()); GriefPrevention.sendMessage(player, TextMode.Success, Messages.DropUnlockOthersConfirmation, otherPlayer.getName());
} } else
else
{ {
playerData = this.dataStore.getPlayerData(player.getUniqueId()); playerData = this.dataStore.getPlayerData(player.getUniqueId());
GriefPrevention.sendMessage(player, TextMode.Success, Messages.DropUnlockConfirmation); GriefPrevention.sendMessage(player, TextMode.Success, Messages.DropUnlockConfirmation);
@ -2332,7 +2288,8 @@ public class GriefPrevention extends JavaPlugin
int newTotal = this.dataStore.adjustGroupBonusBlocks(permissionIdentifier, adjustment); int newTotal = this.dataStore.adjustGroupBonusBlocks(permissionIdentifier, adjustment);
GriefPrevention.sendMessage(player, TextMode.Success, Messages.AdjustGroupBlocksSuccess, permissionIdentifier, String.valueOf(adjustment), String.valueOf(newTotal)); GriefPrevention.sendMessage(player, TextMode.Success, Messages.AdjustGroupBlocksSuccess, permissionIdentifier, String.valueOf(adjustment), String.valueOf(newTotal));
if(player != null) GriefPrevention.AddLogEntry(player.getName() + " adjusted " + permissionIdentifier + "'s bonus claim blocks by " + adjustment + "."); if (player != null)
GriefPrevention.AddLogEntry(player.getName() + " adjusted " + permissionIdentifier + "'s bonus claim blocks by " + adjustment + ".");
return true; return true;
} }
@ -2362,7 +2319,8 @@ public class GriefPrevention extends JavaPlugin
this.dataStore.savePlayerData(targetPlayer.getUniqueId(), playerData); this.dataStore.savePlayerData(targetPlayer.getUniqueId(), playerData);
GriefPrevention.sendMessage(player, TextMode.Success, Messages.AdjustBlocksSuccess, targetPlayer.getName(), String.valueOf(adjustment), String.valueOf(playerData.getBonusClaimBlocks())); GriefPrevention.sendMessage(player, TextMode.Success, Messages.AdjustBlocksSuccess, targetPlayer.getName(), String.valueOf(adjustment), String.valueOf(playerData.getBonusClaimBlocks()));
if(player != null) GriefPrevention.AddLogEntry(player.getName() + " adjusted " + targetPlayer.getName() + "'s bonus claim blocks by " + adjustment + ".", CustomLogEntryTypes.AdminActivity); if (player != null)
GriefPrevention.AddLogEntry(player.getName() + " adjusted " + targetPlayer.getName() + "'s bonus claim blocks by " + adjustment + ".", CustomLogEntryTypes.AdminActivity);
return true; return true;
} }
@ -2434,7 +2392,8 @@ public class GriefPrevention extends JavaPlugin
this.dataStore.savePlayerData(targetPlayer.getUniqueId(), playerData); this.dataStore.savePlayerData(targetPlayer.getUniqueId(), playerData);
GriefPrevention.sendMessage(player, TextMode.Success, Messages.SetClaimBlocksSuccess); GriefPrevention.sendMessage(player, TextMode.Success, Messages.SetClaimBlocksSuccess);
if(player != null) GriefPrevention.AddLogEntry(player.getName() + " set " + targetPlayer.getName() + "'s accrued claim blocks to " + newAmount + ".", CustomLogEntryTypes.AdminActivity); if (player != null)
GriefPrevention.AddLogEntry(player.getName() + " set " + targetPlayer.getName() + "'s accrued claim blocks to " + newAmount + ".", CustomLogEntryTypes.AdminActivity);
return true; return true;
} }
@ -2539,16 +2498,15 @@ public class GriefPrevention extends JavaPlugin
{ {
return false; return false;
} }
} } else
else
{ {
return false; return false;
} }
// First off, you cannot siege yourself, that's just // First off, you cannot siege yourself, that's just
// silly: // silly:
if (attacker.getName().equals( defender.getName() )) { if (attacker.getName().equals(defender.getName()))
{
GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoSiegeYourself); GriefPrevention.sendMessage(player, TextMode.Err, Messages.NoSiegeYourself);
return true; return true;
} }
@ -2620,8 +2578,7 @@ public class GriefPrevention extends JavaPlugin
GriefPrevention.sendMessage(player, TextMode.Success, Messages.SiegeConfirmed, defender.getName()); GriefPrevention.sendMessage(player, TextMode.Success, Messages.SiegeConfirmed, defender.getName());
return true; return true;
} } else if (cmd.getName().equalsIgnoreCase("softmute"))
else if(cmd.getName().equalsIgnoreCase("softmute"))
{ {
//requires one parameter //requires one parameter
if (args.length != 1) return false; if (args.length != 1) return false;
@ -2646,23 +2603,19 @@ public class GriefPrevention extends JavaPlugin
} }
GriefPrevention.AddLogEntry(executorName + " muted " + targetPlayer.getName() + ".", CustomLogEntryTypes.AdminActivity, true); GriefPrevention.AddLogEntry(executorName + " muted " + targetPlayer.getName() + ".", CustomLogEntryTypes.AdminActivity, true);
} } else
else
{ {
GriefPrevention.sendMessage(player, TextMode.Success, Messages.UnSoftMuted, targetPlayer.getName()); GriefPrevention.sendMessage(player, TextMode.Success, Messages.UnSoftMuted, targetPlayer.getName());
} }
return true; return true;
} } else if (cmd.getName().equalsIgnoreCase("gpreload"))
else if(cmd.getName().equalsIgnoreCase("gpreload"))
{ {
this.loadConfig(); this.loadConfig();
if (player != null) if (player != null)
{ {
GriefPrevention.sendMessage(player, TextMode.Success, "Configuration updated. If you have updated your Grief Prevention JAR, you still need to /reload or reboot your server."); GriefPrevention.sendMessage(player, TextMode.Success, "Configuration updated. If you have updated your Grief Prevention JAR, you still need to /reload or reboot your server.");
} } else
else
{ {
GriefPrevention.AddLogEntry("Configuration updated. If you have updated your Grief Prevention JAR, you still need to /reload or reboot your server."); GriefPrevention.AddLogEntry("Configuration updated. If you have updated your Grief Prevention JAR, you still need to /reload or reboot your server.");
} }
@ -2787,8 +2740,7 @@ public class GriefPrevention extends JavaPlugin
if (list.isEmpty()) if (list.isEmpty())
{ {
GriefPrevention.sendMessage(player, TextMode.Info, Messages.NotIgnoringAnyone); GriefPrevention.sendMessage(player, TextMode.Info, Messages.NotIgnoringAnyone);
} } else
else
{ {
GriefPrevention.sendMessage(player, TextMode.Info, list); GriefPrevention.sendMessage(player, TextMode.Info, list);
} }
@ -2861,8 +2813,7 @@ public class GriefPrevention extends JavaPlugin
if (mode == IgnoreMode.None) if (mode == IgnoreMode.None)
{ {
playerData.ignoredPlayers.remove(ignoree.getUniqueId()); playerData.ignoredPlayers.remove(ignoree.getUniqueId());
} } else
else
{ {
playerData.ignoredPlayers.put(ignoree.getUniqueId(), mode == IgnoreMode.StandardIgnore ? false : true); playerData.ignoredPlayers.put(ignoree.getUniqueId(), mode == IgnoreMode.StandardIgnore ? false : true);
} }
@ -2875,15 +2826,15 @@ public class GriefPrevention extends JavaPlugin
} }
} }
public enum IgnoreMode {None, StandardIgnore, AdminIgnore} public enum IgnoreMode
{None, StandardIgnore, AdminIgnore}
private String trustEntryToPlayerName(String entry) private String trustEntryToPlayerName(String entry)
{ {
if (entry.startsWith("[") || entry.equals("public")) if (entry.startsWith("[") || entry.equals("public"))
{ {
return entry; return entry;
} } else
else
{ {
return GriefPrevention.lookupPlayerName(entry); return GriefPrevention.lookupPlayerName(entry);
} }
@ -2916,9 +2867,7 @@ public class GriefPrevention extends JavaPlugin
{ {
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.DeleteTopLevelClaim); GriefPrevention.sendMessage(player, TextMode.Instr, Messages.DeleteTopLevelClaim);
return true; return true;
} } else
else
{ {
//delete it //delete it
claim.removeSurfaceFluids(null); claim.removeSurfaceFluids(null);
@ -2970,14 +2919,10 @@ public class GriefPrevention extends JavaPlugin
GriefPrevention.sendMessage(player, TextMode.Err, Messages.InvalidPermissionID); GriefPrevention.sendMessage(player, TextMode.Err, Messages.InvalidPermissionID);
return; return;
} }
} } else if (recipientName.contains("."))
else if(recipientName.contains("."))
{ {
permission = recipientName; permission = recipientName;
} } else
else
{ {
otherPlayer = this.resolvePlayerByName(recipientName); otherPlayer = this.resolvePlayerByName(recipientName);
if (otherPlayer == null && !recipientName.equals("public") && !recipientName.equals("all")) if (otherPlayer == null && !recipientName.equals("public") && !recipientName.equals("all"))
@ -2990,8 +2935,7 @@ public class GriefPrevention extends JavaPlugin
{ {
recipientName = otherPlayer.getName(); recipientName = otherPlayer.getName();
recipientID = otherPlayer.getUniqueId(); recipientID = otherPlayer.getUniqueId();
} } else
else
{ {
recipientName = "public"; recipientName = "public";
} }
@ -3006,8 +2950,7 @@ public class GriefPrevention extends JavaPlugin
{ {
targetClaims.add(playerData.getClaims().get(i)); targetClaims.add(playerData.getClaims().get(i));
} }
} } else
else
{ {
//check permission here //check permission here
if (claim.allowGrantPermission(player) != null) if (claim.allowGrantPermission(player) != null)
@ -3066,8 +3009,7 @@ public class GriefPrevention extends JavaPlugin
if (permission != null) if (permission != null)
{ {
identifierToAdd = "[" + permission + "]"; identifierToAdd = "[" + permission + "]";
} } else if (recipientID != null)
else if(recipientID != null)
{ {
identifierToAdd = recipientID.toString(); identifierToAdd = recipientID.toString();
} }
@ -3076,7 +3018,8 @@ public class GriefPrevention extends JavaPlugin
TrustChangedEvent event = new TrustChangedEvent(player, targetClaims, permissionLevel, true, identifierToAdd); TrustChangedEvent event = new TrustChangedEvent(player, targetClaims, permissionLevel, true, identifierToAdd);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled())
{
return; return;
} }
@ -3091,8 +3034,7 @@ public class GriefPrevention extends JavaPlugin
{ {
currentClaim.managers.add(identifierToAdd); currentClaim.managers.add(identifierToAdd);
} }
} } else
else
{ {
currentClaim.setPermission(identifierToAdd, permissionLevel); currentClaim.setPermission(identifierToAdd, permissionLevel);
} }
@ -3105,16 +3047,13 @@ public class GriefPrevention extends JavaPlugin
if (permissionLevel == null) if (permissionLevel == null)
{ {
permissionDescription = this.dataStore.getMessage(Messages.PermissionsPermission); permissionDescription = this.dataStore.getMessage(Messages.PermissionsPermission);
} } else if (permissionLevel == ClaimPermission.Build)
else if(permissionLevel == ClaimPermission.Build)
{ {
permissionDescription = this.dataStore.getMessage(Messages.BuildPermission); permissionDescription = this.dataStore.getMessage(Messages.BuildPermission);
} } else if (permissionLevel == ClaimPermission.Access)
else if(permissionLevel == ClaimPermission.Access)
{ {
permissionDescription = this.dataStore.getMessage(Messages.AccessPermission); permissionDescription = this.dataStore.getMessage(Messages.AccessPermission);
} } else //ClaimPermission.Inventory
else //ClaimPermission.Inventory
{ {
permissionDescription = this.dataStore.getMessage(Messages.ContainersPermission); permissionDescription = this.dataStore.getMessage(Messages.ContainersPermission);
} }
@ -3123,8 +3062,7 @@ public class GriefPrevention extends JavaPlugin
if (claim == null) if (claim == null)
{ {
location = this.dataStore.getMessage(Messages.LocationAllClaims); location = this.dataStore.getMessage(Messages.LocationAllClaims);
} } else
else
{ {
location = this.dataStore.getMessage(Messages.LocationCurrentClaim); location = this.dataStore.getMessage(Messages.LocationCurrentClaim);
} }
@ -3214,8 +3152,7 @@ public class GriefPrevention extends JavaPlugin
if (player.hasPlayedBefore() || player.isOnline()) if (player.hasPlayedBefore() || player.isOnline())
{ {
return player.getName(); return player.getName();
} } else
else
{ {
return "someone(" + playerID.toString() + ")"; return "someone(" + playerID.toString() + ")";
} }
@ -3383,8 +3320,7 @@ public class GriefPrevention extends JavaPlugin
if (player == null) if (player == null)
{ {
GriefPrevention.AddLogEntry(color + message); GriefPrevention.AddLogEntry(color + message);
} } else
else
{ {
player.sendMessage(color + message); player.sendMessage(color + message);
} }
@ -3398,8 +3334,7 @@ public class GriefPrevention extends JavaPlugin
if (delayInTicks > 0) if (delayInTicks > 0)
{ {
GriefPrevention.instance.getServer().getScheduler().runTaskLater(GriefPrevention.instance, task, delayInTicks); GriefPrevention.instance.getServer().getScheduler().runTaskLater(GriefPrevention.instance, task, delayInTicks);
} } else
else
{ {
task.run(); task.run();
} }
@ -3449,8 +3384,7 @@ public class GriefPrevention extends JavaPlugin
reason += " " + this.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement); reason += " " + this.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement);
reason += " " + this.dataStore.getMessage(Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL); reason += " " + this.dataStore.getMessage(Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL);
return reason; return reason;
} } else
else
{ {
return null; return null;
} }
@ -3505,8 +3439,7 @@ public class GriefPrevention extends JavaPlugin
{ {
return null; return null;
} }
} } else
else
{ {
//cache the claim for later reference //cache the claim for later reference
playerData.lastClaim = claim; playerData.lastClaim = claim;
@ -3612,8 +3545,7 @@ public class GriefPrevention extends JavaPlugin
if (overrideValue == null || overrideValue == -1) if (overrideValue == null || overrideValue == -1)
{ {
return world.getSeaLevel(); return world.getSeaLevel();
} } else
else
{ {
return overrideValue; return overrideValue;
} }
@ -3701,8 +3633,7 @@ public class GriefPrevention extends JavaPlugin
Bukkit.getServer().dispatchCommand( Bukkit.getServer().dispatchCommand(
Bukkit.getConsoleSender(), Bukkit.getConsoleSender(),
GriefPrevention.instance.config_ban_commandFormat.replace("%name%", player.getName()).replace("%reason%", reason)); GriefPrevention.instance.config_ban_commandFormat.replace("%name%", player.getName()).replace("%reason%", reason));
} } else
else
{ {
BanList bans = Bukkit.getServer().getBanList(Type.NAME); BanList bans = Bukkit.getServer().getBanList(Type.NAME);
bans.addBan(player.getName(), reason, null, source); bans.addBan(player.getName(), reason, null, source);
@ -3788,6 +3719,7 @@ public class GriefPrevention extends JavaPlugin
//Track scheduled "rescues" so we can cancel them if the player happens to teleport elsewhere so we can cancel it. //Track scheduled "rescues" so we can cancel them if the player happens to teleport elsewhere so we can cancel it.
ConcurrentHashMap<UUID, BukkitTask> portalReturnTaskMap = new ConcurrentHashMap<UUID, BukkitTask>(); ConcurrentHashMap<UUID, BukkitTask> portalReturnTaskMap = new ConcurrentHashMap<UUID, BukkitTask>();
public void startRescueTask(Player player, Location location) public void startRescueTask(Player player, Location location)
{ {
//Schedule task to reset player's portal cooldown after 30 seconds (Maximum timeout time for client, in case their network is slow and taking forever to load chunks) //Schedule task to reset player's portal cooldown after 30 seconds (Maximum timeout time for client, in case their network is slow and taking forever to load chunks)

View File

@ -1,13 +1,13 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import com.google.common.io.Files;
import java.io.File; import java.io.File;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import com.google.common.io.Files;
//loads ignore data from file into a hash map //loads ignore data from file into a hash map
class IgnoreLoaderThread extends Thread class IgnoreLoaderThread extends Thread
{ {

View File

@ -79,8 +79,7 @@ public class MaterialInfo
{ {
allDataValues = true; allDataValues = true;
data = 0; data = 0;
} } else
else
{ {
allDataValues = false; allDataValues = false;
data = Byte.parseByte(parts[1]); data = Byte.parseByte(parts[1]);

View File

@ -1,9 +1,10 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.UUID;
class PendingItemProtection class PendingItemProtection
{ {
public Location location; public Location location;

View File

@ -17,24 +17,16 @@
*/ */
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.UUID; import java.util.UUID;
import java.util.Vector; import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import me.ryanhamshire.GriefPrevention.ShovelMode;
import me.ryanhamshire.GriefPrevention.SiegeData;
import me.ryanhamshire.GriefPrevention.Visualization;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
//holds all of GriefPrevention's player-tied data //holds all of GriefPrevention's player-tied data
public class PlayerData public class PlayerData
{ {
@ -231,8 +223,7 @@ public class PlayerData
this.accruedClaimBlocks = GriefPrevention.instance.config_claims_initialBlocks; this.accruedClaimBlocks = GriefPrevention.instance.config_claims_initialBlocks;
} }
} } else
else
{ {
this.accruedClaimBlocks = GriefPrevention.instance.config_claims_initialBlocks; this.accruedClaimBlocks = GriefPrevention.instance.config_claims_initialBlocks;
} }
@ -243,8 +234,7 @@ public class PlayerData
if (storageData.bonusClaimBlocks != null) if (storageData.bonusClaimBlocks != null)
{ {
this.bonusClaimBlocks = storageData.bonusClaimBlocks; this.bonusClaimBlocks = storageData.bonusClaimBlocks;
} } else
else
{ {
this.bonusClaimBlocks = 0; this.bonusClaimBlocks = 0;
} }

View File

@ -17,6 +17,7 @@
*/ */
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import me.ryanhamshire.GriefPrevention.events.VisualizationEvent; import me.ryanhamshire.GriefPrevention.events.VisualizationEvent;
import org.bukkit.BanList; import org.bukkit.BanList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -38,19 +39,19 @@ import org.bukkit.command.Command;
import org.bukkit.entity.AbstractHorse; import org.bukkit.entity.AbstractHorse;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fish; import org.bukkit.entity.Fish;
import org.bukkit.entity.Hanging; import org.bukkit.entity.Hanging;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Mule;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
import org.bukkit.entity.minecart.PoweredMinecart; import org.bukkit.entity.minecart.PoweredMinecart;
import org.bukkit.entity.minecart.StorageMinecart; import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Mule;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -166,8 +167,7 @@ class PlayerEventHandler implements Listener
if (this.dataStore.isSoftMuted(recipient.getUniqueId())) if (this.dataStore.isSoftMuted(recipient.getUniqueId()))
{ {
recipientsToKeep.add(recipient); recipientsToKeep.add(recipient);
} } else if (recipient.hasPermission("griefprevention.eavesdrop"))
else if(recipient.hasPermission("griefprevention.eavesdrop"))
{ {
recipient.sendMessage(ChatColor.GRAY + notificationMessage); recipient.sendMessage(ChatColor.GRAY + notificationMessage);
} }
@ -235,8 +235,7 @@ class PlayerEventHandler implements Listener
if (playerData.ignoredPlayers.containsKey(recipient.getUniqueId())) if (playerData.ignoredPlayers.containsKey(recipient.getUniqueId()))
{ {
recipientsToRemove.add(recipient); recipientsToRemove.add(recipient);
} } else
else
{ {
PlayerData targetPlayerData = this.dataStore.getPlayerData(recipient.getUniqueId()); PlayerData targetPlayerData = this.dataStore.getPlayerData(recipient.getUniqueId());
if (targetPlayerData.ignoredPlayers.containsKey(player.getUniqueId())) if (targetPlayerData.ignoredPlayers.containsKey(player.getUniqueId()))
@ -267,8 +266,7 @@ class PlayerEventHandler implements Listener
if (instance.creativeRulesApply(player.getLocation())) if (instance.creativeRulesApply(player.getLocation()))
{ {
instance.sendMessage(player, TextMode.Info, Messages.CreativeBasicsVideo2, 10L, DataStore.CREATIVE_VIDEO_URL); instance.sendMessage(player, TextMode.Info, Messages.CreativeBasicsVideo2, 10L, DataStore.CREATIVE_VIDEO_URL);
} } else
else
{ {
instance.sendMessage(player, TextMode.Info, Messages.SurvivalBasicsVideo2, 10L, DataStore.SURVIVAL_VIDEO_URL); instance.sendMessage(player, TextMode.Info, Messages.SurvivalBasicsVideo2, 10L, DataStore.SURVIVAL_VIDEO_URL);
} }
@ -279,10 +277,12 @@ class PlayerEventHandler implements Listener
String trappedwords = this.dataStore.getMessage( String trappedwords = this.dataStore.getMessage(
Messages.TrappedChatKeyword Messages.TrappedChatKeyword
); );
if (!trappedwords.isEmpty()) { if (!trappedwords.isEmpty())
{
String[] checkWords = trappedwords.split(";"); String[] checkWords = trappedwords.split(";");
for (String checkWord : checkWords) { for (String checkWord : checkWords)
{
if (!message.contains("/trapped") if (!message.contains("/trapped")
&& message.contains(checkWord)) && message.contains(checkWord))
{ {
@ -323,8 +323,7 @@ class PlayerEventHandler implements Listener
{ {
instance.sendMessage(player, TextMode.Err, Messages.NoChatUntilMove, 10L); instance.sendMessage(player, TextMode.Err, Messages.NoChatUntilMove, 10L);
result.muteReason = "pre-movement chat"; result.muteReason = "pre-movement chat";
} } else
else
{ {
playerData.noChatLocation = null; playerData.noChatLocation = null;
} }
@ -351,8 +350,7 @@ class PlayerEventHandler implements Listener
//kick and ban //kick and ban
PlayerKickBanTask task = new PlayerKickBanTask(player, instance.config_spam_banMessage, "GriefPrevention Anti-Spam", true); PlayerKickBanTask task = new PlayerKickBanTask(player, instance.config_spam_banMessage, "GriefPrevention Anti-Spam", true);
instance.getServer().getScheduler().scheduleSyncDelayedTask(instance, task, 1L); instance.getServer().getScheduler().scheduleSyncDelayedTask(instance, task, 1L);
} } else
else
{ {
//log entry //log entry
instance.AddLogEntry("Kicking " + player.getName() + " for spam.", CustomLogEntryTypes.AdminActivity); instance.AddLogEntry("Kicking " + player.getName() + " for spam.", CustomLogEntryTypes.AdminActivity);
@ -361,9 +359,7 @@ class PlayerEventHandler implements Listener
PlayerKickBanTask task = new PlayerKickBanTask(player, "", "GriefPrevention Anti-Spam", false); PlayerKickBanTask task = new PlayerKickBanTask(player, "", "GriefPrevention Anti-Spam", false);
instance.getServer().getScheduler().scheduleSyncDelayedTask(instance, task, 1L); instance.getServer().getScheduler().scheduleSyncDelayedTask(instance, task, 1L);
} }
} } else if (result.shouldWarnChatter)
else if(result.shouldWarnChatter)
{ {
//warn and log //warn and log
instance.sendMessage(player, TextMode.Warn, instance.config_spam_warningMessage, 10L); instance.sendMessage(player, TextMode.Warn, instance.config_spam_warningMessage, 10L);
@ -534,6 +530,7 @@ class PlayerEventHandler implements Listener
} }
private ConcurrentHashMap<String, CommandCategory> commandCategoryMap = new ConcurrentHashMap<String, CommandCategory>(); private ConcurrentHashMap<String, CommandCategory> commandCategoryMap = new ConcurrentHashMap<String, CommandCategory>();
private CommandCategory getCommandCategory(String commandName) private CommandCategory getCommandCategory(String commandName)
{ {
if (commandName.startsWith("/")) commandName = commandName.substring(1); if (commandName.startsWith("/")) commandName = commandName.substring(1);
@ -584,8 +581,7 @@ class PlayerEventHandler implements Listener
if (instance.config_eavesdrop_whisperCommands.contains("/" + alias)) if (instance.config_eavesdrop_whisperCommands.contains("/" + alias))
{ {
category = CommandCategory.Whisper; category = CommandCategory.Whisper;
} } else if (instance.config_spam_monitorSlashCommands.contains("/" + alias))
else if(instance.config_spam_monitorSlashCommands.contains("/" + alias))
{ {
category = CommandCategory.Chat; category = CommandCategory.Chat;
} }
@ -598,6 +594,7 @@ class PlayerEventHandler implements Listener
} }
static int longestNameLength = 10; static int longestNameLength = 10;
static void makeSocialLogEntry(String name, String message) static void makeSocialLogEntry(String name, String message)
{ {
StringBuilder entryBuilder = new StringBuilder(name); StringBuilder entryBuilder = new StringBuilder(name);
@ -870,6 +867,7 @@ class PlayerEventHandler implements Listener
//when a player dies... //when a player dies...
private HashMap<UUID, Long> deathTimestamps = new HashMap<UUID, Long>(); private HashMap<UUID, Long> deathTimestamps = new HashMap<UUID, Long>();
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
void onPlayerDeath(PlayerDeathEvent event) void onPlayerDeath(PlayerDeathEvent event)
{ {
@ -902,6 +900,7 @@ class PlayerEventHandler implements Listener
//when a player quits... //when a player quits...
private HashMap<UUID, Integer> heldLogoutMessages = new HashMap<UUID, Integer>(); private HashMap<UUID, Integer> heldLogoutMessages = new HashMap<UUID, Integer>();
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
void onPlayerQuit(PlayerQuitEvent event) void onPlayerQuit(PlayerQuitEvent event)
{ {
@ -920,8 +919,7 @@ class PlayerEventHandler implements Listener
if (playerData.wasKicked) if (playerData.wasKicked)
{ {
isBanned = player.isBanned(); isBanned = player.isBanned();
} } else
else
{ {
isBanned = false; isBanned = false;
} }
@ -962,7 +960,8 @@ class PlayerEventHandler implements Listener
//if player was involved in a siege, he forfeits //if player was involved in a siege, he forfeits
if (playerData.siegeData != null) if (playerData.siegeData != null)
{ {
if(player.getHealth() > 0) player.setHealth(0); //might already be zero from above, this avoids a double death message if (player.getHealth() > 0)
player.setHealth(0); //might already be zero from above, this avoids a double death message
} }
//drop data about this player //drop data about this player
@ -1000,8 +999,7 @@ class PlayerEventHandler implements Listener
if (now - notificationTimestamp > ONE_MINUTE) if (now - notificationTimestamp > ONE_MINUTE)
{ {
this.recentLoginLogoutNotifications.remove(i--); this.recentLoginLogoutNotifications.remove(i--);
} } else
else
{ {
break; break;
} }
@ -1186,8 +1184,7 @@ class PlayerEventHandler implements Listener
return; return;
} }
} }
} } else //world repair code for a now-fixed GP bug //TODO: necessary anymore?
else //world repair code for a now-fixed GP bug //TODO: necessary anymore?
{ {
//ensure this entity can be tamed by players //ensure this entity can be tamed by players
tameable.setOwner(null); tameable.setOwner(null);
@ -1421,6 +1418,7 @@ class PlayerEventHandler implements Listener
//block use of buckets within other players' claims //block use of buckets within other players' claims
private HashSet<Material> commonAdjacentBlocks_water = new HashSet<Material>(Arrays.asList(Material.WATER, Material.FARMLAND, Material.DIRT, Material.STONE)); private HashSet<Material> commonAdjacentBlocks_water = new HashSet<Material>(Arrays.asList(Material.WATER, Material.FARMLAND, Material.DIRT, Material.STONE));
private HashSet<Material> commonAdjacentBlocks_lava = new HashSet<Material>(Arrays.asList(Material.LAVA, Material.DIRT, Material.STONE)); private HashSet<Material> commonAdjacentBlocks_lava = new HashSet<Material>(Arrays.asList(Material.LAVA, Material.DIRT, Material.STONE));
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent bucketEvent) public void onPlayerBucketEmpty(PlayerBucketEmptyEvent bucketEvent)
{ {
@ -1510,10 +1508,13 @@ class PlayerEventHandler implements Listener
} }
} }
private boolean doesAllowLavaProximityInWorld(World world) { private boolean doesAllowLavaProximityInWorld(World world)
if (GriefPrevention.instance.pvpRulesApply(world)) { {
if (GriefPrevention.instance.pvpRulesApply(world))
{
return GriefPrevention.instance.config_pvp_allowLavaNearPlayers; return GriefPrevention.instance.config_pvp_allowLavaNearPlayers;
} else { } else
{
return GriefPrevention.instance.config_pvp_allowLavaNearPlayers_NonPvp; return GriefPrevention.instance.config_pvp_allowLavaNearPlayers_NonPvp;
} }
} }
@ -1563,8 +1564,7 @@ class PlayerEventHandler implements Listener
if (clickedBlock != null) if (clickedBlock != null)
{ {
clickedBlockType = clickedBlock.getType(); clickedBlockType = clickedBlock.getType();
} } else
else
{ {
clickedBlockType = Material.AIR; clickedBlockType = Material.AIR;
} }
@ -1904,9 +1904,7 @@ class PlayerEventHandler implements Listener
} }
return; return;
} } else if (clickedBlock != null && (
else if(clickedBlock != null && (
materialInHand == Material.OAK_BOAT || materialInHand == Material.OAK_BOAT ||
materialInHand == Material.SPRUCE_BOAT || materialInHand == Material.SPRUCE_BOAT ||
materialInHand == Material.BIRCH_BOAT || materialInHand == Material.BIRCH_BOAT ||
@ -2073,7 +2071,8 @@ class PlayerEventHandler implements Listener
Visualization.Apply(player, visualization); Visualization.Apply(player, visualization);
if (player.hasPermission("griefprevention.seeclaimsize")) { if (player.hasPermission("griefprevention.seeclaimsize"))
{
instance.sendMessage(player, TextMode.Info, " " + claim.getWidth() + "x" + claim.getHeight() + "=" + claim.getArea()); instance.sendMessage(player, TextMode.Info, " " + claim.getWidth() + "x" + claim.getHeight() + "=" + claim.getArea());
} }
@ -2183,12 +2182,10 @@ class PlayerEventHandler implements Listener
if (environment == Environment.NETHER) if (environment == Environment.NETHER)
{ {
allowedFillBlocks.add(Material.NETHERRACK); allowedFillBlocks.add(Material.NETHERRACK);
} } else if (environment == Environment.THE_END)
else if(environment == Environment.THE_END)
{ {
allowedFillBlocks.add(Material.END_STONE); allowedFillBlocks.add(Material.END_STONE);
} } else
else
{ {
allowedFillBlocks.add(Material.GRASS); allowedFillBlocks.add(Material.GRASS);
allowedFillBlocks.add(Material.DIRT); allowedFillBlocks.add(Material.DIRT);
@ -2274,16 +2271,13 @@ class PlayerEventHandler implements Listener
if (allowedFillBlocks.contains(eastBlock.getType())) if (allowedFillBlocks.contains(eastBlock.getType()))
{ {
block.setType(eastBlock.getType()); block.setType(eastBlock.getType());
} } else if (allowedFillBlocks.contains(westBlock.getType()))
else if(allowedFillBlocks.contains(westBlock.getType()))
{ {
block.setType(westBlock.getType()); block.setType(westBlock.getType());
} } else if (allowedFillBlocks.contains(northBlock.getType()))
else if(allowedFillBlocks.contains(northBlock.getType()))
{ {
block.setType(northBlock.getType()); block.setType(northBlock.getType());
} } else if (allowedFillBlocks.contains(southBlock.getType()))
else if(allowedFillBlocks.contains(southBlock.getType()))
{ {
block.setType(southBlock.getType()); block.setType(southBlock.getType());
} }
@ -2319,8 +2313,7 @@ class PlayerEventHandler implements Listener
if (playerData.lastShovelLocation.getBlockX() == playerData.claimResizing.getLesserBoundaryCorner().getBlockX()) if (playerData.lastShovelLocation.getBlockX() == playerData.claimResizing.getLesserBoundaryCorner().getBlockX())
{ {
newx1 = clickedBlock.getX(); newx1 = clickedBlock.getX();
} } else
else
{ {
newx1 = playerData.claimResizing.getLesserBoundaryCorner().getBlockX(); newx1 = playerData.claimResizing.getLesserBoundaryCorner().getBlockX();
} }
@ -2328,8 +2321,7 @@ class PlayerEventHandler implements Listener
if (playerData.lastShovelLocation.getBlockX() == playerData.claimResizing.getGreaterBoundaryCorner().getBlockX()) if (playerData.lastShovelLocation.getBlockX() == playerData.claimResizing.getGreaterBoundaryCorner().getBlockX())
{ {
newx2 = clickedBlock.getX(); newx2 = clickedBlock.getX();
} } else
else
{ {
newx2 = playerData.claimResizing.getGreaterBoundaryCorner().getBlockX(); newx2 = playerData.claimResizing.getGreaterBoundaryCorner().getBlockX();
} }
@ -2337,8 +2329,7 @@ class PlayerEventHandler implements Listener
if (playerData.lastShovelLocation.getBlockZ() == playerData.claimResizing.getLesserBoundaryCorner().getBlockZ()) if (playerData.lastShovelLocation.getBlockZ() == playerData.claimResizing.getLesserBoundaryCorner().getBlockZ())
{ {
newz1 = clickedBlock.getZ(); newz1 = clickedBlock.getZ();
} } else
else
{ {
newz1 = playerData.claimResizing.getLesserBoundaryCorner().getBlockZ(); newz1 = playerData.claimResizing.getLesserBoundaryCorner().getBlockZ();
} }
@ -2346,8 +2337,7 @@ class PlayerEventHandler implements Listener
if (playerData.lastShovelLocation.getBlockZ() == playerData.claimResizing.getGreaterBoundaryCorner().getBlockZ()) if (playerData.lastShovelLocation.getBlockZ() == playerData.claimResizing.getGreaterBoundaryCorner().getBlockZ())
{ {
newz2 = clickedBlock.getZ(); newz2 = clickedBlock.getZ();
} } else
else
{ {
newz2 = playerData.claimResizing.getGreaterBoundaryCorner().getBlockZ(); newz2 = playerData.claimResizing.getGreaterBoundaryCorner().getBlockZ();
} }
@ -2573,8 +2563,7 @@ class PlayerEventHandler implements Listener
instance.dataStore.tryAdvertiseAdminAlternatives(player); instance.dataStore.tryAdvertiseAdminAlternatives(player);
return; return;
} }
} } else
else
{ {
playerID = null; playerID = null;
} }
@ -2602,8 +2591,7 @@ class PlayerEventHandler implements Listener
Bukkit.getPluginManager().callEvent(new VisualizationEvent(player, result.claim)); Bukkit.getPluginManager().callEvent(new VisualizationEvent(player, result.claim));
Visualization.Apply(player, visualization); Visualization.Apply(player, visualization);
} } else
else
{ {
instance.sendMessage(player, TextMode.Err, Messages.CreateClaimFailOverlapRegion); instance.sendMessage(player, TextMode.Err, Messages.CreateClaimFailOverlapRegion);
} }
@ -2658,6 +2646,7 @@ class PlayerEventHandler implements Listener
//determines whether a block type is an inventory holder. uses a caching strategy to save cpu time //determines whether a block type is an inventory holder. uses a caching strategy to save cpu time
private ConcurrentHashMap<Material, Boolean> inventoryHolderCache = new ConcurrentHashMap<Material, Boolean>(); private ConcurrentHashMap<Material, Boolean> inventoryHolderCache = new ConcurrentHashMap<Material, Boolean>();
private boolean isInventoryHolder(Block clickedBlock) private boolean isInventoryHolder(Block clickedBlock)
{ {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -2667,8 +2656,7 @@ class PlayerEventHandler implements Listener
{ {
return cachedValue.booleanValue(); return cachedValue.booleanValue();
} } else
else
{ {
boolean isHolder = clickedBlock.getState() instanceof InventoryHolder; boolean isHolder = clickedBlock.getState() instanceof InventoryHolder;
this.inventoryHolderCache.put(cacheKey, isHolder); this.inventoryHolderCache.put(cacheKey, isHolder);

View File

@ -62,8 +62,7 @@ class PlayerKickBanTask implements Runnable
{ {
//ban //ban
GriefPrevention.banPlayer(this.player, this.reason, this.source); GriefPrevention.banPlayer(this.player, this.reason, this.source);
} } else if (this.player.isOnline())
else if(this.player.isOnline())
{ {
this.player.kickPlayer(this.reason); this.player.kickPlayer(this.reason);
} }

View File

@ -63,8 +63,7 @@ class PlayerRescueTask implements Runnable
if (this.destination == null) if (this.destination == null)
{ {
this.destination = GriefPrevention.instance.ejectPlayer(this.player); this.destination = GriefPrevention.instance.ejectPlayer(this.player);
} } else
else
{ {
player.teleport(this.destination); player.teleport(this.destination);
} }

View File

@ -45,8 +45,7 @@ class PvPImmunityValidationTask implements Runnable
//if found, cancel invulnerability and notify //if found, cancel invulnerability and notify
playerData.pvpImmune = false; playerData.pvpImmune = false;
GriefPrevention.sendMessage(player, TextMode.Warn, Messages.PvPImmunityEnd); GriefPrevention.sendMessage(player, TextMode.Warn, Messages.PvPImmunityEnd);
} } else
else
{ {
//otherwise check again in one minute //otherwise check again in one minute
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, this, 1200L); GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, this, 1200L);

View File

@ -18,8 +18,6 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.ArrayList;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -30,6 +28,8 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Hanging; import org.bukkit.entity.Hanging;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
//this main thread task takes the output from the RestoreNatureProcessingTask\ //this main thread task takes the output from the RestoreNatureProcessingTask\
//and updates the world accordingly //and updates the world accordingly
class RestoreNatureExecutionTask implements Runnable class RestoreNatureExecutionTask implements Runnable

View File

@ -18,8 +18,6 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.ArrayList;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
@ -29,6 +27,8 @@ import org.bukkit.block.data.Levelled;
import org.bukkit.block.data.type.Leaves; import org.bukkit.block.data.type.Leaves;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
//non-main-thread task which processes world data to repair the unnatural //non-main-thread task which processes world data to repair the unnatural
//after processing is complete, creates a main thread task to make the necessary changes to the world //after processing is complete, creates a main thread task to make the necessary changes to the world
class RestoreNatureProcessingTask implements Runnable class RestoreNatureProcessingTask implements Runnable
@ -217,8 +217,7 @@ class RestoreNatureProcessingTask implements Runnable
underBlock.typeId == Material.SAND) underBlock.typeId == Material.SAND)
{ {
snapshots[x][y][z].typeId = Material.SAND; snapshots[x][y][z].typeId = Material.SAND;
} } else
else
{ {
snapshots[x][y][z].typeId = Material.AIR; snapshots[x][y][z].typeId = Material.AIR;
} }
@ -442,8 +441,7 @@ class RestoreNatureProcessingTask implements Runnable
if (this.biome == Biome.DESERT || this.biome == Biome.DESERT_HILLS || this.biome == Biome.BEACH) if (this.biome == Biome.DESERT || this.biome == Biome.DESERT_HILLS || this.biome == Biome.BEACH)
{ {
this.snapshots[x][y][z].typeId = Material.SAND; this.snapshots[x][y][z].typeId = Material.SAND;
} } else
else
{ {
this.snapshots[x][y][z].typeId = Material.GRASS_BLOCK; this.snapshots[x][y][z].typeId = Material.GRASS_BLOCK;
} }
@ -561,7 +559,8 @@ class RestoreNatureProcessingTask implements Runnable
BlockSnapshot underBlock = this.snapshots[x][y - 1][z]; BlockSnapshot underBlock = this.snapshots[x][y - 1][z];
//block underneath MUST be source water //block underneath MUST be source water
if(!(underBlock.typeId == Material.WATER && ((Levelled) underBlock.data).getLevel() == 0)) continue; if (!(underBlock.typeId == Material.WATER && ((Levelled) underBlock.data).getLevel() == 0))
continue;
//count adjacent source water blocks //count adjacent source water blocks
byte adjacentSourceWaterCount = 0; byte adjacentSourceWaterCount = 0;

View File

@ -18,10 +18,10 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.Collection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collection;
//secures a claim after a siege looting window has closed //secures a claim after a siege looting window has closed
class SecureClaimTask implements Runnable class SecureClaimTask implements Runnable
{ {

View File

@ -18,10 +18,10 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.ArrayList;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
//information about an ongoing siege //information about an ongoing siege
public class SiegeData public class SiegeData
{ {

View File

@ -15,6 +15,7 @@ class SpamDetector
//data for individual chatters //data for individual chatters
ConcurrentHashMap<UUID, ChatterData> dataStore = new ConcurrentHashMap<UUID, ChatterData>(); ConcurrentHashMap<UUID, ChatterData> dataStore = new ConcurrentHashMap<UUID, ChatterData>();
private ChatterData getChatterData(UUID chatterID) private ChatterData getChatterData(UUID chatterID)
{ {
ChatterData data = this.dataStore.get(chatterID); ChatterData data = this.dataStore.get(chatterID);
@ -56,8 +57,7 @@ class SpamDetector
chatterData.spamLevel += ++this.duplicateMessageCount; chatterData.spamLevel += ++this.duplicateMessageCount;
spam = true; spam = true;
result.muteReason = "repeat message"; result.muteReason = "repeat message";
} } else
else
{ {
this.lastChatMessage = message; this.lastChatMessage = message;
this.lastChatMessageTimestamp = timestamp; this.lastChatMessageTimestamp = timestamp;
@ -135,9 +135,7 @@ class SpamDetector
if (chatterData.spamLevel > 8 && chatterData.spamWarned) if (chatterData.spamLevel > 8 && chatterData.spamWarned)
{ {
result.shouldBanChatter = true; result.shouldBanChatter = true;
} } else if (chatterData.spamLevel >= 4)
else if(chatterData.spamLevel >= 4)
{ {
if (!chatterData.spamWarned) if (!chatterData.spamWarned)
{ {
@ -177,8 +175,7 @@ class SpamDetector
{ {
shorterString = lastMessage; shorterString = lastMessage;
longerString = message; longerString = message;
} } else
else
{ {
shorterString = message; shorterString = message;
longerString = lastMessage; longerString = lastMessage;
@ -205,7 +202,8 @@ class SpamDetector
int j; int j;
for (j = 0; j < shorterString.length() - i; j++) for (j = 0; j < shorterString.length() - i; j++)
{ {
if(shorterString.charAt(shorterString.length() - j - 1) == longerString.charAt(longerString.length() - j - 1)) identicalCount++; if (shorterString.charAt(shorterString.length() - j - 1) == longerString.charAt(longerString.length() - j - 1))
identicalCount++;
if (identicalCount > maxIdenticalCharacters) return true; if (identicalCount > maxIdenticalCharacters) return true;
} }

View File

@ -13,9 +13,12 @@ import java.io.OutputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.*; import java.util.HashMap;
import java.util.List;
import java.util.UUID;
class UUIDFetcher { class UUIDFetcher
{
private static int PROFILES_PER_REQUEST = 100; private static int PROFILES_PER_REQUEST = 100;
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft"; private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
private final JSONParser jsonParser = new JSONParser(); private final JSONParser jsonParser = new JSONParser();
@ -28,12 +31,14 @@ class UUIDFetcher {
//record of username -> proper casing updates //record of username -> proper casing updates
static HashMap<String, String> correctedNames; static HashMap<String, String> correctedNames;
public UUIDFetcher(List<String> names, boolean rateLimiting) { public UUIDFetcher(List<String> names, boolean rateLimiting)
{
this.names = names; this.names = names;
this.rateLimiting = rateLimiting; this.rateLimiting = rateLimiting;
} }
public UUIDFetcher(List<String> names) { public UUIDFetcher(List<String> names)
{
this(names, true); this(names, true);
} }
@ -131,15 +136,15 @@ class UUIDFetcher {
GriefPrevention.AddLogEntry("Mojang says we're sending requests too fast. Will retry every 30 seconds until we succeed..."); GriefPrevention.AddLogEntry("Mojang says we're sending requests too fast. Will retry every 30 seconds until we succeed...");
Thread.sleep(30000); Thread.sleep(30000);
} }
} } else
else
{ {
throw e; throw e;
} }
} }
} while (retry); } while (retry);
for (Object profile : array) { for (Object profile : array)
{
JSONObject jsonProfile = (JSONObject) profile; JSONObject jsonProfile = (JSONObject) profile;
String id = (String) jsonProfile.get("id"); String id = (String) jsonProfile.get("id");
String name = (String) jsonProfile.get("name"); String name = (String) jsonProfile.get("name");
@ -148,7 +153,8 @@ class UUIDFetcher {
lookupCache.put(name, uuid); lookupCache.put(name, uuid);
lookupCache.put(name.toLowerCase(), uuid); lookupCache.put(name.toLowerCase(), uuid);
} }
if (rateLimiting) { if (rateLimiting)
{
Thread.sleep(200L); Thread.sleep(200L);
} }
} }
@ -170,14 +176,16 @@ class UUIDFetcher {
} }
} }
private static void writeBody(HttpURLConnection connection, String body) throws Exception { private static void writeBody(HttpURLConnection connection, String body) throws Exception
{
OutputStream stream = connection.getOutputStream(); OutputStream stream = connection.getOutputStream();
stream.write(body.getBytes()); stream.write(body.getBytes());
stream.flush(); stream.flush();
stream.close(); stream.close();
} }
private static HttpURLConnection createConnection() throws Exception { private static HttpURLConnection createConnection() throws Exception
{
URL url = new URL(PROFILE_URL); URL url = new URL(PROFILE_URL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
@ -188,19 +196,23 @@ class UUIDFetcher {
return connection; return connection;
} }
private static UUID getUUID(String id) { private static UUID getUUID(String id)
{
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32)); return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
} }
public static byte[] toBytes(UUID uuid) { public static byte[] toBytes(UUID uuid)
{
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]); ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
byteBuffer.putLong(uuid.getMostSignificantBits()); byteBuffer.putLong(uuid.getMostSignificantBits());
byteBuffer.putLong(uuid.getLeastSignificantBits()); byteBuffer.putLong(uuid.getLeastSignificantBits());
return byteBuffer.array(); return byteBuffer.array();
} }
public static UUID fromBytes(byte[] array) { public static UUID fromBytes(byte[] array)
if (array.length != 16) { {
if (array.length != 16)
{
throw new IllegalArgumentException("Illegal byte array length: " + array.length); throw new IllegalArgumentException("Illegal byte array length: " + array.length);
} }
ByteBuffer byteBuffer = ByteBuffer.wrap(array); ByteBuffer byteBuffer = ByteBuffer.wrap(array);

View File

@ -18,8 +18,6 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import java.util.ArrayList;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
@ -30,6 +28,8 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Lightable; import org.bukkit.block.data.Lightable;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
//represents a visualization sent to a player //represents a visualization sent to a player
//FEATURE: to show players visually where claim boundaries are, we send them fake block change packets //FEATURE: to show players visually where claim boundaries are, we send them fake block change packets
//the result is that those players see new blocks, but the world hasn't been changed. other players can't see the new blocks, either. //the result is that those players see new blocks, but the world hasn't been changed. other players can't see the new blocks, either.
@ -151,27 +151,19 @@ public class Visualization
{ {
cornerBlockData = Material.GLOWSTONE.createBlockData(); cornerBlockData = Material.GLOWSTONE.createBlockData();
accentBlockData = Material.GOLD_BLOCK.createBlockData(); accentBlockData = Material.GOLD_BLOCK.createBlockData();
} } else if (visualizationType == VisualizationType.AdminClaim)
else if(visualizationType == VisualizationType.AdminClaim)
{ {
cornerBlockData = Material.GLOWSTONE.createBlockData(); cornerBlockData = Material.GLOWSTONE.createBlockData();
accentBlockData = Material.PUMPKIN.createBlockData(); accentBlockData = Material.PUMPKIN.createBlockData();
} } else if (visualizationType == VisualizationType.Subdivision)
else if(visualizationType == VisualizationType.Subdivision)
{ {
cornerBlockData = Material.IRON_BLOCK.createBlockData(); cornerBlockData = Material.IRON_BLOCK.createBlockData();
accentBlockData = Material.WHITE_WOOL.createBlockData(); accentBlockData = Material.WHITE_WOOL.createBlockData();
} } else if (visualizationType == VisualizationType.RestoreNature)
else if(visualizationType == VisualizationType.RestoreNature)
{ {
cornerBlockData = Material.DIAMOND_BLOCK.createBlockData(); cornerBlockData = Material.DIAMOND_BLOCK.createBlockData();
accentBlockData = Material.DIAMOND_BLOCK.createBlockData(); accentBlockData = Material.DIAMOND_BLOCK.createBlockData();
} } else
else
{ {
cornerBlockData = Material.REDSTONE_ORE.createBlockData(); cornerBlockData = Material.REDSTONE_ORE.createBlockData();
((Lightable) cornerBlockData).setLit(true); ((Lightable) cornerBlockData).setLit(true);

View File

@ -17,8 +17,8 @@
*/ */
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
//represents a "fake" block sent to a player as part of a visualization //represents a "fake" block sent to a player as part of a visualization

View File

@ -1,19 +1,18 @@
package me.ryanhamshire.GriefPrevention; package me.ryanhamshire.GriefPrevention;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.bukkit.BukkitPlayer; import com.sk89q.worldguard.bukkit.BukkitPlayer;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.internal.permission.RegionPermissionModel; import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.Flags; import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.bukkit.Location;
import org.bukkit.entity.Player;
class WorldGuardWrapper class WorldGuardWrapper
{ {
@ -43,8 +42,10 @@ class WorldGuardWrapper
BlockVector3.at(greaterCorner.getX(), world.getMaxY(), greaterCorner.getZ())); BlockVector3.at(greaterCorner.getX(), world.getMaxY(), greaterCorner.getZ()));
ApplicableRegionSet overlaps = manager.getApplicableRegions(tempRegion); ApplicableRegionSet overlaps = manager.getApplicableRegions(tempRegion);
for (ProtectedRegion r : overlaps.getRegions()) { for (ProtectedRegion r : overlaps.getRegions())
if (!manager.getApplicableRegions(r).testState(localPlayer, Flags.BUILD)) { {
if (!manager.getApplicableRegions(r).testState(localPlayer, Flags.BUILD))
{
return false; return false;
} }
} }

View File

@ -14,11 +14,15 @@ public class AccrueClaimBlocksEvent extends Event
{ {
// Custom Event Requirements // Custom Event Requirements
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() {
public static HandlerList getHandlerList()
{
return handlers; return handlers;
} }
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers()
{
return handlers; return handlers;
} }
@ -30,7 +34,6 @@ public class AccrueClaimBlocksEvent extends Event
/** /**
* @param player Player receiving accruals * @param player Player receiving accruals
* @param blocksToAccrue Blocks to accrue * @param blocksToAccrue Blocks to accrue
*
* @deprecated Use {@link #AccrueClaimBlocksEvent(Player, int, boolean)} instead * @deprecated Use {@link #AccrueClaimBlocksEvent(Player, int, boolean)} instead
*/ */
public AccrueClaimBlocksEvent(Player player, int blocksToAccrue) public AccrueClaimBlocksEvent(Player player, int blocksToAccrue)
@ -67,7 +70,8 @@ public class AccrueClaimBlocksEvent extends Event
/** /**
* @return whether the player was detected as idle (used for idle accrual percentage) * @return whether the player was detected as idle (used for idle accrual percentage)
*/ */
public boolean isIdle() { public boolean isIdle()
{
return this.isIdle; return this.isIdle;
} }
@ -78,6 +82,7 @@ public class AccrueClaimBlocksEvent extends Event
/** /**
* Modify the amount of claim blocks to deliver to the player for this 10 minute interval * Modify the amount of claim blocks to deliver to the player for this 10 minute interval
*
* @param blocksToAccrue blocks to deliver * @param blocksToAccrue blocks to deliver
*/ */
public void setBlocksToAccrue(int blocksToAccrue) public void setBlocksToAccrue(int blocksToAccrue)
@ -87,6 +92,7 @@ public class AccrueClaimBlocksEvent extends Event
/** /**
* Similar to setBlocksToAccrue(int), but automatically converting from a per-hour rate value to a 10-minute rate value * Similar to setBlocksToAccrue(int), but automatically converting from a per-hour rate value to a 10-minute rate value
*
* @param blocksToAccruePerHour the per-hour rate of blocks to deliver * @param blocksToAccruePerHour the per-hour rate of blocks to deliver
*/ */

View File

@ -13,11 +13,13 @@ import org.bukkit.event.HandlerList;
* Created by Narimm on 5/08/2018. * Created by Narimm on 5/08/2018.
*/ */
public class ClaimCreatedEvent extends Event implements Cancellable { public class ClaimCreatedEvent extends Event implements Cancellable
{
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { public static HandlerList getHandlerList()
{
return handlers; return handlers;
} }
@ -27,23 +29,27 @@ public class ClaimCreatedEvent extends Event implements Cancellable {
private boolean cancelled = false; private boolean cancelled = false;
public ClaimCreatedEvent(Claim claim, CommandSender creator) { public ClaimCreatedEvent(Claim claim, CommandSender creator)
{
this.claim = claim; this.claim = claim;
this.creator = creator; this.creator = creator;
} }
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers()
{
return handlers; return handlers;
} }
@Override @Override
public boolean isCancelled() { public boolean isCancelled()
{
return cancelled; return cancelled;
} }
@Override @Override
public void setCancelled(boolean b) { public void setCancelled(boolean b)
{
this.cancelled = b; this.cancelled = b;
} }
@ -52,7 +58,8 @@ public class ClaimCreatedEvent extends Event implements Cancellable {
* *
* @return Claim * @return Claim
*/ */
public Claim getClaim() { public Claim getClaim()
{
return claim; return claim;
} }
@ -61,7 +68,8 @@ public class ClaimCreatedEvent extends Event implements Cancellable {
* *
* @return the CommandSender * @return the CommandSender
*/ */
public CommandSender getCreator() { public CommandSender getCreator()
{
return creator; return creator;
} }
} }

View File

@ -1,7 +1,6 @@
package me.ryanhamshire.GriefPrevention.events; package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -10,20 +9,22 @@ import org.bukkit.event.HandlerList;
* not called when a claim is resized. * not called when a claim is resized.
* *
* @author Tux2 * @author Tux2
*
*/ */
public class ClaimDeletedEvent extends Event{ public class ClaimDeletedEvent extends Event
{
// Custom Event Requirements // Custom Event Requirements
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { public static HandlerList getHandlerList()
{
return handlers; return handlers;
} }
private Claim claim; private Claim claim;
public ClaimDeletedEvent(Claim claim) { public ClaimDeletedEvent(Claim claim)
{
this.claim = claim; this.claim = claim;
} }
@ -32,12 +33,14 @@ public class ClaimDeletedEvent extends Event{
* *
* @return * @return
*/ */
public Claim getClaim() { public Claim getClaim()
{
return claim; return claim;
} }
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers()
{
return handlers; return handlers;
} }
} }

View File

@ -1,7 +1,6 @@
package me.ryanhamshire.GriefPrevention.events; package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;

View File

@ -11,24 +11,28 @@ import org.bukkit.event.HandlerList;
* a claim has changed. The CommandSender can be null in the event that the modification is called by the plugin itself. * a claim has changed. The CommandSender can be null in the event that the modification is called by the plugin itself.
* Created by Narimm on 5/08/2018. * Created by Narimm on 5/08/2018.
*/ */
public class ClaimModifiedEvent extends Event { public class ClaimModifiedEvent extends Event
{
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { public static HandlerList getHandlerList()
{
return handlers; return handlers;
} }
private final Claim claim; private final Claim claim;
private CommandSender modifier; private CommandSender modifier;
public ClaimModifiedEvent(Claim claim, CommandSender modifier) { public ClaimModifiedEvent(Claim claim, CommandSender modifier)
{
this.claim = claim; this.claim = claim;
this.modifier = modifier; this.modifier = modifier;
} }
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers()
{
return handlers; return handlers;
} }
@ -37,7 +41,8 @@ public class ClaimModifiedEvent extends Event {
* *
* @return the claim * @return the claim
*/ */
public Claim getClaim() { public Claim getClaim()
{
return claim; return claim;
} }
@ -46,7 +51,8 @@ public class ClaimModifiedEvent extends Event {
* *
* @return the CommandSender or null * @return the CommandSender or null
*/ */
public CommandSender getModifier() { public CommandSender getModifier()
{
return modifier; return modifier;
} }
} }

View File

@ -1,7 +1,6 @@
package me.ryanhamshire.GriefPrevention.events; package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;

View File

@ -1,7 +1,6 @@
package me.ryanhamshire.GriefPrevention.events; package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;

View File

@ -1,7 +1,6 @@
package me.ryanhamshire.GriefPrevention.events; package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;

View File

@ -1,23 +1,22 @@
package me.ryanhamshire.GriefPrevention.events; package me.ryanhamshire.GriefPrevention.events;
import java.util.ArrayList; import me.ryanhamshire.GriefPrevention.Claim;
import java.util.List; import me.ryanhamshire.GriefPrevention.ClaimPermission;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import me.ryanhamshire.GriefPrevention.Claim; import java.util.ArrayList;
import me.ryanhamshire.GriefPrevention.ClaimPermission; import java.util.List;
/** /**
* This event is thrown when the trust is changed in one or more claims * This event is thrown when the trust is changed in one or more claims
* *
* @author roinujnosde * @author roinujnosde
*
*/ */
public class TrustChangedEvent extends Event implements Cancellable { public class TrustChangedEvent extends Event implements Cancellable
{
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@ -29,7 +28,8 @@ public class TrustChangedEvent extends Event implements Cancellable {
private boolean cancelled; private boolean cancelled;
public TrustChangedEvent(Player changer, List<Claim> claims, ClaimPermission claimPermission, boolean given, public TrustChangedEvent(Player changer, List<Claim> claims, ClaimPermission claimPermission, boolean given,
String identifier) { String identifier)
{
super(); super();
this.changer = changer; this.changer = changer;
this.claims = claims; this.claims = claims;
@ -38,7 +38,8 @@ public class TrustChangedEvent extends Event implements Cancellable {
this.identifier = identifier; this.identifier = identifier;
} }
public TrustChangedEvent(Player changer, Claim claim, ClaimPermission claimPermission, boolean given, String identifier) { public TrustChangedEvent(Player changer, Claim claim, ClaimPermission claimPermission, boolean given, String identifier)
{
this.changer = changer; this.changer = changer;
claims = new ArrayList<>(); claims = new ArrayList<>();
claims.add(claim); claims.add(claim);
@ -48,7 +49,8 @@ public class TrustChangedEvent extends Event implements Cancellable {
} }
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers()
{
return handlers; return handlers;
} }
@ -57,7 +59,8 @@ public class TrustChangedEvent extends Event implements Cancellable {
* *
* @return the changer * @return the changer
*/ */
public Player getChanger() { public Player getChanger()
{
return changer; return changer;
} }
@ -66,7 +69,8 @@ public class TrustChangedEvent extends Event implements Cancellable {
* *
* @return the changed claims * @return the changed claims
*/ */
public List<Claim> getClaims() { public List<Claim> getClaims()
{
return claims; return claims;
} }
@ -75,7 +79,8 @@ public class TrustChangedEvent extends Event implements Cancellable {
* *
* @return the claim permission * @return the claim permission
*/ */
public ClaimPermission getClaimPermission() { public ClaimPermission getClaimPermission()
{
return claimPermission; return claimPermission;
} }
@ -84,7 +89,8 @@ public class TrustChangedEvent extends Event implements Cancellable {
* *
* @return true if given, false if taken * @return true if given, false if taken
*/ */
public boolean isGiven() { public boolean isGiven()
{
return given; return given;
} }
@ -94,17 +100,20 @@ public class TrustChangedEvent extends Event implements Cancellable {
* *
* @return the identifier * @return the identifier
*/ */
public String getIdentifier() { public String getIdentifier()
{
return identifier; return identifier;
} }
@Override @Override
public boolean isCancelled() { public boolean isCancelled()
{
return cancelled; return cancelled;
} }
@Override @Override
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled)
{
this.cancelled = cancelled; this.cancelled = cancelled;
} }
} }

View File

@ -11,7 +11,8 @@ import java.util.Collections;
/** /**
* Called when GriefPrevention is sending claim visuals to a player * Called when GriefPrevention is sending claim visuals to a player
*/ */
public class VisualizationEvent extends PlayerEvent { public class VisualizationEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final Collection<Claim> claims; private final Collection<Claim> claims;
private final boolean showSubdivides; private final boolean showSubdivides;
@ -22,7 +23,8 @@ public class VisualizationEvent extends PlayerEvent {
* @param player Player receiving visuals * @param player Player receiving visuals
* @param claim The claim being visualized (with subdivides), or null if visuals being removed * @param claim The claim being visualized (with subdivides), or null if visuals being removed
*/ */
public VisualizationEvent(Player player, Claim claim) { public VisualizationEvent(Player player, Claim claim)
{
super(player); super(player);
this.claims = Collections.singleton(claim); this.claims = Collections.singleton(claim);
this.showSubdivides = true; this.showSubdivides = true;
@ -34,7 +36,8 @@ public class VisualizationEvent extends PlayerEvent {
* @param player Player receiving visuals * @param player Player receiving visuals
* @param claims Claims being visualized (without subdivides) * @param claims Claims being visualized (without subdivides)
*/ */
public VisualizationEvent(Player player, Collection<Claim> claims) { public VisualizationEvent(Player player, Collection<Claim> claims)
{
super(player); super(player);
this.claims = claims; this.claims = claims;
this.showSubdivides = false; this.showSubdivides = false;
@ -45,7 +48,8 @@ public class VisualizationEvent extends PlayerEvent {
* *
* @return Claims being visualized * @return Claims being visualized
*/ */
public Collection<Claim> getClaims() { public Collection<Claim> getClaims()
{
return claims; return claims;
} }
@ -54,16 +58,19 @@ public class VisualizationEvent extends PlayerEvent {
* *
* @return True if subdivide claims are being shown * @return True if subdivide claims are being shown
*/ */
public boolean showSubdivides() { public boolean showSubdivides()
{
return showSubdivides; return showSubdivides;
} }
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers()
{
return handlers; return handlers;
} }
public static HandlerList getHandlerList() { public static HandlerList getHandlerList()
{
return handlers; return handlers;
} }
} }

View File

@ -1,5 +1,5 @@
/** /**
* * @author Ryan
*/ */
/** /**
* @author Ryan * @author Ryan

View File

@ -14,6 +14,7 @@ import java.util.concurrent.Callable;
public class MetricsHandler public class MetricsHandler
{ {
private Metrics metrics; private Metrics metrics;
public MetricsHandler(GriefPrevention plugin, String dataMode) public MetricsHandler(GriefPrevention plugin, String dataMode)
{ {
metrics = new Metrics(plugin); metrics = new Metrics(plugin);