Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 124.05 KB | None | 0 0
  1. package me.ryanhamshire.GriefPrevention;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.ArrayList;
  6. import java.util.Collection;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map.Entry;
  10. import java.util.UUID;
  11. import java.util.concurrent.ConcurrentHashMap;
  12. import java.util.logging.Logger;
  13. import java.util.regex.Matcher;
  14. import java.util.regex.Pattern;
  15. import me.ryanhamshire.GriefPrevention.events.PreventBlockBreakEvent;
  16. import me.ryanhamshire.GriefPrevention.events.SaveTrappedPlayerEvent;
  17. import net.milkbowl.vault.economy.Economy;
  18. import org.bukkit.BanList;
  19. import org.bukkit.BanList.Type;
  20. import org.bukkit.Bukkit;
  21. import org.bukkit.ChatColor;
  22. import org.bukkit.Chunk;
  23. import org.bukkit.ChunkSnapshot;
  24. import org.bukkit.GameMode;
  25. import org.bukkit.Location;
  26. import org.bukkit.Material;
  27. import org.bukkit.OfflinePlayer;
  28. import org.bukkit.Server;
  29. import org.bukkit.Statistic;
  30. import org.bukkit.World;
  31. import org.bukkit.World.Environment;
  32. import org.bukkit.block.Block;
  33. import org.bukkit.block.BlockFace;
  34. import org.bukkit.command.Command;
  35. import org.bukkit.command.CommandSender;
  36. import org.bukkit.configuration.file.FileConfiguration;
  37. import org.bukkit.configuration.file.FileConfigurationOptions;
  38. import org.bukkit.configuration.file.YamlConfiguration;
  39. import org.bukkit.entity.Player;
  40. import org.bukkit.event.block.BlockBreakEvent;
  41. import org.bukkit.inventory.EquipmentSlot;
  42. import org.bukkit.inventory.ItemStack;
  43. import org.bukkit.inventory.PlayerInventory;
  44. import org.bukkit.material.MaterialData;
  45. import org.bukkit.plugin.PluginManager;
  46. import org.bukkit.plugin.RegisteredServiceProvider;
  47. import org.bukkit.plugin.ServicesManager;
  48. import org.bukkit.plugin.java.JavaPlugin;
  49. import org.bukkit.scheduler.BukkitScheduler;
  50. import org.bukkit.scheduler.BukkitTask;
  51. import org.bukkit.util.BlockIterator;
  52.  
  53. public class GriefPrevention
  54. extends JavaPlugin
  55. {
  56. public static GriefPrevention instance;
  57. private static Logger log;
  58. public DataStore dataStore;
  59. ArrayList<PendingItemProtection> pendingItemWatchList = new ArrayList();
  60. CustomLogger customLogger;
  61. public ConcurrentHashMap<World, ClaimsMode> config_claims_worldModes;
  62. private boolean config_creativeWorldsExist;
  63. public boolean config_claims_preventGlobalMonsterEggs;
  64. public boolean config_claims_preventTheft;
  65. public boolean config_claims_protectCreatures;
  66. public boolean config_claims_protectHorses;
  67. public boolean config_claims_preventButtonsSwitches;
  68. public boolean config_claims_lockWoodenDoors;
  69. public boolean config_claims_lockTrapDoors;
  70. public boolean config_claims_lockFenceGates;
  71. public boolean config_claims_enderPearlsRequireAccessTrust;
  72. public int config_claims_maxClaimsPerPlayer;
  73. public boolean config_claims_respectWorldGuard;
  74. public boolean config_claims_portalsRequirePermission;
  75. public boolean config_claims_villagerTradingRequiresTrust;
  76. public int config_claims_initialBlocks;
  77. public double config_claims_abandonReturnRatio;
  78. public int config_claims_blocksAccruedPerHour_default;
  79. public int config_claims_maxAccruedBlocks_default;
  80. public int config_claims_accruedIdleThreshold;
  81. public int config_claims_accruedIdlePercent;
  82. public int config_claims_maxDepth;
  83. public int config_claims_expirationDays;
  84. public int config_claims_expirationExemptionTotalBlocks;
  85. public int config_claims_expirationExemptionBonusBlocks;
  86. public int config_claims_automaticClaimsForNewPlayersRadius;
  87. public int config_claims_claimsExtendIntoGroundDistance;
  88. public int config_claims_minWidth;
  89. public int config_claims_minArea;
  90. public int config_claims_chestClaimExpirationDays;
  91. public int config_claims_unusedClaimExpirationDays;
  92. public boolean config_claims_survivalAutoNatureRestoration;
  93. public boolean config_claims_allowTrappedInAdminClaims;
  94. public Material config_claims_investigationTool;
  95. public Material config_claims_modificationTool;
  96. public ArrayList<String> config_claims_commandsRequiringAccessTrust;
  97. public boolean config_claims_supplyPlayerManual;
  98. public int config_claims_manualDeliveryDelaySeconds;
  99. public ArrayList<World> config_siege_enabledWorlds;
  100. public ArrayList<Material> config_siege_blocks;
  101. public boolean config_spam_enabled;
  102. public int config_spam_loginCooldownSeconds;
  103. public int config_spam_loginLogoutNotificationsPerMinute;
  104. public ArrayList<String> config_spam_monitorSlashCommands;
  105. public boolean config_spam_banOffenders;
  106. public String config_spam_banMessage;
  107. public String config_spam_warningMessage;
  108. public String config_spam_allowedIpAddresses;
  109. public int config_spam_deathMessageCooldownSeconds;
  110. public int config_spam_logoutMessageDelaySeconds;
  111. HashMap<World, Boolean> config_pvp_specifiedWorlds;
  112. public boolean config_pvp_protectFreshSpawns;
  113. public boolean config_pvp_punishLogout;
  114. public int config_pvp_combatTimeoutSeconds;
  115. public boolean config_pvp_allowCombatItemDrop;
  116. public ArrayList<String> config_pvp_blockedCommands;
  117. public boolean config_pvp_noCombatInPlayerLandClaims;
  118. public boolean config_pvp_noCombatInAdminLandClaims;
  119. public boolean config_pvp_noCombatInAdminSubdivisions;
  120. public boolean config_pvp_allowLavaNearPlayers;
  121. public boolean config_pvp_allowFireNearPlayers;
  122. public boolean config_pvp_protectPets;
  123. public boolean config_lockDeathDropsInPvpWorlds;
  124. public boolean config_lockDeathDropsInNonPvpWorlds;
  125. public double config_economy_claimBlocksPurchaseCost;
  126. public double config_economy_claimBlocksSellValue;
  127. public boolean config_blockClaimExplosions;
  128. public boolean config_blockSurfaceCreeperExplosions;
  129. public boolean config_blockSurfaceOtherExplosions;
  130. public boolean config_blockSkyTrees;
  131. public boolean config_fireSpreads;
  132. public boolean config_fireDestroys;
  133. public boolean config_whisperNotifications;
  134. public boolean config_signNotifications;
  135. public ArrayList<String> config_eavesdrop_whisperCommands;
  136. public boolean config_smartBan;
  137. public boolean config_endermenMoveBlocks;
  138. public boolean config_silverfishBreakBlocks;
  139. public boolean config_creaturesTrampleCrops;
  140. public boolean config_rabbitsEatCrops;
  141. public boolean config_zombiesBreakDoors;
  142. public int config_ipLimit;
  143. public boolean config_trollFilterEnabled;
  144. public MaterialCollection config_mods_accessTrustIds;
  145. public MaterialCollection config_mods_containerTrustIds;
  146. public List<String> config_mods_ignoreClaimsAccounts;
  147. public MaterialCollection config_mods_explodableIds;
  148. public HashMap<String, Integer> config_seaLevelOverride;
  149. public boolean config_limitTreeGrowth;
  150. public boolean config_pistonsInClaimsOnly;
  151. public int config_logs_daysToKeep;
  152. public boolean config_logs_socialEnabled;
  153. public boolean config_logs_suspiciousEnabled;
  154. public boolean config_logs_adminEnabled;
  155. public boolean config_logs_debugEnabled;
  156. public boolean config_logs_mutedChatEnabled;
  157. public boolean config_ban_useCommand;
  158. public String config_ban_commandFormat;
  159. private String databaseUrl;
  160. private String databaseUserName;
  161. private String databasePassword;
  162. public static Economy economy = null;
  163. public static final int TREE_RADIUS = 5;
  164. public static final int NOTIFICATION_SECONDS = 20;
  165.  
  166. public static synchronized void AddLogEntry(String entry, CustomLogEntryTypes customLogType, boolean excludeFromServerLogs)
  167. {
  168. if ((customLogType != null) && (instance.customLogger != null)) {
  169. instance.customLogger.AddEntry(entry, customLogType);
  170. }
  171. if (!excludeFromServerLogs) {
  172. log.info(entry);
  173. }
  174. }
  175.  
  176. public static synchronized void AddLogEntry(String entry, CustomLogEntryTypes customLogType)
  177. {
  178. AddLogEntry(entry, customLogType, false);
  179. }
  180.  
  181. public static synchronized void AddLogEntry(String entry)
  182. {
  183. AddLogEntry(entry, CustomLogEntryTypes.Debug);
  184. }
  185.  
  186. public void onEnable()
  187. {
  188. instance = this;
  189. log = instance.getLogger();
  190.  
  191. loadConfig();
  192.  
  193. this.customLogger = new CustomLogger();
  194.  
  195. AddLogEntry("Finished loading configuration.");
  196. if (this.databaseUrl.length() > 0) {
  197. try
  198. {
  199. DatabaseDataStore databaseStore = new DatabaseDataStore(this.databaseUrl, this.databaseUserName, this.databasePassword);
  200. if (FlatFileDataStore.hasData())
  201. {
  202. AddLogEntry("There appears to be some data on the hard drive. Migrating those data to the database...");
  203. FlatFileDataStore flatFileStore = new FlatFileDataStore();
  204. this.dataStore = flatFileStore;
  205. flatFileStore.migrateData(databaseStore);
  206. AddLogEntry("Data migration process complete. Reloading data from the database...");
  207. databaseStore.close();
  208. databaseStore = new DatabaseDataStore(this.databaseUrl, this.databaseUserName, this.databasePassword);
  209. }
  210. this.dataStore = databaseStore;
  211. }
  212. catch (Exception e)
  213. {
  214. AddLogEntry("Because there was a problem with the database, GriefPrevention will not function properly. Either update the database config settings resolve the issue, or delete those lines from your config.yml so that GriefPrevention can use the file system to store data.");
  215. e.printStackTrace();
  216. getServer().getPluginManager().disablePlugin(this);
  217. return;
  218. }
  219. }
  220. if (this.dataStore == null)
  221. {
  222. File oldclaimdata = new File(getDataFolder(), "ClaimData");
  223. if ((oldclaimdata.exists()) &&
  224. (!FlatFileDataStore.hasData()))
  225. {
  226. File claimdata = new File("plugins" + File.separator + "GriefPreventionData" + File.separator + "ClaimData");
  227. oldclaimdata.renameTo(claimdata);
  228. File oldplayerdata = new File(getDataFolder(), "PlayerData");
  229. File playerdata = new File("plugins" + File.separator + "GriefPreventionData" + File.separator + "PlayerData");
  230. oldplayerdata.renameTo(playerdata);
  231. }
  232. try
  233. {
  234. this.dataStore = new FlatFileDataStore();
  235. }
  236. catch (Exception e)
  237. {
  238. AddLogEntry("Unable to initialize the file system data store. Details:");
  239. AddLogEntry(e.getMessage());
  240. e.printStackTrace();
  241. }
  242. }
  243. String dataMode = (this.dataStore instanceof FlatFileDataStore) ? "(File Mode)" : "(Database Mode)";
  244. AddLogEntry("Finished loading data " + dataMode + ".");
  245. if (this.config_claims_blocksAccruedPerHour_default > 0)
  246. {
  247. DeliverClaimBlocksTask task = new DeliverClaimBlocksTask(null, this);
  248. getServer().getScheduler().scheduleSyncRepeatingTask(this, task, 12000L, 12000L);
  249. }
  250. EntityCleanupTask task = new EntityCleanupTask(0.0D);
  251. getServer().getScheduler().scheduleSyncDelayedTask(instance, task, 2400L);
  252.  
  253. FindUnusedClaimsTask task2 = new FindUnusedClaimsTask();
  254. getServer().getScheduler().scheduleSyncRepeatingTask(this, task2, 1200L, 1200L);
  255.  
  256. PluginManager pluginManager = getServer().getPluginManager();
  257.  
  258. PlayerEventHandler playerEventHandler = new PlayerEventHandler(this.dataStore, this);
  259. pluginManager.registerEvents(playerEventHandler, this);
  260.  
  261. BlockEventHandler blockEventHandler = new BlockEventHandler(this.dataStore);
  262. pluginManager.registerEvents(blockEventHandler, this);
  263.  
  264. EntityEventHandler entityEventHandler = new EntityEventHandler(this.dataStore, this);
  265. pluginManager.registerEvents(entityEventHandler, this);
  266. if ((this.config_economy_claimBlocksPurchaseCost > 0.0D) || (this.config_economy_claimBlocksSellValue > 0.0D))
  267. {
  268. AddLogEntry("GriefPrevention requires Vault for economy integration.");
  269. AddLogEntry("Attempting to load Vault...");
  270. RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
  271. AddLogEntry("Vault loaded successfully!");
  272.  
  273. AddLogEntry("Looking for a Vault-compatible economy plugin...");
  274. if (economyProvider != null)
  275. {
  276. economy = (Economy)economyProvider.getProvider();
  277. if (economy != null)
  278. {
  279. AddLogEntry("Hooked into economy: " + economy.getName() + ".");
  280. AddLogEntry("Ready to buy/sell claim blocks!");
  281. }
  282. else
  283. {
  284. AddLogEntry("ERROR: Vault was unable to find a supported economy plugin. Either install a Vault-compatible economy plugin, or set both of the economy config variables to zero.");
  285. }
  286. }
  287. else
  288. {
  289. AddLogEntry("ERROR: Vault was unable to find a supported economy plugin. Either install a Vault-compatible economy plugin, or set both of the economy config variables to zero.");
  290. }
  291. }
  292. OfflinePlayer[] offlinePlayers = getServer().getOfflinePlayers();
  293. CacheOfflinePlayerNamesThread namesThread = new CacheOfflinePlayerNamesThread(offlinePlayers, this.playerNameToIDMap);
  294. namesThread.setPriority(1);
  295. namesThread.start();
  296.  
  297. Collection<Player> players = instance.getServer().getOnlinePlayers();
  298. for (Player player : players) {
  299. new IgnoreLoaderThread(player.getUniqueId(), this.dataStore.getPlayerData(player.getUniqueId()).ignoredPlayers).start();
  300. }
  301. AddLogEntry("Boot finished.");
  302. }
  303.  
  304. private void loadConfig()
  305. {
  306. FileConfiguration config = YamlConfiguration.loadConfiguration(new File(DataStore.configFilePath));
  307. FileConfiguration outConfig = new YamlConfiguration();
  308. outConfig.options().header("Default values are perfect for most servers. If you want to customize and have a question, look for the answer here first: http://dev.bukkit.org/bukkit-plugins/grief-prevention/pages/setup-and-configuration/");
  309.  
  310. List<World> worlds = getServer().getWorlds();
  311. List<String> deprecated_claimsEnabledWorldNames = config.getStringList("GriefPrevention.Claims.Worlds");
  312. for (int i = 0; i < deprecated_claimsEnabledWorldNames.size(); i++)
  313. {
  314. String worldName = (String)deprecated_claimsEnabledWorldNames.get(i);
  315. World world = getServer().getWorld(worldName);
  316. if (world == null) {
  317. deprecated_claimsEnabledWorldNames.remove(i--);
  318. }
  319. }
  320. List<String> deprecated_creativeClaimsEnabledWorldNames = config.getStringList("GriefPrevention.Claims.CreativeRulesWorlds");
  321. for (int i = 0; i < deprecated_creativeClaimsEnabledWorldNames.size(); i++)
  322. {
  323. String worldName = (String)deprecated_creativeClaimsEnabledWorldNames.get(i);
  324. World world = getServer().getWorld(worldName);
  325. if (world == null) {
  326. deprecated_claimsEnabledWorldNames.remove(i--);
  327. }
  328. }
  329. this.config_claims_worldModes = new ConcurrentHashMap();
  330. this.config_creativeWorldsExist = false;
  331. for (World world : worlds)
  332. {
  333. String configSetting = config.getString("GriefPrevention.Claims.Mode." + world.getName());
  334. if (configSetting != null)
  335. {
  336. ClaimsMode claimsMode = configStringToClaimsMode(configSetting);
  337. if (claimsMode != null)
  338. {
  339. this.config_claims_worldModes.put(world, claimsMode);
  340. if (claimsMode == ClaimsMode.Creative) {
  341. this.config_creativeWorldsExist = true;
  342. }
  343. }
  344. else
  345. {
  346. AddLogEntry("Error: Invalid claim mode \"" + configSetting + "\". Options are Survival, Creative, and Disabled.");
  347. this.config_claims_worldModes.put(world, ClaimsMode.Creative);
  348. this.config_creativeWorldsExist = true;
  349. }
  350. }
  351. else
  352. {
  353. if (deprecated_creativeClaimsEnabledWorldNames.contains(world.getName()))
  354. {
  355. this.config_claims_worldModes.put(world, ClaimsMode.Creative);
  356. this.config_creativeWorldsExist = true;
  357. }
  358. else if (deprecated_claimsEnabledWorldNames.contains(world.getName()))
  359. {
  360. this.config_claims_worldModes.put(world, ClaimsMode.Survival);
  361. }
  362. else if (world.getName().toLowerCase().contains("survival"))
  363. {
  364. this.config_claims_worldModes.put(world, ClaimsMode.Survival);
  365. }
  366. else if (world.getName().toLowerCase().contains("creative"))
  367. {
  368. this.config_claims_worldModes.put(world, ClaimsMode.Creative);
  369. this.config_creativeWorldsExist = true;
  370. }
  371. else if (getServer().getDefaultGameMode() == GameMode.CREATIVE)
  372. {
  373. this.config_claims_worldModes.put(world, ClaimsMode.Creative);
  374. this.config_creativeWorldsExist = true;
  375. }
  376. else if (world.getEnvironment() == World.Environment.NORMAL)
  377. {
  378. this.config_claims_worldModes.put(world, ClaimsMode.Survival);
  379. }
  380. else
  381. {
  382. this.config_claims_worldModes.put(world, ClaimsMode.Disabled);
  383. }
  384. if ((this.config_claims_worldModes.get(world) == ClaimsMode.Disabled) &&
  385. (deprecated_claimsEnabledWorldNames.size() > 0)) {
  386. this.config_claims_worldModes.put(world, ClaimsMode.Survival);
  387. }
  388. }
  389. }
  390. this.config_pvp_specifiedWorlds = new HashMap();
  391. for (World world : worlds)
  392. {
  393. boolean pvpWorld = config.getBoolean("GriefPrevention.PvP.RulesEnabledInWorld." + world.getName(), world.getPVP());
  394. this.config_pvp_specifiedWorlds.put(world, Boolean.valueOf(pvpWorld));
  395. }
  396. this.config_seaLevelOverride = new HashMap();
  397. for (int i = 0; i < worlds.size(); i++)
  398. {
  399. int seaLevelOverride = config.getInt("GriefPrevention.SeaLevelOverrides." + ((World)worlds.get(i)).getName(), -1);
  400. outConfig.set("GriefPrevention.SeaLevelOverrides." + ((World)worlds.get(i)).getName(), Integer.valueOf(seaLevelOverride));
  401. this.config_seaLevelOverride.put(((World)worlds.get(i)).getName(), Integer.valueOf(seaLevelOverride));
  402. }
  403. this.config_claims_preventGlobalMonsterEggs = config.getBoolean("GriefPrevention.Claims.PreventGlobalMonsterEggs", true);
  404. this.config_claims_preventTheft = config.getBoolean("GriefPrevention.Claims.PreventTheft", true);
  405. this.config_claims_protectCreatures = config.getBoolean("GriefPrevention.Claims.ProtectCreatures", true);
  406. this.config_claims_protectHorses = config.getBoolean("GriefPrevention.Claims.ProtectHorses", true);
  407. this.config_claims_preventButtonsSwitches = config.getBoolean("GriefPrevention.Claims.PreventButtonsSwitches", true);
  408. this.config_claims_lockWoodenDoors = config.getBoolean("GriefPrevention.Claims.LockWoodenDoors", false);
  409. this.config_claims_lockTrapDoors = config.getBoolean("GriefPrevention.Claims.LockTrapDoors", false);
  410. this.config_claims_lockFenceGates = config.getBoolean("GriefPrevention.Claims.LockFenceGates", true);
  411. this.config_claims_enderPearlsRequireAccessTrust = config.getBoolean("GriefPrevention.Claims.EnderPearlsRequireAccessTrust", true);
  412. this.config_claims_initialBlocks = config.getInt("GriefPrevention.Claims.InitialBlocks", 100);
  413. this.config_claims_blocksAccruedPerHour_default = config.getInt("GriefPrevention.Claims.BlocksAccruedPerHour", 100);
  414. this.config_claims_blocksAccruedPerHour_default = config.getInt("GriefPrevention.Claims.Claim Blocks Accrued Per Hour.Default", this.config_claims_blocksAccruedPerHour_default);
  415. this.config_claims_maxAccruedBlocks_default = config.getInt("GriefPrevention.Claims.MaxAccruedBlocks", 2000);
  416. this.config_claims_maxAccruedBlocks_default = config.getInt("GriefPrevention.Claims.Max Accrued Claim Blocks.Default", this.config_claims_maxAccruedBlocks_default);
  417. this.config_claims_accruedIdleThreshold = config.getInt("GriefPrevention.Claims.AccruedIdleThreshold", 0);
  418. this.config_claims_accruedIdleThreshold = config.getInt("GriefPrevention.Claims.Accrued Idle Threshold", this.config_claims_accruedIdleThreshold);
  419. this.config_claims_accruedIdlePercent = config.getInt("GriefPrevention.Claims.AccruedIdlePercent", 0);
  420. this.config_claims_abandonReturnRatio = config.getDouble("GriefPrevention.Claims.AbandonReturnRatio", 1.0D);
  421. this.config_claims_automaticClaimsForNewPlayersRadius = config.getInt("GriefPrevention.Claims.AutomaticNewPlayerClaimsRadius", 4);
  422. this.config_claims_claimsExtendIntoGroundDistance = Math.abs(config.getInt("GriefPrevention.Claims.ExtendIntoGroundDistance", 5));
  423. this.config_claims_minWidth = config.getInt("GriefPrevention.Claims.MinimumWidth", 5);
  424. this.config_claims_minArea = config.getInt("GriefPrevention.Claims.MinimumArea", 100);
  425. this.config_claims_maxDepth = config.getInt("GriefPrevention.Claims.MaximumDepth", 0);
  426. this.config_claims_chestClaimExpirationDays = config.getInt("GriefPrevention.Claims.Expiration.ChestClaimDays", 7);
  427. this.config_claims_unusedClaimExpirationDays = config.getInt("GriefPrevention.Claims.Expiration.UnusedClaimDays", 14);
  428. this.config_claims_expirationDays = config.getInt("GriefPrevention.Claims.Expiration.AllClaims.DaysInactive", 60);
  429. this.config_claims_expirationExemptionTotalBlocks = config.getInt("GriefPrevention.Claims.Expiration.AllClaims.ExceptWhenOwnerHasTotalClaimBlocks", 10000);
  430. this.config_claims_expirationExemptionBonusBlocks = config.getInt("GriefPrevention.Claims.Expiration.AllClaims.ExceptWhenOwnerHasBonusClaimBlocks", 5000);
  431. this.config_claims_survivalAutoNatureRestoration = config.getBoolean("GriefPrevention.Claims.Expiration.AutomaticNatureRestoration.SurvivalWorlds", false);
  432. this.config_claims_allowTrappedInAdminClaims = config.getBoolean("GriefPrevention.Claims.AllowTrappedInAdminClaims", false);
  433.  
  434. this.config_claims_maxClaimsPerPlayer = config.getInt("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", 0);
  435. this.config_claims_respectWorldGuard = config.getBoolean("GriefPrevention.Claims.CreationRequiresWorldGuardBuildPermission", true);
  436. this.config_claims_portalsRequirePermission = config.getBoolean("GriefPrevention.Claims.PortalGenerationRequiresPermission", false);
  437. this.config_claims_villagerTradingRequiresTrust = config.getBoolean("GriefPrevention.Claims.VillagerTradingRequiresPermission", true);
  438. String accessTrustSlashCommands = config.getString("GriefPrevention.Claims.CommandsRequiringAccessTrust", "/sethome");
  439. this.config_claims_supplyPlayerManual = config.getBoolean("GriefPrevention.Claims.DeliverManuals", true);
  440. this.config_claims_manualDeliveryDelaySeconds = config.getInt("GriefPrevention.Claims.ManualDeliveryDelaySeconds", 30);
  441.  
  442. this.config_spam_enabled = config.getBoolean("GriefPrevention.Spam.Enabled", true);
  443. this.config_spam_loginCooldownSeconds = config.getInt("GriefPrevention.Spam.LoginCooldownSeconds", 60);
  444. this.config_spam_loginLogoutNotificationsPerMinute = config.getInt("GriefPrevention.Spam.LoginLogoutNotificationsPerMinute", 5);
  445. this.config_spam_warningMessage = config.getString("GriefPrevention.Spam.WarningMessage", "Please reduce your noise level. Spammers will be banned.");
  446. this.config_spam_allowedIpAddresses = config.getString("GriefPrevention.Spam.AllowedIpAddresses", "1.2.3.4; 5.6.7.8");
  447. this.config_spam_banOffenders = config.getBoolean("GriefPrevention.Spam.BanOffenders", true);
  448. this.config_spam_banMessage = config.getString("GriefPrevention.Spam.BanMessage", "Banned for spam.");
  449. String slashCommandsToMonitor = config.getString("GriefPrevention.Spam.MonitorSlashCommands", "/me;/global;/local");
  450. slashCommandsToMonitor = config.getString("GriefPrevention.Spam.ChatSlashCommands", slashCommandsToMonitor);
  451. this.config_spam_deathMessageCooldownSeconds = config.getInt("GriefPrevention.Spam.DeathMessageCooldownSeconds", 120);
  452. this.config_spam_logoutMessageDelaySeconds = config.getInt("GriefPrevention.Spam.Logout Message Delay In Seconds", 0);
  453.  
  454. this.config_pvp_protectFreshSpawns = config.getBoolean("GriefPrevention.PvP.ProtectFreshSpawns", true);
  455. this.config_pvp_punishLogout = config.getBoolean("GriefPrevention.PvP.PunishLogout", true);
  456. this.config_pvp_combatTimeoutSeconds = config.getInt("GriefPrevention.PvP.CombatTimeoutSeconds", 15);
  457. this.config_pvp_allowCombatItemDrop = config.getBoolean("GriefPrevention.PvP.AllowCombatItemDrop", false);
  458. String bannedPvPCommandsList = config.getString("GriefPrevention.PvP.BlockedSlashCommands", "/home;/vanish;/spawn;/tpa");
  459.  
  460. this.config_economy_claimBlocksPurchaseCost = config.getDouble("GriefPrevention.Economy.ClaimBlocksPurchaseCost", 0.0D);
  461. this.config_economy_claimBlocksSellValue = config.getDouble("GriefPrevention.Economy.ClaimBlocksSellValue", 0.0D);
  462.  
  463. this.config_lockDeathDropsInPvpWorlds = config.getBoolean("GriefPrevention.ProtectItemsDroppedOnDeath.PvPWorlds", false);
  464. this.config_lockDeathDropsInNonPvpWorlds = config.getBoolean("GriefPrevention.ProtectItemsDroppedOnDeath.NonPvPWorlds", true);
  465.  
  466. this.config_blockClaimExplosions = config.getBoolean("GriefPrevention.BlockLandClaimExplosions", true);
  467. this.config_blockSurfaceCreeperExplosions = config.getBoolean("GriefPrevention.BlockSurfaceCreeperExplosions", true);
  468. this.config_blockSurfaceOtherExplosions = config.getBoolean("GriefPrevention.BlockSurfaceOtherExplosions", true);
  469. this.config_blockSkyTrees = config.getBoolean("GriefPrevention.LimitSkyTrees", true);
  470. this.config_limitTreeGrowth = config.getBoolean("GriefPrevention.LimitTreeGrowth", false);
  471. this.config_pistonsInClaimsOnly = config.getBoolean("GriefPrevention.LimitPistonsToLandClaims", true);
  472.  
  473. this.config_fireSpreads = config.getBoolean("GriefPrevention.FireSpreads", false);
  474. this.config_fireDestroys = config.getBoolean("GriefPrevention.FireDestroys", false);
  475.  
  476. this.config_whisperNotifications = config.getBoolean("GriefPrevention.AdminsGetWhispers", true);
  477. this.config_signNotifications = config.getBoolean("GriefPrevention.AdminsGetSignNotifications", true);
  478. String whisperCommandsToMonitor = config.getString("GriefPrevention.WhisperCommands", "/tell;/pm;/r;/whisper;/msg");
  479. whisperCommandsToMonitor = config.getString("GriefPrevention.Spam.WhisperSlashCommands", whisperCommandsToMonitor);
  480.  
  481. this.config_smartBan = config.getBoolean("GriefPrevention.SmartBan", true);
  482. this.config_trollFilterEnabled = config.getBoolean("GriefPrevention.Mute New Players Using Banned Words", true);
  483. this.config_ipLimit = config.getInt("GriefPrevention.MaxPlayersPerIpAddress", 3);
  484.  
  485. this.config_endermenMoveBlocks = config.getBoolean("GriefPrevention.EndermenMoveBlocks", false);
  486. this.config_silverfishBreakBlocks = config.getBoolean("GriefPrevention.SilverfishBreakBlocks", false);
  487. this.config_creaturesTrampleCrops = config.getBoolean("GriefPrevention.CreaturesTrampleCrops", false);
  488. this.config_rabbitsEatCrops = config.getBoolean("GriefPrevention.RabbitsEatCrops", true);
  489. this.config_zombiesBreakDoors = config.getBoolean("GriefPrevention.HardModeZombiesBreakDoors", false);
  490. this.config_ban_useCommand = config.getBoolean("GriefPrevention.UseBanCommand", false);
  491. this.config_ban_commandFormat = config.getString("GriefPrevention.BanCommandPattern", "ban %name% %reason%");
  492.  
  493. this.config_mods_ignoreClaimsAccounts = config.getStringList("GriefPrevention.Mods.PlayersIgnoringAllClaims");
  494. if (this.config_mods_ignoreClaimsAccounts == null) {
  495. this.config_mods_ignoreClaimsAccounts = new ArrayList();
  496. }
  497. this.config_mods_accessTrustIds = new MaterialCollection();
  498. List<String> accessTrustStrings = config.getStringList("GriefPrevention.Mods.BlockIdsRequiringAccessTrust");
  499.  
  500. parseMaterialListFromConfig(accessTrustStrings, this.config_mods_accessTrustIds);
  501.  
  502. this.config_mods_containerTrustIds = new MaterialCollection();
  503. List<String> containerTrustStrings = config.getStringList("GriefPrevention.Mods.BlockIdsRequiringContainerTrust");
  504. if ((containerTrustStrings == null) || (containerTrustStrings.size() == 0)) {
  505. containerTrustStrings.add(new MaterialInfo(99999, "Example - ID 99999, all data values.").toString());
  506. }
  507. parseMaterialListFromConfig(containerTrustStrings, this.config_mods_containerTrustIds);
  508.  
  509. this.config_mods_explodableIds = new MaterialCollection();
  510. List<String> explodableStrings = config.getStringList("GriefPrevention.Mods.BlockIdsExplodable");
  511.  
  512. parseMaterialListFromConfig(explodableStrings, this.config_mods_explodableIds);
  513.  
  514. String investigationToolMaterialName = Material.STICK.name();
  515.  
  516. investigationToolMaterialName = config.getString("GriefPrevention.Claims.InvestigationTool", investigationToolMaterialName);
  517.  
  518. this.config_claims_investigationTool = Material.getMaterial(investigationToolMaterialName);
  519. if (this.config_claims_investigationTool == null)
  520. {
  521. AddLogEntry("ERROR: Material " + investigationToolMaterialName + " not found. Defaulting to the stick. Please update your config.yml.");
  522. this.config_claims_investigationTool = Material.STICK;
  523. }
  524. String modificationToolMaterialName = Material.GOLD_SPADE.name();
  525.  
  526. modificationToolMaterialName = config.getString("GriefPrevention.Claims.ModificationTool", modificationToolMaterialName);
  527.  
  528. this.config_claims_modificationTool = Material.getMaterial(modificationToolMaterialName);
  529. if (this.config_claims_modificationTool == null)
  530. {
  531. AddLogEntry("ERROR: Material " + modificationToolMaterialName + " not found. Defaulting to the golden shovel. Please update your config.yml.");
  532. this.config_claims_modificationTool = Material.GOLD_SPADE;
  533. }
  534. ArrayList<String> defaultSiegeWorldNames = new ArrayList();
  535.  
  536. List<String> siegeEnabledWorldNames = config.getStringList("GriefPrevention.Siege.Worlds");
  537. if (siegeEnabledWorldNames == null) {
  538. siegeEnabledWorldNames = defaultSiegeWorldNames;
  539. }
  540. this.config_siege_enabledWorlds = new ArrayList();
  541. for (int i = 0; i < siegeEnabledWorldNames.size(); i++)
  542. {
  543. String worldName = (String)siegeEnabledWorldNames.get(i);
  544. World world = getServer().getWorld(worldName);
  545. if (world == null) {
  546. AddLogEntry("Error: Siege Configuration: There's no world named \"" + worldName + "\". Please update your config.yml.");
  547. } else {
  548. this.config_siege_enabledWorlds.add(world);
  549. }
  550. }
  551. this.config_siege_blocks = new ArrayList();
  552. this.config_siege_blocks.add(Material.DIRT);
  553. this.config_siege_blocks.add(Material.GRASS);
  554. this.config_siege_blocks.add(Material.LONG_GRASS);
  555. this.config_siege_blocks.add(Material.COBBLESTONE);
  556. this.config_siege_blocks.add(Material.GRAVEL);
  557. this.config_siege_blocks.add(Material.SAND);
  558. this.config_siege_blocks.add(Material.GLASS);
  559. this.config_siege_blocks.add(Material.THIN_GLASS);
  560. this.config_siege_blocks.add(Material.WOOD);
  561. this.config_siege_blocks.add(Material.WOOL);
  562. this.config_siege_blocks.add(Material.SNOW);
  563.  
  564. ArrayList<String> defaultBreakableBlocksList = new ArrayList();
  565. for (int i = 0; i < this.config_siege_blocks.size(); i++) {
  566. defaultBreakableBlocksList.add(((Material)this.config_siege_blocks.get(i)).name());
  567. }
  568. List<String> breakableBlocksList = config.getStringList("GriefPrevention.Siege.BreakableBlocks");
  569. if ((breakableBlocksList == null) || (breakableBlocksList.size() == 0)) {
  570. breakableBlocksList = defaultBreakableBlocksList;
  571. }
  572. this.config_siege_blocks = new ArrayList();
  573. for (int i = 0; i < breakableBlocksList.size(); i++)
  574. {
  575. String blockName = (String)breakableBlocksList.get(i);
  576. Material material = Material.getMaterial(blockName);
  577. if (material == null) {
  578. AddLogEntry("Siege Configuration: Material not found: " + blockName + ".");
  579. } else {
  580. this.config_siege_blocks.add(material);
  581. }
  582. }
  583. this.config_pvp_noCombatInPlayerLandClaims = config.getBoolean("GriefPrevention.PvP.ProtectPlayersInLandClaims.PlayerOwnedClaims", this.config_siege_enabledWorlds.size() == 0);
  584. this.config_pvp_noCombatInAdminLandClaims = config.getBoolean("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeClaims", this.config_siege_enabledWorlds.size() == 0);
  585. this.config_pvp_noCombatInAdminSubdivisions = config.getBoolean("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeSubdivisions", this.config_siege_enabledWorlds.size() == 0);
  586. this.config_pvp_allowLavaNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers", true);
  587. this.config_pvp_allowFireNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers", true);
  588. this.config_pvp_protectPets = config.getBoolean("GriefPrevention.PvP.ProtectPetsOutsideLandClaims", false);
  589.  
  590. this.databaseUrl = config.getString("GriefPrevention.Database.URL", "");
  591. this.databaseUserName = config.getString("GriefPrevention.Database.UserName", "");
  592. this.databasePassword = config.getString("GriefPrevention.Database.Password", "");
  593.  
  594. this.config_logs_daysToKeep = config.getInt("GriefPrevention.Abridged Logs.Days To Keep", 7);
  595. this.config_logs_socialEnabled = config.getBoolean("GriefPrevention.Abridged Logs.Included Entry Types.Social Activity", true);
  596. this.config_logs_suspiciousEnabled = config.getBoolean("GriefPrevention.Abridged Logs.Included Entry Types.Suspicious Activity", true);
  597. this.config_logs_adminEnabled = config.getBoolean("GriefPrevention.Abridged Logs.Included Entry Types.Administrative Activity", false);
  598. this.config_logs_debugEnabled = config.getBoolean("GriefPrevention.Abridged Logs.Included Entry Types.Debug", false);
  599. this.config_logs_mutedChatEnabled = config.getBoolean("GriefPrevention.Abridged Logs.Included Entry Types.Muted Chat Messages", false);
  600. try
  601. {
  602. for (World world : this.config_claims_worldModes.keySet()) {
  603. outConfig.set("GriefPrevention.Claims.Mode." + world
  604. .getName(),
  605. ((ClaimsMode)this.config_claims_worldModes.get(world)).name());
  606. }
  607. }
  608. catch (NoSuchMethodError e)
  609. {
  610. getLogger().severe("You are running an old version of Java which is susceptible to security exploits. Please update to Java 8.");
  611. getLogger().severe("If you are on a shared host, tell your hosting provider to update, as Java 7 is End of Life, and you're missing out on security and performance improvements");
  612. getLogger().severe("If they refuse, I'd suggesting switching to a more secure and responsive host.");
  613. getLogger().severe("But if you truly have absolutely no choice, then please download the Java 7 version of GriefPrevention.");
  614. getServer().getPluginManager().disablePlugin(this);
  615. return;
  616. }
  617. outConfig.set("GriefPrevention.Claims.PreventGlobalMonsterEggs", Boolean.valueOf(this.config_claims_preventGlobalMonsterEggs));
  618. outConfig.set("GriefPrevention.Claims.PreventTheft", Boolean.valueOf(this.config_claims_preventTheft));
  619. outConfig.set("GriefPrevention.Claims.ProtectCreatures", Boolean.valueOf(this.config_claims_protectCreatures));
  620. outConfig.set("GriefPrevention.Claims.PreventButtonsSwitches", Boolean.valueOf(this.config_claims_preventButtonsSwitches));
  621. outConfig.set("GriefPrevention.Claims.LockWoodenDoors", Boolean.valueOf(this.config_claims_lockWoodenDoors));
  622. outConfig.set("GriefPrevention.Claims.LockTrapDoors", Boolean.valueOf(this.config_claims_lockTrapDoors));
  623. outConfig.set("GriefPrevention.Claims.LockFenceGates", Boolean.valueOf(this.config_claims_lockFenceGates));
  624. outConfig.set("GriefPrevention.Claims.EnderPearlsRequireAccessTrust", Boolean.valueOf(this.config_claims_enderPearlsRequireAccessTrust));
  625. outConfig.set("GriefPrevention.Claims.ProtectHorses", Boolean.valueOf(this.config_claims_protectHorses));
  626. outConfig.set("GriefPrevention.Claims.InitialBlocks", Integer.valueOf(this.config_claims_initialBlocks));
  627. outConfig.set("GriefPrevention.Claims.Claim Blocks Accrued Per Hour.Default", Integer.valueOf(this.config_claims_blocksAccruedPerHour_default));
  628. outConfig.set("GriefPrevention.Claims.Max Accrued Claim Blocks.Default", Integer.valueOf(this.config_claims_maxAccruedBlocks_default));
  629. outConfig.set("GriefPrevention.Claims.Accrued Idle Threshold", Integer.valueOf(this.config_claims_accruedIdleThreshold));
  630. outConfig.set("GriefPrevention.Claims.AccruedIdlePercent", Integer.valueOf(this.config_claims_accruedIdlePercent));
  631. outConfig.set("GriefPrevention.Claims.AbandonReturnRatio", Double.valueOf(this.config_claims_abandonReturnRatio));
  632. outConfig.set("GriefPrevention.Claims.AutomaticNewPlayerClaimsRadius", Integer.valueOf(this.config_claims_automaticClaimsForNewPlayersRadius));
  633. outConfig.set("GriefPrevention.Claims.ExtendIntoGroundDistance", Integer.valueOf(this.config_claims_claimsExtendIntoGroundDistance));
  634. outConfig.set("GriefPrevention.Claims.MinimumWidth", Integer.valueOf(this.config_claims_minWidth));
  635. outConfig.set("GriefPrevention.Claims.MinimumArea", Integer.valueOf(this.config_claims_minArea));
  636. outConfig.set("GriefPrevention.Claims.MaximumDepth", Integer.valueOf(this.config_claims_maxDepth));
  637. outConfig.set("GriefPrevention.Claims.InvestigationTool", this.config_claims_investigationTool.name());
  638. outConfig.set("GriefPrevention.Claims.ModificationTool", this.config_claims_modificationTool.name());
  639. outConfig.set("GriefPrevention.Claims.Expiration.ChestClaimDays", Integer.valueOf(this.config_claims_chestClaimExpirationDays));
  640. outConfig.set("GriefPrevention.Claims.Expiration.UnusedClaimDays", Integer.valueOf(this.config_claims_unusedClaimExpirationDays));
  641. outConfig.set("GriefPrevention.Claims.Expiration.AllClaims.DaysInactive", Integer.valueOf(this.config_claims_expirationDays));
  642. outConfig.set("GriefPrevention.Claims.Expiration.AllClaims.ExceptWhenOwnerHasTotalClaimBlocks", Integer.valueOf(this.config_claims_expirationExemptionTotalBlocks));
  643. outConfig.set("GriefPrevention.Claims.Expiration.AllClaims.ExceptWhenOwnerHasBonusClaimBlocks", Integer.valueOf(this.config_claims_expirationExemptionBonusBlocks));
  644. outConfig.set("GriefPrevention.Claims.Expiration.AutomaticNatureRestoration.SurvivalWorlds", Boolean.valueOf(this.config_claims_survivalAutoNatureRestoration));
  645. outConfig.set("GriefPrevention.Claims.AllowTrappedInAdminClaims", Boolean.valueOf(this.config_claims_allowTrappedInAdminClaims));
  646. outConfig.set("GriefPrevention.Claims.MaximumNumberOfClaimsPerPlayer", Integer.valueOf(this.config_claims_maxClaimsPerPlayer));
  647. outConfig.set("GriefPrevention.Claims.CreationRequiresWorldGuardBuildPermission", Boolean.valueOf(this.config_claims_respectWorldGuard));
  648. outConfig.set("GriefPrevention.Claims.PortalGenerationRequiresPermission", Boolean.valueOf(this.config_claims_portalsRequirePermission));
  649. outConfig.set("GriefPrevention.Claims.VillagerTradingRequiresPermission", Boolean.valueOf(this.config_claims_villagerTradingRequiresTrust));
  650. outConfig.set("GriefPrevention.Claims.CommandsRequiringAccessTrust", accessTrustSlashCommands);
  651. outConfig.set("GriefPrevention.Claims.DeliverManuals", Boolean.valueOf(this.config_claims_supplyPlayerManual));
  652. outConfig.set("GriefPrevention.Claims.ManualDeliveryDelaySeconds", Integer.valueOf(this.config_claims_manualDeliveryDelaySeconds));
  653.  
  654. outConfig.set("GriefPrevention.Spam.Enabled", Boolean.valueOf(this.config_spam_enabled));
  655. outConfig.set("GriefPrevention.Spam.LoginCooldownSeconds", Integer.valueOf(this.config_spam_loginCooldownSeconds));
  656. outConfig.set("GriefPrevention.Spam.LoginLogoutNotificationsPerMinute", Integer.valueOf(this.config_spam_loginLogoutNotificationsPerMinute));
  657. outConfig.set("GriefPrevention.Spam.ChatSlashCommands", slashCommandsToMonitor);
  658. outConfig.set("GriefPrevention.Spam.WhisperSlashCommands", whisperCommandsToMonitor);
  659. outConfig.set("GriefPrevention.Spam.WarningMessage", this.config_spam_warningMessage);
  660. outConfig.set("GriefPrevention.Spam.BanOffenders", Boolean.valueOf(this.config_spam_banOffenders));
  661. outConfig.set("GriefPrevention.Spam.BanMessage", this.config_spam_banMessage);
  662. outConfig.set("GriefPrevention.Spam.AllowedIpAddresses", this.config_spam_allowedIpAddresses);
  663. outConfig.set("GriefPrevention.Spam.DeathMessageCooldownSeconds", Integer.valueOf(this.config_spam_deathMessageCooldownSeconds));
  664. outConfig.set("GriefPrevention.Spam.Logout Message Delay In Seconds", Integer.valueOf(this.config_spam_logoutMessageDelaySeconds));
  665. for (World world : worlds) {
  666. outConfig.set("GriefPrevention.PvP.RulesEnabledInWorld." + world.getName(), Boolean.valueOf(pvpRulesApply(world)));
  667. }
  668. outConfig.set("GriefPrevention.PvP.ProtectFreshSpawns", Boolean.valueOf(this.config_pvp_protectFreshSpawns));
  669. outConfig.set("GriefPrevention.PvP.PunishLogout", Boolean.valueOf(this.config_pvp_punishLogout));
  670. outConfig.set("GriefPrevention.PvP.CombatTimeoutSeconds", Integer.valueOf(this.config_pvp_combatTimeoutSeconds));
  671. outConfig.set("GriefPrevention.PvP.AllowCombatItemDrop", Boolean.valueOf(this.config_pvp_allowCombatItemDrop));
  672. outConfig.set("GriefPrevention.PvP.BlockedSlashCommands", bannedPvPCommandsList);
  673. outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.PlayerOwnedClaims", Boolean.valueOf(this.config_pvp_noCombatInPlayerLandClaims));
  674. outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeClaims", Boolean.valueOf(this.config_pvp_noCombatInAdminLandClaims));
  675. outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeSubdivisions", Boolean.valueOf(this.config_pvp_noCombatInAdminSubdivisions));
  676. outConfig.set("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers", Boolean.valueOf(this.config_pvp_allowLavaNearPlayers));
  677. outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers", Boolean.valueOf(this.config_pvp_allowFireNearPlayers));
  678. outConfig.set("GriefPrevention.PvP.ProtectPetsOutsideLandClaims", Boolean.valueOf(this.config_pvp_protectPets));
  679.  
  680. outConfig.set("GriefPrevention.Economy.ClaimBlocksPurchaseCost", Double.valueOf(this.config_economy_claimBlocksPurchaseCost));
  681. outConfig.set("GriefPrevention.Economy.ClaimBlocksSellValue", Double.valueOf(this.config_economy_claimBlocksSellValue));
  682.  
  683. outConfig.set("GriefPrevention.ProtectItemsDroppedOnDeath.PvPWorlds", Boolean.valueOf(this.config_lockDeathDropsInPvpWorlds));
  684. outConfig.set("GriefPrevention.ProtectItemsDroppedOnDeath.NonPvPWorlds", Boolean.valueOf(this.config_lockDeathDropsInNonPvpWorlds));
  685.  
  686. outConfig.set("GriefPrevention.BlockLandClaimExplosions", Boolean.valueOf(this.config_blockClaimExplosions));
  687. outConfig.set("GriefPrevention.BlockSurfaceCreeperExplosions", Boolean.valueOf(this.config_blockSurfaceCreeperExplosions));
  688. outConfig.set("GriefPrevention.BlockSurfaceOtherExplosions", Boolean.valueOf(this.config_blockSurfaceOtherExplosions));
  689. outConfig.set("GriefPrevention.LimitSkyTrees", Boolean.valueOf(this.config_blockSkyTrees));
  690. outConfig.set("GriefPrevention.LimitTreeGrowth", Boolean.valueOf(this.config_limitTreeGrowth));
  691. outConfig.set("GriefPrevention.LimitPistonsToLandClaims", Boolean.valueOf(this.config_pistonsInClaimsOnly));
  692.  
  693. outConfig.set("GriefPrevention.FireSpreads", Boolean.valueOf(this.config_fireSpreads));
  694. outConfig.set("GriefPrevention.FireDestroys", Boolean.valueOf(this.config_fireDestroys));
  695.  
  696. outConfig.set("GriefPrevention.AdminsGetWhispers", Boolean.valueOf(this.config_whisperNotifications));
  697. outConfig.set("GriefPrevention.AdminsGetSignNotifications", Boolean.valueOf(this.config_signNotifications));
  698.  
  699. outConfig.set("GriefPrevention.SmartBan", Boolean.valueOf(this.config_smartBan));
  700. outConfig.set("GriefPrevention.Mute New Players Using Banned Words", Boolean.valueOf(this.config_trollFilterEnabled));
  701. outConfig.set("GriefPrevention.MaxPlayersPerIpAddress", Integer.valueOf(this.config_ipLimit));
  702.  
  703. outConfig.set("GriefPrevention.Siege.Worlds", siegeEnabledWorldNames);
  704. outConfig.set("GriefPrevention.Siege.BreakableBlocks", breakableBlocksList);
  705.  
  706. outConfig.set("GriefPrevention.EndermenMoveBlocks", Boolean.valueOf(this.config_endermenMoveBlocks));
  707. outConfig.set("GriefPrevention.SilverfishBreakBlocks", Boolean.valueOf(this.config_silverfishBreakBlocks));
  708. outConfig.set("GriefPrevention.CreaturesTrampleCrops", Boolean.valueOf(this.config_creaturesTrampleCrops));
  709. outConfig.set("GriefPrevention.RabbitsEatCrops", Boolean.valueOf(this.config_rabbitsEatCrops));
  710. outConfig.set("GriefPrevention.HardModeZombiesBreakDoors", Boolean.valueOf(this.config_zombiesBreakDoors));
  711.  
  712. outConfig.set("GriefPrevention.Database.URL", this.databaseUrl);
  713. outConfig.set("GriefPrevention.Database.UserName", this.databaseUserName);
  714. outConfig.set("GriefPrevention.Database.Password", this.databasePassword);
  715.  
  716. outConfig.set("GriefPrevention.UseBanCommand", Boolean.valueOf(this.config_ban_useCommand));
  717. outConfig.set("GriefPrevention.BanCommandPattern", this.config_ban_commandFormat);
  718.  
  719. outConfig.set("GriefPrevention.Mods.BlockIdsRequiringAccessTrust", this.config_mods_accessTrustIds);
  720. outConfig.set("GriefPrevention.Mods.BlockIdsRequiringContainerTrust", this.config_mods_containerTrustIds);
  721. outConfig.set("GriefPrevention.Mods.BlockIdsExplodable", this.config_mods_explodableIds);
  722. outConfig.set("GriefPrevention.Mods.PlayersIgnoringAllClaims", this.config_mods_ignoreClaimsAccounts);
  723. outConfig.set("GriefPrevention.Mods.BlockIdsRequiringAccessTrust", accessTrustStrings);
  724. outConfig.set("GriefPrevention.Mods.BlockIdsRequiringContainerTrust", containerTrustStrings);
  725. outConfig.set("GriefPrevention.Mods.BlockIdsExplodable", explodableStrings);
  726.  
  727. outConfig.set("GriefPrevention.Abridged Logs.Days To Keep", Integer.valueOf(this.config_logs_daysToKeep));
  728. outConfig.set("GriefPrevention.Abridged Logs.Included Entry Types.Social Activity", Boolean.valueOf(this.config_logs_socialEnabled));
  729. outConfig.set("GriefPrevention.Abridged Logs.Included Entry Types.Suspicious Activity", Boolean.valueOf(this.config_logs_suspiciousEnabled));
  730. outConfig.set("GriefPrevention.Abridged Logs.Included Entry Types.Administrative Activity", Boolean.valueOf(this.config_logs_adminEnabled));
  731. outConfig.set("GriefPrevention.Abridged Logs.Included Entry Types.Debug", Boolean.valueOf(this.config_logs_debugEnabled));
  732. outConfig.set("GriefPrevention.Abridged Logs.Included Entry Types.Muted Chat Messages", Boolean.valueOf(this.config_logs_mutedChatEnabled));
  733. try
  734. {
  735. outConfig.save(DataStore.configFilePath);
  736. }
  737. catch (IOException exception)
  738. {
  739. AddLogEntry("Unable to write to the configuration file at \"" + DataStore.configFilePath + "\"");
  740. }
  741. this.config_claims_commandsRequiringAccessTrust = new ArrayList();
  742. String[] commands = accessTrustSlashCommands.split(";");
  743. for (int i = 0; i < commands.length; i++) {
  744. if (!commands[i].isEmpty()) {
  745. this.config_claims_commandsRequiringAccessTrust.add(commands[i].trim().toLowerCase());
  746. }
  747. }
  748. this.config_spam_monitorSlashCommands = new ArrayList();
  749. commands = slashCommandsToMonitor.split(";");
  750. for (int i = 0; i < commands.length; i++) {
  751. this.config_spam_monitorSlashCommands.add(commands[i].trim().toLowerCase());
  752. }
  753. this.config_eavesdrop_whisperCommands = new ArrayList();
  754. commands = whisperCommandsToMonitor.split(";");
  755. for (int i = 0; i < commands.length; i++) {
  756. this.config_eavesdrop_whisperCommands.add(commands[i].trim().toLowerCase());
  757. }
  758. this.config_pvp_blockedCommands = new ArrayList();
  759. commands = bannedPvPCommandsList.split(";");
  760. for (int i = 0; i < commands.length; i++) {
  761. this.config_pvp_blockedCommands.add(commands[i].trim().toLowerCase());
  762. }
  763. }
  764.  
  765. private ClaimsMode configStringToClaimsMode(String configSetting)
  766. {
  767. if (configSetting.equalsIgnoreCase("Survival")) {
  768. return ClaimsMode.Survival;
  769. }
  770. if (configSetting.equalsIgnoreCase("Creative")) {
  771. return ClaimsMode.Creative;
  772. }
  773. if (configSetting.equalsIgnoreCase("Disabled")) {
  774. return ClaimsMode.Disabled;
  775. }
  776. if (configSetting.equalsIgnoreCase("SurvivalRequiringClaims")) {
  777. return ClaimsMode.SurvivalRequiringClaims;
  778. }
  779. return null;
  780. }
  781.  
  782. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
  783. {
  784. Player player = null;
  785. if ((sender instanceof Player)) {
  786. player = (Player)sender;
  787. }
  788. if ((cmd.getName().equalsIgnoreCase("claim")) && (player != null))
  789. {
  790. if (!instance.claimsEnabledForWorld(player.getWorld()))
  791. {
  792. sendMessage(player, TextMode.Err, Messages.ClaimsDisabledWorld, new String[0]);
  793. return true;
  794. }
  795. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  796. if ((instance.config_claims_maxClaimsPerPlayer > 0) &&
  797. (!player.hasPermission("griefprevention.overrideclaimcountlimit")) &&
  798. (playerData.getClaims().size() >= instance.config_claims_maxClaimsPerPlayer))
  799. {
  800. sendMessage(player, TextMode.Err, Messages.ClaimCreationFailedOverClaimCountLimit, new String[0]);
  801. return true;
  802. }
  803. int radius = instance.config_claims_automaticClaimsForNewPlayersRadius;
  804. if (radius < 0) {
  805. radius = (int)Math.ceil(Math.sqrt(instance.config_claims_minArea) / 2.0D);
  806. }
  807. if (playerData.getClaims().size() > 0)
  808. {
  809. if ((playerData.getClaims().size() == 1) && (player.getGameMode() != GameMode.CREATIVE) && (player.getItemInHand().getType() != instance.config_claims_modificationTool))
  810. {
  811. sendMessage(player, TextMode.Err, Messages.MustHoldModificationToolForThat, new String[0]);
  812. return true;
  813. }
  814. radius = (int)Math.ceil(Math.sqrt(instance.config_claims_minArea) / 2.0D);
  815. }
  816. if (args.length > 0)
  817. {
  818. if ((playerData.getClaims().size() < 2) && (player.getGameMode() != GameMode.CREATIVE) && (player.getItemInHand().getType() != instance.config_claims_modificationTool))
  819. {
  820. sendMessage(player, TextMode.Err, Messages.RadiusRequiresGoldenShovel, new String[0]);
  821. return true;
  822. }
  823. try
  824. {
  825. specifiedRadius = Integer.parseInt(args[0]);
  826. }
  827. catch (NumberFormatException e)
  828. {
  829. int specifiedRadius;
  830. return false;
  831. }
  832. int specifiedRadius;
  833. if (specifiedRadius < radius)
  834. {
  835. sendMessage(player, TextMode.Err, Messages.MinimumRadius, new String[] { String.valueOf(radius) });
  836. return true;
  837. }
  838. radius = specifiedRadius;
  839. }
  840. if (radius < 0) {
  841. radius = 0;
  842. }
  843. Location lc = player.getLocation().add(-radius, 0.0D, -radius);
  844. Location gc = player.getLocation().add(radius, 0.0D, radius);
  845.  
  846. int area = Math.abs((gc.getBlockX() - lc.getBlockX() + 1) * (gc.getBlockZ() - lc.getBlockZ() + 1));
  847. int remaining = playerData.getRemainingClaimBlocks();
  848. if (remaining < area)
  849. {
  850. sendMessage(player, TextMode.Err, Messages.CreateClaimInsufficientBlocks, new String[] { String.valueOf(area - remaining) });
  851. instance.dataStore.tryAdvertiseAdminAlternatives(player);
  852. return true;
  853. }
  854. CreateClaimResult result = this.dataStore.createClaim(lc.getWorld(), lc
  855. .getBlockX(), gc.getBlockX(), lc
  856. .getBlockY() - instance.config_claims_claimsExtendIntoGroundDistance - 1, gc
  857. .getWorld().getHighestBlockYAt(gc) - instance.config_claims_claimsExtendIntoGroundDistance - 1, lc
  858. .getBlockZ(), gc.getBlockZ(), player
  859. .getUniqueId(), null, null, player);
  860. if (!result.succeeded)
  861. {
  862. if (result.claim != null)
  863. {
  864. sendMessage(player, TextMode.Err, Messages.CreateClaimFailOverlapShort, new String[0]);
  865.  
  866. Visualization visualization = Visualization.FromClaim(result.claim, player.getEyeLocation().getBlockY(), VisualizationType.ErrorClaim, player.getLocation());
  867. Visualization.Apply(player, visualization);
  868. }
  869. else
  870. {
  871. sendMessage(player, TextMode.Err, Messages.CreateClaimFailOverlapRegion, new String[0]);
  872. }
  873. }
  874. else
  875. {
  876. sendMessage(player, TextMode.Success, Messages.CreateClaimSuccess, new String[0]);
  877. if (instance.creativeRulesApply(player.getLocation())) {
  878. sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, new String[] { DataStore.CREATIVE_VIDEO_URL });
  879. } else if (instance.claimsEnabledForWorld(player.getLocation().getWorld())) {
  880. sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, new String[] { DataStore.SURVIVAL_VIDEO_URL });
  881. }
  882. Visualization visualization = Visualization.FromClaim(result.claim, player.getEyeLocation().getBlockY(), VisualizationType.Claim, player.getLocation());
  883. Visualization.Apply(player, visualization);
  884. playerData.claimResizing = null;
  885. playerData.lastShovelLocation = null;
  886.  
  887. autoExtendClaim(result.claim);
  888. }
  889. return true;
  890. }
  891. Claim claim;
  892. if ((cmd.getName().equalsIgnoreCase("extendclaim")) && (player != null))
  893. {
  894. if (args.length < 1)
  895. {
  896. if (instance.creativeRulesApply(player.getLocation())) {
  897. sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, new String[] { DataStore.CREATIVE_VIDEO_URL });
  898. } else if (instance.claimsEnabledForWorld(player.getLocation().getWorld())) {
  899. sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, new String[] { DataStore.SURVIVAL_VIDEO_URL });
  900. }
  901. return false;
  902. }
  903. try
  904. {
  905. amount = Integer.parseInt(args[0]);
  906. }
  907. catch (NumberFormatException e)
  908. {
  909. int amount;
  910. if (instance.creativeRulesApply(player.getLocation())) {
  911. sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, new String[] { DataStore.CREATIVE_VIDEO_URL });
  912. } else if (instance.claimsEnabledForWorld(player.getLocation().getWorld())) {
  913. sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, new String[] { DataStore.SURVIVAL_VIDEO_URL });
  914. }
  915. return false;
  916. }
  917. int amount;
  918. if ((player.getGameMode() != GameMode.CREATIVE) && (player.getItemInHand().getType() != instance.config_claims_modificationTool))
  919. {
  920. sendMessage(player, TextMode.Err, Messages.MustHoldModificationToolForThat, new String[0]);
  921. return true;
  922. }
  923. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  924. claim = this.dataStore.getClaimAt(player.getLocation(), true, playerData.lastClaim);
  925. if (claim == null)
  926. {
  927. sendMessage(player, TextMode.Err, Messages.StandInClaimToResize, new String[0]);
  928. return true;
  929. }
  930. String errorMessage = claim.allowEdit(player);
  931. if (errorMessage != null)
  932. {
  933. sendMessage(player, TextMode.Err, Messages.NotYourClaim, new String[0]);
  934. return true;
  935. }
  936. org.bukkit.util.Vector direction = player.getLocation().getDirection();
  937. if (direction.getY() > 0.75D)
  938. {
  939. sendMessage(player, TextMode.Info, Messages.ClaimsExtendToSky, new String[0]);
  940. return true;
  941. }
  942. if (direction.getY() < -0.75D)
  943. {
  944. sendMessage(player, TextMode.Info, Messages.ClaimsAutoExtendDownward, new String[0]);
  945. return true;
  946. }
  947. Location lc = claim.getLesserBoundaryCorner();
  948. Location gc = claim.getGreaterBoundaryCorner();
  949. int newx1 = lc.getBlockX();
  950. int newx2 = gc.getBlockX();
  951. int newy1 = lc.getBlockY();
  952. int newy2 = gc.getBlockY();
  953. int newz1 = lc.getBlockZ();
  954. int newz2 = gc.getBlockZ();
  955. if (Math.abs(direction.getX()) < 0.3D)
  956. {
  957. if (direction.getZ() > 0.0D) {
  958. newz2 += amount;
  959. } else {
  960. newz1 -= amount;
  961. }
  962. }
  963. else if (Math.abs(direction.getZ()) < 0.3D)
  964. {
  965. if (direction.getX() > 0.0D) {
  966. newx2 += amount;
  967. } else {
  968. newx1 -= amount;
  969. }
  970. }
  971. else
  972. {
  973. if (direction.getX() > 0.0D) {
  974. newx2 += amount;
  975. } else {
  976. newx1 -= amount;
  977. }
  978. if (direction.getZ() > 0.0D) {
  979. newz2 += amount;
  980. } else {
  981. newz1 -= amount;
  982. }
  983. }
  984. playerData.claimResizing = claim;
  985. this.dataStore.resizeClaimWithChecks(player, playerData, newx1, newx2, newy1, newy2, newz1, newz2);
  986. playerData.claimResizing = null;
  987.  
  988. return true;
  989. }
  990. if ((cmd.getName().equalsIgnoreCase("abandonclaim")) && (player != null)) {
  991. return abandonClaimHandler(player, false);
  992. }
  993. if ((cmd.getName().equalsIgnoreCase("abandontoplevelclaim")) && (player != null)) {
  994. return abandonClaimHandler(player, true);
  995. }
  996. if ((cmd.getName().equalsIgnoreCase("ignoreclaims")) && (player != null))
  997. {
  998. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  999.  
  1000. playerData.ignoreClaims = (!playerData.ignoreClaims);
  1001. if (!playerData.ignoreClaims) {
  1002. sendMessage(player, TextMode.Success, Messages.RespectingClaims, new String[0]);
  1003. } else {
  1004. sendMessage(player, TextMode.Success, Messages.IgnoringClaims, new String[0]);
  1005. }
  1006. return true;
  1007. }
  1008. if ((cmd.getName().equalsIgnoreCase("abandonallclaims")) && (player != null))
  1009. {
  1010. if (args.length != 0) {
  1011. return false;
  1012. }
  1013. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1014. int originalClaimCount = playerData.getClaims().size();
  1015. if (originalClaimCount == 0)
  1016. {
  1017. sendMessage(player, TextMode.Err, Messages.YouHaveNoClaims, new String[0]);
  1018. return true;
  1019. }
  1020. for (Claim claim : playerData.getClaims()) {
  1021. playerData.setAccruedClaimBlocks(Integer.valueOf(playerData.getAccruedClaimBlocks() - (int)Math.ceil(claim.getArea() * (1.0D - this.config_claims_abandonReturnRatio))));
  1022. }
  1023. this.dataStore.deleteClaimsForPlayer(player.getUniqueId(), false);
  1024.  
  1025. int remainingBlocks = playerData.getRemainingClaimBlocks();
  1026. sendMessage(player, TextMode.Success, Messages.SuccessfulAbandon, new String[] { String.valueOf(remainingBlocks) });
  1027.  
  1028. Visualization.Revert(player);
  1029.  
  1030. return true;
  1031. }
  1032. if ((cmd.getName().equalsIgnoreCase("restorenature")) && (player != null))
  1033. {
  1034. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1035. playerData.shovelMode = ShovelMode.RestoreNature;
  1036. sendMessage(player, TextMode.Instr, Messages.RestoreNatureActivate, new String[0]);
  1037. return true;
  1038. }
  1039. if ((cmd.getName().equalsIgnoreCase("restorenatureaggressive")) && (player != null))
  1040. {
  1041. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1042. playerData.shovelMode = ShovelMode.RestoreNatureAggressive;
  1043. sendMessage(player, TextMode.Warn, Messages.RestoreNatureAggressiveActivate, new String[0]);
  1044. return true;
  1045. }
  1046. if ((cmd.getName().equalsIgnoreCase("restorenaturefill")) && (player != null))
  1047. {
  1048. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1049. playerData.shovelMode = ShovelMode.RestoreNatureFill;
  1050.  
  1051. playerData.fillRadius = 2;
  1052. if (args.length > 0) {
  1053. try
  1054. {
  1055. playerData.fillRadius = Integer.parseInt(args[0]);
  1056. }
  1057. catch (Exception localException) {}
  1058. }
  1059. if (playerData.fillRadius < 0) {
  1060. playerData.fillRadius = 2;
  1061. }
  1062. sendMessage(player, TextMode.Success, Messages.FillModeActive, new String[] { String.valueOf(playerData.fillRadius) });
  1063. return true;
  1064. }
  1065. if ((cmd.getName().equalsIgnoreCase("trust")) && (player != null))
  1066. {
  1067. if (args.length != 1) {
  1068. return false;
  1069. }
  1070. handleTrustCommand(player, ClaimPermission.Build, args[0]);
  1071.  
  1072. return true;
  1073. }
  1074. if ((cmd.getName().equalsIgnoreCase("transferclaim")) && (player != null))
  1075. {
  1076. Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, null);
  1077. if (claim == null)
  1078. {
  1079. sendMessage(player, TextMode.Instr, Messages.TransferClaimMissing, new String[0]);
  1080. return true;
  1081. }
  1082. if ((claim.isAdminClaim()) && (!player.hasPermission("griefprevention.adminclaims")))
  1083. {
  1084. sendMessage(player, TextMode.Err, Messages.TransferClaimPermission, new String[0]);
  1085. return true;
  1086. }
  1087. UUID newOwnerID = null;
  1088. String ownerName = "admin";
  1089. if (args.length > 0)
  1090. {
  1091. OfflinePlayer targetPlayer = resolvePlayerByName(args[0]);
  1092. if (targetPlayer == null)
  1093. {
  1094. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1095. return true;
  1096. }
  1097. newOwnerID = targetPlayer.getUniqueId();
  1098. ownerName = targetPlayer.getName();
  1099. }
  1100. try
  1101. {
  1102. this.dataStore.changeClaimOwner(claim, newOwnerID);
  1103. }
  1104. catch (DataStore.NoTransferException e)
  1105. {
  1106. sendMessage(player, TextMode.Instr, Messages.TransferTopLevel, new String[0]);
  1107. return true;
  1108. }
  1109. sendMessage(player, TextMode.Success, Messages.TransferSuccess, new String[0]);
  1110. AddLogEntry(player.getName() + " transferred a claim at " + getfriendlyLocationString(claim.getLesserBoundaryCorner()) + " to " + ownerName + ".", CustomLogEntryTypes.AdminActivity);
  1111.  
  1112. return true;
  1113. }
  1114. if ((cmd.getName().equalsIgnoreCase("trustlist")) && (player != null))
  1115. {
  1116. Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, null);
  1117. if (claim == null)
  1118. {
  1119. sendMessage(player, TextMode.Err, Messages.TrustListNoClaim, new String[0]);
  1120. return true;
  1121. }
  1122. String errorMessage = claim.allowGrantPermission(player);
  1123. if (errorMessage != null)
  1124. {
  1125. sendMessage(player, TextMode.Err, errorMessage);
  1126. return true;
  1127. }
  1128. ArrayList<String> builders = new ArrayList();
  1129. ArrayList<String> containers = new ArrayList();
  1130. ArrayList<String> accessors = new ArrayList();
  1131. ArrayList<String> managers = new ArrayList();
  1132. claim.getPermissions(builders, containers, accessors, managers);
  1133.  
  1134. sendMessage(player, TextMode.Info, Messages.TrustListHeader, new String[0]);
  1135.  
  1136. StringBuilder permissions = new StringBuilder();
  1137. permissions.append(ChatColor.GOLD + ">");
  1138. if (managers.size() > 0) {
  1139. for (int i = 0; i < managers.size(); i++) {
  1140. permissions.append(trustEntryToPlayerName((String)managers.get(i)) + " ");
  1141. }
  1142. }
  1143. player.sendMessage(permissions.toString());
  1144. permissions = new StringBuilder();
  1145. permissions.append(ChatColor.YELLOW + ">");
  1146. if (builders.size() > 0) {
  1147. for (int i = 0; i < builders.size(); i++) {
  1148. permissions.append(trustEntryToPlayerName((String)builders.get(i)) + " ");
  1149. }
  1150. }
  1151. player.sendMessage(permissions.toString());
  1152. permissions = new StringBuilder();
  1153. permissions.append(ChatColor.GREEN + ">");
  1154. if (containers.size() > 0) {
  1155. for (int i = 0; i < containers.size(); i++) {
  1156. permissions.append(trustEntryToPlayerName((String)containers.get(i)) + " ");
  1157. }
  1158. }
  1159. player.sendMessage(permissions.toString());
  1160. permissions = new StringBuilder();
  1161. permissions.append(ChatColor.BLUE + ">");
  1162. if (accessors.size() > 0) {
  1163. for (int i = 0; i < accessors.size(); i++) {
  1164. permissions.append(trustEntryToPlayerName((String)accessors.get(i)) + " ");
  1165. }
  1166. }
  1167. player.sendMessage(permissions.toString());
  1168.  
  1169. player.sendMessage(ChatColor.GOLD + this.dataStore
  1170. .getMessage(Messages.Manage, new String[0]) + " " + ChatColor.YELLOW + this.dataStore
  1171. .getMessage(Messages.Build, new String[0]) + " " + ChatColor.GREEN + this.dataStore
  1172. .getMessage(Messages.Containers, new String[0]) + " " + ChatColor.BLUE + this.dataStore
  1173. .getMessage(Messages.Access, new String[0]));
  1174.  
  1175. return true;
  1176. }
  1177. if ((cmd.getName().equalsIgnoreCase("untrust")) && (player != null))
  1178. {
  1179. if (args.length != 1) {
  1180. return false;
  1181. }
  1182. Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, null);
  1183. if ((args[0].contains(".")) && (!args[0].startsWith("[")) && (!args[0].endsWith("]"))) {
  1184. args[0] = ("[" + args[0] + "]");
  1185. }
  1186. boolean clearPermissions = false;
  1187. OfflinePlayer otherPlayer = null;
  1188. if (args[0].equals("all"))
  1189. {
  1190. if ((claim == null) || (claim.allowEdit(player) == null))
  1191. {
  1192. clearPermissions = true;
  1193. }
  1194. else
  1195. {
  1196. sendMessage(player, TextMode.Err, Messages.ClearPermsOwnerOnly, new String[0]);
  1197. return true;
  1198. }
  1199. }
  1200. else if ((!args[0].startsWith("[")) || (!args[0].endsWith("]")))
  1201. {
  1202. otherPlayer = resolvePlayerByName(args[0]);
  1203. if ((!clearPermissions) && (otherPlayer == null) && (!args[0].equals("public")))
  1204. {
  1205. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1206. return true;
  1207. }
  1208. if (otherPlayer != null) {
  1209. args[0] = otherPlayer.getName();
  1210. }
  1211. }
  1212. if (claim == null)
  1213. {
  1214. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1215. for (int i = 0; i < playerData.getClaims().size(); i++)
  1216. {
  1217. claim = (Claim)playerData.getClaims().get(i);
  1218. if (clearPermissions)
  1219. {
  1220. claim.clearPermissions();
  1221. }
  1222. else
  1223. {
  1224. String idToDrop = args[0];
  1225. if (otherPlayer != null) {
  1226. idToDrop = otherPlayer.getUniqueId().toString();
  1227. }
  1228. claim.dropPermission(idToDrop);
  1229. claim.managers.remove(idToDrop);
  1230. }
  1231. this.dataStore.saveClaim(claim);
  1232. }
  1233. if (args[0].equals("public")) {
  1234. args[0] = "the public";
  1235. }
  1236. if (!clearPermissions) {
  1237. sendMessage(player, TextMode.Success, Messages.UntrustIndividualAllClaims, new String[] { args[0] });
  1238. } else {
  1239. sendMessage(player, TextMode.Success, Messages.UntrustEveryoneAllClaims, new String[0]);
  1240. }
  1241. }
  1242. else
  1243. {
  1244. if (claim.allowGrantPermission(player) != null)
  1245. {
  1246. sendMessage(player, TextMode.Err, Messages.NoPermissionTrust, new String[] { claim.getOwnerName() });
  1247. return true;
  1248. }
  1249. if (clearPermissions)
  1250. {
  1251. if (claim.allowEdit(player) != null)
  1252. {
  1253. sendMessage(player, TextMode.Err, Messages.UntrustAllOwnerOnly, new String[0]);
  1254. return true;
  1255. }
  1256. claim.clearPermissions();
  1257. sendMessage(player, TextMode.Success, Messages.ClearPermissionsOneClaim, new String[0]);
  1258. }
  1259. else
  1260. {
  1261. String idToDrop = args[0];
  1262. if (otherPlayer != null) {
  1263. idToDrop = otherPlayer.getUniqueId().toString();
  1264. }
  1265. boolean targetIsManager = claim.managers.contains(idToDrop);
  1266. if ((targetIsManager) && (claim.allowEdit(player) != null))
  1267. {
  1268. sendMessage(player, TextMode.Err, Messages.ManagersDontUntrustManagers, new String[] { claim.getOwnerName() });
  1269. return true;
  1270. }
  1271. claim.dropPermission(idToDrop);
  1272. claim.managers.remove(idToDrop);
  1273. if (args[0].equals("public")) {
  1274. args[0] = "the public";
  1275. }
  1276. sendMessage(player, TextMode.Success, Messages.UntrustIndividualSingleClaim, new String[] { args[0] });
  1277. }
  1278. this.dataStore.saveClaim(claim);
  1279. }
  1280. return true;
  1281. }
  1282. if ((cmd.getName().equalsIgnoreCase("accesstrust")) && (player != null))
  1283. {
  1284. if (args.length != 1) {
  1285. return false;
  1286. }
  1287. handleTrustCommand(player, ClaimPermission.Access, args[0]);
  1288.  
  1289. return true;
  1290. }
  1291. if ((cmd.getName().equalsIgnoreCase("containertrust")) && (player != null))
  1292. {
  1293. if (args.length != 1) {
  1294. return false;
  1295. }
  1296. handleTrustCommand(player, ClaimPermission.Inventory, args[0]);
  1297.  
  1298. return true;
  1299. }
  1300. if ((cmd.getName().equalsIgnoreCase("permissiontrust")) && (player != null))
  1301. {
  1302. if (args.length != 1) {
  1303. return false;
  1304. }
  1305. handleTrustCommand(player, null, args[0]);
  1306.  
  1307. return true;
  1308. }
  1309. if ((cmd.getName().equalsIgnoreCase("buyclaimblocks")) && (player != null))
  1310. {
  1311. if (economy == null)
  1312. {
  1313. sendMessage(player, TextMode.Err, Messages.BuySellNotConfigured, new String[0]);
  1314. return true;
  1315. }
  1316. if (!player.hasPermission("griefprevention.buysellclaimblocks"))
  1317. {
  1318. sendMessage(player, TextMode.Err, Messages.NoPermissionForCommand, new String[0]);
  1319. return true;
  1320. }
  1321. if (instance.config_economy_claimBlocksPurchaseCost == 0.0D)
  1322. {
  1323. sendMessage(player, TextMode.Err, Messages.OnlySellBlocks, new String[0]);
  1324. return true;
  1325. }
  1326. if (args.length != 1)
  1327. {
  1328. sendMessage(player, TextMode.Info, Messages.BlockPurchaseCost, new String[] { String.valueOf(instance.config_economy_claimBlocksPurchaseCost), String.valueOf(economy.getBalance(player.getName())) });
  1329. return false;
  1330. }
  1331. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1332. try
  1333. {
  1334. blockCount = Integer.parseInt(args[0]);
  1335. }
  1336. catch (NumberFormatException numberFormatException)
  1337. {
  1338. int blockCount;
  1339. return false;
  1340. }
  1341. int blockCount;
  1342. if (blockCount <= 0) {
  1343. return false;
  1344. }
  1345. double balance = economy.getBalance(player.getName());
  1346. double totalCost = blockCount * instance.config_economy_claimBlocksPurchaseCost;
  1347. if (totalCost > balance)
  1348. {
  1349. sendMessage(player, TextMode.Err, Messages.InsufficientFunds, new String[] { String.valueOf(totalCost), String.valueOf(balance) });
  1350. }
  1351. else
  1352. {
  1353. economy.withdrawPlayer(player.getName(), totalCost);
  1354.  
  1355. playerData.setBonusClaimBlocks(Integer.valueOf(playerData.getBonusClaimBlocks() + blockCount));
  1356. this.dataStore.savePlayerData(player.getUniqueId(), playerData);
  1357.  
  1358. sendMessage(player, TextMode.Success, Messages.PurchaseConfirmation, new String[] { String.valueOf(totalCost), String.valueOf(playerData.getRemainingClaimBlocks()) });
  1359. }
  1360. return true;
  1361. }
  1362. if ((cmd.getName().equalsIgnoreCase("sellclaimblocks")) && (player != null))
  1363. {
  1364. if (economy == null)
  1365. {
  1366. sendMessage(player, TextMode.Err, Messages.BuySellNotConfigured, new String[0]);
  1367. return true;
  1368. }
  1369. if (!player.hasPermission("griefprevention.buysellclaimblocks"))
  1370. {
  1371. sendMessage(player, TextMode.Err, Messages.NoPermissionForCommand, new String[0]);
  1372. return true;
  1373. }
  1374. if (instance.config_economy_claimBlocksSellValue == 0.0D)
  1375. {
  1376. sendMessage(player, TextMode.Err, Messages.OnlyPurchaseBlocks, new String[0]);
  1377. return true;
  1378. }
  1379. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1380. int availableBlocks = playerData.getRemainingClaimBlocks();
  1381. if (args.length != 1)
  1382. {
  1383. sendMessage(player, TextMode.Info, Messages.BlockSaleValue, new String[] { String.valueOf(instance.config_economy_claimBlocksSellValue), String.valueOf(availableBlocks) });
  1384. return false;
  1385. }
  1386. try
  1387. {
  1388. blockCount = Integer.parseInt(args[0]);
  1389. }
  1390. catch (NumberFormatException numberFormatException)
  1391. {
  1392. int blockCount;
  1393. return false;
  1394. }
  1395. int blockCount;
  1396. if (blockCount <= 0) {
  1397. return false;
  1398. }
  1399. if (blockCount > availableBlocks)
  1400. {
  1401. sendMessage(player, TextMode.Err, Messages.NotEnoughBlocksForSale, new String[0]);
  1402. }
  1403. else
  1404. {
  1405. double totalValue = blockCount * instance.config_economy_claimBlocksSellValue;
  1406. economy.depositPlayer(player.getName(), totalValue);
  1407.  
  1408. playerData.setBonusClaimBlocks(Integer.valueOf(playerData.getBonusClaimBlocks() - blockCount));
  1409. this.dataStore.savePlayerData(player.getUniqueId(), playerData);
  1410.  
  1411. sendMessage(player, TextMode.Success, Messages.BlockSaleConfirmation, new String[] { String.valueOf(totalValue), String.valueOf(playerData.getRemainingClaimBlocks()) });
  1412. }
  1413. return true;
  1414. }
  1415. if ((cmd.getName().equalsIgnoreCase("adminclaims")) && (player != null))
  1416. {
  1417. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1418. playerData.shovelMode = ShovelMode.Admin;
  1419. sendMessage(player, TextMode.Success, Messages.AdminClaimsMode, new String[0]);
  1420.  
  1421. return true;
  1422. }
  1423. if ((cmd.getName().equalsIgnoreCase("basicclaims")) && (player != null))
  1424. {
  1425. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1426. playerData.shovelMode = ShovelMode.Basic;
  1427. playerData.claimSubdividing = null;
  1428. sendMessage(player, TextMode.Success, Messages.BasicClaimsMode, new String[0]);
  1429.  
  1430. return true;
  1431. }
  1432. if ((cmd.getName().equalsIgnoreCase("subdivideclaims")) && (player != null))
  1433. {
  1434. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1435. playerData.shovelMode = ShovelMode.Subdivide;
  1436. playerData.claimSubdividing = null;
  1437. sendMessage(player, TextMode.Instr, Messages.SubdivisionMode, new String[0]);
  1438. sendMessage(player, TextMode.Instr, Messages.SubdivisionVideo2, new String[] { DataStore.SUBDIVISION_VIDEO_URL });
  1439.  
  1440. return true;
  1441. }
  1442. if ((cmd.getName().equalsIgnoreCase("deleteclaim")) && (player != null))
  1443. {
  1444. Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, null);
  1445. if (claim == null)
  1446. {
  1447. sendMessage(player, TextMode.Err, Messages.DeleteClaimMissing, new String[0]);
  1448. }
  1449. else if ((!claim.isAdminClaim()) || (player.hasPermission("griefprevention.adminclaims")))
  1450. {
  1451. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1452. if ((claim.children.size() > 0) && (!playerData.warnedAboutMajorDeletion))
  1453. {
  1454. sendMessage(player, TextMode.Warn, Messages.DeletionSubdivisionWarning, new String[0]);
  1455. playerData.warnedAboutMajorDeletion = true;
  1456. }
  1457. else
  1458. {
  1459. claim.removeSurfaceFluids(null);
  1460. this.dataStore.deleteClaim(claim, true, true);
  1461. if ((instance.creativeRulesApply(claim.getLesserBoundaryCorner())) || (instance.config_claims_survivalAutoNatureRestoration)) {
  1462. instance.restoreClaim(claim, 0L);
  1463. }
  1464. sendMessage(player, TextMode.Success, Messages.DeleteSuccess, new String[0]);
  1465. AddLogEntry(player.getName() + " deleted " + claim.getOwnerName() + "'s claim at " + getfriendlyLocationString(claim.getLesserBoundaryCorner()), CustomLogEntryTypes.AdminActivity);
  1466.  
  1467. Visualization.Revert(player);
  1468.  
  1469. playerData.warnedAboutMajorDeletion = false;
  1470. }
  1471. }
  1472. else
  1473. {
  1474. sendMessage(player, TextMode.Err, Messages.CantDeleteAdminClaim, new String[0]);
  1475. }
  1476. return true;
  1477. }
  1478. if ((cmd.getName().equalsIgnoreCase("claimexplosions")) && (player != null))
  1479. {
  1480. Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, null);
  1481. if (claim == null)
  1482. {
  1483. sendMessage(player, TextMode.Err, Messages.DeleteClaimMissing, new String[0]);
  1484. }
  1485. else
  1486. {
  1487. String noBuildReason = claim.allowBuild(player, Material.STONE);
  1488. if (noBuildReason != null)
  1489. {
  1490. sendMessage(player, TextMode.Err, noBuildReason);
  1491. return true;
  1492. }
  1493. if (claim.areExplosivesAllowed)
  1494. {
  1495. claim.areExplosivesAllowed = false;
  1496. sendMessage(player, TextMode.Success, Messages.ExplosivesDisabled, new String[0]);
  1497. }
  1498. else
  1499. {
  1500. claim.areExplosivesAllowed = true;
  1501. sendMessage(player, TextMode.Success, Messages.ExplosivesEnabled, new String[0]);
  1502. }
  1503. }
  1504. return true;
  1505. }
  1506. if (cmd.getName().equalsIgnoreCase("deleteallclaims"))
  1507. {
  1508. if (args.length != 1) {
  1509. return false;
  1510. }
  1511. OfflinePlayer otherPlayer = resolvePlayerByName(args[0]);
  1512. if (otherPlayer == null)
  1513. {
  1514. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1515. return true;
  1516. }
  1517. this.dataStore.deleteClaimsForPlayer(otherPlayer.getUniqueId(), true);
  1518.  
  1519. sendMessage(player, TextMode.Success, Messages.DeleteAllSuccess, new String[] { otherPlayer.getName() });
  1520. if (player != null)
  1521. {
  1522. AddLogEntry(player.getName() + " deleted all claims belonging to " + otherPlayer.getName() + ".", CustomLogEntryTypes.AdminActivity);
  1523.  
  1524. Visualization.Revert(player);
  1525. }
  1526. return true;
  1527. }
  1528. if (cmd.getName().equalsIgnoreCase("deleteclaimsinworld"))
  1529. {
  1530. if (player != null)
  1531. {
  1532. sendMessage(player, TextMode.Err, Messages.ConsoleOnlyCommand, new String[0]);
  1533. return true;
  1534. }
  1535. if (args.length != 1) {
  1536. return false;
  1537. }
  1538. World world = Bukkit.getServer().getWorld(args[0]);
  1539. if (world == null)
  1540. {
  1541. sendMessage(player, TextMode.Err, Messages.WorldNotFound, new String[0]);
  1542. return true;
  1543. }
  1544. this.dataStore.deleteClaimsInWorld(world, true);
  1545. AddLogEntry("Deleted all claims in world: " + world.getName() + ".", CustomLogEntryTypes.AdminActivity);
  1546. return true;
  1547. }
  1548. if (cmd.getName().equalsIgnoreCase("deleteclaimsinworld"))
  1549. {
  1550. if (player != null)
  1551. {
  1552. sendMessage(player, TextMode.Err, Messages.ConsoleOnlyCommand, new String[0]);
  1553. return true;
  1554. }
  1555. if (args.length != 1) {
  1556. return false;
  1557. }
  1558. World world = Bukkit.getServer().getWorld(args[0]);
  1559. if (world == null)
  1560. {
  1561. sendMessage(player, TextMode.Err, Messages.WorldNotFound, new String[0]);
  1562. return true;
  1563. }
  1564. this.dataStore.deleteClaimsInWorld(world, false);
  1565. AddLogEntry("Deleted all user claims in world: " + world.getName() + ".", CustomLogEntryTypes.AdminActivity);
  1566. return true;
  1567. }
  1568. if (cmd.getName().equalsIgnoreCase("claimbook"))
  1569. {
  1570. if (args.length != 1) {
  1571. return false;
  1572. }
  1573. Player otherPlayer = getServer().getPlayer(args[0]);
  1574. if (otherPlayer == null)
  1575. {
  1576. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1577. return true;
  1578. }
  1579. WelcomeTask task = new WelcomeTask(otherPlayer);
  1580. task.run();
  1581. return true;
  1582. }
  1583. PlayerData playerData;
  1584. int i;
  1585. if (cmd.getName().equalsIgnoreCase("claimslist"))
  1586. {
  1587. if (args.length > 1) {
  1588. return false;
  1589. }
  1590. OfflinePlayer otherPlayer;
  1591. if (args.length < 1)
  1592. {
  1593. OfflinePlayer otherPlayer;
  1594. if (player != null) {
  1595. otherPlayer = player;
  1596. } else {
  1597. return false;
  1598. }
  1599. }
  1600. else
  1601. {
  1602. if ((player != null) && (!player.hasPermission("griefprevention.claimslistother")))
  1603. {
  1604. sendMessage(player, TextMode.Err, Messages.ClaimsListNoPermission, new String[0]);
  1605. return true;
  1606. }
  1607. otherPlayer = resolvePlayerByName(args[0]);
  1608. if (otherPlayer == null)
  1609. {
  1610. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1611. return true;
  1612. }
  1613. }
  1614. playerData = this.dataStore.getPlayerData(otherPlayer.getUniqueId());
  1615. java.util.Vector<Claim> claims = playerData.getClaims();
  1616. sendMessage(player, TextMode.Instr, Messages.StartBlockMath, new String[] {
  1617. String.valueOf(playerData.getAccruedClaimBlocks()),
  1618. String.valueOf(playerData.getBonusClaimBlocks() + this.dataStore.getGroupBonusBlocks(otherPlayer.getUniqueId())),
  1619. String.valueOf(playerData.getAccruedClaimBlocks() + playerData.getBonusClaimBlocks() + this.dataStore.getGroupBonusBlocks(otherPlayer.getUniqueId())) });
  1620. if (claims.size() > 0)
  1621. {
  1622. sendMessage(player, TextMode.Instr, Messages.ClaimsListHeader, new String[0]);
  1623. for (i = 0; i < playerData.getClaims().size(); i++)
  1624. {
  1625. Claim claim = (Claim)playerData.getClaims().get(i);
  1626. sendMessage(player, TextMode.Instr, getfriendlyLocationString(claim.getLesserBoundaryCorner()) + this.dataStore.getMessage(Messages.ContinueBlockMath, new String[] { String.valueOf(claim.getArea()) }));
  1627. }
  1628. sendMessage(player, TextMode.Instr, Messages.EndBlockMath, new String[] { String.valueOf(playerData.getRemainingClaimBlocks()) });
  1629. }
  1630. if (!otherPlayer.isOnline()) {
  1631. this.dataStore.clearCachedPlayerData(otherPlayer.getUniqueId());
  1632. }
  1633. return true;
  1634. }
  1635. if (cmd.getName().equalsIgnoreCase("adminclaimslist"))
  1636. {
  1637. java.util.Vector<Claim> claims = new java.util.Vector();
  1638. for (Claim claim : this.dataStore.claims) {
  1639. if (claim.ownerID == null) {
  1640. claims.add(claim);
  1641. }
  1642. }
  1643. if (claims.size() > 0)
  1644. {
  1645. sendMessage(player, TextMode.Instr, Messages.ClaimsListHeader, new String[0]);
  1646. for (int i = 0; i < claims.size(); i++)
  1647. {
  1648. Claim claim = (Claim)claims.get(i);
  1649. sendMessage(player, TextMode.Instr, getfriendlyLocationString(claim.getLesserBoundaryCorner()));
  1650. }
  1651. }
  1652. return true;
  1653. }
  1654. if ((cmd.getName().equalsIgnoreCase("unlockdrops")) && (player != null))
  1655. {
  1656. PlayerData playerData;
  1657. if ((player.hasPermission("griefprevention.unlockothersdrops")) && (args.length == 1))
  1658. {
  1659. Player otherPlayer = Bukkit.getPlayer(args[0]);
  1660. if (otherPlayer == null)
  1661. {
  1662. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1663. return true;
  1664. }
  1665. PlayerData playerData = this.dataStore.getPlayerData(otherPlayer.getUniqueId());
  1666. sendMessage(player, TextMode.Success, Messages.DropUnlockOthersConfirmation, new String[] { otherPlayer.getName() });
  1667. }
  1668. else
  1669. {
  1670. playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1671. sendMessage(player, TextMode.Success, Messages.DropUnlockConfirmation, new String[0]);
  1672. }
  1673. playerData.dropsAreUnlocked = true;
  1674.  
  1675. return true;
  1676. }
  1677. if ((player != null) && (cmd.getName().equalsIgnoreCase("deletealladminclaims")))
  1678. {
  1679. if (!player.hasPermission("griefprevention.deleteclaims"))
  1680. {
  1681. sendMessage(player, TextMode.Err, Messages.NoDeletePermission, new String[0]);
  1682. return true;
  1683. }
  1684. this.dataStore.deleteClaimsForPlayer(null, true);
  1685.  
  1686. sendMessage(player, TextMode.Success, Messages.AllAdminDeleted, new String[0]);
  1687. if (player != null)
  1688. {
  1689. AddLogEntry(player.getName() + " deleted all administrative claims.", CustomLogEntryTypes.AdminActivity);
  1690.  
  1691. Visualization.Revert(player);
  1692. }
  1693. return true;
  1694. }
  1695. if (cmd.getName().equalsIgnoreCase("adjustbonusclaimblocks"))
  1696. {
  1697. if (args.length != 2) {
  1698. return false;
  1699. }
  1700. try
  1701. {
  1702. adjustment = Integer.parseInt(args[1]);
  1703. }
  1704. catch (NumberFormatException numberFormatException)
  1705. {
  1706. int adjustment;
  1707. return false;
  1708. }
  1709. int adjustment;
  1710. if ((args[0].startsWith("[")) && (args[0].endsWith("]")))
  1711. {
  1712. String permissionIdentifier = args[0].substring(1, args[0].length() - 1);
  1713. int newTotal = this.dataStore.adjustGroupBonusBlocks(permissionIdentifier, adjustment);
  1714.  
  1715. sendMessage(player, TextMode.Success, Messages.AdjustGroupBlocksSuccess, new String[] { permissionIdentifier, String.valueOf(adjustment), String.valueOf(newTotal) });
  1716. if (player != null) {
  1717. AddLogEntry(player.getName() + " adjusted " + permissionIdentifier + "'s bonus claim blocks by " + adjustment + ".");
  1718. }
  1719. return true;
  1720. }
  1721. OfflinePlayer targetPlayer;
  1722. try
  1723. {
  1724. UUID playerID = UUID.fromString(args[0]);
  1725. targetPlayer = getServer().getOfflinePlayer(playerID);
  1726. }
  1727. catch (IllegalArgumentException e)
  1728. {
  1729. OfflinePlayer targetPlayer;
  1730. targetPlayer = resolvePlayerByName(args[0]);
  1731. }
  1732. if (targetPlayer == null)
  1733. {
  1734. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1735. return true;
  1736. }
  1737. PlayerData playerData = this.dataStore.getPlayerData(targetPlayer.getUniqueId());
  1738. playerData.setBonusClaimBlocks(Integer.valueOf(playerData.getBonusClaimBlocks() + adjustment));
  1739. this.dataStore.savePlayerData(targetPlayer.getUniqueId(), playerData);
  1740.  
  1741. sendMessage(player, TextMode.Success, Messages.AdjustBlocksSuccess, new String[] { targetPlayer.getName(), String.valueOf(adjustment), String.valueOf(playerData.getBonusClaimBlocks()) });
  1742. if (player != null) {
  1743. AddLogEntry(player.getName() + " adjusted " + targetPlayer.getName() + "'s bonus claim blocks by " + adjustment + ".", CustomLogEntryTypes.AdminActivity);
  1744. }
  1745. return true;
  1746. }
  1747. if (cmd.getName().equalsIgnoreCase("adjustbonusclaimblocksall"))
  1748. {
  1749. if (args.length != 1) {
  1750. return false;
  1751. }
  1752. try
  1753. {
  1754. adjustment = Integer.parseInt(args[0]);
  1755. }
  1756. catch (NumberFormatException numberFormatException)
  1757. {
  1758. int adjustment;
  1759. return false;
  1760. }
  1761. int adjustment;
  1762. Collection<Player> players = getServer().getOnlinePlayers();
  1763. StringBuilder builder = new StringBuilder();
  1764. for (Player onlinePlayer : players)
  1765. {
  1766. UUID playerID = onlinePlayer.getUniqueId();
  1767. PlayerData playerData = this.dataStore.getPlayerData(playerID);
  1768. playerData.setBonusClaimBlocks(Integer.valueOf(playerData.getBonusClaimBlocks() + adjustment));
  1769. this.dataStore.savePlayerData(playerID, playerData);
  1770. builder.append(onlinePlayer.getName() + " ");
  1771. }
  1772. sendMessage(player, TextMode.Success, Messages.AdjustBlocksAllSuccess, new String[] { String.valueOf(adjustment) });
  1773. AddLogEntry("Adjusted all " + players.size() + "players' bonus claim blocks by " + adjustment + ". " + builder.toString(), CustomLogEntryTypes.AdminActivity);
  1774.  
  1775. return true;
  1776. }
  1777. if (cmd.getName().equalsIgnoreCase("setaccruedclaimblocks"))
  1778. {
  1779. if (args.length != 2) {
  1780. return false;
  1781. }
  1782. try
  1783. {
  1784. newAmount = Integer.parseInt(args[1]);
  1785. }
  1786. catch (NumberFormatException numberFormatException)
  1787. {
  1788. int newAmount;
  1789. return false;
  1790. }
  1791. int newAmount;
  1792. OfflinePlayer targetPlayer = resolvePlayerByName(args[0]);
  1793. if (targetPlayer == null)
  1794. {
  1795. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1796. return true;
  1797. }
  1798. PlayerData playerData = this.dataStore.getPlayerData(targetPlayer.getUniqueId());
  1799. playerData.setAccruedClaimBlocks(Integer.valueOf(newAmount));
  1800. this.dataStore.savePlayerData(targetPlayer.getUniqueId(), playerData);
  1801.  
  1802. sendMessage(player, TextMode.Success, Messages.SetClaimBlocksSuccess, new String[0]);
  1803. if (player != null) {
  1804. AddLogEntry(player.getName() + " set " + targetPlayer.getName() + "'s accrued claim blocks to " + newAmount + ".", CustomLogEntryTypes.AdminActivity);
  1805. }
  1806. return true;
  1807. }
  1808. if ((cmd.getName().equalsIgnoreCase("trapped")) && (player != null))
  1809. {
  1810. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1811. Claim claim = this.dataStore.getClaimAt(player.getLocation(), false, playerData.lastClaim);
  1812. if (playerData.pendingTrapped) {
  1813. return true;
  1814. }
  1815. if ((claim == null) || (claim.allowBuild(player, Material.AIR) == null))
  1816. {
  1817. sendMessage(player, TextMode.Err, Messages.NotTrappedHere, new String[0]);
  1818. return true;
  1819. }
  1820. SaveTrappedPlayerEvent event = new SaveTrappedPlayerEvent(claim);
  1821. Bukkit.getPluginManager().callEvent(event);
  1822. if ((player.getWorld().getEnvironment() != World.Environment.NORMAL) && (event.getDestination() == null))
  1823. {
  1824. sendMessage(player, TextMode.Err, Messages.TrappedWontWorkHere, new String[0]);
  1825. return true;
  1826. }
  1827. if ((!instance.config_claims_allowTrappedInAdminClaims) && (claim.isAdminClaim()) && (event.getDestination() == null))
  1828. {
  1829. sendMessage(player, TextMode.Err, Messages.TrappedWontWorkHere, new String[0]);
  1830. return true;
  1831. }
  1832. sendMessage(player, TextMode.Instr, Messages.RescuePending, new String[0]);
  1833.  
  1834. PlayerRescueTask task = new PlayerRescueTask(player, player.getLocation(), event.getDestination());
  1835. getServer().getScheduler().scheduleSyncDelayedTask(this, task, 200L);
  1836.  
  1837. return true;
  1838. }
  1839. if ((cmd.getName().equalsIgnoreCase("siege")) && (player != null))
  1840. {
  1841. if (!siegeEnabledForWorld(player.getWorld()))
  1842. {
  1843. sendMessage(player, TextMode.Err, Messages.NonSiegeWorld, new String[0]);
  1844. return true;
  1845. }
  1846. if (args.length > 1) {
  1847. return false;
  1848. }
  1849. Player attacker = player;
  1850. PlayerData attackerData = this.dataStore.getPlayerData(attacker.getUniqueId());
  1851. if (attackerData.siegeData != null)
  1852. {
  1853. sendMessage(player, TextMode.Err, Messages.AlreadySieging, new String[0]);
  1854. return true;
  1855. }
  1856. if (attackerData.pvpImmune)
  1857. {
  1858. sendMessage(player, TextMode.Err, Messages.CantFightWhileImmune, new String[0]);
  1859. return true;
  1860. }
  1861. Player defender = null;
  1862. if (args.length >= 1)
  1863. {
  1864. defender = getServer().getPlayer(args[0]);
  1865. if (defender == null)
  1866. {
  1867. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1868. return true;
  1869. }
  1870. }
  1871. else if (attackerData.lastPvpPlayer.length() > 0)
  1872. {
  1873. defender = getServer().getPlayer(attackerData.lastPvpPlayer);
  1874. if (defender == null) {
  1875. return false;
  1876. }
  1877. }
  1878. else
  1879. {
  1880. return false;
  1881. }
  1882. if (attacker.getName().equals(defender.getName()))
  1883. {
  1884. sendMessage(player, TextMode.Err, Messages.NoSiegeYourself, new String[0]);
  1885. return true;
  1886. }
  1887. if (defender.hasPermission("griefprevention.siegeimmune"))
  1888. {
  1889. sendMessage(player, TextMode.Err, Messages.SiegeImmune, new String[0]);
  1890. return true;
  1891. }
  1892. PlayerData defenderData = this.dataStore.getPlayerData(defender.getUniqueId());
  1893. if (defenderData.siegeData != null)
  1894. {
  1895. sendMessage(player, TextMode.Err, Messages.AlreadyUnderSiegePlayer, new String[0]);
  1896. return true;
  1897. }
  1898. if (defenderData.pvpImmune)
  1899. {
  1900. sendMessage(player, TextMode.Err, Messages.NoSiegeDefenseless, new String[0]);
  1901. return true;
  1902. }
  1903. Claim defenderClaim = this.dataStore.getClaimAt(defender.getLocation(), false, null);
  1904. if ((defenderClaim == null) || (defenderClaim.allowAccess(defender) != null))
  1905. {
  1906. sendMessage(player, TextMode.Err, Messages.NotSiegableThere, new String[0]);
  1907. return true;
  1908. }
  1909. if (!defenderClaim.isNear(attacker.getLocation(), 25))
  1910. {
  1911. sendMessage(player, TextMode.Err, Messages.SiegeTooFarAway, new String[0]);
  1912. return true;
  1913. }
  1914. if (defenderClaim.siegeData != null)
  1915. {
  1916. sendMessage(player, TextMode.Err, Messages.AlreadyUnderSiegeArea, new String[0]);
  1917. return true;
  1918. }
  1919. if (defenderClaim.isAdminClaim())
  1920. {
  1921. sendMessage(player, TextMode.Err, Messages.NoSiegeAdminClaim, new String[0]);
  1922. return true;
  1923. }
  1924. if (this.dataStore.onCooldown(attacker, defender, defenderClaim))
  1925. {
  1926. sendMessage(player, TextMode.Err, Messages.SiegeOnCooldown, new String[0]);
  1927. return true;
  1928. }
  1929. this.dataStore.startSiege(attacker, defender, defenderClaim);
  1930.  
  1931. sendMessage(defender, TextMode.Warn, Messages.SiegeAlert, new String[] { attacker.getName() });
  1932. sendMessage(player, TextMode.Success, Messages.SiegeConfirmed, new String[] { defender.getName() });
  1933.  
  1934. return true;
  1935. }
  1936. if (cmd.getName().equalsIgnoreCase("softmute"))
  1937. {
  1938. if (args.length != 1) {
  1939. return false;
  1940. }
  1941. OfflinePlayer targetPlayer = resolvePlayerByName(args[0]);
  1942. if (targetPlayer == null)
  1943. {
  1944. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1945. return true;
  1946. }
  1947. boolean isMuted = this.dataStore.toggleSoftMute(targetPlayer.getUniqueId());
  1948. if (isMuted)
  1949. {
  1950. sendMessage(player, TextMode.Success, Messages.SoftMuted, new String[] { targetPlayer.getName() });
  1951. String executorName = "console";
  1952. if (player != null) {
  1953. executorName = player.getName();
  1954. }
  1955. AddLogEntry(executorName + " muted " + targetPlayer.getName() + ".", CustomLogEntryTypes.AdminActivity, true);
  1956. }
  1957. else
  1958. {
  1959. sendMessage(player, TextMode.Success, Messages.UnSoftMuted, new String[] { targetPlayer.getName() });
  1960. }
  1961. return true;
  1962. }
  1963. if (cmd.getName().equalsIgnoreCase("gpreload"))
  1964. {
  1965. loadConfig();
  1966. if (player != null) {
  1967. sendMessage(player, TextMode.Success, "Configuration updated. If you have updated your Grief Prevention JAR, you still need to /reload or reboot your server.");
  1968. } else {
  1969. AddLogEntry("Configuration updated. If you have updated your Grief Prevention JAR, you still need to /reload or reboot your server.");
  1970. }
  1971. return true;
  1972. }
  1973. if ((cmd.getName().equalsIgnoreCase("givepet")) && (player != null))
  1974. {
  1975. if (args.length < 1) {
  1976. return false;
  1977. }
  1978. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  1979. if (args[0].equalsIgnoreCase("cancel"))
  1980. {
  1981. playerData.petGiveawayRecipient = null;
  1982. sendMessage(player, TextMode.Success, Messages.PetTransferCancellation, new String[0]);
  1983. return true;
  1984. }
  1985. OfflinePlayer targetPlayer = resolvePlayerByName(args[0]);
  1986. if (targetPlayer == null)
  1987. {
  1988. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  1989. return true;
  1990. }
  1991. playerData.petGiveawayRecipient = targetPlayer;
  1992.  
  1993. sendMessage(player, TextMode.Instr, Messages.ReadyToTransferPet, new String[0]);
  1994.  
  1995. return true;
  1996. }
  1997. if ((cmd.getName().equalsIgnoreCase("gpblockinfo")) && (player != null))
  1998. {
  1999. ItemStack inHand = player.getItemInHand();
  2000. player.sendMessage("In Hand: " + String.format("%s(%d:%d)", new Object[] { inHand.getType().name(), Integer.valueOf(inHand.getTypeId()), Byte.valueOf(inHand.getData().getData()) }));
  2001.  
  2002. Block inWorld = getTargetNonAirBlock(player, 300);
  2003. player.sendMessage("In World: " + String.format("%s(%d:%d)", new Object[] { inWorld.getType().name(), Integer.valueOf(inWorld.getTypeId()), Byte.valueOf(inWorld.getData()) }));
  2004.  
  2005. return true;
  2006. }
  2007. if ((cmd.getName().equalsIgnoreCase("ignoreplayer")) && (player != null))
  2008. {
  2009. if (args.length < 1) {
  2010. return false;
  2011. }
  2012. OfflinePlayer targetPlayer = resolvePlayerByName(args[0]);
  2013. if (targetPlayer == null)
  2014. {
  2015. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  2016. return true;
  2017. }
  2018. setIgnoreStatus(player, targetPlayer, IgnoreMode.StandardIgnore);
  2019.  
  2020. sendMessage(player, TextMode.Success, Messages.IgnoreConfirmation, new String[0]);
  2021.  
  2022. return true;
  2023. }
  2024. Boolean ignoreStatus;
  2025. if ((cmd.getName().equalsIgnoreCase("unignoreplayer")) && (player != null))
  2026. {
  2027. if (args.length < 1) {
  2028. return false;
  2029. }
  2030. OfflinePlayer targetPlayer = resolvePlayerByName(args[0]);
  2031. if (targetPlayer == null)
  2032. {
  2033. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  2034. return true;
  2035. }
  2036. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  2037. ignoreStatus = (Boolean)playerData.ignoredPlayers.get(targetPlayer.getUniqueId());
  2038. if ((ignoreStatus == null) || (ignoreStatus.booleanValue() == true))
  2039. {
  2040. sendMessage(player, TextMode.Err, Messages.NotIgnoringPlayer, new String[0]);
  2041. return true;
  2042. }
  2043. setIgnoreStatus(player, targetPlayer, IgnoreMode.None);
  2044.  
  2045. sendMessage(player, TextMode.Success, Messages.UnIgnoreConfirmation, new String[0]);
  2046.  
  2047. return true;
  2048. }
  2049. if ((cmd.getName().equalsIgnoreCase("ignoredplayerlist")) && (player != null))
  2050. {
  2051. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  2052. StringBuilder builder = new StringBuilder();
  2053. for (Map.Entry<UUID, Boolean> entry : playerData.ignoredPlayers.entrySet()) {
  2054. if (entry.getValue() != null) {
  2055. if (!((Boolean)entry.getValue()).booleanValue())
  2056. {
  2057. builder.append(lookupPlayerName((UUID)entry.getKey()));
  2058. builder.append(" ");
  2059. }
  2060. }
  2061. }
  2062. String list = builder.toString().trim();
  2063. if (list.isEmpty()) {
  2064. sendMessage(player, TextMode.Info, Messages.NotIgnoringAnyone, new String[0]);
  2065. } else {
  2066. sendMessage(player, TextMode.Info, list);
  2067. }
  2068. return true;
  2069. }
  2070. if (cmd.getName().equalsIgnoreCase("separate"))
  2071. {
  2072. if (args.length < 2) {
  2073. return false;
  2074. }
  2075. OfflinePlayer targetPlayer = resolvePlayerByName(args[0]);
  2076. if (targetPlayer == null)
  2077. {
  2078. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  2079. return true;
  2080. }
  2081. OfflinePlayer targetPlayer2 = resolvePlayerByName(args[1]);
  2082. if (targetPlayer2 == null)
  2083. {
  2084. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  2085. return true;
  2086. }
  2087. setIgnoreStatus(targetPlayer, targetPlayer2, IgnoreMode.AdminIgnore);
  2088.  
  2089. sendMessage(player, TextMode.Success, Messages.SeparateConfirmation, new String[0]);
  2090.  
  2091. return true;
  2092. }
  2093. if (cmd.getName().equalsIgnoreCase("unseparate"))
  2094. {
  2095. if (args.length < 2) {
  2096. return false;
  2097. }
  2098. OfflinePlayer targetPlayer = resolvePlayerByName(args[0]);
  2099. if (targetPlayer == null)
  2100. {
  2101. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  2102. return true;
  2103. }
  2104. OfflinePlayer targetPlayer2 = resolvePlayerByName(args[1]);
  2105. if (targetPlayer2 == null)
  2106. {
  2107. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  2108. return true;
  2109. }
  2110. setIgnoreStatus(targetPlayer, targetPlayer2, IgnoreMode.None);
  2111. setIgnoreStatus(targetPlayer2, targetPlayer, IgnoreMode.None);
  2112.  
  2113. sendMessage(player, TextMode.Success, Messages.UnSeparateConfirmation, new String[0]);
  2114.  
  2115. return true;
  2116. }
  2117. return false;
  2118. }
  2119.  
  2120. void setIgnoreStatus(OfflinePlayer ignorer, OfflinePlayer ignoree, IgnoreMode mode)
  2121. {
  2122. PlayerData playerData = this.dataStore.getPlayerData(ignorer.getUniqueId());
  2123. if (mode == IgnoreMode.None) {
  2124. playerData.ignoredPlayers.remove(ignoree.getUniqueId());
  2125. } else {
  2126. playerData.ignoredPlayers.put(ignoree.getUniqueId(), Boolean.valueOf(mode != IgnoreMode.StandardIgnore));
  2127. }
  2128. playerData.ignoreListChanged = true;
  2129. if (!ignorer.isOnline())
  2130. {
  2131. this.dataStore.savePlayerData(ignorer.getUniqueId(), playerData);
  2132. this.dataStore.clearCachedPlayerData(ignorer.getUniqueId());
  2133. }
  2134. }
  2135.  
  2136. public static enum IgnoreMode
  2137. {
  2138. None, StandardIgnore, AdminIgnore;
  2139.  
  2140. private IgnoreMode() {}
  2141. }
  2142.  
  2143. private String trustEntryToPlayerName(String entry)
  2144. {
  2145. if ((entry.startsWith("[")) || (entry.equals("public"))) {
  2146. return entry;
  2147. }
  2148. return lookupPlayerName(entry);
  2149. }
  2150.  
  2151. public static String getfriendlyLocationString(Location location)
  2152. {
  2153. return location.getWorld().getName() + ": x" + location.getBlockX() + ", z" + location.getBlockZ();
  2154. }
  2155.  
  2156. private boolean abandonClaimHandler(Player player, boolean deleteTopLevelClaim)
  2157. {
  2158. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  2159.  
  2160. Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, null);
  2161. if (claim == null)
  2162. {
  2163. sendMessage(player, TextMode.Instr, Messages.AbandonClaimMissing, new String[0]);
  2164. }
  2165. else if (claim.allowEdit(player) != null)
  2166. {
  2167. sendMessage(player, TextMode.Err, Messages.NotYourClaim, new String[0]);
  2168. }
  2169. else
  2170. {
  2171. if ((claim.children.size() > 0) && (!deleteTopLevelClaim))
  2172. {
  2173. sendMessage(player, TextMode.Instr, Messages.DeleteTopLevelClaim, new String[0]);
  2174. return true;
  2175. }
  2176. claim.removeSurfaceFluids(null);
  2177. this.dataStore.deleteClaim(claim, true, false);
  2178. if (instance.creativeRulesApply(claim.getLesserBoundaryCorner()))
  2179. {
  2180. AddLogEntry(player.getName() + " abandoned a claim @ " + getfriendlyLocationString(claim.getLesserBoundaryCorner()));
  2181. sendMessage(player, TextMode.Warn, Messages.UnclaimCleanupWarning, new String[0]);
  2182. instance.restoreClaim(claim, 2400L);
  2183. }
  2184. if (claim.parent == null) {
  2185. playerData.setAccruedClaimBlocks(Integer.valueOf(playerData.getAccruedClaimBlocks() - (int)Math.ceil(claim.getArea() * (1.0D - this.config_claims_abandonReturnRatio))));
  2186. }
  2187. int remainingBlocks = playerData.getRemainingClaimBlocks();
  2188. sendMessage(player, TextMode.Success, Messages.AbandonSuccess, new String[] { String.valueOf(remainingBlocks) });
  2189.  
  2190. Visualization.Revert(player);
  2191.  
  2192. playerData.warnedAboutMajorDeletion = false;
  2193. }
  2194. return true;
  2195. }
  2196.  
  2197. private void handleTrustCommand(Player player, ClaimPermission permissionLevel, String recipientName)
  2198. {
  2199. Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, null);
  2200.  
  2201. String permission = null;
  2202. OfflinePlayer otherPlayer = null;
  2203. UUID recipientID = null;
  2204. if ((recipientName.startsWith("[")) && (recipientName.endsWith("]")))
  2205. {
  2206. permission = recipientName.substring(1, recipientName.length() - 1);
  2207. if ((permission == null) || (permission.isEmpty())) {
  2208. sendMessage(player, TextMode.Err, Messages.InvalidPermissionID, new String[0]);
  2209. }
  2210. }
  2211. else if (recipientName.contains("."))
  2212. {
  2213. permission = recipientName;
  2214. }
  2215. else
  2216. {
  2217. otherPlayer = resolvePlayerByName(recipientName);
  2218. if ((otherPlayer == null) && (!recipientName.equals("public")) && (!recipientName.equals("all")))
  2219. {
  2220. sendMessage(player, TextMode.Err, Messages.PlayerNotFound2, new String[0]);
  2221. return;
  2222. }
  2223. if (otherPlayer != null)
  2224. {
  2225. recipientName = otherPlayer.getName();
  2226. recipientID = otherPlayer.getUniqueId();
  2227. }
  2228. else
  2229. {
  2230. recipientName = "public";
  2231. }
  2232. }
  2233. ArrayList<Claim> targetClaims = new ArrayList();
  2234. if (claim == null)
  2235. {
  2236. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  2237. for (int i = 0; i < playerData.getClaims().size(); i++) {
  2238. targetClaims.add(playerData.getClaims().get(i));
  2239. }
  2240. }
  2241. else
  2242. {
  2243. if (claim.allowGrantPermission(player) != null)
  2244. {
  2245. sendMessage(player, TextMode.Err, Messages.NoPermissionTrust, new String[] { claim.getOwnerName() });
  2246. return;
  2247. }
  2248. String errorMessage = null;
  2249. if (permissionLevel == null)
  2250. {
  2251. errorMessage = claim.allowEdit(player);
  2252. if (errorMessage != null) {
  2253. errorMessage = "Only " + claim.getOwnerName() + " can grant /PermissionTrust here.";
  2254. }
  2255. }
  2256. else
  2257. {
  2258. switch (permissionLevel)
  2259. {
  2260. case Access:
  2261. errorMessage = claim.allowAccess(player);
  2262. break;
  2263. case Inventory:
  2264. errorMessage = claim.allowContainers(player);
  2265. break;
  2266. default:
  2267. errorMessage = claim.allowBuild(player, Material.AIR);
  2268. }
  2269. }
  2270. if (errorMessage != null)
  2271. {
  2272. sendMessage(player, TextMode.Err, Messages.CantGrantThatPermission, new String[0]);
  2273. return;
  2274. }
  2275. targetClaims.add(claim);
  2276. }
  2277. if (targetClaims.size() == 0)
  2278. {
  2279. sendMessage(player, TextMode.Err, Messages.GrantPermissionNoClaim, new String[0]);
  2280. return;
  2281. }
  2282. for (int i = 0; i < targetClaims.size(); i++)
  2283. {
  2284. Claim currentClaim = (Claim)targetClaims.get(i);
  2285. String identifierToAdd = recipientName;
  2286. if (permission != null) {
  2287. identifierToAdd = "[" + permission + "]";
  2288. } else if (recipientID != null) {
  2289. identifierToAdd = recipientID.toString();
  2290. }
  2291. if (permissionLevel == null)
  2292. {
  2293. if (!currentClaim.managers.contains(identifierToAdd)) {
  2294. currentClaim.managers.add(identifierToAdd);
  2295. }
  2296. }
  2297. else {
  2298. currentClaim.setPermission(identifierToAdd, permissionLevel);
  2299. }
  2300. this.dataStore.saveClaim(currentClaim);
  2301. }
  2302. if (recipientName.equals("public")) {
  2303. recipientName = this.dataStore.getMessage(Messages.CollectivePublic, new String[0]);
  2304. }
  2305. String permissionDescription;
  2306. String permissionDescription;
  2307. if (permissionLevel == null)
  2308. {
  2309. permissionDescription = this.dataStore.getMessage(Messages.PermissionsPermission, new String[0]);
  2310. }
  2311. else
  2312. {
  2313. String permissionDescription;
  2314. if (permissionLevel == ClaimPermission.Build)
  2315. {
  2316. permissionDescription = this.dataStore.getMessage(Messages.BuildPermission, new String[0]);
  2317. }
  2318. else
  2319. {
  2320. String permissionDescription;
  2321. if (permissionLevel == ClaimPermission.Access) {
  2322. permissionDescription = this.dataStore.getMessage(Messages.AccessPermission, new String[0]);
  2323. } else {
  2324. permissionDescription = this.dataStore.getMessage(Messages.ContainersPermission, new String[0]);
  2325. }
  2326. }
  2327. }
  2328. String location;
  2329. String location;
  2330. if (claim == null) {
  2331. location = this.dataStore.getMessage(Messages.LocationAllClaims, new String[0]);
  2332. } else {
  2333. location = this.dataStore.getMessage(Messages.LocationCurrentClaim, new String[0]);
  2334. }
  2335. sendMessage(player, TextMode.Success, Messages.GrantPermissionConfirmation, new String[] { recipientName, permissionDescription, location });
  2336. }
  2337.  
  2338. ConcurrentHashMap<String, UUID> playerNameToIDMap = new ConcurrentHashMap();
  2339.  
  2340. private class CacheOfflinePlayerNamesThread
  2341. extends Thread
  2342. {
  2343. private OfflinePlayer[] offlinePlayers;
  2344. private ConcurrentHashMap<String, UUID> playerNameToIDMap;
  2345.  
  2346. CacheOfflinePlayerNamesThread(ConcurrentHashMap<String, UUID> offlinePlayers)
  2347. {
  2348. this.offlinePlayers = offlinePlayers;
  2349. this.playerNameToIDMap = playerNameToIDMap;
  2350. }
  2351.  
  2352. public void run()
  2353. {
  2354. long now = System.currentTimeMillis();
  2355. long millisecondsPerDay = 86400000L;
  2356. for (OfflinePlayer player : this.offlinePlayers) {
  2357. try
  2358. {
  2359. UUID playerID = player.getUniqueId();
  2360. if (playerID != null)
  2361. {
  2362. long lastSeen = player.getLastPlayed();
  2363.  
  2364. long diff = now - lastSeen;
  2365. long daysDiff = diff / 86400000L;
  2366. if (daysDiff <= 90L)
  2367. {
  2368. String playerName = player.getName();
  2369. if (playerName == null) {
  2370. continue;
  2371. }
  2372. this.playerNameToIDMap.put(playerName, playerID);
  2373. this.playerNameToIDMap.put(playerName.toLowerCase(), playerID);
  2374. }
  2375. }
  2376. }
  2377. catch (Exception e)
  2378. {
  2379. e.printStackTrace();
  2380. }
  2381. }
  2382. }
  2383. }
  2384.  
  2385. public OfflinePlayer resolvePlayerByName(String name)
  2386. {
  2387. Player targetPlayer = getServer().getPlayerExact(name);
  2388. if (targetPlayer != null) {
  2389. return targetPlayer;
  2390. }
  2391. targetPlayer = getServer().getPlayer(name);
  2392. if (targetPlayer != null) {
  2393. return targetPlayer;
  2394. }
  2395. UUID bestMatchID = null;
  2396.  
  2397. bestMatchID = (UUID)this.playerNameToIDMap.get(name);
  2398. if (bestMatchID == null) {
  2399. bestMatchID = (UUID)this.playerNameToIDMap.get(name.toLowerCase());
  2400. }
  2401. if (bestMatchID == null) {
  2402. return null;
  2403. }
  2404. return getServer().getOfflinePlayer(bestMatchID);
  2405. }
  2406.  
  2407. static String lookupPlayerName(UUID playerID)
  2408. {
  2409. if (playerID == null) {
  2410. return "somebody";
  2411. }
  2412. OfflinePlayer player = instance.getServer().getOfflinePlayer(playerID);
  2413. if ((player.hasPlayedBefore()) || (player.isOnline())) {
  2414. return player.getName();
  2415. }
  2416. return "someone(" + playerID.toString() + ")";
  2417. }
  2418.  
  2419. static void cacheUUIDNamePair(UUID playerID, String playerName)
  2420. {
  2421. instance.playerNameToIDMap.put(playerName, playerID);
  2422. instance.playerNameToIDMap.put(playerName.toLowerCase(), playerID);
  2423. }
  2424.  
  2425. static String lookupPlayerName(String playerID)
  2426. {
  2427. try
  2428. {
  2429. id = UUID.fromString(playerID);
  2430. }
  2431. catch (IllegalArgumentException ex)
  2432. {
  2433. UUID id;
  2434. AddLogEntry("Error: Tried to look up a local player name for invalid UUID: " + playerID);
  2435. return "someone";
  2436. }
  2437. UUID id;
  2438. return lookupPlayerName(id);
  2439. }
  2440.  
  2441. public void onDisable()
  2442. {
  2443. Collection<Player> players = getServer().getOnlinePlayers();
  2444. for (Player player : players)
  2445. {
  2446. UUID playerID = player.getUniqueId();
  2447. PlayerData playerData = this.dataStore.getPlayerData(playerID);
  2448. this.dataStore.savePlayerDataSync(playerID, playerData);
  2449. }
  2450. this.dataStore.close();
  2451.  
  2452. this.customLogger.WriteEntries();
  2453.  
  2454. AddLogEntry("GriefPrevention disabled.");
  2455. }
  2456.  
  2457. public void checkPvpProtectionNeeded(Player player)
  2458. {
  2459. if (!this.config_pvp_protectFreshSpawns) {
  2460. return;
  2461. }
  2462. if (!pvpRulesApply(player.getWorld())) {
  2463. return;
  2464. }
  2465. if (player.getGameMode() == GameMode.CREATIVE) {
  2466. return;
  2467. }
  2468. if (player.hasPermission("griefprevention.nopvpimmunity")) {
  2469. return;
  2470. }
  2471. if (isInventoryEmpty(player))
  2472. {
  2473. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  2474. playerData.pvpImmune = true;
  2475.  
  2476. sendMessage(player, TextMode.Success, Messages.PvPImmunityStart, 5L, new String[0]);
  2477.  
  2478. PvPImmunityValidationTask task = new PvPImmunityValidationTask(player);
  2479. getServer().getScheduler().scheduleSyncDelayedTask(this, task, 1200L);
  2480. }
  2481. }
  2482.  
  2483. static boolean isInventoryEmpty(Player player)
  2484. {
  2485. PlayerInventory inventory = player.getInventory();
  2486. ItemStack[] armorStacks = inventory.getArmorContents();
  2487. for (int i = 0; i < armorStacks.length; i++) {
  2488. if ((armorStacks[i] != null) && (armorStacks[i].getType() != Material.AIR)) {
  2489. return false;
  2490. }
  2491. }
  2492. ItemStack[] generalStacks = inventory.getContents();
  2493. for (int i = 0; i < generalStacks.length; i++) {
  2494. if ((generalStacks[i] != null) && (generalStacks[i].getType() != Material.AIR)) {
  2495. return false;
  2496. }
  2497. }
  2498. return true;
  2499. }
  2500.  
  2501. public boolean siegeEnabledForWorld(World world)
  2502. {
  2503. return this.config_siege_enabledWorlds.contains(world);
  2504. }
  2505.  
  2506. public Location ejectPlayer(Player player)
  2507. {
  2508. Location candidateLocation = player.getLocation();
  2509. for (;;)
  2510. {
  2511. Claim claim = null;
  2512. claim = instance.dataStore.getClaimAt(candidateLocation, false, null);
  2513. if (claim == null) {
  2514. break;
  2515. }
  2516. candidateLocation = new Location(claim.lesserBoundaryCorner.getWorld(), claim.lesserBoundaryCorner.getBlockX() - 1, claim.lesserBoundaryCorner.getBlockY(), claim.lesserBoundaryCorner.getBlockZ() - 1);
  2517. }
  2518. GuaranteeChunkLoaded(candidateLocation);
  2519. Block highestBlock = candidateLocation.getWorld().getHighestBlockAt(candidateLocation.getBlockX(), candidateLocation.getBlockZ());
  2520. Location destination = new Location(highestBlock.getWorld(), highestBlock.getX(), highestBlock.getY() + 2, highestBlock.getZ());
  2521. player.teleport(destination);
  2522. return destination;
  2523. }
  2524.  
  2525. private static void GuaranteeChunkLoaded(Location location)
  2526. {
  2527. Chunk chunk = location.getChunk();
  2528. while ((!chunk.isLoaded()) || (!chunk.load(true))) {}
  2529. }
  2530.  
  2531. static void sendMessage(Player player, ChatColor color, Messages messageID, String... args)
  2532. {
  2533. sendMessage(player, color, messageID, 0L, args);
  2534. }
  2535.  
  2536. static void sendMessage(Player player, ChatColor color, Messages messageID, long delayInTicks, String... args)
  2537. {
  2538. String message = instance.dataStore.getMessage(messageID, args);
  2539. sendMessage(player, color, message, delayInTicks);
  2540. }
  2541.  
  2542. static void sendMessage(Player player, ChatColor color, String message)
  2543. {
  2544. if ((message == null) || (message.length() == 0)) {
  2545. return;
  2546. }
  2547. if (player == null) {
  2548. AddLogEntry(color + message);
  2549. } else {
  2550. player.sendMessage(color + message);
  2551. }
  2552. }
  2553.  
  2554. static void sendMessage(Player player, ChatColor color, String message, long delayInTicks)
  2555. {
  2556. SendPlayerMessageTask task = new SendPlayerMessageTask(player, color, message);
  2557. instance.getServer().getScheduler().runTaskLater(instance, task, delayInTicks);
  2558. }
  2559.  
  2560. public boolean claimsEnabledForWorld(World world)
  2561. {
  2562. ClaimsMode mode = (ClaimsMode)this.config_claims_worldModes.get(world);
  2563. return (mode != null) && (mode != ClaimsMode.Disabled);
  2564. }
  2565.  
  2566. boolean creativeRulesApply(Location location)
  2567. {
  2568. if (!this.config_creativeWorldsExist) {
  2569. return false;
  2570. }
  2571. return this.config_claims_worldModes.get(location.getWorld()) == ClaimsMode.Creative;
  2572. }
  2573.  
  2574. public String allowBuild(Player player, Location location)
  2575. {
  2576. return allowBuild(player, location, location.getBlock().getType());
  2577. }
  2578.  
  2579. public String allowBuild(Player player, Location location, Material material)
  2580. {
  2581. if (!instance.claimsEnabledForWorld(location.getWorld())) {
  2582. return null;
  2583. }
  2584. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  2585. Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
  2586. if ((playerData.ignoreClaims) || (instance.config_mods_ignoreClaimsAccounts.contains(player.getName()))) {
  2587. return null;
  2588. }
  2589. if (claim == null)
  2590. {
  2591. if ((creativeRulesApply(location)) || (this.config_claims_worldModes.get(location.getWorld()) == ClaimsMode.SurvivalRequiringClaims))
  2592. {
  2593. if ((material != Material.CHEST) || (playerData.getClaims().size() > 0) || (instance.config_claims_automaticClaimsForNewPlayersRadius == -1))
  2594. {
  2595. String reason = this.dataStore.getMessage(Messages.NoBuildOutsideClaims, new String[0]);
  2596. if (player.hasPermission("griefprevention.ignoreclaims")) {
  2597. reason = reason + " " + this.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement, new String[0]);
  2598. }
  2599. reason = reason + " " + this.dataStore.getMessage(Messages.CreativeBasicsVideo2, new String[] { DataStore.CREATIVE_VIDEO_URL });
  2600. return reason;
  2601. }
  2602. return null;
  2603. }
  2604. return null;
  2605. }
  2606. playerData.lastClaim = claim;
  2607. return claim.allowBuild(player, material);
  2608. }
  2609.  
  2610. public String allowBreak(Player player, Block block, Location location)
  2611. {
  2612. return allowBreak(player, block, location, null);
  2613. }
  2614.  
  2615. public String allowBreak(Player player, Block block, Location location, BlockBreakEvent breakEvent)
  2616. {
  2617. if (!instance.claimsEnabledForWorld(location.getWorld())) {
  2618. return null;
  2619. }
  2620. PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
  2621. Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
  2622. if ((playerData.ignoreClaims) || (instance.config_mods_ignoreClaimsAccounts.contains(player.getName()))) {
  2623. return null;
  2624. }
  2625. if (claim == null)
  2626. {
  2627. if ((creativeRulesApply(location)) || (this.config_claims_worldModes.get(location.getWorld()) == ClaimsMode.SurvivalRequiringClaims))
  2628. {
  2629. String reason = this.dataStore.getMessage(Messages.NoBuildOutsideClaims, new String[0]);
  2630. if (player.hasPermission("griefprevention.ignoreclaims")) {
  2631. reason = reason + " " + this.dataStore.getMessage(Messages.IgnoreClaimsAdvertisement, new String[0]);
  2632. }
  2633. reason = reason + " " + this.dataStore.getMessage(Messages.CreativeBasicsVideo2, new String[] { DataStore.CREATIVE_VIDEO_URL });
  2634. return reason;
  2635. }
  2636. return null;
  2637. }
  2638. playerData.lastClaim = claim;
  2639.  
  2640. String cancel = claim.allowBreak(player, block.getType());
  2641. if ((cancel != null) && (breakEvent != null))
  2642. {
  2643. PreventBlockBreakEvent preventionEvent = new PreventBlockBreakEvent(breakEvent);
  2644. Bukkit.getPluginManager().callEvent(preventionEvent);
  2645. if (preventionEvent.isCancelled()) {
  2646. cancel = null;
  2647. }
  2648. }
  2649. return cancel;
  2650. }
  2651.  
  2652. public void restoreClaim(Claim claim, long delayInTicks)
  2653. {
  2654. if (claim.isAdminClaim()) {
  2655. return;
  2656. }
  2657. if (claim.getArea() > 10000) {
  2658. return;
  2659. }
  2660. ArrayList<Chunk> chunks = claim.getChunks();
  2661. for (Chunk chunk : chunks) {
  2662. restoreChunk(chunk, getSeaLevel(chunk.getWorld()) - 15, false, delayInTicks, null);
  2663. }
  2664. }
  2665.  
  2666. public void restoreChunk(Chunk chunk, int miny, boolean aggressiveMode, long delayInTicks, Player playerReceivingVisualization)
  2667. {
  2668. int maxHeight = chunk.getWorld().getMaxHeight();
  2669. BlockSnapshot[][][] snapshots = new BlockSnapshot[18][maxHeight][18];
  2670. Block startBlock = chunk.getBlock(0, 0, 0);
  2671. Location startLocation = new Location(chunk.getWorld(), startBlock.getX() - 1, 0.0D, startBlock.getZ() - 1);
  2672. for (int x = 0; x < snapshots.length; x++) {
  2673. for (int z = 0; z < snapshots[0][0].length; z++) {
  2674. for (int y = 0; y < snapshots[0].length; y++)
  2675. {
  2676. Block block = chunk.getWorld().getBlockAt(startLocation.getBlockX() + x, startLocation.getBlockY() + y, startLocation.getBlockZ() + z);
  2677. snapshots[x][y][z] = new BlockSnapshot(block.getLocation(), block.getTypeId(), block.getData());
  2678. }
  2679. }
  2680. }
  2681. Location lesserBoundaryCorner = chunk.getBlock(0, 0, 0).getLocation();
  2682. Location greaterBoundaryCorner = chunk.getBlock(15, 0, 15).getLocation();
  2683.  
  2684. RestoreNatureProcessingTask task = new RestoreNatureProcessingTask(snapshots, miny, chunk.getWorld().getEnvironment(), lesserBoundaryCorner.getBlock().getBiome(), lesserBoundaryCorner, greaterBoundaryCorner, getSeaLevel(chunk.getWorld()), aggressiveMode, instance.creativeRulesApply(lesserBoundaryCorner), playerReceivingVisualization);
  2685. instance.getServer().getScheduler().runTaskLaterAsynchronously(instance, task, delayInTicks);
  2686. }
  2687.  
  2688. private void parseMaterialListFromConfig(List<String> stringsToParse, MaterialCollection materialCollection)
  2689. {
  2690. materialCollection.clear();
  2691. for (int i = 0; i < stringsToParse.size(); i++)
  2692. {
  2693. MaterialInfo materialInfo = MaterialInfo.fromString((String)stringsToParse.get(i));
  2694. if (materialInfo == null)
  2695. {
  2696. AddLogEntry("ERROR: Unable to read a material entry from the config file. Please update your config.yml.");
  2697. if (!((String)stringsToParse.get(i)).contains("can't")) {
  2698. stringsToParse.set(i, (String)stringsToParse.get(i) + " <-- can't understand this entry, see BukkitDev documentation");
  2699. }
  2700. }
  2701. else
  2702. {
  2703. materialCollection.Add(materialInfo);
  2704. }
  2705. }
  2706. }
  2707.  
  2708. public int getSeaLevel(World world)
  2709. {
  2710. Integer overrideValue = (Integer)this.config_seaLevelOverride.get(world.getName());
  2711. if ((overrideValue == null) || (overrideValue.intValue() == -1)) {
  2712. return world.getSeaLevel();
  2713. }
  2714. return overrideValue.intValue();
  2715. }
  2716.  
  2717. private static Block getTargetNonAirBlock(Player player, int maxDistance)
  2718. throws IllegalStateException
  2719. {
  2720. BlockIterator iterator = new BlockIterator(player.getLocation(), player.getEyeHeight(), maxDistance);
  2721. Block result = player.getLocation().getBlock().getRelative(BlockFace.UP);
  2722. while (iterator.hasNext())
  2723. {
  2724. result = iterator.next();
  2725. if (result.getType() != Material.AIR) {
  2726. return result;
  2727. }
  2728. }
  2729. return result;
  2730. }
  2731.  
  2732. public boolean containsBlockedIP(String message)
  2733. {
  2734. message = message.replace("\r\n", "");
  2735. Pattern ipAddressPattern = Pattern.compile("([0-9]{1,3}\\.){3}[0-9]{1,3}");
  2736. Matcher matcher = ipAddressPattern.matcher(message);
  2737. if (matcher.find()) {
  2738. if (!instance.config_spam_allowedIpAddresses.contains(matcher.group())) {
  2739. return true;
  2740. }
  2741. }
  2742. return false;
  2743. }
  2744.  
  2745. void autoExtendClaim(Claim newClaim)
  2746. {
  2747. Location lesserCorner = newClaim.getLesserBoundaryCorner();
  2748. Location greaterCorner = newClaim.getGreaterBoundaryCorner();
  2749. World world = lesserCorner.getWorld();
  2750. ArrayList<ChunkSnapshot> snapshots = new ArrayList();
  2751. for (int chunkx = lesserCorner.getBlockX() / 16; chunkx <= greaterCorner.getBlockX() / 16; chunkx++) {
  2752. for (int chunkz = lesserCorner.getBlockZ() / 16; chunkz <= greaterCorner.getBlockZ() / 16; chunkz++) {
  2753. if (world.isChunkLoaded(chunkx, chunkz)) {
  2754. snapshots.add(world.getChunkAt(chunkx, chunkz).getChunkSnapshot(true, true, false));
  2755. }
  2756. }
  2757. }
  2758. Bukkit.getScheduler().runTaskAsynchronously(instance, new AutoExtendClaimTask(newClaim, snapshots, world.getEnvironment()));
  2759. }
  2760.  
  2761. public boolean pvpRulesApply(World world)
  2762. {
  2763. Boolean configSetting = (Boolean)this.config_pvp_specifiedWorlds.get(world);
  2764. if (configSetting != null) {
  2765. return configSetting.booleanValue();
  2766. }
  2767. return world.getPVP();
  2768. }
  2769.  
  2770. public static boolean isNewToServer(Player player)
  2771. {
  2772. if (player.getStatistic(Statistic.PICKUP, Material.WOOD) > 0) {
  2773. return false;
  2774. }
  2775. PlayerData playerData = instance.dataStore.getPlayerData(player.getUniqueId());
  2776. if (playerData.getClaims().size() > 0) {
  2777. return false;
  2778. }
  2779. return true;
  2780. }
  2781.  
  2782. static void banPlayer(Player player, String reason, String source)
  2783. {
  2784. if (instance.config_ban_useCommand)
  2785. {
  2786. Bukkit.getServer().dispatchCommand(
  2787. Bukkit.getConsoleSender(), instance.config_ban_commandFormat
  2788. .replace("%name%", player.getName()).replace("%reason%", reason));
  2789. }
  2790. else
  2791. {
  2792. BanList bans = Bukkit.getServer().getBanList(BanList.Type.NAME);
  2793. bans.addBan(player.getName(), reason, null, source);
  2794. if (player.isOnline()) {
  2795. player.kickPlayer(reason);
  2796. }
  2797. }
  2798. }
  2799.  
  2800. public ItemStack getItemInHand(Player player, EquipmentSlot hand)
  2801. {
  2802. if (hand == EquipmentSlot.OFF_HAND) {
  2803. return player.getInventory().getItemInOffHand();
  2804. }
  2805. return player.getInventory().getItemInMainHand();
  2806. }
  2807.  
  2808. public boolean claimIsPvPSafeZone(Claim claim)
  2809. {
  2810. return ((claim.isAdminClaim()) && (claim.parent == null) && (instance.config_pvp_noCombatInAdminLandClaims)) ||
  2811. ((claim.isAdminClaim()) && (claim.parent != null) && (instance.config_pvp_noCombatInAdminSubdivisions)) || (
  2812. (!claim.isAdminClaim()) && (instance.config_pvp_noCombatInPlayerLandClaims));
  2813. }
  2814.  
  2815. ConcurrentHashMap<UUID, BukkitTask> portalReturnTaskMap = new ConcurrentHashMap();
  2816.  
  2817. public void startRescueTask(Player player)
  2818. {
  2819. BukkitTask task = new CheckForPortalTrapTask(player, this).runTaskLater(instance, 400L);
  2820. if (this.portalReturnTaskMap.containsKey(player.getUniqueId())) {
  2821. ((BukkitTask)this.portalReturnTaskMap.put(player.getUniqueId(), task)).cancel();
  2822. } else {
  2823. this.portalReturnTaskMap.put(player.getUniqueId(), task);
  2824. }
  2825. }
  2826. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement