mirror of
https://github.com/songoda/EpicVouchers.git
synced 2024-11-14 22:25:29 +01:00
Removed useless old save system.
This commit is contained in:
parent
3470a75ea7
commit
e553c48099
@ -32,31 +32,31 @@ public class VoucherEditorMenu extends IconInv {
|
||||
|
||||
//Booleans
|
||||
|
||||
addIcon(0, new ToggleableIcon("Glow", event -> voucher.setGlow(!voucher.isGlow()).saveSetting("glow", voucher.isGlow()), voucher.isGlow()));
|
||||
addIcon(0, new ToggleableIcon("Glow", event -> voucher.setGlow(!voucher.isGlow()), voucher.isGlow()));
|
||||
|
||||
addIcon(1, new ToggleableIcon("Confirm", event -> voucher.setConfirm(!voucher.isConfirm()).saveSetting("confirm", voucher.isConfirm()), voucher.isConfirm()));
|
||||
addIcon(1, new ToggleableIcon("Confirm", event -> voucher.setConfirm(!voucher.isConfirm()), voucher.isConfirm()));
|
||||
|
||||
addIcon(2, new ToggleableIcon("Unbreakable", event -> voucher.setUnbreakable(!voucher.isUnbreakable()).saveSetting("unbreakable", voucher.isUnbreakable()), voucher.isUnbreakable()));
|
||||
addIcon(2, new ToggleableIcon("Unbreakable", event -> voucher.setUnbreakable(!voucher.isUnbreakable()), voucher.isUnbreakable()));
|
||||
|
||||
addIcon(3, new ToggleableIcon("Hide Attributes", event -> voucher.setHideAttributes(!voucher.isHideAttributes()).saveSetting("hide-attributes", voucher.isHideAttributes()), voucher.isHideAttributes()));
|
||||
addIcon(3, new ToggleableIcon("Hide Attributes", event -> voucher.setHideAttributes(!voucher.isHideAttributes()), voucher.isHideAttributes()));
|
||||
|
||||
addIcon(4, new ToggleableIcon("Remove Item", event -> voucher.setRemoveItem(!voucher.isRemoveItem()).saveSetting("remove-item", voucher.isRemoveItem()), voucher.isRemoveItem()));
|
||||
addIcon(4, new ToggleableIcon("Remove Item", event -> voucher.setRemoveItem(!voucher.isRemoveItem()), voucher.isRemoveItem()));
|
||||
|
||||
addIcon(5, new ToggleableIcon("Feed Player", event -> voucher.setFeedPlayer(!voucher.isFeedPlayer()).saveSetting("feed-player", voucher.isFeedPlayer()), voucher.isFeedPlayer()));
|
||||
addIcon(5, new ToggleableIcon("Feed Player", event -> voucher.setFeedPlayer(!voucher.isFeedPlayer()), voucher.isFeedPlayer()));
|
||||
|
||||
addIcon(6, new ToggleableIcon("Heal Player", event -> voucher.setHealPlayer(!voucher.isHealPlayer()).saveSetting("heal-player", voucher.isHealPlayer()), voucher.isHealPlayer()));
|
||||
addIcon(6, new ToggleableIcon("Heal Player", event -> voucher.setHealPlayer(!voucher.isHealPlayer()), voucher.isHealPlayer()));
|
||||
|
||||
addIcon(7, new ToggleableIcon("Smite Effect", event -> voucher.setSmiteEffect(!voucher.isSmiteEffect()).saveSetting("smite-effect", voucher.isSmiteEffect()), voucher.isSmiteEffect()));
|
||||
addIcon(7, new ToggleableIcon("Smite Effect", event -> voucher.setSmiteEffect(!voucher.isSmiteEffect()), voucher.isSmiteEffect()));
|
||||
|
||||
//Strings
|
||||
|
||||
addIcon(9, new StringIcon(instance, "Permission", voucher.getPermission(), (player, editString) -> {
|
||||
voucher.setPermission(editString).saveSetting("permission", editString);
|
||||
voucher.setPermission(editString);
|
||||
reopen(player);
|
||||
}));
|
||||
|
||||
addIcon(10, new StringIcon(instance, "Actionbar", voucher.getActionBar(), (player, editString) -> {
|
||||
voucher.setActionBar(editString).saveSetting("actionbar", editString);
|
||||
voucher.setActionBar(editString);
|
||||
reopen(player);
|
||||
}));
|
||||
|
||||
@ -65,7 +65,7 @@ public class VoucherEditorMenu extends IconInv {
|
||||
voucher.setData(Short.parseShort(editString.split(":")[1]));
|
||||
voucher.setMaterial(Material.valueOf(editString.split(":")[0]));
|
||||
} else {
|
||||
voucher.setMaterial(Material.valueOf(editString)).saveSetting("material", editString);
|
||||
voucher.setMaterial(Material.valueOf(editString));
|
||||
}
|
||||
|
||||
reopen(player);
|
||||
@ -83,7 +83,7 @@ public class VoucherEditorMenu extends IconInv {
|
||||
}, true));
|
||||
|
||||
addIcon(12, new StringIcon(instance, "Name", voucher.getName(false), (player, editString) -> {
|
||||
voucher.setName(editString).saveSetting("name", editString);
|
||||
voucher.setName(editString);
|
||||
reopen(player);
|
||||
}));
|
||||
|
||||
|
@ -17,17 +17,17 @@ public class EffectsMenu extends IconInv {
|
||||
super(9, "Titles");
|
||||
|
||||
addIcon(1, new StringIcon(instance, "Effect", voucher.getEffect(), (player, editString) -> {
|
||||
voucher.setEffect(editString).saveSetting("effects.effect", editString);
|
||||
voucher.setEffect(editString);
|
||||
new EffectsMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
addIcon(2, new IntegerIcon(instance, "Effect Amplifier", voucher.getEffectAmplifier(), (player, number) -> {
|
||||
voucher.setEffectAmplifier(number).saveSetting("effects.amplifier", number);
|
||||
voucher.setEffectAmplifier(number);
|
||||
new EffectsMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
addIcon(3, new IntegerIcon(instance, "Duration", voucher.getEffectDuration(), (player, number) -> {
|
||||
voucher.setEffectDuration(number).saveSetting("effects.duration", number);
|
||||
voucher.setEffectDuration(number);
|
||||
new EffectsMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
|
@ -17,12 +17,12 @@ public class ParticlesMenu extends IconInv {
|
||||
super(9, "Particles");
|
||||
|
||||
addIcon(1, new StringIcon(instance, "Particle", voucher.getParticle(), (player, editString) -> {
|
||||
voucher.setParticle(editString).saveSetting("particles.particle", editString);
|
||||
voucher.setParticle(editString);
|
||||
new ParticlesMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
addIcon(2, new IntegerIcon(instance, "Stay", voucher.getParticleAmount(), (player, number) -> {
|
||||
voucher.setParticleAmount(number).saveSetting("particles.amount", number);
|
||||
voucher.setParticleAmount(number);
|
||||
new ParticlesMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
|
@ -51,11 +51,9 @@ public class SetItemMenu extends FastInv {
|
||||
voucher.setName("");
|
||||
voucher.setLore(null);
|
||||
voucher.setItemStack(itemStack);
|
||||
voucher.saveSetting("itemstack", itemStack);
|
||||
}
|
||||
|
||||
voucher.setMaterial(itemStack.getType());
|
||||
voucher.saveSetting("material", itemStack.getType().toString());
|
||||
|
||||
if (itemStack.getDurability() != 0) {
|
||||
voucher.setData(itemStack.getDurability());
|
||||
@ -68,12 +66,10 @@ public class SetItemMenu extends FastInv {
|
||||
|
||||
if (itemStack.getItemMeta().hasDisplayName()) {
|
||||
voucher.setName(itemStack.getItemMeta().getDisplayName());
|
||||
voucher.saveSetting("name", itemStack.getItemMeta().getDisplayName());
|
||||
}
|
||||
|
||||
if (itemStack.getItemMeta().hasLore()) {
|
||||
voucher.setLore(itemStack.getItemMeta().getLore());
|
||||
voucher.saveSetting("lore", itemStack.getItemMeta().getLore());
|
||||
}
|
||||
|
||||
new OptionMenu(instance, voucher).open(event.getPlayer());
|
||||
|
@ -19,12 +19,12 @@ public class SoundsMenu extends IconInv {
|
||||
super(9, "Sound");
|
||||
|
||||
addIcon(1, new StringIcon(instance, "Sound", voucher.getSound(), (player, editString) -> {
|
||||
voucher.setSound(editString).saveSetting("sounds.sound", editString);
|
||||
voucher.setSound(editString);
|
||||
new SoundsMenu(instance, voucher).open(player);
|
||||
}, string -> Enums.getIfPresent(Sound.class, string).isPresent()));
|
||||
|
||||
addIcon(2, new IntegerIcon(instance, "Pitch", voucher.getSoundPitch(), (player, number) -> {
|
||||
voucher.setSoundPitch(number).saveSetting("sounds.pitch", number);
|
||||
voucher.setSoundPitch(number);
|
||||
new SoundsMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
|
@ -17,27 +17,27 @@ public class TitlesMenu extends IconInv {
|
||||
super(9, "Titles");
|
||||
|
||||
addIcon(1, new StringIcon(instance, "Title", voucher.getTitle(), (player, editString) -> {
|
||||
voucher.setTitle(editString).saveSetting("titles.title", editString);
|
||||
voucher.setTitle(editString);
|
||||
new TitlesMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
addIcon(2, new StringIcon(instance, "Subtitle", voucher.getSubTitle(), (player, editString) -> {
|
||||
voucher.setSubTitle(editString).saveSetting("titles.subtitle", editString);
|
||||
voucher.setSubTitle(editString);
|
||||
new TitlesMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
addIcon(3, new IntegerIcon(instance, "Fade in", voucher.getTitleFadeIn(), (player, number) -> {
|
||||
voucher.setTitleFadeIn(number).saveSetting("titles.fade-in", number);
|
||||
voucher.setTitleFadeIn(number);
|
||||
new TitlesMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
addIcon(4, new IntegerIcon(instance, "Fade out", voucher.getTitleFadeOut(), (player, number) -> {
|
||||
voucher.setTitleFadeOut(number).saveSetting("titles.fade-out", number);
|
||||
voucher.setTitleFadeOut(number);
|
||||
new TitlesMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
addIcon(5, new IntegerIcon(instance, "Stay", voucher.getTitleStay(), (player, number) -> {
|
||||
voucher.setTitleStay(number).saveSetting("titles.stay", number);
|
||||
voucher.setTitleStay(number);
|
||||
new TitlesMenu(instance, voucher).open(player);
|
||||
}));
|
||||
|
||||
|
@ -8,7 +8,6 @@ import lombok.experimental.Accessors;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
@ -123,10 +122,21 @@ public class Voucher {
|
||||
return applyFormatting ? messages.stream().map(TextUtils::formatText).collect(Collectors.toList()) : messages;
|
||||
}
|
||||
|
||||
public void saveSetting(String key, Object value) {
|
||||
ConfigurationSection cs = instance.getConfig().getConfigurationSection("vouchers." + getKey());
|
||||
cs.set(key, value);
|
||||
instance.getVouchersConfig().save();
|
||||
public void saveSetting(String key, List<String> list) {
|
||||
switch (key) {
|
||||
case "Commands":
|
||||
commands = list;
|
||||
break;
|
||||
case "Broadcasts":
|
||||
broadcasts = list;
|
||||
break;
|
||||
case "Messages":
|
||||
messages = list;
|
||||
break;
|
||||
case "Lore":
|
||||
lore = list;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user