Added configuration conversion!

This commit is contained in:
BuildTools 2019-09-12 15:53:52 -05:00
parent a25e134f20
commit 8ede39413c
4 changed files with 297 additions and 129 deletions

View File

@ -0,0 +1,27 @@
package com.massivecraft.factions.cmd.config;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdConvertConfig extends FCommand {
public CmdConvertConfig() {
super();
this.aliases.add("convertconfig");
this.permission = Permission.CONVERTCONFIG.node;
this.disableOnLock = false;
senderMustBePlayer = true;
}
@Override
public void perform() {
ConvertConfigHandler.convertconfig(fme.getPlayer());
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_CONVERTCONFIG_DESCRIPTION;
}
}

View File

@ -0,0 +1,137 @@
package com.massivecraft.factions.cmd.config;
import com.massivecraft.factions.P;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class ConvertConfigHandler {
static File savageConfigFile = new File("plugins/Factions/SavageFactions/config.yml");
static FileConfiguration sv = YamlConfiguration.loadConfiguration(savageConfigFile);
static File configFile = new File("plugins/Factions/config.yml");
static FileConfiguration sb = YamlConfiguration.loadConfiguration(configFile);
public static void setString(String s){
sb.set(s, sv.getString(s));
}
public static void setInt(String s){
sb.set(s, sv.getInt(s));
}
public static void setConfigSec(String s){
ConfigurationSection cs = sv.getConfigurationSection(s);
sb.set(s, cs);
}
static JavaPlugin plugin = JavaPlugin.getProvidingPlugin(P.class);
public static void setBoolean(String s){
sb.set(s, sv.getBoolean(s));
}
public static void convertconfig(Player player) {
if (new File("plugins/Factions/SavageFactions/config.yml").exists()) {
BukkitScheduler scheduler = plugin.getServer().getScheduler();
scheduler.scheduleAsyncDelayedTask(plugin, () -> {
File savageConfigFile = new File("plugins/Factions/SavageFactions/config.yml");
FileConfiguration sv = YamlConfiguration.loadConfiguration(savageConfigFile);
File configFile = new File("plugins/Factions/config.yml");
FileConfiguration sb = YamlConfiguration.loadConfiguration(configFile);
sb.set("ConfigConvertedFromSavageFactions", true);
sb.set("debug", sv.getBoolean("debug"));
ConfigurationSection ffe = sv.getConfigurationSection("findfactionsexploit");
sb.set("findfactionsexploit", ffe);
setString("default-relation");
ConfigurationSection pC = sv.getConfigurationSection("portals");
sb.set("portals", pC);
sb.set("maxwarps", sv.getInt("maxwarps"));
setConfigSec("warp-cost");
setBoolean("enable-faction-flight");
setBoolean("ffly.AutoEnable");
setInt("fly-falldamage-cooldown");
setBoolean("disable-pistons-in-territory");
setConfigSec("tooltips");
setConfigSec("scoreboard");
sb.set("scoreboard.also-send-chat", true);
setConfigSec("warmups");
setConfigSec("max-relations");
setInt("world-border.buffer");
setConfigSec("hcf");
sb.set("show", sv.getStringList("show"));
setBoolean("show-exempt");
sb.set("map", sv.getStringList("map"));
setConfigSec("list");
setBoolean("use-old-help");
setConfigSec("help");
setConfigSec("fperm-gui");
sb.set("fperm-gui.action.slots.check", 50);
setConfigSec("fwarp-gui");
setBoolean("faction-creation-broadcast");
setBoolean("faction-disband-broadcast");
setBoolean("See-Invisible-Faction-Members");
setConfigSec("frules");
setConfigSec("ftnt");
setBoolean("fpaypal.Enabled");
setBoolean("checkpoints.Enabled");
setConfigSec("fnear");
setConfigSec("ffocus");
setConfigSec("fvualt");
sb.set("fupgrades.MainMenu.DummyItem.slots", sv.getStringList("fupgrades.MainMenu.DummyItem.slots"));
setConfigSec("fupgrades.MainMenu.Crops.Crop-Boost");
setConfigSec("fupgrades.MainMenu.Crops.Cost");
sb.set("fupgrades.MainMenu.Crops.CropItem", sv.getConfigurationSection("fupgrades.MainMenu.Crops.DisplayItem"));
setConfigSec("fupgrades.MainMenu.EXP.EXP-Boost");
setConfigSec("fupgrades.MainMenu.EXP.Cost");
sb.set("fupgrades.MainMenu.EXP.EXPItem", sv.getConfigurationSection("fupgrades.MainMenu.EXP.DisplayItem"));
setConfigSec("fupgrades.MainMenu.Power.Power-Boost");
setConfigSec("fupgrades.MainMenu.Power.Cost");
sb.set("fupgrades.MainMenu.Power.PowerItem", sv.getConfigurationSection("fupgrades.MainMenu.Power.DisplayItem"));
List<Integer> p = new ArrayList();
p.add(sv.getInt("fupgrades.MainMenu.Power.DisplayItem.Slot"));
sb.set("fupgrades.MainMenu.Power.PowerItem.slots", p);
sb.set("fupgrades.MainMenu.Power.PowerItem.Amount", 1);
sb.set("fupgrades.MainMenu.Power.PowerItem.Damage", 0);
sb.set("fupgrades.MainMenu.Power.PowerItem.Slot", null);
sb.set("fupgrades.MainMenu.Members.Members-Limit", sv.getConfigurationSection("fupgrades.MainMenu.Members.Members-Boost"));
setConfigSec("fupgrades.MainMenu.Spawners.Spawner-Boost");
setConfigSec("fupgrades.MainMenu.Spawners.Cost");
sb.set("fupgrades.MainMenu.Spawners.SpawnerItem", sv.getConfigurationSection("fupgrades.MainMenu.Spawners.DisplayItem"));
setConfigSec("fupgrades.MainMenu.Chest.Chest-Size");
setConfigSec("fupgrades.MainMenu.Chest.Cost");
sb.set("fupgrades.MainMenu.Chest.ChestItem", sv.getConfigurationSection("fupgrades.MainMenu.Chest.DisplayItem"));
setConfigSec("fupgrades.MainMenu.Members.Cost");
sb.set("fupgrades.MainMenu.Members.MembersItem", sv.getConfigurationSection("fupgrades.MainMenu.Members.DisplayItem"));
sb.set("fupgrades.MainMenu.Members.MembersItem.Amount", 1);
sb.set("fupgrades.MainMenu.Members.MembersItem.Damage", 0);
if (sv.getString("fupgrades.MainMenu.Members.DisplayItem.Type").equalsIgnoreCase("PLAYER_HEAD"))
sb.set("fupgrades.MainMenu.Members.MembersItem.Type", "PAPER");
List<Integer> x = new ArrayList();
x.add(sv.getInt("fupgrades.MainMenu.Members.DisplayItem.Slot"));
sb.set("fupgrades.MainMenu.Members.MembersItem.slots", x);
sb.set("fupgrades.MainMenu.Members.MembersItem.Slot", null);
sb.set("fupgrades.MainMenu.Members.Members-Limit", sv.getConfigurationSection("fupgrades.MainMenu.Members.Members-Boost"));
setConfigSec("fbanners");
setConfigSec("Title");
setConfigSec("see-chunk");
setConfigSec("Tntfill");
try {
sb.save(configFile);
P.p.reloadConfig();
} catch (IOException e) {
player.sendMessage(TL.COMMAND_CONVERTCONFIG_FAIL.toString());
Bukkit.getLogger().log(Level.SEVERE, e.getStackTrace().toString());
}
player.sendMessage(TL.COMMAND_CONVERTCONFIG_SUCCESS.toString());
}, 0L);
} else {
player.sendMessage(TL.COMMAND_CONVERTCONFIG_FAILCONFIGMISSING.toString());
}
}
}

