Made the sync threshold configurable (server admins can tune how long clients have to wait before they can sync their energy values with the server again)

This commit is contained in:
Pahimar 2014-09-16 12:53:22 -04:00
parent b3efb75ef8
commit 5066ec80f1
5 changed files with 16 additions and 3 deletions

View file

@ -3,6 +3,7 @@ package com.pahimar.ee3.command;
import com.pahimar.ee3.exchange.EnergyValueRegistry;
import com.pahimar.ee3.network.PacketHandler;
import com.pahimar.ee3.network.message.MessageSyncEnergyValues;
import com.pahimar.ee3.reference.Settings;
import com.pahimar.ee3.util.LogHelper;
import com.pahimar.ee3.util.PlayerHelper;
import net.minecraft.command.CommandBase;
@ -19,7 +20,6 @@ import java.util.UUID;
public class CommandSyncValues extends CommandBase
{
private static final long SYNC_THRESHOLD = 5000;
private static Map<UUID, Long> requesterMap = new HashMap<UUID, Long>();
@Override
@ -57,13 +57,13 @@ public class CommandSyncValues extends CommandBase
if (requesterMap.containsKey(commandSenderUUID))
{
long timeDifference = System.currentTimeMillis() - requesterMap.get(commandSenderUUID).longValue();
if (timeDifference >= SYNC_THRESHOLD)
if (timeDifference >= (Settings.General.syncThreshold * 1000))
{
requesterMap.remove(commandSenderUUID);
}
else
{
coolDown = SYNC_THRESHOLD - timeDifference;
coolDown = (Settings.General.syncThreshold * 1000) - timeDifference;
shouldSync = false;
}
}

View file

@ -27,6 +27,7 @@ public class ConfigurationHandler
private static void loadConfiguration()
{
// TODO Come back and do these constants in logical locations and names
Settings.General.syncThreshold = configuration.getInt(Messages.Configuration.GENERAL_SYNC_THRESHOLD, Configuration.CATEGORY_GENERAL, 5, 0, Short.MAX_VALUE, StatCollector.translateToLocal(Messages.Configuration.GENERAL_SYNC_THRESHOLD_COMMENT), Messages.Configuration.GENERAL_SYNC_THRESHOLD_LABEL);
Settings.Transmutation.knowledgeMode = ConfigurationHelper.getString(configuration, Messages.Configuration.TRANSMUTATION_KNOWLEDGE_MODE, Messages.Configuration.CATEGORY_TRANSMUTATION, "All", StatCollector.translateToLocal(Messages.Configuration.TRANSMUTATION_KNOWLEDGE_MODE_COMMENT), new String[]{"All", "Select", "Tier", "Restricted", "None"}, Messages.Configuration.TRANSMUTATION_KNOWLEDGE_MODE_LABEL);
Settings.Transmutation.maxKnowledgeTier = configuration.getInt(Messages.Configuration.TRANSMUTATION_KNOWLEDGE_MAX_TIER, Messages.Configuration.CATEGORY_TRANSMUTATION, 0, 0, Short.MAX_VALUE, StatCollector.translateToLocal(Messages.Configuration.TRANSMUTATION_KNOWLEDGE_MAX_TIER_COMMENT), Messages.Configuration.TRANSMUTATION_KNOWLEDGE_MAX_TIER_LABEL);
Settings.Transmutation.useTemplateFile = configuration.getBoolean(Messages.Configuration.TRANSMUTATION_KNOWLEDGE_TEMPLATE, Messages.Configuration.CATEGORY_TRANSMUTATION, true, StatCollector.translateToLocal(Messages.Configuration.TRANSMUTATION_KNOWLEDGE_TEMPLATE_COMMENT), Messages.Configuration.TRANSMUTATION_KNOWLEDGE_TEMPLATE_LABEL);

View file

@ -17,6 +17,10 @@ public final class Messages
public static final String DEBUG_MODE_LABEL = "general.debug.mode.label";
public static final String DEBUG_MODE_COMMENT = "general.debug.mode.comment";
public static final String GENERAL_SYNC_THRESHOLD = "sync.threshold";
public static final String GENERAL_SYNC_THRESHOLD_LABEL = "general.sync.threshold.label";
public static final String GENERAL_SYNC_THRESHOLD_COMMENT = "general.sync.threshold.comment";
public static final String CATEGORY_TRANSMUTATION = "general.transmutation";
public static final String TRANSMUTATION_KNOWLEDGE_MODE = "knowledgeMode";

View file

@ -7,6 +7,11 @@ public class Settings
public static boolean debugMode;
}
public static class General
{
public static int syncThreshold;
}
public static class Transmutation
{
public static String knowledgeMode;

View file

@ -3,6 +3,9 @@ general.transmutation=Transmutation Settings
general.transmutation.knowledge.mode.label=Transmutation Knowledge Mode
general.transmutation.knowledge.mode.comment=All - Player can learn all items that have a value, Select - Player can learn select items, Tier - Player can learn items below this tier level, Restricted - Player can only learn items listed in the restricted file, None - Player cannot learn any items
general.sync.threshold.label=Sync Threshold
general.sync.threshold.comment=The number of seconds a player must wait before they can sync their Energy Values with the server again
general.transmutation.knowledge.maxTier.label=Highest Available Knowledge Tier
general.transmutation.knowledge.maxTier.comment=The highest available knowledge tier for which players can learn transmutations