From e96cbd344b032dc97a91508e3d686d1b9f884a72 Mon Sep 17 00:00:00 2001 From: destro174 <40720638+destro174@users.noreply.github.com> Date: Sun, 20 Feb 2022 14:34:43 +0100 Subject: [PATCH] Remove IgnoreLoaderThread --- .../GriefPrevention/GriefPrevention.java | 8 -- .../GriefPrevention/IgnoreLoaderThread.java | 85 ------------------- .../GriefPrevention/PlayerEventHandler.java | 3 - 3 files changed, 96 deletions(-) delete mode 100644 src/main/java/me/ryanhamshire/GriefPrevention/IgnoreLoaderThread.java diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 7332875..606c612 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -378,14 +378,6 @@ public class GriefPrevention extends JavaPlugin economyHandler = new EconomyHandler(this); pluginManager.registerEvents(economyHandler, this); - //load ignore lists for any already-online players - @SuppressWarnings("unchecked") - Collection players = (Collection) GriefPrevention.instance.getServer().getOnlinePlayers(); - for (Player player : players) - { - new IgnoreLoaderThread(player.getUniqueId(), this.dataStore.getPlayerData(player.getUniqueId()).ignoredPlayers).start(); - } - new AltitudeListener(this.dataStore, this); if (getServer().getPluginManager().isPluginEnabled("Pl3xMap")) { pl3xmapHook = new Pl3xMapHook(this); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/IgnoreLoaderThread.java b/src/main/java/me/ryanhamshire/GriefPrevention/IgnoreLoaderThread.java deleted file mode 100644 index 9c352ac..0000000 --- a/src/main/java/me/ryanhamshire/GriefPrevention/IgnoreLoaderThread.java +++ /dev/null @@ -1,85 +0,0 @@ -package me.ryanhamshire.GriefPrevention; - -import com.google.common.io.Files; - -import java.io.File; -import java.nio.charset.Charset; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -//loads ignore data from file into a hash map -class IgnoreLoaderThread extends Thread -{ - private final UUID playerToLoad; - private final ConcurrentHashMap destinationMap; - - IgnoreLoaderThread(UUID playerToLoad, ConcurrentHashMap destinationMap) - { - this.playerToLoad = playerToLoad; - this.destinationMap = destinationMap; - this.setPriority(MIN_PRIORITY); - } - - @Override - public void run() - { - File ignoreFile = new File(DataStore.playerDataFolderPath + File.separator + this.playerToLoad + ".ignore"); - - //if the file doesn't exist, there's nothing to do here - if (!ignoreFile.exists()) return; - - boolean needRetry = false; - int retriesRemaining = 5; - Exception latestException = null; - do - { - try - { - needRetry = false; - - //read the file content and immediately close it - List lines = Files.readLines(ignoreFile, Charset.forName("UTF-8")); - - //each line is one ignore. asterisks indicate administrative ignores - for (String line : lines) - { - boolean adminIgnore = false; - if (line.startsWith("*")) - { - adminIgnore = true; - line = line.substring(1); - } - try - { - UUID ignoredUUID = UUID.fromString(line); - this.destinationMap.put(ignoredUUID, adminIgnore); - } - catch (IllegalArgumentException e) {} //if a bad UUID, ignore the line - } - } - - //if there's any problem with the file's content, retry up to 5 times with 5 milliseconds between - catch (Exception e) - { - latestException = e; - needRetry = true; - retriesRemaining--; - } - - try - { - if (needRetry) Thread.sleep(5); - } - catch (InterruptedException exception) {} - - } while (needRetry && retriesRemaining >= 0); - - //if last attempt failed, log information about the problem - if (needRetry) - { - GriefPrevention.AddLogEntry("Retry attempts exhausted. Unable to load ignore data for player \"" + playerToLoad.toString() + "\": " + latestException.toString()); - latestException.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index aef8e0b..d8cdc20 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -293,9 +293,6 @@ class PlayerEventHandler implements Listener } } - //create a thread to load ignore information - new IgnoreLoaderThread(playerID, playerData.ignoredPlayers).start(); - //is he stuck in a portal frame? if (player.hasMetadata("GP_PORTALRESCUE")) {