TotalFreedomMod Electrum

Version 5.0

This TotalFreedomMod release implements many changes. Most notably, the
internals have been completely revamped. TotalFreedomMod now relies on the
Aero library for core mechanics such as command handling and services.

Another important change is the UUID system. In TotalFreedomMod Electrum,
it has been completely removed. The core reason for this is that the
system as a whole was very bugged. Additionally, it did not solve the
primary reason for its conception: preserving player data when the player
changes their username. This is because TotalFreedomMod servers usually
run in offline-mode. This meaning that some of the players joining do not
have a registerd Mojang UUID whatsoever. All in all, the UUID system was
buggy, and it did not fix the reason it was implemented, so it has been
completely removed. The admin list and the ban list now use usernames and
IPs again.

Lastly, many smaller changes have been implemented. Due to the amount of
changes, they have not been named individualy. Please refer to the issues
below for more details.

Fixes #342
Fixes #350
Fixes #380
Fixes #684
Fixes #704
Fixes #716
Fixes #735
Fixes #745
Fixes #784
Fixes #765
Fixes #791
Fixes #805
Fixes #826
Fixes #883
Fixes #1524
Fixes #1534
Fixes #1536
Fixes #1538
Fixes #1545
Fixes #1546
Fixes #1568
Fixes #1627
Resolves #403
Resolves #435
Resolves #597
Resolves #603
Resolves #628
Resolves #690
Resolves #708
Resolves #747
Resolves #748
Resolves #749
Resolves #764
Resolves #767
Resolves #782
Resolves #809
Resolves #803
Resolves #811
Resolves #813
Resolves #830
Resolves #848
Resolves #856
Resolves #876
Resolves #908
Resolves #992
Resolves #1018
Resolves #1432
Resolves #1446
Resolves #1494
Resolves #1501
Resolves #1526
Resolves #1540
Resolves #1550
Resolves #1560
Resolves #1561
Resolves #1578
Resolves #1613
This commit is contained in:
Jerom van der Sar
2016-05-12 21:40:39 +02:00
parent 924f718d5a
commit aca3398d21
109 changed files with 2112 additions and 2036 deletions

View File

@ -1,34 +0,0 @@
package me.totalfreedom.totalfreedommod.config;
import java.io.File;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
public class ConfigConverter
{
public static void convert()
{
for (File file : new File(TotalFreedomMod.plugin.getDataFolder(), "players").listFiles())
{
if (file.isDirectory())
{
continue;
}
final UUID uuid;
try
{
uuid = UUID.fromString(file.getName().split(".")[0]);
}
catch (IllegalArgumentException ex)
{
continue;
}
}
}
}

View File

