mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-04-11 14:36:52 +02:00
Move kits to kits.yml (#1774)
* Move kits to kits.yml We will now use a separate kits.yml file. Any kits that were defined in the config.yml will be migrated over to the kits.yml file automatically on startup.
This commit is contained in:
parent
1f0f77ff72
commit
cd43355d4c
39
Essentials/kits.yml
Normal file
39
Essentials/kits.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# EssentialsX new Kit configuration.
|
||||||
|
# If you don't have any kits defined in this file, the plugin will try to copy them from the config.yml
|
||||||
|
|
||||||
|
# Note: All items MUST be followed by a quantity!
|
||||||
|
# All kit names should be lower case, and will be treated as lower in permissions/costs.
|
||||||
|
# Syntax: - itemID[:DataValue/Durability] Amount [Enchantment:Level].. [itemmeta:value]...
|
||||||
|
# For Item Meta information visit http://wiki.ess3.net/wiki/Item_Meta
|
||||||
|
# 'delay' refers to the cooldown between how often you can use each kit, measured in seconds.
|
||||||
|
# Set delay to -1 for a one time kit.
|
||||||
|
# For more information, visit http://wiki.ess3.net/wiki/Kits
|
||||||
|
kits:
|
||||||
|
tools:
|
||||||
|
delay: 10
|
||||||
|
items:
|
||||||
|
- 272 1
|
||||||
|
- 273 1
|
||||||
|
- 274 1
|
||||||
|
- 275 1
|
||||||
|
dtools:
|
||||||
|
delay: 600
|
||||||
|
items:
|
||||||
|
- 278 1 efficiency:1 durability:1 fortune:1 name:&4Gigadrill lore:The_drill_that_&npierces|the_heavens
|
||||||
|
- 277 1 digspeed:3 name:Dwarf lore:Diggy|Diggy|Hole
|
||||||
|
- 298 1 color:255,255,255 name:Top_Hat lore:Good_day,_Good_day
|
||||||
|
- 279:780 1
|
||||||
|
notch:
|
||||||
|
delay: 6000
|
||||||
|
items:
|
||||||
|
- 397:3 1 player:Notch
|
||||||
|
color:
|
||||||
|
delay: 6000
|
||||||
|
items:
|
||||||
|
- 387 1 title:&4Book_&9o_&6Colors author:KHobbits lore:Ingame_color_codes book:Colors
|
||||||
|
firework:
|
||||||
|
delay: 6000
|
||||||
|
items:
|
||||||
|
- 401 1 name:Angry_Creeper color:red fade:green type:creeper power:1
|
||||||
|
- 401 1 name:Starry_Night color:yellow,orange fade:blue type:star effect:trail,twinkle power:1
|
||||||
|
- 401 2 name:Solar_Wind color:yellow,orange fade:red shape:large effect:twinkle color:yellow,orange fade:red shape:ball effect:trail color:red,purple fade:pink shape:star effect:trail power:1
|
@ -106,6 +106,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||||||
private transient SpawnerProvider spawnerProvider;
|
private transient SpawnerProvider spawnerProvider;
|
||||||
private transient SpawnEggProvider spawnEggProvider;
|
private transient SpawnEggProvider spawnEggProvider;
|
||||||
private transient PotionMetaProvider potionMetaProvider;
|
private transient PotionMetaProvider potionMetaProvider;
|
||||||
|
private transient Kits kits;
|
||||||
|
|
||||||
public Essentials() {
|
public Essentials() {
|
||||||
}
|
}
|
||||||
@ -150,6 +151,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||||||
confList = new ArrayList<>();
|
confList = new ArrayList<>();
|
||||||
jails = new Jails(this);
|
jails = new Jails(this);
|
||||||
registerListeners(server.getPluginManager());
|
registerListeners(server.getPluginManager());
|
||||||
|
kits = new Kits(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -193,6 +195,10 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||||||
userMap = new UserMap(this);
|
userMap = new UserMap(this);
|
||||||
confList.add(userMap);
|
confList.add(userMap);
|
||||||
execTimer.mark("Init(Usermap)");
|
execTimer.mark("Init(Usermap)");
|
||||||
|
kits = new Kits(this);
|
||||||
|
confList.add(kits);
|
||||||
|
upgrade.convertKits();
|
||||||
|
execTimer.mark("Kits");
|
||||||
upgrade.afterSettings();
|
upgrade.afterSettings();
|
||||||
execTimer.mark("Upgrade2");
|
execTimer.mark("Upgrade2");
|
||||||
warps = new Warps(getServer(), this.getDataFolder());
|
warps = new Warps(getServer(), this.getDataFolder());
|
||||||
@ -585,6 +591,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||||||
return backup;
|
return backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Kits getKits() {
|
||||||
|
return kits;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Metrics getMetrics() {
|
public Metrics getMetrics() {
|
||||||
return metrics;
|
return metrics;
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.BanList;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -41,6 +42,34 @@ public class EssentialsUpgrade {
|
|||||||
doneFile.load();
|
doneFile.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void convertKits() {
|
||||||
|
Kits kits = ess.getKits();
|
||||||
|
EssentialsConf config = kits.getConfig();
|
||||||
|
if (doneFile.getBoolean("kitsyml", false)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.info("Attempting to convert old kits in config.yml to new kits.yml");
|
||||||
|
|
||||||
|
ConfigurationSection section = ess.getSettings().getKitSection();
|
||||||
|
if (section == null) {
|
||||||
|
LOGGER.info("No kits found to migrate.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> legacyKits = ess.getSettings().getKitSection().getValues(true);
|
||||||
|
|
||||||
|
for (Map.Entry<String, Object> entry : legacyKits.entrySet()) {
|
||||||
|
LOGGER.info("Converting " + entry.getKey());
|
||||||
|
config.set("kits." + entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
config.save();
|
||||||
|
doneFile.setProperty("kitsyml", true);
|
||||||
|
doneFile.save();
|
||||||
|
LOGGER.info("Done converting kits.");
|
||||||
|
}
|
||||||
|
|
||||||
private void moveMotdRulesToFile(String name) {
|
private void moveMotdRulesToFile(String name) {
|
||||||
if (doneFile.getBoolean("move" + name + "ToFile", false)) {
|
if (doneFile.getBoolean("move" + name + "ToFile", false)) {
|
||||||
return;
|
return;
|
||||||
|
@ -19,7 +19,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
public interface IEssentials extends Plugin {
|
public interface IEssentials extends Plugin {
|
||||||
void addReloadListener(IConf listener);
|
void addReloadListener(IConf listener);
|
||||||
|
|
||||||
@ -62,6 +61,8 @@ public interface IEssentials extends Plugin {
|
|||||||
|
|
||||||
Backup getBackup();
|
Backup getBackup();
|
||||||
|
|
||||||
|
Kits getKits();
|
||||||
|
|
||||||
Methods getPaymentMethod();
|
Methods getPaymentMethod();
|
||||||
|
|
||||||
BukkitTask runTaskAsynchronously(Runnable run);
|
BukkitTask runTaskAsynchronously(Runnable run);
|
||||||
|
@ -58,12 +58,27 @@ public interface ISettings extends IConf {
|
|||||||
|
|
||||||
Set<String> getMuteCommands();
|
Set<String> getMuteCommands();
|
||||||
|
|
||||||
Map<String, Object> getKit(String name);
|
/**
|
||||||
|
* @Deprecated in favor of {@link Kits#getKits()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
ConfigurationSection getKits();
|
ConfigurationSection getKits();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Deprecated in favor of {@link Kits#getKit(String)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
Map<String, Object> getKit(String kit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Deprecated in favor of {@link Kits#addKit(String, List, long)}}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
void addKit(String name, List<String> lines, long delay);
|
void addKit(String name, List<String> lines, long delay);
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
ConfigurationSection getKitSection();
|
||||||
|
|
||||||
boolean isSkippingUsedOneTimeKitsFromKitList();
|
boolean isSkippingUsedOneTimeKitsFromKitList();
|
||||||
|
|
||||||
String getLocale();
|
String getLocale();
|
||||||
@ -243,7 +258,7 @@ public interface ISettings extends IConf {
|
|||||||
boolean isLastMessageReplyRecipient();
|
boolean isLastMessageReplyRecipient();
|
||||||
|
|
||||||
BigDecimal getMinimumPayAmount();
|
BigDecimal getMinimumPayAmount();
|
||||||
|
|
||||||
long getLastMessageReplyRecipientTimeout();
|
long getLastMessageReplyRecipientTimeout();
|
||||||
|
|
||||||
boolean isMilkBucketEasterEggEnabled();
|
boolean isMilkBucketEasterEggEnabled();
|
||||||
@ -255,13 +270,13 @@ public interface ISettings extends IConf {
|
|||||||
boolean isSpawnOnJoin();
|
boolean isSpawnOnJoin();
|
||||||
|
|
||||||
List<String> getSpawnOnJoinGroups();
|
List<String> getSpawnOnJoinGroups();
|
||||||
|
|
||||||
boolean isUserInSpawnOnJoinGroup(IUser user);
|
boolean isUserInSpawnOnJoinGroup(IUser user);
|
||||||
|
|
||||||
boolean isTeleportToCenterLocation();
|
boolean isTeleportToCenterLocation();
|
||||||
|
|
||||||
boolean isCommandCooldownsEnabled();
|
boolean isCommandCooldownsEnabled();
|
||||||
|
|
||||||
long getCommandCooldownMs(String label);
|
long getCommandCooldownMs(String label);
|
||||||
|
|
||||||
Entry<Pattern, Long> getCommandCooldownEntry(String label);
|
Entry<Pattern, Long> getCommandCooldownEntry(String label);
|
||||||
@ -273,11 +288,11 @@ public interface ISettings extends IConf {
|
|||||||
NumberFormat getCurrencyFormat();
|
NumberFormat getCurrencyFormat();
|
||||||
|
|
||||||
List<EssentialsSign> getUnprotectedSignNames();
|
List<EssentialsSign> getUnprotectedSignNames();
|
||||||
|
|
||||||
boolean isPastebinCreateKit();
|
boolean isPastebinCreateKit();
|
||||||
|
|
||||||
boolean isAllowBulkBuySell();
|
boolean isAllowBulkBuySell();
|
||||||
|
|
||||||
boolean isAddingPrefixInPlayerlist();
|
boolean isAddingPrefixInPlayerlist();
|
||||||
|
|
||||||
boolean isAddingSuffixInPlayerlist();
|
boolean isAddingSuffixInPlayerlist();
|
||||||
@ -287,4 +302,4 @@ public interface ISettings extends IConf {
|
|||||||
int getMotdDelay();
|
int getMotdDelay();
|
||||||
|
|
||||||
boolean isDirectHatAllowed();
|
boolean isDirectHatAllowed();
|
||||||
}
|
}
|
@ -7,18 +7,15 @@ import com.earth2me.essentials.textreader.IText;
|
|||||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||||
import com.earth2me.essentials.utils.DateUtil;
|
import com.earth2me.essentials.utils.DateUtil;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.capitalCase;
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +28,7 @@ public class Kit {
|
|||||||
public Kit(final String kitName, final IEssentials ess) throws Exception {
|
public Kit(final String kitName, final IEssentials ess) throws Exception {
|
||||||
this.kitName = kitName;
|
this.kitName = kitName;
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
this.kit = ess.getSettings().getKit(kitName);
|
this.kit = ess.getKits().getKit(kitName);
|
||||||
this.charge = new Trade("kit-" + kitName, new Trade("kit-kit", ess), ess);
|
this.charge = new Trade("kit-" + kitName, new Trade("kit-kit", ess), ess);
|
||||||
|
|
||||||
if (kit == null) {
|
if (kit == null) {
|
||||||
@ -39,40 +36,6 @@ public class Kit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Convert this to use one of the new text classes?
|
|
||||||
public static String listKits(final IEssentials ess, final User user) throws Exception {
|
|
||||||
try {
|
|
||||||
final ConfigurationSection kits = ess.getSettings().getKits();
|
|
||||||
final StringBuilder list = new StringBuilder();
|
|
||||||
for (String kitItem : kits.getKeys(false)) {
|
|
||||||
if (user == null) {
|
|
||||||
list.append(" ").append(capitalCase(kitItem));
|
|
||||||
} else if (user.isAuthorized("essentials.kits." + kitItem.toLowerCase(Locale.ENGLISH))) {
|
|
||||||
String cost = "";
|
|
||||||
String name = capitalCase(kitItem);
|
|
||||||
BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
|
|
||||||
if (costPrice.signum() > 0) {
|
|
||||||
cost = tl("kitCost", NumberUtil.displayCurrency(costPrice, ess));
|
|
||||||
}
|
|
||||||
|
|
||||||
Kit kit = new Kit(kitItem, ess);
|
|
||||||
double nextUse = kit.getNextUse(user);
|
|
||||||
if (nextUse == -1 && ess.getSettings().isSkippingUsedOneTimeKitsFromKitList()) {
|
|
||||||
continue;
|
|
||||||
} else if (nextUse != 0) {
|
|
||||||
name = tl("kitDelay", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
list.append(" ").append(name).append(cost);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list.toString().trim();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw new Exception(tl("kitError"), ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return kitName;
|
return kitName;
|
||||||
}
|
}
|
||||||
|
114
Essentials/src/com/earth2me/essentials/Kits.java
Normal file
114
Essentials/src/com/earth2me/essentials/Kits.java
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.MemoryConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.earth2me.essentials.I18n.capitalCase;
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
public class Kits implements IConf {
|
||||||
|
|
||||||
|
private final EssentialsConf config;
|
||||||
|
private ConfigurationSection kits;
|
||||||
|
|
||||||
|
public Kits(final IEssentials essentials) {
|
||||||
|
config = new EssentialsConf(new File(essentials.getDataFolder(), "kits.yml"));
|
||||||
|
config.setTemplateName("/kits.yml");
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
kits = _getKits();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reloadConfig() {
|
||||||
|
kits = _getKits();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ConfigurationSection _getKits() {
|
||||||
|
if (config.isConfigurationSection("kits")) {
|
||||||
|
final ConfigurationSection section = config.getConfigurationSection("kits");
|
||||||
|
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||||
|
for (String kitItem : section.getKeys(false)) {
|
||||||
|
if (section.isConfigurationSection(kitItem)) {
|
||||||
|
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newSection;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EssentialsConf getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigurationSection getKits() {
|
||||||
|
return kits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getKit(String name) {
|
||||||
|
name = name.replace('.', '_').replace('/', '_');
|
||||||
|
if (getKits() != null) {
|
||||||
|
final ConfigurationSection kits = getKits();
|
||||||
|
// For some reason, YAML doesn't sees keys as always lowercase even if they aren't defined like that.
|
||||||
|
// Workaround is to toLowercase when getting from the config, but showing normally elsewhere.
|
||||||
|
// ODDLY ENOUGH when you get the configuration section for ALL kits, it will return the proper
|
||||||
|
// case of each kit. But when you check for each kit's configuration section, it won't return the kit
|
||||||
|
// you just found if you don't toLowercase it.
|
||||||
|
if (kits.isConfigurationSection(name.toLowerCase())) {
|
||||||
|
return kits.getConfigurationSection(name.toLowerCase()).getValues(true);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addKit(String name, List<String> lines, long delay) {
|
||||||
|
// Will overwrite but w/e
|
||||||
|
config.set("kits." + name + ".delay", delay);
|
||||||
|
config.set("kits." + name + ".items", lines);
|
||||||
|
kits = _getKits();
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String listKits(final net.ess3.api.IEssentials ess, final User user) throws Exception {
|
||||||
|
try {
|
||||||
|
final ConfigurationSection kits = config.getConfigurationSection("kits");
|
||||||
|
final StringBuilder list = new StringBuilder();
|
||||||
|
for (String kitItem : kits.getKeys(false)) {
|
||||||
|
if (user == null) {
|
||||||
|
list.append(" ").append(capitalCase(kitItem));
|
||||||
|
} else if (user.isAuthorized("essentials.kits." + kitItem.toLowerCase(Locale.ENGLISH))) {
|
||||||
|
String cost = "";
|
||||||
|
String name = capitalCase(kitItem);
|
||||||
|
BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
|
||||||
|
if (costPrice.signum() > 0) {
|
||||||
|
cost = tl("kitCost", NumberUtil.displayCurrency(costPrice, ess));
|
||||||
|
}
|
||||||
|
|
||||||
|
Kit kit = new Kit(kitItem, ess);
|
||||||
|
double nextUse = kit.getNextUse(user);
|
||||||
|
if (nextUse == -1 && ess.getSettings().isSkippingUsedOneTimeKitsFromKitList()) {
|
||||||
|
continue;
|
||||||
|
} else if (nextUse != 0) {
|
||||||
|
name = tl("kitDelay", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
list.append(" ").append(name).append(cost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list.toString().trim();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new Exception(tl("kitError"), ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -325,46 +325,24 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return config.getDouble("heal-cooldown", 0);
|
return config.getDouble("heal-cooldown", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfigurationSection kits;
|
|
||||||
|
|
||||||
private ConfigurationSection _getKits() {
|
|
||||||
if (config.isConfigurationSection("kits")) {
|
|
||||||
final ConfigurationSection section = config.getConfigurationSection("kits");
|
|
||||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
|
||||||
for (String kitItem : section.getKeys(false)) {
|
|
||||||
if (section.isConfigurationSection(kitItem)) {
|
|
||||||
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newSection;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigurationSection getKits() {
|
public ConfigurationSection getKits() {
|
||||||
return kits;
|
return ess.getKits().getKits();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getKit(String name) {
|
public Map<String, Object> getKit(String name) {
|
||||||
name = name.replace('.', '_').replace('/', '_');
|
return ess.getKits().getKit(name);
|
||||||
if (getKits() != null) {
|
|
||||||
final ConfigurationSection kits = getKits();
|
|
||||||
if (kits.isConfigurationSection(name)) {
|
|
||||||
return kits.getConfigurationSection(name).getValues(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addKit(String name, List<String> lines, long delay) {
|
public void addKit(String name, List<String> lines, long delay) {
|
||||||
// Will overwrite but w/e
|
ess.getKits().addKit(name, lines, delay);
|
||||||
config.set("kits." + name + ".delay", delay);
|
}
|
||||||
config.set("kits." + name + ".items", lines);
|
|
||||||
kits = _getKits();
|
@Override
|
||||||
config.save();
|
public ConfigurationSection getKitSection() {
|
||||||
|
return config.getConfigurationSection("kits");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -516,7 +494,6 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
itemSpawnBl = _getItemSpawnBlacklist();
|
itemSpawnBl = _getItemSpawnBlacklist();
|
||||||
loginAttackDelay = _getLoginAttackDelay();
|
loginAttackDelay = _getLoginAttackDelay();
|
||||||
signUsePerSecond = _getSignUsePerSecond();
|
signUsePerSecond = _getSignUsePerSecond();
|
||||||
kits = _getKits();
|
|
||||||
chatFormats.clear();
|
chatFormats.clear();
|
||||||
changeDisplayName = _changeDisplayName();
|
changeDisplayName = _changeDisplayName();
|
||||||
disabledCommands = getDisabledCommands();
|
disabledCommands = getDisabledCommands();
|
||||||
@ -1202,7 +1179,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
public boolean isSpawnOnJoin() {
|
public boolean isSpawnOnJoin() {
|
||||||
return !this.spawnOnJoinGroups.isEmpty();
|
return !this.spawnOnJoinGroups.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> spawnOnJoinGroups;
|
private List<String> spawnOnJoinGroups;
|
||||||
|
|
||||||
public List<String> _getSpawnOnJoinGroups() {
|
public List<String> _getSpawnOnJoinGroups() {
|
||||||
@ -1241,7 +1218,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
public boolean isTeleportToCenterLocation() {
|
public boolean isTeleportToCenterLocation() {
|
||||||
return config.getBoolean("teleport-to-center", true);
|
return config.getBoolean("teleport-to-center", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Pattern, Long> commandCooldowns;
|
private Map<Pattern, Long> commandCooldowns;
|
||||||
|
|
||||||
private Map<Pattern, Long> _getCommandCooldowns() {
|
private Map<Pattern, Long> _getCommandCooldowns() {
|
||||||
@ -1268,10 +1245,10 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
cmdEntry = cmdEntry.substring(1);
|
cmdEntry = cmdEntry.substring(1);
|
||||||
}
|
}
|
||||||
String cmd = cmdEntry
|
String cmd = cmdEntry
|
||||||
.replaceAll("\\*", ".*"); // Wildcards are accepted as asterisk * as known universally.
|
.replaceAll("\\*", ".*"); // Wildcards are accepted as asterisk * as known universally.
|
||||||
pattern = Pattern.compile(cmd + "( .*)?"); // This matches arguments, if present, to "ignore" them from the feature.
|
pattern = Pattern.compile(cmd + "( .*)?"); // This matches arguments, if present, to "ignore" them from the feature.
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================
|
/* ================================
|
||||||
* >> Process cooldown value
|
* >> Process cooldown value
|
||||||
* ================================ */
|
* ================================ */
|
||||||
@ -1439,4 +1416,4 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
public boolean isDirectHatAllowed() {
|
public boolean isDirectHatAllowed() {
|
||||||
return config.getBoolean("allow-direct-hat", true);
|
return config.getBoolean("allow-direct-hat", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -72,7 +72,7 @@ public class Commandcreatekit extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
// Some users might want to directly write to config knowing the consequences. *shrug*
|
// Some users might want to directly write to config knowing the consequences. *shrug*
|
||||||
if (!ess.getSettings().isPastebinCreateKit()) {
|
if (!ess.getSettings().isPastebinCreateKit()) {
|
||||||
ess.getSettings().addKit(kitname, list, delay);
|
ess.getKits().addKit(kitname, list, delay);
|
||||||
user.sendMessage(tl("createdKit", kitname, list.size(), delay));
|
user.sendMessage(tl("createdKit", kitname, list.size(), delay));
|
||||||
} else {
|
} else {
|
||||||
ConfigurationSection config = new MemoryConfiguration();
|
ConfigurationSection config = new MemoryConfiguration();
|
||||||
|
@ -23,7 +23,7 @@ public class Commandkit extends EssentialsCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
final String kitList = Kit.listKits(ess, user);
|
final String kitList = ess.getKits().listKits(ess, user);
|
||||||
user.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits"));
|
user.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits"));
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
} else if (args.length > 1 && user.isAuthorized("essentials.kit.others")) {
|
} else if (args.length > 1 && user.isAuthorized("essentials.kit.others")) {
|
||||||
@ -39,7 +39,7 @@ public class Commandkit extends EssentialsCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
final String kitList = Kit.listKits(ess, null);
|
final String kitList = ess.getKits().listKits(ess, null);
|
||||||
sender.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits"));
|
sender.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits"));
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
} else {
|
} else {
|
||||||
@ -106,7 +106,7 @@ public class Commandkit extends EssentialsCommand {
|
|||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
List<String> options = new ArrayList<>();
|
List<String> options = new ArrayList<>();
|
||||||
// TODO: Move all of this to its own method
|
// TODO: Move all of this to its own method
|
||||||
for (String kitName : ess.getSettings().getKits().getKeys(false)) {
|
for (String kitName : ess.getKits().getKits().getKeys(false)) {
|
||||||
if (!user.isAuthorized("essentials.kits." + kitName)) { // Only check perm, not time or money
|
if (!user.isAuthorized("essentials.kits." + kitName)) { // Only check perm, not time or money
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ public class Commandkit extends EssentialsCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
return new ArrayList<>(ess.getSettings().getKits().getKeys(false)); // TODO: Move this to its own method
|
return new ArrayList<>(ess.getKits().getKits().getKeys(false)); // TODO: Move this to its own method
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
return getPlayers(server, sender);
|
return getPlayers(server, sender);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
|||||||
|
|
||||||
import com.earth2me.essentials.Kit;
|
import com.earth2me.essentials.Kit;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.Settings;
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -37,7 +36,7 @@ public class Commandshowkit extends EssentialsCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
return new ArrayList<>(ess.getSettings().getKits().getKeys(false)); // TODO: Move this to its own method
|
return new ArrayList<>(ess.getKits().getKits().getKeys(false)); // TODO: Move this to its own method
|
||||||
} else {
|
} else {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class SignKit extends EssentialsSign {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
ess.getSettings().getKit(kitName);
|
ess.getKits().getKit(kitName);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new SignException(ex.getMessage(), ex);
|
throw new SignException(ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
# Version ${project.version}-b${build.number}
|
# Version ${project.version}-b${build.number}
|
||||||
|
|
||||||
|
# KITS ARE NOW IN THE kits.yml FILE
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
# | Essentials (Global) | #
|
# | Essentials (Global) | #
|
||||||
@ -279,42 +281,11 @@ player-commands:
|
|||||||
# removed from the /kit list when a player can no longer use it
|
# removed from the /kit list when a player can no longer use it
|
||||||
skip-used-one-time-kits-from-kit-list: false
|
skip-used-one-time-kits-from-kit-list: false
|
||||||
|
|
||||||
# Note: All items MUST be followed by a quantity!
|
# Determines the functionality of the /createkit command.
|
||||||
# All kit names should be lower case, and will be treated as lower in permissions/costs.
|
# If this is true, /createkit will give the user a link with the kit code.
|
||||||
# Syntax: - itemID[:DataValue/Durability] Amount [Enchantment:Level].. [itemmeta:value]...
|
# If this is false, /createkit will add the kit to the kits.yml config file directly.
|
||||||
# For Item Meta information visit http://wiki.ess3.net/wiki/Item_Meta
|
#
|
||||||
# 'delay' refers to the cooldown between how often you can use each kit, measured in seconds.
|
pastebin-createkit: false
|
||||||
# Set delay to -1 for a one time kit.
|
|
||||||
# For more information, visit http://wiki.ess3.net/wiki/Kits
|
|
||||||
kits:
|
|
||||||
tools:
|
|
||||||
delay: 10
|
|
||||||
items:
|
|
||||||
- 272 1
|
|
||||||
- 273 1
|
|
||||||
- 274 1
|
|
||||||
- 275 1
|
|
||||||
dtools:
|
|
||||||
delay: 600
|
|
||||||
items:
|
|
||||||
- 278 1 efficiency:1 durability:1 fortune:1 name:&4Gigadrill lore:The_drill_that_&npierces|the_heavens
|
|
||||||
- 277 1 digspeed:3 name:Dwarf lore:Diggy|Diggy|Hole
|
|
||||||
- 298 1 color:255,255,255 name:Top_Hat lore:Good_day,_Good_day
|
|
||||||
- 279:780 1
|
|
||||||
notch:
|
|
||||||
delay: 6000
|
|
||||||
items:
|
|
||||||
- 397:3 1 player:Notch
|
|
||||||
color:
|
|
||||||
delay: 6000
|
|
||||||
items:
|
|
||||||
- 387 1 title:&4Book_&9o_&6Colors author:KHobbits lore:Ingame_color_codes book:Colors
|
|
||||||
firework:
|
|
||||||
delay: 6000
|
|
||||||
items:
|
|
||||||
- 401 1 name:Angry_Creeper color:red fade:green type:creeper power:1
|
|
||||||
- 401 1 name:Starry_Night color:yellow,orange fade:blue type:star effect:trail,twinkle power:1
|
|
||||||
- 401 2 name:Solar_Wind color:yellow,orange fade:red shape:large effect:twinkle color:yellow,orange fade:red shape:ball effect:trail color:red,purple fade:pink shape:star effect:trail power:1
|
|
||||||
|
|
||||||
# Essentials Sign Control
|
# Essentials Sign Control
|
||||||
# See http://wiki.ess3.net/wiki/Sign_Tutorial for instructions on how to use these.
|
# See http://wiki.ess3.net/wiki/Sign_Tutorial for instructions on how to use these.
|
||||||
@ -537,13 +508,6 @@ command-cooldown-persistence: true
|
|||||||
# NPC balances can include features like factions from FactionsUUID plugin.
|
# NPC balances can include features like factions from FactionsUUID plugin.
|
||||||
npcs-in-balance-ranking: false
|
npcs-in-balance-ranking: false
|
||||||
|
|
||||||
# Determines the functionality of the /createkit command.
|
|
||||||
# If this is true, /createkit will give the user a link with the kit code.
|
|
||||||
# If this is false, /createkit will add the kit to this config file directly.
|
|
||||||
#
|
|
||||||
# WARNING: If this is false, the config comments WILL be removed and it won't look the same as it does now.
|
|
||||||
pastebin-createkit: true
|
|
||||||
|
|
||||||
# Allow bulk buying and selling signs when the player is sneaking.
|
# Allow bulk buying and selling signs when the player is sneaking.
|
||||||
# This is useful when a sign sells or buys one item at a time and the player wants to sell a bunch at once.
|
# This is useful when a sign sells or buys one item at a time and the player wants to sell a bunch at once.
|
||||||
allow-bulk-buy-sell: true
|
allow-bulk-buy-sell: true
|
||||||
|
39
Essentials/src/kits.yml
Normal file
39
Essentials/src/kits.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# EssentialsX new Kit configuration.
|
||||||
|
# If you don't have any kits defined in this file, the plugin will try to copy them from the config.yml
|
||||||
|
|
||||||
|
# Note: All items MUST be followed by a quantity!
|
||||||
|
# All kit names should be lower case, and will be treated as lower in permissions/costs.
|
||||||
|
# Syntax: - itemID[:DataValue/Durability] Amount [Enchantment:Level].. [itemmeta:value]...
|
||||||
|
# For Item Meta information visit http://wiki.ess3.net/wiki/Item_Meta
|
||||||
|
# 'delay' refers to the cooldown between how often you can use each kit, measured in seconds.
|
||||||
|
# Set delay to -1 for a one time kit.
|
||||||
|
# For more information, visit http://wiki.ess3.net/wiki/Kits
|
||||||
|
kits:
|
||||||
|
tools:
|
||||||
|
delay: 10
|
||||||
|
items:
|
||||||
|
- 272 1
|
||||||
|
- 273 1
|
||||||
|
- 274 1
|
||||||
|
- 275 1
|
||||||
|
dtools:
|
||||||
|
delay: 600
|
||||||
|
items:
|
||||||
|
- 278 1 efficiency:1 durability:1 fortune:1 name:&4Gigadrill lore:The_drill_that_&npierces|the_heavens
|
||||||
|
- 277 1 digspeed:3 name:Dwarf lore:Diggy|Diggy|Hole
|
||||||
|
- 298 1 color:255,255,255 name:Top_Hat lore:Good_day,_Good_day
|
||||||
|
- 279:780 1
|
||||||
|
notch:
|
||||||
|
delay: 6000
|
||||||
|
items:
|
||||||
|
- 397:3 1 player:Notch
|
||||||
|
color:
|
||||||
|
delay: 6000
|
||||||
|
items:
|
||||||
|
- 387 1 title:&4Book_&9o_&6Colors author:KHobbits lore:Ingame_color_codes book:Colors
|
||||||
|
firework:
|
||||||
|
delay: 6000
|
||||||
|
items:
|
||||||
|
- 401 1 name:Angry_Creeper color:red fade:green type:creeper power:1
|
||||||
|
- 401 1 name:Starry_Night color:yellow,orange fade:blue type:star effect:trail,twinkle power:1
|
||||||
|
- 401 2 name:Solar_Wind color:yellow,orange fade:red shape:large effect:twinkle color:yellow,orange fade:red shape:ball effect:trail color:red,purple fade:pink shape:star effect:trail power:1
|
Loading…
Reference in New Issue
Block a user