This commit is contained in:
GeorgH93 2023-06-03 21:22:23 +02:00
parent 6d6482374c
commit b2fd938c00
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
9 changed files with 21 additions and 20 deletions

View File

@ -123,12 +123,12 @@ Database:
# Settings controlling the cache behavior of the plugin. You may optimize it a little depending on your player count, ram or cpu bottlenecks.
Cache:
UnCache:
# The strategie used to uncache offline players. Options
# The strategy used to uncache offline players. Options
# interval (offline players get uncached every x seconds)
# intervalChecked (like interval, but also ensures that the player is already offline for at least the interval time, adds a cpu overhead)
# ondisconnect (player instantly gets uncached as soon as he disconnects, may adds overhead if other plugins try to access the player data when they go offline, also it may be problematic for players with unstable connections)
# ondisconnectdelayed (player gets uncached x seconds after he went offline, adds overhead on disconnect, you shouldn't use this with a lot of players joining and leaving.)
Strategie: interval
Strategy: interval
# Used for the interval based uncaching algorithms, and is also used as delay for ondisconnectdelayed. Value in seconds. Default: 600 = 10 minutes
Interval: 600
Delay: 600

View File

@ -70,6 +70,7 @@ protected void doUpgrade(@NotNull YamlFileManager oldConfig)
remappedKeys.put("WorldSettings.FilteredWorlds", "WorldSettings.Blacklist");
remappedKeys.put("WorldSettings.BockMode", "WorldSettings.BlacklistMode");
}
if(oldConfig.getVersion().olderOrEqualThan(new Version(33))) remappedKeys.put("Database.Cache.UnCache.Strategy", "Database.Cache.UnCache.Strategie");
Collection<String> keysToKeep = oldConfig.getYamlE().getKeysFiltered("Database\\.SQL\\.(MaxLifetime|IdleTimeout)");
keysToKeep.addAll(oldConfig.getYamlE().getKeysFiltered("Database\\.Tables\\.Fields\\..+"));
doUpgrade(oldConfig, remappedKeys, keysToKeep);
@ -151,9 +152,9 @@ public boolean isForceSaveOnUnloadEnabled()
return getConfigE().getBoolean("Database.ForceSaveOnUnload", false);
}
public String getUnCacheStrategie()
public String getUnCacheStrategy()
{
return getConfigE().getString("Database.Cache.UnCache.Strategie", "interval").toLowerCase(Locale.ENGLISH);
return getConfigE().getString("Database.Cache.UnCache.Strategy", "interval").toLowerCase(Locale.ENGLISH);
}
public long getUnCacheInterval()

View File

@ -22,7 +22,7 @@
import at.pcgamingfreaks.Minepacks.Bukkit.API.Callback;
import at.pcgamingfreaks.Minepacks.Bukkit.Backpack;
import at.pcgamingfreaks.Minepacks.Bukkit.Database.UnCacheStrategies.OnDisconnect;
import at.pcgamingfreaks.Minepacks.Bukkit.Database.UnCacheStrategies.UnCacheStrategie;
import at.pcgamingfreaks.Minepacks.Bukkit.Database.UnCacheStrategies.UnCacheStrategy;
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
import org.bukkit.OfflinePlayer;
@ -54,7 +54,7 @@ public abstract class Database implements Listener
protected boolean useUUIDSeparators, asyncSave = true;
protected long maxAge;
private final Map<OfflinePlayer, Backpack> backpacks = new ConcurrentHashMap<>();
private final UnCacheStrategie unCacheStrategie;
private final UnCacheStrategy unCacheStrategie;
private final File backupFolder;
public Database(Minepacks mp)
@ -66,7 +66,7 @@ public Database(Minepacks mp)
bungeeCordMode = plugin.getConfiguration().isBungeeCordModeEnabled();
forceSaveOnUnload = plugin.getConfiguration().isForceSaveOnUnloadEnabled();
maxAge = plugin.getConfiguration().getAutoCleanupMaxInactiveDays();
unCacheStrategie = bungeeCordMode ? new OnDisconnect(this) : UnCacheStrategie.getUnCacheStrategie(this);
unCacheStrategie = bungeeCordMode ? new OnDisconnect(this) : UnCacheStrategy.getUnCacheStrategie(this);
backupFolder = new File(this.plugin.getDataFolder(), "backups");
if(!backupFolder.exists() && !backupFolder.mkdirs()) mp.getLogger().info("Failed to create backups folder.");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 GeorgH93
* Copyright (C) 2023 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,7 +23,7 @@
import org.bukkit.Bukkit;
public class Interval extends UnCacheStrategie implements Runnable
public class Interval extends UnCacheStrategy implements Runnable
{
private final int taskID;

View File

@ -23,7 +23,7 @@
import org.bukkit.Bukkit;
public class IntervalChecked extends UnCacheStrategie implements Runnable
public class IntervalChecked extends UnCacheStrategy implements Runnable
{
private final long delay;
private final int taskID;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 GeorgH93
* Copyright (C) 2023 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,7 +28,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class OnDisconnect extends UnCacheStrategie implements Listener
public class OnDisconnect extends UnCacheStrategy implements Listener
{
public OnDisconnect(Database cache)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 GeorgH93
* Copyright (C) 2023 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -29,7 +29,7 @@
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class OnDisconnectDelayed extends UnCacheStrategie implements Listener
public class OnDisconnectDelayed extends UnCacheStrategy implements Listener
{
private final long delay;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 GeorgH93
* Copyright (C) 2023 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,18 +20,18 @@
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Database;
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
public abstract class UnCacheStrategie
public abstract class UnCacheStrategy
{
protected Database cache;
public UnCacheStrategie(Database cache)
public UnCacheStrategy(Database cache)
{
this.cache = cache;
}
public static UnCacheStrategie getUnCacheStrategie(Database cache)
public static UnCacheStrategy getUnCacheStrategie(Database cache)
{
switch(Minepacks.getInstance().getConfiguration().getUnCacheStrategie())
switch(Minepacks.getInstance().getConfiguration().getUnCacheStrategy())
{
case "ondisconnect": return new OnDisconnect(cache);
case "ondisconnectdelayed": return new OnDisconnectDelayed(cache);

View File

@ -7,7 +7,7 @@
<packaging>pom</packaging>
<properties>
<revision>2.4.19</revision>
<revision>2.4.20-SNAPSHOT</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>