mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-07 19:20:39 +01:00
Clean up
This commit is contained in:
parent
12ce9fabaf
commit
48754f886d
@ -100,8 +100,6 @@ public class UltimateKits extends JavaPlugin {
|
||||
|
||||
new Convert(this);
|
||||
|
||||
this.references = new References();
|
||||
|
||||
new ParticleHandler(this);
|
||||
this.displayItemHandler = new DisplayItemHandler(this);
|
||||
|
||||
@ -118,6 +116,8 @@ public class UltimateKits extends JavaPlugin {
|
||||
this.update();
|
||||
}
|
||||
|
||||
this.references = new References();
|
||||
|
||||
this.kitManager = new KitManager();
|
||||
this.keyManager = new KeyManager();
|
||||
this.commandManager = new CommandManager(this);
|
||||
|
@ -12,65 +12,65 @@ import java.util.Set;
|
||||
|
||||
public class Convert {
|
||||
|
||||
private final UltimateKits instance;
|
||||
private final UltimateKits instance;
|
||||
|
||||
private Hook hook;
|
||||
private Hook hook;
|
||||
|
||||
public Convert(UltimateKits instance) {
|
||||
this.instance = instance;
|
||||
if (instance.getServer().getPluginManager().getPlugin("Essentials") != null) {
|
||||
try {
|
||||
Class.forName("com.earth2me.essentials.metrics.MetricsListener");
|
||||
hook = new DefaultHook();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
hook = new EssentialsHook();
|
||||
}
|
||||
} else if (instance.getServer().getPluginManager().getPlugin("UltimateCore") != null) {
|
||||
hook = new UltimateCoreHook();
|
||||
} else {
|
||||
hook = new DefaultHook();
|
||||
}
|
||||
public Convert(UltimateKits instance) {
|
||||
this.instance = instance;
|
||||
if (instance.getServer().getPluginManager().getPlugin("Essentials") != null) {
|
||||
try {
|
||||
Class.forName("com.earth2me.essentials.metrics.MetricsListener");
|
||||
hook = new DefaultHook();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
hook = new EssentialsHook();
|
||||
}
|
||||
} else if (instance.getServer().getPluginManager().getPlugin("UltimateCore") != null) {
|
||||
hook = new UltimateCoreHook();
|
||||
} else {
|
||||
hook = new DefaultHook();
|
||||
}
|
||||
|
||||
if (hook.getKits().size() == 0)
|
||||
hook = new DefaultHook();
|
||||
if (hook.getKits().size() == 0)
|
||||
hook = new DefaultHook();
|
||||
|
||||
convertKits();
|
||||
}
|
||||
convertKits();
|
||||
}
|
||||
|
||||
private void convertKits() {
|
||||
Set<String> kits = hook.getKits();
|
||||
private void convertKits() {
|
||||
Set<String> kits = hook.getKits();
|
||||
|
||||
if (!instance.getKitFile().getConfig().contains("Kits")) {
|
||||
this.convertKits(kits);
|
||||
}else if(!isInJsonFormat()) {
|
||||
hook = new DefaultHook();
|
||||
this.convertKits(hook.getKits());
|
||||
}
|
||||
}
|
||||
|
||||
private void convertKits(Set<String> kits) {
|
||||
for (String kit : kits) {
|
||||
List<String> serializedItems = new ArrayList<>();
|
||||
for (ItemStack item : hook.getItems(kit)) {
|
||||
serializedItems.add(instance.getItemSerializer().serializeItemStackToJson(item));
|
||||
}
|
||||
instance.getKitFile().getConfig().set("Kits." + kit + ".items", serializedItems);
|
||||
instance.getKitFile().getConfig().set("Kits." + kit + ".delay", hook.getDelay(kit));
|
||||
instance.getKitFile().getConfig().set("Kits." + kit + ".price", 0D);
|
||||
}
|
||||
instance.getKitFile().saveConfig();
|
||||
}
|
||||
if (!instance.getKitFile().getConfig().contains("Kits")) {
|
||||
this.convertKits(kits);
|
||||
} else if (!isInJsonFormat()) {
|
||||
hook = new DefaultHook();
|
||||
this.convertKits(hook.getKits());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInJsonFormat() {
|
||||
for (String kit : instance.getKitFile().getConfig().getConfigurationSection("Kits").getKeys(false)) {
|
||||
if (instance.getKitFile().getConfig().contains("Kits." + kit + ".items")) {
|
||||
List<String> itemList = instance.getKitFile().getConfig().getStringList("Kits." + kit + ".items");
|
||||
if (itemList.size() > 0) {
|
||||
if (itemList.get(0).startsWith("{"))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private void convertKits(Set<String> kits) {
|
||||
for (String kit : kits) {
|
||||
List<String> serializedItems = new ArrayList<>();
|
||||
for (ItemStack item : hook.getItems(kit)) {
|
||||
serializedItems.add(instance.getItemSerializer().serializeItemStackToJson(item));
|
||||
}
|
||||
instance.getKitFile().getConfig().set("Kits." + kit + ".items", serializedItems);
|
||||
instance.getKitFile().getConfig().set("Kits." + kit + ".delay", hook.getDelay(kit));
|
||||
instance.getKitFile().getConfig().set("Kits." + kit + ".price", 0D);
|
||||
}
|
||||
instance.getKitFile().saveConfig();
|
||||
}
|
||||
|
||||
private boolean isInJsonFormat() {
|
||||
for (String kit : instance.getKitFile().getConfig().getConfigurationSection("Kits").getKeys(false)) {
|
||||
if (instance.getKitFile().getConfig().contains("Kits." + kit + ".items")) {
|
||||
List<String> itemList = instance.getKitFile().getConfig().getStringList("Kits." + kit + ".items");
|
||||
if (itemList.size() > 0) {
|
||||
if (itemList.get(0).startsWith("{"))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,9 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HologramArconix extends Hologram {
|
||||
|
||||
|
||||
private com.songoda.arconix.api.packets.Hologram hologramManager;
|
||||
|
||||
public HologramArconix(UltimateKits instance) {
|
||||
|
@ -41,7 +41,7 @@ public class KitBlockData {
|
||||
public Location getLocation() {
|
||||
return location.clone();
|
||||
}
|
||||
|
||||
|
||||
public int getX() {
|
||||
return location.getBlockX();
|
||||
}
|
||||
@ -97,6 +97,6 @@ public class KitBlockData {
|
||||
public void setType(KitType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.songoda.ultimatekits.kit.type;
|
||||
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class KitContentItem implements KitContent {
|
||||
|
@ -11,7 +11,7 @@ general.type.free = "Free"
|
||||
|
||||
interface.selector.kit = "&c%kit%"
|
||||
interface.selector.title = "&8Server kits"
|
||||
interface.selector.details = "&7Hello &e{PLAYER}&7!|&7Listed below are our servers kit.||&7Click on the &eicon &7representing the &ekit |&7inorder to &epreview, claim or buy &7it."
|
||||
interface.selector.details = "&7Hello &e%player%&7!|&7Listed below are our servers kit.||&7Click on the &eicon &7representing the &ekit |&7inorder to &epreview, claim or buy &7it."
|
||||
interface.selector.aboutkit = "&7Can't open a kit?|&7Rank up to gain access!"
|
||||
interface.selector.leftpreview = "&6&lLEFT CLICK &7to preview kit."
|
||||
interface.selector.rightclaim = "&6&lRIGHT CLICK &7to claim kit."
|
||||
|
Loading…
Reference in New Issue
Block a user