@ -1,6 +1,7 @@
package me.totalfreedom.totalfreedommod.config;
import java.util.List;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
public enum ConfigEntry
{
@ -106,51 +107,62 @@ public enum ConfigEntry
public String getString()
{
return MainConfig.getString(this);
return getConfig().getString(this);
}
public String setString(String value)
{
MainConfig.setString(this, value);
getConfig().setString(this, value);
return value;
}
public Double getDouble()
{
return MainConfig.getDouble(this);
return getConfig().getDouble(this);
}
public Double setDouble(Double value)
{
MainConfig.setDouble(this, value);
getConfig().setDouble(this, value);
return value;
}
public Boolean getBoolean()
{
return MainConfig.getBoolean(this);
return getConfig().getBoolean(this);
}
public Boolean setBoolean(Boolean value)
{
MainConfig.setBoolean(this, value);
getConfig().setBoolean(this, value);
return value;
}
public Integer getInteger()
{
return MainConfig.getInteger(this);
return getConfig().getInteger(this);
}
public Integer setInteger(Integer value)
{
MainConfig.setInteger(this, value);
getConfig().setInteger(this, value);
return value;
}
public List<?> getList()
{
return MainConfig.getList(this);
return getConfig().getList(this);
}
@SuppressWarnings("unchecked")
public List<String> getStringList()
{
return (List<String>) getList();
}
private MainConfig getConfig()
{
return TotalFreedomMod.plugin().config;
}
public static ConfigEntry findConfigEntry(String name)

View File

@ -9,41 +9,45 @@ import java.util.EnumMap;
import java.util.List;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.component.PluginComponent;
import org.apache.commons.io.FileUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
public class MainConfig
public class MainConfig extends PluginComponent<TotalFreedomMod>
{
public static final File CONFIG_FILE = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.CONFIG_FILENAME);
public static final String CONFIG_FILENAME = "config.yml";
//
private static final EnumMap<ConfigEntry, Object> ENTRY_MAP;
private static final TFM_Defaults DEFAULTS;
private final EnumMap<ConfigEntry, Object> entries;
private final ConfigDefaults defaults;
static
public MainConfig(TotalFreedomMod plugin)
{
ENTRY_MAP = new EnumMap<>(ConfigEntry.class);
super(plugin);
TFM_Defaults tempDefaults = null;
entries = new EnumMap<>(ConfigEntry.class);
ConfigDefaults tempDefaults = null;
try
{
try
{
InputStream defaultConfig = getDefaultConfig();
tempDefaults = new TFM_Defaults(defaultConfig);
for (ConfigEntry entry : ConfigEntry.values())
try (InputStream defaultConfig = getDefaultConfig())
{
ENTRY_MAP.put(entry, tempDefaults.get(entry.getConfigName()));
tempDefaults = new ConfigDefaults(defaultConfig);
for (ConfigEntry entry : ConfigEntry.values())
{
entries.put(entry, tempDefaults.get(entry.getConfigName()));
}
}
defaultConfig.close();
}
catch (IOException ex)
{
FLog.severe(ex);
}
copyDefaultConfig(CONFIG_FILE);
copyDefaultConfig(getConfigFile());
load();
}
@ -52,21 +56,16 @@ public class MainConfig
FLog.severe(ex);
}
DEFAULTS = tempDefaults;
defaults = tempDefaults;
}
private MainConfig()
{
throw new AssertionError();
}
public static void load()
public void load()
{
try
{
YamlConfiguration config = new YamlConfiguration();
config.load(CONFIG_FILE);
config.load(getConfigFile());
for (ConfigEntry entry : ConfigEntry.values())
{
@ -76,7 +75,7 @@ public class MainConfig
Object value = config.get(path);
if (value == null || entry.getType().isAssignableFrom(value.getClass()))
{
ENTRY_MAP.put(entry, value);
entries.put(entry, value);
}
else
{
@ -90,21 +89,18 @@ public class MainConfig
}
}
}
catch (FileNotFoundException ex)
{
FLog.severe(ex);
}
catch (IOException ex)
{
FLog.severe(ex);
}
catch (InvalidConfigurationException ex)
catch (IOException | InvalidConfigurationException ex)
{
FLog.severe(ex);
}
}
public static String getString(ConfigEntry entry)
private File getConfigFile()
{
return new File(plugin.getDataFolder(), "config.yml");
}
public String getString(ConfigEntry entry)
{
try
{
@ -117,7 +113,7 @@ public class MainConfig
return null;
}
public static void setString(ConfigEntry entry, String value)
public void setString(ConfigEntry entry, String value)
{
try
{
@ -129,7 +125,7 @@ public class MainConfig
}
}
public static Double getDouble(ConfigEntry entry)
public Double getDouble(ConfigEntry entry)
{
try
{
@ -142,7 +138,7 @@ public class MainConfig
return null;
}
public static void setDouble(ConfigEntry entry, Double value)
public void setDouble(ConfigEntry entry, Double value)
{
try
{
@ -154,7 +150,7 @@ public class MainConfig
}
}
public static Boolean getBoolean(ConfigEntry entry)
public Boolean getBoolean(ConfigEntry entry)
{
try
{
@ -167,7 +163,7 @@ public class MainConfig
return null;
}
public static void setBoolean(ConfigEntry entry, Boolean value)
public void setBoolean(ConfigEntry entry, Boolean value)
{
try
{
@ -179,7 +175,7 @@ public class MainConfig
}
}
public static Integer getInteger(ConfigEntry entry)
public Integer getInteger(ConfigEntry entry)
{
try
{
@ -192,7 +188,7 @@ public class MainConfig
return null;
}
public static void setInteger(ConfigEntry entry, Integer value)
public void setInteger(ConfigEntry entry, Integer value)
{
try
{
@ -204,7 +200,7 @@ public class MainConfig
}
}
public static List getList(ConfigEntry entry)
public List getList(ConfigEntry entry)
{
try
{
@ -217,9 +213,9 @@ public class MainConfig
return null;
}
public static <T> T get(ConfigEntry entry, Class<T> type) throws IllegalArgumentException
public <T> T get(ConfigEntry entry, Class<T> type) throws IllegalArgumentException
{
Object value = ENTRY_MAP.get(entry);
Object value = entries.get(entry);
try
{
return type.cast(value);
@ -230,7 +226,7 @@ public class MainConfig
}
}
public static <T> void set(ConfigEntry entry, T value, Class<T> type) throws IllegalArgumentException
public <T> void set(ConfigEntry entry, T value, Class<T> type) throws IllegalArgumentException
{
if (!type.isAssignableFrom(entry.getType()))
{
@ -240,10 +236,10 @@ public class MainConfig
{
throw new IllegalArgumentException("Value is not of type " + type.getSimpleName());
}
ENTRY_MAP.put(entry, value);
entries.put(entry, value);
}
private static void copyDefaultConfig(File targetFile)
private void copyDefaultConfig(File targetFile)
{
if (targetFile.exists())
{
@ -254,9 +250,10 @@ public class MainConfig
try
{
InputStream defaultConfig = getDefaultConfig();
FileUtils.copyInputStreamToFile(defaultConfig, targetFile);
defaultConfig.close();
try (InputStream defaultConfig = getDefaultConfig())
{
FileUtils.copyInputStreamToFile(defaultConfig, targetFile);
}
}
catch (IOException ex)
{
@ -264,22 +261,22 @@ public class MainConfig
}
}
private static InputStream getDefaultConfig()
private InputStream getDefaultConfig()
{
return TotalFreedomMod.plugin.getResource(TotalFreedomMod.CONFIG_FILENAME);
return plugin.getResource(TotalFreedomMod.CONFIG_FILENAME);
}
public static TFM_Defaults getDefaults()
public ConfigDefaults getDefaults()
{
return DEFAULTS;
return defaults;
}
public static class TFM_Defaults
public static class ConfigDefaults
{
private YamlConfiguration defaults = null;
private TFM_Defaults(InputStream defaultConfig)
private ConfigDefaults(InputStream defaultConfig)
{
try
{