Remove IgnoreLoaderThread

This commit is contained in:
destro174 2022-02-20 14:34:43 +01:00
parent e18ec1e55c
commit e96cbd344b
3 changed files with 0 additions and 96 deletions

View File

@ -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<Player> players = (Collection<Player>) 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);

View File

@ -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<UUID, Boolean> destinationMap;
IgnoreLoaderThread(UUID playerToLoad, ConcurrentHashMap<UUID, Boolean> 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<String> 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();
}
}
}

View File

@ -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"))
{