View File

@ -4,137 +4,136 @@ import com.massivecraft.factions.P;
import org.bukkit.command.CommandSender;
public enum Permission {
MANAGE_SAFE_ZONE("managesafezone"),
MANAGE_WAR_ZONE("managewarzone"),
OWNERSHIP_BYPASS("ownershipbypass"),
ADMIN("admin"),
ALTS("alts"),
ADMIN_ANY("admin.any"),
AHOME("ahome"),
ANNOUNCE("announce"),
AUTOCLAIM("autoclaim"),
AUTO_LEAVE_BYPASS("autoleavebypass"),
BAN("ban"),
BYPASS("bypass"),
CHAT("chat"),
CHATSPY("chatspy"),
CHECK("check"),
CLAIM("claim"),
CLAIMAT("claimat"),
CLAIM_LINE("claim.line"),
CLAIM_RADIUS("claim.radius"),
CONFIG("config"),
CONVERT("convert"),
CREATE("create"),
CORNER("corner"),
DEFAULTRANK("defaultrank"),
DEINVITE("deinvite"),
DELHOME("delhome"),
DESCRIPTION("description"),
DISBAND("disband"),
DISBAND_ANY("disband.any"),
FLY("fly"),
FOCUS("focus"),
GRACE("grace"),
HELP("help"),
HOME("home"),
INVITE("invite"),
INVSEE("invsee"),
JOIN("join"),
JOIN_ANY("join.any"),
JOIN_OTHERS("join.others"),
KICK("kick"),
KICK_ANY("kick.any"),
LEAVE("leave"),
LIST("list"),
LOCK("lock"),
LOGOUT("logout"),
MAP("map"),
MAPHEIGHT("mapheight"),
MOD("mod"),
COLEADER("coleader"),
MOD_ANY("mod.any"),
COLEADER_ANY("coleader.any"),
MISSIONS("missions"),
MODIFY_POWER("modifypower"),
MONEY_BALANCE("money.balance"),
MONEY_BALANCE_ANY("money.balance.any"),
MONEY_DEPOSIT("money.deposit"),
MONEY_WITHDRAW("money.withdraw"),
MONEY_WITHDRAW_ANY("money.withdraw.any"),
MONEY_F2F("money.f2f"),
MONEY_F2P("money.f2p"),
MONEY_P2F("money.p2f"),
MONITOR_LOGINS("monitorlogins"),
NO_BOOM("noboom"),
OPEN("open"),
OWNER("owner"),
OWNERLIST("ownerlist"),
SET_PEACEFUL("setpeaceful"),
SET_PERMANENT("setpermanent"),
SET_PERMANENTPOWER("setpermanentpower"),
SHOW_INVITES("showinvites"),
PAYPAL("paypal"),
PAYPALSET("setpaypal"),
PERMISSIONS("permissions"),
POWERBOOST("powerboost"),
POWER("power"),
POWER_ANY("power.any"),
PROMOTE("promote"),
RELATION("relation"),
RELOAD("reload"),
SAVE("save"),
SPAM("spam"),
SETHOME("sethome"),
SETHOME_ANY("sethome.any"),
SETSTRIKES("setstrikes"),
SHOW("show"),
STATUS("status"),
STEALTH("stealth"),
STUCK("stuck"),
TAG("tag"),
TNT("tnt"),
TITLE("title"),
TITLE_COLOR("title.color"),
TOGGLE_ALLIANCE_CHAT("togglealliancechat"),
UNCLAIM("unclaim"),
UNCLAIM_ALL("unclaimall"),
VERSION("version"),
SCOREBOARD("scoreboard"),
SEECHUNK("seechunk"),
SETWARP("setwarp"),
TOP("top"),
VIEWCHEST("viewchest"),
ADDPOINTS("addpoints"),
REMOVEPOINTS("removepoints"),
SETPOINTS("setpoints"),
VAULT("vault"),
GETVAULT("getvault"),
SETMAXVAULTS("setmaxvaults"),
RULES("rules"),
CHECKPOINT("checkpoint"),
UPGRADES("upgrades"),
BANNER("banner"),
TPBANNER("tpbanner"),
KILLHOLOS("killholos"),
INSPECT("inspect"),
TNTFILL("tntfill"),
COORD("coords"),
SHOWCLAIMS("showclaims"),
WARP("warp"),
CHEST("chest");
MANAGE_SAFE_ZONE("managesafezone"),
MANAGE_WAR_ZONE("managewarzone"),
OWNERSHIP_BYPASS("ownershipbypass"),
ADMIN("admin"),
ALTS("alts"),
ADMIN_ANY("admin.any"),
AHOME("ahome"),
ANNOUNCE("announce"),
AUTOCLAIM("autoclaim"),
AUTO_LEAVE_BYPASS("autoleavebypass"),
BAN("ban"),
BYPASS("bypass"),
CHAT("chat"),
CHATSPY("chatspy"),
CLAIM("claim"),
CLAIMAT("claimat"),
CLAIM_LINE("claim.line"),
CLAIM_RADIUS("claim.radius"),
CONFIG("config"),
CONVERT("convert"),
CREATE("create"),
CORNER("corner"),
DEFAULTRANK("defaultrank"),
DEINVITE("deinvite"),
DESCRIPTION("description"),
DISBAND("disband"),
DISBAND_ANY("disband.any"),
FLY("fly"),
FOCUS("focus"),
GRACE("grace"),
HELP("help"),
HOME("home"),
INVITE("invite"),
INVSEE("invsee"),
JOIN("join"),
JOIN_ANY("join.any"),
JOIN_OTHERS("join.others"),
KICK("kick"),
KICK_ANY("kick.any"),
LEAVE("leave"),
LIST("list"),
LOCK("lock"),
LOGOUT("logout"),
MAP("map"),
MAPHEIGHT("mapheight"),
MOD("mod"),
COLEADER("coleader"),
MOD_ANY("mod.any"),
COLEADER_ANY("coleader.any"),
MISSIONS("missions"),
MODIFY_POWER("modifypower"),
MONEY_BALANCE("money.balance"),
MONEY_BALANCE_ANY("money.balance.any"),
MONEY_DEPOSIT("money.deposit"),
MONEY_WITHDRAW("money.withdraw"),
MONEY_WITHDRAW_ANY("money.withdraw.any"),
MONEY_F2F("money.f2f"),
MONEY_F2P("money.f2p"),
MONEY_P2F("money.p2f"),
MONITOR_LOGINS("monitorlogins"),
NO_BOOM("noboom"),
OPEN("open"),
OWNER("owner"),
OWNERLIST("ownerlist"),
SET_PEACEFUL("setpeaceful"),
SET_PERMANENT("setpermanent"),
SET_PERMANENTPOWER("setpermanentpower"),
SHOW_INVITES("showinvites"),
PAYPAL("paypal"),
PAYPALSET("setpaypal"),
PERMISSIONS("permissions"),
POWERBOOST("powerboost"),
POWER("power"),
POWER_ANY("power.any"),
PROMOTE("promote"),
RELATION("relation"),
RELOAD("reload"),
SAVE("save"),
SPAM("spam"),
SETHOME("sethome"),
SETHOME_ANY("sethome.any"),
SETSTRIKES("setstrikes"),
SHOW("show"),
STATUS("status"),
STEALTH("stealth"),
STUCK("stuck"),
TAG("tag"),
TNT("tnt"),
TITLE("title"),
TITLE_COLOR("title.color"),
TOGGLE_ALLIANCE_CHAT("togglealliancechat"),
UNCLAIM("unclaim"),
UNCLAIM_ALL("unclaimall"),
VERSION("version"),
SCOREBOARD("scoreboard"),
SEECHUNK("seechunk"),
SETWARP("setwarp"),
TOP("top"),
VIEWCHEST("viewchest"),
ADDPOINTS("addpoints"),
REMOVEPOINTS("removepoints"),
SETPOINTS("setpoints"),
VAULT("vault"),
GETVAULT("getvault"),
SETMAXVAULTS("setmaxvaults"),
RULES("rules"),
CHECKPOINT("checkpoint"),
UPGRADES("upgrades"),
BANNER("banner"),
TPBANNER("tpbanner"),
KILLHOLOS("killholos"),
INSPECT("inspect"),
TNTFILL("tntfill"),
COORD("coords"),
SHOWCLAIMS("showclaims"),
WARP("warp"),
CHEST("chest"),
CONVERTCONFIG("convertconfig");
public final String node;
public final String node;
Permission(final String node) {
this.node = "factions." + node;
}
Permission(final String node) {
this.node = "factions." + node;
}
public boolean has(CommandSender sender, boolean informSenderIfNot) {
return P.p.perm.has(sender, this.node, informSenderIfNot);
}
public boolean has(CommandSender sender, boolean informSenderIfNot) {
return P.p.perm.has(sender, this.node, informSenderIfNot);
}
public boolean has(CommandSender sender) {
return has(sender, false);
}
public boolean has(CommandSender sender) {
return has(sender, false);
}
}

View File

@ -889,6 +889,11 @@ public enum TL {
COMMAND_RULES_SET_SUCCESS("&cRule set successfully!"),
COMMAND_RULES_CLEAR_SUCCESS("&cRule cleared successfully!"),
COMMAND_CONVERTCONFIG_DESCRIPTION("Convert your SavageFactions config to SaberFactions"),
COMMAND_CONVERTCONFIG_SUCCESS("&cConfiguration successfully converted"),
COMMAND_CONVERTCONFIG_FAIL("&cConfiguration conversion failed!"),
COMMAND_CONVERTCONFIG_FAILCONFIGMISSING("&cPlease ensure you have placed SavageFactions files in a folder called SavageFactions"),
// F Global \\
COMMAND_F_GLOBAL_TOGGLE("&c&l[!] &7You have &b%1$s &7Global Chat"),
COMMAND_F_GLOBAL_DESCRIPTION("Toggle global chat and only allow factions based chats"),