From 35ff7494a4978136d621c7f50491335a406a7d68 Mon Sep 17 00:00:00 2001 From: Robinson Gallego Date: Wed, 6 Nov 2019 21:29:04 -0500 Subject: [PATCH] ivan did this --- .../totalfreedommod/ConfigConverter.java | 168 ------------------ .../totalfreedommod/TotalFreedomMod.java | 3 - .../totalfreedommod/blocking/SignBlocker.java | 2 +- .../totalfreedommod/command/Command_cuck.java | 9 +- 4 files changed, 3 insertions(+), 179 deletions(-) delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/ConfigConverter.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ConfigConverter.java b/src/main/java/me/totalfreedom/totalfreedommod/ConfigConverter.java deleted file mode 100644 index 2693914f..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/ConfigConverter.java +++ /dev/null @@ -1,168 +0,0 @@ -package me.totalfreedom.totalfreedommod; - -import com.google.common.collect.Lists; -import com.google.common.io.Files; -import java.io.File; -import java.io.IOException; -import java.util.Date; -import java.util.List; -import me.totalfreedom.totalfreedommod.admin.Admin; -import me.totalfreedom.totalfreedommod.admin.AdminList; -import me.totalfreedom.totalfreedommod.banning.PermbanList; -import me.totalfreedom.totalfreedommod.rank.Rank; -import net.pravian.aero.component.PluginComponent; -import net.pravian.aero.config.YamlConfig; -import org.bukkit.configuration.ConfigurationSection; - -public class ConfigConverter extends PluginComponent -{ - - public static final int CURRENT_CONFIG_VERSION = 1; - - public ConfigConverter(TotalFreedomMod plugin) - { - super(plugin); - } - - public void convert() - { - File data = plugin.getDataFolder(); - data.mkdirs(); - File versionFile = new File(data, "version.yml"); - - boolean convert = false; - if (!versionFile.exists() && data.listFiles().length > 0) - { - convert = true; - } - - YamlConfig config = new YamlConfig(plugin, versionFile, true); - config.load(); - - if (config.getInt("version", -1) < CURRENT_CONFIG_VERSION) - { - convert = true; - } - - if (!convert) - { - return; - } - - logger.warning("Converting old configs to new format..."); - - File backup = new File(data, "backup_old_format"); - backup.mkdirs(); - - for (File file : data.listFiles()) - { - if (file.equals(backup) || file.equals(versionFile)) - { - continue; - } - - try - { - Files.move(file, new File(backup, file.getName())); - } - catch (IOException ex) - { - logger.severe("Could not backup file: " + file.getName()); - logger.severe(ex); - } - } - - convertSuperadmins(new File(backup, "superadmin.yml")); - convertPermbans(new File(backup, "permban.yml")); - - logger.info("Conversion complete!"); - } - - private void convertSuperadmins(File oldFile) - { - if (!oldFile.exists() || !oldFile.isFile()) - { - logger.warning("No old superadmin list found!"); - return; - } - - // Convert old admin list - YamlConfig oldYaml = new YamlConfig(plugin, oldFile, false); - oldYaml.load(); - - ConfigurationSection admins = oldYaml.getConfigurationSection("admins"); - if (admins == null) - { - logger.warning("No admin section in superadmin list!"); - return; - } - - List conversions = Lists.newArrayList(); - for (String uuid : admins.getKeys(false)) - { - ConfigurationSection asec = admins.getConfigurationSection(uuid); - if (asec == null) - { - logger.warning("Invalid superadmin format for admin: " + uuid); - continue; - } - - String username = asec.getString("last_login_name"); - Rank rank; - if (asec.getBoolean("is_senior_admin")) - { - rank = Rank.SENIOR_ADMIN; - } - else if (asec.getBoolean("is_telnet_admin")) - { - rank = Rank.TELNET_ADMIN; - } - else - { - rank = Rank.SUPER_ADMIN; - } - List ips = asec.getStringList("ips"); - String loginMessage = asec.getString("custom_login_message"); - boolean active = asec.getBoolean("is_activated"); - - Admin admin = new Admin(username); - admin.setName(username); - admin.setRank(rank); - admin.addIps(ips); - admin.setLoginMessage(loginMessage); - admin.setActive(active); - admin.setLastLogin(new Date()); - conversions.add(admin); - } - - YamlConfig newYaml = new YamlConfig(plugin, AdminList.CONFIG_FILENAME); - for (Admin admin : conversions) - { - admin.saveTo(newYaml.createSection(admin.getName().toLowerCase())); - } - newYaml.save(); - - logger.info("Converted " + conversions.size() + " admins"); - } - - private void convertPermbans(File oldFile) - { - if (!oldFile.exists()) - { - logger.warning("No old permban list found!"); - return; - } - - try - { - Files.copy(oldFile, new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME)); - logger.info("Converted permban list"); - } - catch (IOException ex) - { - logger.warning("Could not copy old permban list!"); - } - - } - -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 881eb8bb..48893d42 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -168,9 +168,6 @@ public class TotalFreedomMod extends AeroPlugin FUtil.deleteCoreDumps(); FUtil.deleteFolder(new File("./_deleteme")); - // Convert old config files - new ConfigConverter(plugin).convert(); - BackupManager backups = new BackupManager(this); backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true); backups.createBackups(AdminList.CONFIG_FILENAME); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java index 26ef97d3..2e855008 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java @@ -38,7 +38,7 @@ public class SignBlocker extends FreedomService { final Player player = event.getPlayer(); - if (Tag.SIGNS.getValues().contains(event.getBlock().getType()) + if (Tag.SIGNS.getValues().contains(event.getBlock().getType())) { ItemStack sign = event.getItemInHand(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cuck.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cuck.java index 6ed44560..c99cb867 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cuck.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cuck.java @@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.ChatColor; -@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH) +@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Cuck someone", usage = "/ ") public class Command_cuck extends FreedomCommand { @@ -18,11 +18,6 @@ public class Command_cuck extends FreedomCommand public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (!FUtil.isExecutive(sender.getName())) - { - return noPerms(); - } - if (args.length == 0) { return false; @@ -49,7 +44,7 @@ public class Command_cuck extends FreedomCommand @Override public List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) { - if (args.length == 1 && plugin.al.isAdmin(sender) && FUtil.isExecutive(sender.getName())) + if (args.length == 1 && plugin.al.isAdmin(sender)) { return FUtil.getPlayerList(); }