mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 11:35:18 +01:00
Full config api for all platforms using snakeyaml + comments
This commit is contained in:
parent
771c00b146
commit
b7b322a525
@ -1,210 +0,0 @@
|
||||
package us.myles.ViaVersion;
|
||||
|
||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
|
||||
import us.myles.ViaVersion.bukkit.util.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ViaConfig implements ViaVersionConfig, ConfigurationProvider {
|
||||
private final ViaVersionPlugin plugin;
|
||||
|
||||
public ViaConfig(ViaVersionPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public void generateConfig() {
|
||||
File file = new File(plugin.getDataFolder(), "config.yml");
|
||||
if (file.exists()) {
|
||||
// Update conf options
|
||||
Configuration oldConfig = new Configuration(file);
|
||||
oldConfig.reload(false); // Load current options from conf
|
||||
file.delete(); // Delete old conf
|
||||
plugin.saveDefaultConfig(); // Generate new conf
|
||||
Configuration newConfig = new Configuration(file);
|
||||
newConfig.reload(true); // Load default options
|
||||
for (String key : oldConfig.getKeys(false)) {
|
||||
// Set option in new conf if exists
|
||||
if (newConfig.contains(key)) {
|
||||
newConfig.set(key, oldConfig.get(key));
|
||||
}
|
||||
}
|
||||
newConfig.save();
|
||||
} else {
|
||||
plugin.saveDefaultConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckForUpdates() {
|
||||
return plugin.getConfig().getBoolean("checkforupdates", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreventCollision() {
|
||||
return plugin.getConfig().getBoolean("prevent-collision", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewEffectIndicator() {
|
||||
return plugin.getConfig().getBoolean("use-new-effect-indicator", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowNewDeathMessages() {
|
||||
return plugin.getConfig().getBoolean("use-new-deathmessages", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressMetadataErrors() {
|
||||
return plugin.getConfig().getBoolean("suppress-metadata-errors", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShieldBlocking() {
|
||||
return plugin.getConfig().getBoolean("shield-blocking", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHologramPatch() {
|
||||
return plugin.getConfig().getBoolean("hologram-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarPatch() {
|
||||
return plugin.getConfig().getBoolean("bossbar-patch", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarAntiflicker() {
|
||||
return plugin.getConfig().getBoolean("bossbar-anti-flicker", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnknownEntitiesSuppressed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHologramYOffset() {
|
||||
return plugin.getConfig().getDouble("hologram-y", -0.96D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockBreakPatch() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPPS() {
|
||||
return plugin.getConfig().getInt("max-pps", 140);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxPPSKickMessage() {
|
||||
return plugin.getConfig().getString("max-pps-kick-msg", "Sending packets too fast? lag?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrackingPeriod() {
|
||||
return plugin.getConfig().getInt("tracking-period", 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningPPS() {
|
||||
return plugin.getConfig().getInt("tracking-warning-pps", 120);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxWarnings() {
|
||||
return plugin.getConfig().getInt("tracking-max-warnings", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxWarningsKickMessage() {
|
||||
return plugin.getConfig().getString("tracking-max-kick-msg", "You are sending too many packets, :(");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAntiXRay() {
|
||||
return plugin.getConfig().getBoolean("anti-xray-patch", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSendSupportedVersions() {
|
||||
return plugin.getConfig().getBoolean("send-supported-versions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStimulatePlayerTick() {
|
||||
return plugin.getConfig().getBoolean("simulate-pt", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemCache() {
|
||||
return plugin.getConfig().getBoolean("item-cache", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSPlayerTicking() {
|
||||
return plugin.getConfig().getBoolean("nms-player-ticking", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplacePistons() {
|
||||
return plugin.getConfig().getBoolean("replace-pistons", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPistonReplacementId() {
|
||||
return plugin.getConfig().getInt("replacement-piston-id", 0);
|
||||
}
|
||||
|
||||
public boolean isAutoTeam() {
|
||||
// Collision has to be enabled first
|
||||
return isPreventCollision() && plugin.getConfig().getBoolean("auto-team", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForceJsonTransform() {
|
||||
return plugin.getConfig().getBoolean("force-json-transform", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBlockedProtocols() {
|
||||
return plugin.getConfig().getIntegerList("block-protocols");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockedDisconnectMsg() {
|
||||
return plugin.getConfig().getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReloadDisconnectMsg() {
|
||||
return plugin.getConfig().getString("reload-disconnect-msg", "Server reload, please rejoin!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(String path, Object value) {
|
||||
plugin.getConfig().set(path, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
generateConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getValues() {
|
||||
return plugin.getConfig().getValues(false);
|
||||
}
|
||||
}
|
@ -17,10 +17,7 @@ import us.myles.ViaVersion.api.platform.ViaPlatform;
|
||||
import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator;
|
||||
import us.myles.ViaVersion.bukkit.commands.BukkitCommandHandler;
|
||||
import us.myles.ViaVersion.bukkit.commands.BukkitCommandSender;
|
||||
import us.myles.ViaVersion.bukkit.platform.BukkitTaskId;
|
||||
import us.myles.ViaVersion.bukkit.platform.BukkitViaAPI;
|
||||
import us.myles.ViaVersion.bukkit.platform.BukkitViaInjector;
|
||||
import us.myles.ViaVersion.bukkit.platform.BukkitViaLoader;
|
||||
import us.myles.ViaVersion.bukkit.platform.*;
|
||||
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
||||
import us.myles.ViaVersion.dump.PluginInfo;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
@ -37,7 +34,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
|
||||
private boolean lateBind = false;
|
||||
private boolean protocolSupport = false;
|
||||
@Getter
|
||||
private ViaConfig conf;
|
||||
private BukkitConfigAPI conf;
|
||||
@Getter
|
||||
private ViaAPI<Player> api = new BukkitViaAPI(this);
|
||||
private List<Runnable> queuedTasks = new ArrayList<>();
|
||||
@ -45,7 +42,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
|
||||
|
||||
public ViaVersionPlugin() {
|
||||
// Config magic
|
||||
conf = new ViaConfig(this);
|
||||
conf = new BukkitConfigAPI();
|
||||
// Command handler
|
||||
commandHandler = new BukkitCommandHandler();
|
||||
// Init platform
|
||||
|
@ -22,8 +22,8 @@ import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||
|
||||
import java.io.DataOutput;
|
||||
|
@ -0,0 +1,173 @@
|
||||
package us.myles.ViaVersion.bukkit.platform;
|
||||
|
||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||
import us.myles.ViaVersion.util.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BukkitConfigAPI extends Config implements ViaVersionConfig {
|
||||
private static List<String> UNSUPPORTED = Arrays.asList();
|
||||
|
||||
public BukkitConfigAPI() {
|
||||
super(new File(((ViaVersionPlugin) Via.getPlatform()).getDataFolder(), "config.yml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckForUpdates() {
|
||||
return getBoolean("checkforupdates", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreventCollision() {
|
||||
return getBoolean("prevent-collision", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewEffectIndicator() {
|
||||
return getBoolean("use-new-effect-indicator", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowNewDeathMessages() {
|
||||
return getBoolean("use-new-deathmessages", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressMetadataErrors() {
|
||||
return getBoolean("suppress-metadata-errors", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShieldBlocking() {
|
||||
return getBoolean("shield-blocking", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHologramPatch() {
|
||||
return getBoolean("hologram-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarPatch() {
|
||||
return getBoolean("bossbar-patch", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarAntiflicker() {
|
||||
return getBoolean("bossbar-anti-flicker", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnknownEntitiesSuppressed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHologramYOffset() {
|
||||
return getDouble("hologram-y", -0.96D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockBreakPatch() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPPS() {
|
||||
return getInt("max-pps", 800);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxPPSKickMessage() {
|
||||
return getString("max-pps-kick-msg", "Sending packets too fast? lag?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrackingPeriod() {
|
||||
return getInt("tracking-period", 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningPPS() {
|
||||
return getInt("tracking-warning-pps", 120);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxWarnings() {
|
||||
return getInt("tracking-max-warnings", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxWarningsKickMessage() {
|
||||
return getString("tracking-max-kick-msg", "You are sending too many packets, :(");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAntiXRay() {
|
||||
return getBoolean("anti-xray-patch", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSendSupportedVersions() {
|
||||
return getBoolean("send-supported-versions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStimulatePlayerTick() {
|
||||
return getBoolean("simulate-pt", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemCache() {
|
||||
return getBoolean("item-cache", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSPlayerTicking() {
|
||||
return getBoolean("nms-player-ticking", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplacePistons() {
|
||||
return getBoolean("replace-pistons", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPistonReplacementId() {
|
||||
return getInt("replacement-piston-id", 0);
|
||||
}
|
||||
|
||||
public boolean isAutoTeam() {
|
||||
// Collision has to be enabled first
|
||||
return isPreventCollision() && getBoolean("auto-team", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForceJsonTransform() {
|
||||
return getBoolean("force-json-transform", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBlockedProtocols() {
|
||||
return getIntegerList("block-protocols");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockedDisconnectMsg() {
|
||||
return getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReloadDisconnectMsg() {
|
||||
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUnsupportedOptions() {
|
||||
return UNSUPPORTED;
|
||||
}
|
||||
}
|
@ -16,8 +16,8 @@ import us.myles.ViaVersion.api.command.ViaVersionCommand;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.boss.ViaBossBar;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.bukkit.util.ProtocolSupportUtil;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
@ -9,9 +9,9 @@ import us.myles.ViaVersion.api.Pair;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.platform.ViaInjector;
|
||||
import us.myles.ViaVersion.bukkit.handlers.BukkitChannelInitializer;
|
||||
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
||||
import us.myles.ViaVersion.util.ConcurrentList;
|
||||
import us.myles.ViaVersion.util.ListWrapper;
|
||||
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -4,10 +4,10 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -12,10 +12,10 @@ import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
|
||||
import us.myles.ViaVersion.api.platform.TaskId;
|
||||
import us.myles.ViaVersion.api.platform.ViaPlatform;
|
||||
import us.myles.ViaVersion.bungee.platform.*;
|
||||
import us.myles.ViaVersion.bungee.commands.BungeeCommand;
|
||||
import us.myles.ViaVersion.bungee.commands.BungeeCommandHandler;
|
||||
import us.myles.ViaVersion.bungee.commands.BungeeCommandSender;
|
||||
import us.myles.ViaVersion.bungee.platform.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -29,7 +29,7 @@ public class Bungee extends Plugin implements ViaPlatform {
|
||||
@Override
|
||||
public void onLoad() {
|
||||
api = new BungeeViaAPI();
|
||||
config = new BungeeConfigAPI();
|
||||
config = new BungeeConfigAPI(getDataFolder());
|
||||
commandHandler = new BungeeCommandHandler();
|
||||
ProxyServer.getInstance().getPluginManager().registerCommand(this, new BungeeCommand(commandHandler));
|
||||
// Init platform
|
||||
|
@ -1,57 +1,66 @@
|
||||
package us.myles.ViaVersion.bungee.platform;
|
||||
|
||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
|
||||
import us.myles.ViaVersion.util.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// TODO implement
|
||||
public class BungeeConfigAPI implements ViaVersionConfig, ConfigurationProvider {
|
||||
public class BungeeConfigAPI extends Config implements ViaVersionConfig {
|
||||
private static List<String> UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch");
|
||||
|
||||
public BungeeConfigAPI(File configFile) {
|
||||
super(new File(configFile, "config.yml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUnsupportedOptions() {
|
||||
return UNSUPPORTED;
|
||||
}
|
||||
|
||||
public boolean isCheckForUpdates() {
|
||||
return false;
|
||||
return getBoolean("checkforupdates", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreventCollision() {
|
||||
return false;
|
||||
return getBoolean("prevent-collision", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewEffectIndicator() {
|
||||
return false;
|
||||
return getBoolean("use-new-effect-indicator", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowNewDeathMessages() {
|
||||
return false;
|
||||
return getBoolean("use-new-deathmessages", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressMetadataErrors() {
|
||||
return false;
|
||||
return getBoolean("suppress-metadata-errors", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShieldBlocking() {
|
||||
return false;
|
||||
return getBoolean("shield-blocking", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHologramPatch() {
|
||||
return false;
|
||||
return getBoolean("hologram-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarPatch() {
|
||||
return false;
|
||||
return getBoolean("bossbar-patch", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarAntiflicker() {
|
||||
return false;
|
||||
return getBoolean("bossbar-anti-flicker", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,12 +70,7 @@ public class BungeeConfigAPI implements ViaVersionConfig, ConfigurationProvider
|
||||
|
||||
@Override
|
||||
public double getHologramYOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoTeam() {
|
||||
return false;
|
||||
return getDouble("hologram-y", -0.96D);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,32 +80,32 @@ public class BungeeConfigAPI implements ViaVersionConfig, ConfigurationProvider
|
||||
|
||||
@Override
|
||||
public int getMaxPPS() {
|
||||
return 0;
|
||||
return getInt("max-pps", 800);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxPPSKickMessage() {
|
||||
return null;
|
||||
return getString("max-pps-kick-msg", "Sending packets too fast? lag?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrackingPeriod() {
|
||||
return 0;
|
||||
return getInt("tracking-period", 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningPPS() {
|
||||
return 0;
|
||||
return getInt("tracking-warning-pps", 120);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxWarnings() {
|
||||
return 0;
|
||||
return getInt("tracking-max-warnings", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaxWarningsKickMessage() {
|
||||
return null;
|
||||
return getString("tracking-max-kick-msg", "You are sending too many packets, :(");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,12 +115,12 @@ public class BungeeConfigAPI implements ViaVersionConfig, ConfigurationProvider
|
||||
|
||||
@Override
|
||||
public boolean isSendSupportedVersions() {
|
||||
return false;
|
||||
return getBoolean("send-supported-versions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStimulatePlayerTick() {
|
||||
return true;
|
||||
return getBoolean("simulate-pt", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,51 +135,36 @@ public class BungeeConfigAPI implements ViaVersionConfig, ConfigurationProvider
|
||||
|
||||
@Override
|
||||
public boolean isReplacePistons() {
|
||||
return false;
|
||||
return getBoolean("replace-pistons", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPistonReplacementId() {
|
||||
return 0;
|
||||
return getInt("replacement-piston-id", 0);
|
||||
}
|
||||
|
||||
public boolean isAutoTeam() {
|
||||
// Collision has to be enabled first
|
||||
return isPreventCollision() && getBoolean("auto-team", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForceJsonTransform() {
|
||||
return false;
|
||||
return getBoolean("force-json-transform", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBlockedProtocols() {
|
||||
return Arrays.asList();
|
||||
return getIntegerList("block-protocols");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockedDisconnectMsg() {
|
||||
return null;
|
||||
return getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReloadDisconnectMsg() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(String path, Object value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getValues() {
|
||||
return null;
|
||||
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmit
|
||||
public class BungeeViaLoader implements ViaPlatformLoader {
|
||||
@Override
|
||||
public void load() {
|
||||
// TODO: Config
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.MinecraftDecoder;
|
||||
import net.md_5.bungee.protocol.MinecraftEncoder;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -11,4 +11,14 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>viaversion-common</artifactId>
|
||||
<dependencies>
|
||||
<!-- Snake YAML -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.18-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -15,7 +15,6 @@ import us.myles.ViaVersion.exception.InformativeException;
|
||||
import us.myles.ViaVersion.packets.Direction;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.util.PipelineUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -102,6 +102,7 @@ public abstract class ViaCommandHandler implements ViaVersionCommand {
|
||||
|
||||
/**
|
||||
* Shows the ViaVersion help to a sender
|
||||
*
|
||||
* @param sender The sender to send the help to
|
||||
*/
|
||||
public void showHelp(ViaCommandSender sender) {
|
||||
|
@ -46,8 +46,8 @@ public enum ArmorType {
|
||||
|
||||
/**
|
||||
* Find an armour type by the item id
|
||||
* @param id ID of the item
|
||||
*
|
||||
* @param id ID of the item
|
||||
* @return Return the ArmourType, ArmourType.NONE if not found
|
||||
*/
|
||||
public static ArmorType findById(int id) {
|
||||
@ -59,8 +59,8 @@ public enum ArmorType {
|
||||
|
||||
/**
|
||||
* Find an armour type by the item string
|
||||
* @param type String name for the item
|
||||
*
|
||||
* @param type String name for the item
|
||||
* @return Return the ArmourType, ArmourType.NONE if not found
|
||||
*/
|
||||
public static ArmorType findByType(String type) {
|
||||
@ -72,6 +72,7 @@ public enum ArmorType {
|
||||
|
||||
/**
|
||||
* Check if an item id is armour
|
||||
*
|
||||
* @param id The item ID
|
||||
* @return True if the item is a piece of armour
|
||||
*/
|
||||
@ -84,6 +85,7 @@ public enum ArmorType {
|
||||
|
||||
/**
|
||||
* Check if an item id is armour
|
||||
*
|
||||
* @param type The item material name
|
||||
* @return True if the item is a piece of armour
|
||||
*/
|
||||
@ -96,6 +98,7 @@ public enum ArmorType {
|
||||
|
||||
/**
|
||||
* Get the Minecraft ID for the Armour Type
|
||||
*
|
||||
* @return The ID
|
||||
*/
|
||||
public int getId() {
|
||||
|
@ -1,29 +1,25 @@
|
||||
package us.myles.ViaVersion.bukkit.util;
|
||||
package us.myles.ViaVersion.util;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import com.google.common.io.CharStreams;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Configuration extends YamlConfiguration {
|
||||
public class CommentStore {
|
||||
private final Map<String, List<String>> headers = Maps.newConcurrentMap();
|
||||
private final File file;
|
||||
private final char pathSeperator;
|
||||
private final int indents;
|
||||
private List<String> mainHeader = Lists.newArrayList();
|
||||
private boolean loadHeaders;
|
||||
|
||||
public Configuration(File file) {
|
||||
this.file = file;
|
||||
public CommentStore(char pathSeperator, int indents) {
|
||||
this.pathSeperator = pathSeperator;
|
||||
this.indents = indents;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,43 +61,13 @@ public class Configuration extends YamlConfiguration {
|
||||
return headers.get(key);
|
||||
}
|
||||
|
||||
public <T> T get(String key, Class<T> type) {
|
||||
return type.cast(get(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload config from file.
|
||||
*/
|
||||
public void reload() {
|
||||
reload(headers.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload config from file.
|
||||
*
|
||||
* @param loadHeaders Whether or not to load headers.
|
||||
*/
|
||||
public void reload(boolean loadHeaders) {
|
||||
this.loadHeaders = loadHeaders;
|
||||
try {
|
||||
load(file);
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "failed to reload file", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFromString(String contents) throws InvalidConfigurationException {
|
||||
if (!loadHeaders) {
|
||||
super.loadFromString(contents);
|
||||
return;
|
||||
}
|
||||
public void storeComments(InputStream inputStream) throws IOException {
|
||||
InputStreamReader reader = new InputStreamReader(inputStream);
|
||||
String contents = CharStreams.toString(reader);
|
||||
|
||||
StringBuilder memoryData = new StringBuilder();
|
||||
|
||||
// Parse headers
|
||||
final int indentLength = options().indent();
|
||||
final String pathSeparator = Character.toString(options().pathSeparator());
|
||||
final String pathSeparator = Character.toString(this.pathSeperator);
|
||||
int currentIndents = 0;
|
||||
String key = "";
|
||||
List<String> headers = Lists.newArrayList();
|
||||
@ -122,12 +88,12 @@ public class Configuration extends YamlConfiguration {
|
||||
continue;
|
||||
}
|
||||
|
||||
int indents = indent / indentLength;
|
||||
int indents = indent / this.indents;
|
||||
if (indents <= currentIndents) {
|
||||
// Remove last section of key
|
||||
String[] array = key.split(Pattern.quote(pathSeparator));
|
||||
int backspace = currentIndents - indents + 1;
|
||||
key = join(array, options().pathSeparator(), 0, array.length - backspace);
|
||||
key = join(array, this.pathSeperator, 0, array.length - backspace);
|
||||
}
|
||||
|
||||
// Add new section to key
|
||||
@ -143,32 +109,13 @@ public class Configuration extends YamlConfiguration {
|
||||
headers = Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
|
||||
// Parse remaining text
|
||||
super.loadFromString(memoryData.toString());
|
||||
|
||||
// Clear bukkit header
|
||||
options().header(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save config to file
|
||||
*/
|
||||
public void save() {
|
||||
if (headers.isEmpty() && mainHeader.isEmpty()) {
|
||||
try {
|
||||
super.save(file);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to save file", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public void writeComments(String yaml, File output) throws IOException {
|
||||
// Custom save
|
||||
final int indentLength = options().indent();
|
||||
final String pathSeparator = Character.toString(options().pathSeparator());
|
||||
String content = saveToString();
|
||||
StringBuilder fileData = new StringBuilder(buildHeader());
|
||||
final int indentLength = this.indents;
|
||||
final String pathSeparator = Character.toString(this.pathSeperator);
|
||||
StringBuilder fileData = new StringBuilder();
|
||||
int currentIndents = 0;
|
||||
String key = "";
|
||||
for (String h : mainHeader) {
|
||||
@ -176,7 +123,7 @@ public class Configuration extends YamlConfiguration {
|
||||
fileData.append("#> ").append(h).append('\n');
|
||||
}
|
||||
|
||||
for (String line : content.split("\n")) {
|
||||
for (String line : yaml.split("\n")) {
|
||||
if (line.isEmpty()) continue; // Skip empty lines
|
||||
int indent = getSuccessiveCharCount(line, ' ');
|
||||
int indents = indent / indentLength;
|
||||
@ -185,7 +132,7 @@ public class Configuration extends YamlConfiguration {
|
||||
// Remove last section of key
|
||||
String[] array = key.split(Pattern.quote(pathSeparator));
|
||||
int backspace = currentIndents - indents + 1;
|
||||
key = join(array, options().pathSeparator(), 0, array.length - backspace);
|
||||
key = join(array, this.pathSeperator, 0, array.length - backspace);
|
||||
}
|
||||
|
||||
// Add new section to key
|
||||
@ -203,11 +150,9 @@ public class Configuration extends YamlConfiguration {
|
||||
// Write data to file
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(file);
|
||||
writer = new FileWriter(output);
|
||||
writer.write(fileData.toString());
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to save file", e);
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
try {
|
150
common/src/main/java/us/myles/ViaVersion/util/Config.java
Normal file
150
common/src/main/java/us/myles/ViaVersion/util/Config.java
Normal file
@ -0,0 +1,150 @@
|
||||
package us.myles.ViaVersion.util;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class Config implements ConfigurationProvider {
|
||||
private static ThreadLocal<Yaml> yaml = new ThreadLocal<Yaml>() {
|
||||
@Override
|
||||
protected Yaml initialValue() {
|
||||
return new Yaml();
|
||||
}
|
||||
};
|
||||
private CommentStore commentStore = new CommentStore('.', 2);
|
||||
private final File configFile;
|
||||
private Map<String, Object> config;
|
||||
|
||||
public Config(File configFile) {
|
||||
this.configFile = configFile;
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public Map<String, Object> loadConfig(File location) {
|
||||
List<String> unsupported = getUnsupportedOptions();
|
||||
URL jarConfigFile = Config.class.getClassLoader().getResource("config.yml");
|
||||
try {
|
||||
commentStore.storeComments(jarConfigFile.openStream());
|
||||
for (String option : unsupported) {
|
||||
List<String> comments = commentStore.header(option);
|
||||
if (comments != null) {
|
||||
comments.clear();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Map<String, Object> config = null;
|
||||
if (location.exists()) {
|
||||
try (FileInputStream input = new FileInputStream(location)) {
|
||||
config = (Map<String, Object>) yaml.get().load(input);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (config == null) {
|
||||
config = new HashMap<>();
|
||||
}
|
||||
|
||||
Map<String, Object> defaults = config;
|
||||
try (InputStream stream = jarConfigFile.openStream()) {
|
||||
defaults = (Map<String, Object>) yaml.get().load(stream);
|
||||
for (String option : unsupported) {
|
||||
defaults.remove(option);
|
||||
}
|
||||
// Merge with defaultLoader
|
||||
for (Object key : config.keySet()) {
|
||||
// Set option in new conf if exists
|
||||
if (defaults.containsKey(key) && !unsupported.contains(key.toString())) {
|
||||
defaults.put((String) key, config.get(key));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Save
|
||||
saveConfig(location, defaults);
|
||||
|
||||
return defaults;
|
||||
}
|
||||
|
||||
public void saveConfig(File location, Map<String, Object> config) {
|
||||
try {
|
||||
commentStore.writeComments(yaml.get().dump(config), location);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract List<String> getUnsupportedOptions();
|
||||
|
||||
@Override
|
||||
public void set(String path, Object value) {
|
||||
set(path, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
this.configFile.getParentFile().mkdirs();
|
||||
saveConfig(this.configFile, this.config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
this.configFile.getParentFile().mkdirs();
|
||||
this.config = loadConfig(this.configFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getValues() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public boolean getBoolean(String key, boolean def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (boolean) this.config.get(key);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String key, String def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (String) this.config.get(key);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public int getInt(String key, int def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (int) this.config.get(key);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDouble(String key, double def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (double) this.config.get(key);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Integer> getIntegerList(String key) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (List<Integer>) this.config.get(key);
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ import com.google.common.collect.Maps;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
@ -32,7 +32,7 @@ reload-disconnect-msg: "Server reload, please rejoin!"
|
||||
#
|
||||
# What is the maximum per second a client can send (Use %pps to display their pps)
|
||||
# Use -1 to disable.
|
||||
max-pps: 600
|
||||
max-pps: 800
|
||||
max-pps-kick-msg: "You are sending too many packets!"
|
||||
#
|
||||
# We can also kick them if over a period they send over a threshold a certain amount of times.
|
@ -1,29 +1,22 @@
|
||||
package us.myles.ViaVersion.sponge.platform;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
|
||||
import us.myles.ViaVersion.util.Config;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SpongeConfigAPI implements ViaVersionConfig, ConfigurationProvider {
|
||||
private final File defaultConfig;
|
||||
private Map<Object, Object> config;
|
||||
private ThreadLocal<Yaml> yaml = new ThreadLocal<Yaml>() {
|
||||
@Override
|
||||
protected Yaml initialValue() {
|
||||
return new Yaml();
|
||||
}
|
||||
};
|
||||
public class SpongeConfigAPI extends Config implements ViaVersionConfig {
|
||||
private static List<String> UNSUPPORTED = Arrays.asList("anti-xray-patch");
|
||||
|
||||
public SpongeConfigAPI(File defaultConfig) {
|
||||
this.defaultConfig = defaultConfig;
|
||||
reloadConfig();
|
||||
public SpongeConfigAPI(File configFile) {
|
||||
super(new File(configFile, "config.yml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUnsupportedOptions() {
|
||||
return UNSUPPORTED;
|
||||
}
|
||||
|
||||
public boolean isCheckForUpdates() {
|
||||
@ -87,7 +80,7 @@ public class SpongeConfigAPI implements ViaVersionConfig, ConfigurationProvider
|
||||
|
||||
@Override
|
||||
public int getMaxPPS() {
|
||||
return getInt("max-pps", 140);
|
||||
return getInt("max-pps", 800);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,7 +110,7 @@ public class SpongeConfigAPI implements ViaVersionConfig, ConfigurationProvider
|
||||
|
||||
@Override
|
||||
public boolean isAntiXRay() {
|
||||
return getBoolean("anti-xray-patch", true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -174,107 +167,4 @@ public class SpongeConfigAPI implements ViaVersionConfig, ConfigurationProvider
|
||||
public String getReloadDisconnectMsg() {
|
||||
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(String path, Object value) {
|
||||
config.put(path, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
if (!defaultConfig.isDirectory()) {
|
||||
defaultConfig.mkdir();
|
||||
}
|
||||
File config = new File(defaultConfig, "config.yml");
|
||||
try (FileWriter fw = new FileWriter(config)) {
|
||||
yaml.get().dump(this.config, fw);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
if (!defaultConfig.isDirectory()) {
|
||||
defaultConfig.mkdir();
|
||||
}
|
||||
File config = new File(defaultConfig, "config.yml");
|
||||
URL jarConfigFile = this.getClass().getClassLoader().getResource("config.yml");
|
||||
this.config = null;
|
||||
if (config.exists()) {
|
||||
try (FileInputStream input = new FileInputStream(config)) {
|
||||
this.config = (Map<Object, Object>) yaml.get().load(input);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (this.config == null) {
|
||||
this.config = new HashMap<>();
|
||||
}
|
||||
Map<Object, Object> defaults;
|
||||
try (InputStream stream = jarConfigFile.openStream()) {
|
||||
defaults = (Map<Object, Object>) yaml.get().load(stream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
// Merge with defaultLoader
|
||||
for (Object key : this.config.keySet()) {
|
||||
// Set option in new conf if exists
|
||||
if (defaults.containsKey(key)) {
|
||||
defaults.put(key, this.config.get(key));
|
||||
}
|
||||
}
|
||||
this.config = defaults;
|
||||
// Save
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
public boolean getBoolean(String key, boolean def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (boolean) this.config.get(key);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String key, String def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (String) this.config.get(key);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public int getInt(String key, int def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (int) this.config.get(key);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDouble(String key, double def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (double) this.config.get(key);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Integer> getIntegerList(String key) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (List<Integer>) this.config.get(key);
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getValues() {
|
||||
return (Map<String, Object>) ((Map) this.config);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user