Compare commits

...

3 Commits
6.6.0 ... 6.6.1

Author SHA1 Message Date
Auxilor
7c9d226bc3 Updated to 6.6.1 2021-08-31 14:52:52 +01:00
Auxilor
031401bb8e Added option to lang.yml 2021-08-31 14:52:37 +01:00
Auxilor
1a5c429b67 Fixed villager trade display with players 2021-08-31 14:51:45 +01:00
6 changed files with 25 additions and 29 deletions

View File

@@ -2,6 +2,7 @@ package com.willfp.eco.core.config.base;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.yaml.YamlBaseConfig;
import com.willfp.eco.util.StringUtils;
import org.jetbrains.annotations.NotNull;
/**
@@ -42,6 +43,18 @@ public class LangYml extends YamlBaseConfig {
* @return The message with a prefix appended.
*/
public String getMessage(@NotNull final String message) {
return getPrefix() + this.getString("messages." + message);
return getMessage(message, StringUtils.FormatOption.WITH_PLACEHOLDERS);
}
/**
* Get a chat message.
*
* @param message The key of the message.
* @param option The format options.
* @return The message with a prefix appended.
*/
public String getMessage(@NotNull final String message,
@NotNull final StringUtils.FormatOption option) {
return getPrefix() + this.getString("messages." + message, option);
}
}

View File

@@ -1,9 +1,9 @@
package com.willfp.eco.proxy.v1_16_R3
import com.willfp.eco.core.display.Display
import com.willfp.eco.proxy.VillagerTradeProxy
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMerchantRecipe
import org.bukkit.entity.Player
import org.bukkit.inventory.MerchantRecipe
import com.willfp.eco.proxy.VillagerTradeProxy
import java.lang.reflect.Field
class VillagerTrade : VillagerTradeProxy {
@@ -15,7 +15,7 @@ class VillagerTrade : VillagerTradeProxy {
): MerchantRecipe {
val oldRecipe = recipe as CraftMerchantRecipe
val newRecipe = CraftMerchantRecipe(
Display.display(recipe.getResult().clone()),
Display.display(recipe.getResult().clone(), player),
recipe.getUses(),
recipe.getMaxUses(),
recipe.hasExperienceReward(),

View File

@@ -1,15 +1,15 @@
package com.willfp.eco.proxy.v1_17_R1
import com.willfp.eco.core.display.Display
import com.willfp.eco.proxy.VillagerTradeProxy
import net.minecraft.world.item.trading.MerchantOffer
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMerchantRecipe
import org.bukkit.entity.Player
import org.bukkit.inventory.MerchantRecipe
import com.willfp.eco.proxy.VillagerTradeProxy
import java.lang.reflect.Field
class VillagerTrade : VillagerTradeProxy {
private var handle: Field
private val handle: Field = CraftMerchantRecipe::class.java.getDeclaredField("handle")
override fun displayTrade(
recipe: MerchantRecipe,
@@ -17,7 +17,7 @@ class VillagerTrade : VillagerTradeProxy {
): MerchantRecipe {
val oldRecipe = recipe as CraftMerchantRecipe
val newRecipe = CraftMerchantRecipe(
Display.display(recipe.getResult().clone()),
Display.display(recipe.getResult().clone(), player),
recipe.getUses(),
recipe.getMaxUses(),
recipe.hasExperienceReward(),
@@ -32,21 +32,10 @@ class VillagerTrade : VillagerTradeProxy {
}
private fun getHandle(recipe: CraftMerchantRecipe): MerchantOffer {
try {
return handle[recipe] as MerchantOffer
} catch (e: IllegalAccessException) {
e.printStackTrace()
}
throw IllegalArgumentException("Not CMR")
return handle[recipe] as MerchantOffer
}
init {
try {
handle = CraftMerchantRecipe::class.java.getDeclaredField("handle")
handle.isAccessible = true
} catch (e: NoSuchFieldException) {
e.printStackTrace()
throw RuntimeException("Error!")
}
handle.isAccessible = true
}
}

View File

@@ -121,19 +121,14 @@ abstract class EcoSpigotPlugin : EcoPlugin(
}
override fun loadPacketAdapters(): List<AbstractPacketAdapter> {
val adapters = mutableListOf(
return listOf(
PacketAutoRecipe(this),
PacketChat(this),
PacketSetCreativeSlot(this),
PacketSetSlot(this),
PacketWindowItems(this)
PacketWindowItems(this),
PacketOpenWindowMerchant(this)
)
if (!configYml.getBool("disable-display-on-villagers")) {
adapters.add(PacketOpenWindowMerchant(this))
}
return adapters
}
override fun loadListeners(): List<Listener> {

View File

@@ -5,7 +5,6 @@
# Options to fix villager bugs left behind from old (buggy) versions.
disable-display-on-villagers: false
villager-display-fix: false
# DropQueue by default uses a faster collated queue system where all drops

View File

@@ -1,2 +1,2 @@
version = 6.6.0
version = 6.6.1
plugin-name = eco