Compare commits

..

4 Commits
6.3.2 ... 6.3.3

Author SHA1 Message Date
Auxilor
60c3b58a33 Updated to 6.3.3 2021-08-10 18:19:46 +01:00
Auxilor
7216d0b09f Fixed component serialization 2021-08-10 18:18:09 +01:00
Auxilor
97eeea8d48 Updated to 6.3.2 2021-08-10 16:18:49 +01:00
Auxilor
82061ee6a3 Added get/set repair cost methods to FastItemStack 2021-08-09 17:30:09 +01:00
6 changed files with 45 additions and 4 deletions

View File

@@ -47,6 +47,21 @@ public interface FastItemStack {
*/ */
List<String> getLore(); List<String> getLore();
/**
* Set the rework penalty.
*
* @param cost The rework penalty to set.
*/
void setRepairCost(int cost);
/**
* Get the rework penalty.
*.
* @return The rework penalty found on the item.
*/
int getRepairCost();
/** /**
* Get the Bukkit ItemStack again. * Get the Bukkit ItemStack again.
* *

View File

@@ -47,6 +47,15 @@ public class StringUtils {
.add(Pattern.compile("<#" + "([A-Fa-f0-9]{6})" + ">")) .add(Pattern.compile("<#" + "([A-Fa-f0-9]{6})" + ">"))
.build(); .build();
/**
* Legacy serializer.
*/
private static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.builder()
.character('\u00a7')
.useUnusualXRepeatedCharacterHexFormat()
.hexColors()
.build();
/** /**
* Format a list of strings - converts Placeholders and Color codes. * Format a list of strings - converts Placeholders and Color codes.
* *
@@ -246,7 +255,7 @@ public class StringUtils {
public String legacyToJson(@NotNull final String legacy) { public String legacyToJson(@NotNull final String legacy) {
return GsonComponentSerializer.gson().serialize( return GsonComponentSerializer.gson().serialize(
Component.empty().decoration(TextDecoration.ITALIC, false).append( Component.empty().decoration(TextDecoration.ITALIC, false).append(
LegacyComponentSerializer.legacySection().deserialize(legacy) LEGACY_COMPONENT_SERIALIZER.deserialize(legacy)
) )
); );
} }
@@ -258,7 +267,7 @@ public class StringUtils {
* @return The legacy string. * @return The legacy string.
*/ */
public String jsonToLegacy(@NotNull final String json) { public String jsonToLegacy(@NotNull final String json) {
return LegacyComponentSerializer.legacySection().serialize( return LEGACY_COMPONENT_SERIALIZER.serialize(
GsonComponentSerializer.gson().deserialize(json) GsonComponentSerializer.gson().deserialize(json)
); );
} }

View File

@@ -207,7 +207,8 @@ open class EcoYamlConfigWrapper<T : ConfigurationSection> : Config {
return if (cache.containsKey("$path\$FMT")) { return if (cache.containsKey("$path\$FMT")) {
cache["$path\$FMT"] as List<String> cache["$path\$FMT"] as List<String>
} else { } else {
cache["$path\$FMT"] = StringUtils.formatList(if (has(path)) ArrayList(handle.getStringList(path)) else ArrayList<String>()) val list = if (has(path)) handle.getStringList(path) else ArrayList()
cache["$path\$FMT"] = StringUtils.formatList(list);
getStrings(path, true) getStrings(path, true)
} }
} else { } else {

View File

@@ -96,6 +96,14 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS
} }
} }
override fun getRepairCost(): Int {
return handle.repairCost;
}
override fun setRepairCost(cost: Int) {
handle.repairCost = cost;
}
private fun apply() { private fun apply() {
if (bukkit !is CraftItemStack) { if (bukkit !is CraftItemStack) {
bukkit.itemMeta = CraftItemStack.asCraftMirror(handle).itemMeta bukkit.itemMeta = CraftItemStack.asCraftMirror(handle).itemMeta

View File

@@ -115,6 +115,14 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS
} }
} }
override fun getRepairCost(): Int {
return handle.baseRepairCost;
}
override fun setRepairCost(cost: Int) {
handle.setRepairCost(cost);
}
private fun apply() { private fun apply() {
if (bukkit !is CraftItemStack) { if (bukkit !is CraftItemStack) {
bukkit.itemMeta = CraftItemStack.asCraftMirror(handle).itemMeta bukkit.itemMeta = CraftItemStack.asCraftMirror(handle).itemMeta

View File

@@ -1,2 +1,2 @@
version = 6.3.1 version = 6.3.3
plugin-name = eco plugin-name = eco