Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c9d226bc3 | ||
|
|
031401bb8e | ||
|
|
1a5c429b67 |
@@ -2,6 +2,7 @@ package com.willfp.eco.core.config.base;
|
|||||||
|
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.config.yaml.YamlBaseConfig;
|
import com.willfp.eco.core.config.yaml.YamlBaseConfig;
|
||||||
|
import com.willfp.eco.util.StringUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +43,18 @@ public class LangYml extends YamlBaseConfig {
|
|||||||
* @return The message with a prefix appended.
|
* @return The message with a prefix appended.
|
||||||
*/
|
*/
|
||||||
public String getMessage(@NotNull final String message) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.willfp.eco.proxy.v1_16_R3
|
package com.willfp.eco.proxy.v1_16_R3
|
||||||
import com.willfp.eco.core.display.Display
|
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.craftbukkit.v1_16_R3.inventory.CraftMerchantRecipe
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.inventory.MerchantRecipe
|
import org.bukkit.inventory.MerchantRecipe
|
||||||
import com.willfp.eco.proxy.VillagerTradeProxy
|
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
|
|
||||||
class VillagerTrade : VillagerTradeProxy {
|
class VillagerTrade : VillagerTradeProxy {
|
||||||
@@ -15,7 +15,7 @@ class VillagerTrade : VillagerTradeProxy {
|
|||||||
): MerchantRecipe {
|
): MerchantRecipe {
|
||||||
val oldRecipe = recipe as CraftMerchantRecipe
|
val oldRecipe = recipe as CraftMerchantRecipe
|
||||||
val newRecipe = CraftMerchantRecipe(
|
val newRecipe = CraftMerchantRecipe(
|
||||||
Display.display(recipe.getResult().clone()),
|
Display.display(recipe.getResult().clone(), player),
|
||||||
recipe.getUses(),
|
recipe.getUses(),
|
||||||
recipe.getMaxUses(),
|
recipe.getMaxUses(),
|
||||||
recipe.hasExperienceReward(),
|
recipe.hasExperienceReward(),
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.willfp.eco.proxy.v1_17_R1
|
package com.willfp.eco.proxy.v1_17_R1
|
||||||
|
|
||||||
import com.willfp.eco.core.display.Display
|
import com.willfp.eco.core.display.Display
|
||||||
|
import com.willfp.eco.proxy.VillagerTradeProxy
|
||||||
import net.minecraft.world.item.trading.MerchantOffer
|
import net.minecraft.world.item.trading.MerchantOffer
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMerchantRecipe
|
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMerchantRecipe
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.inventory.MerchantRecipe
|
import org.bukkit.inventory.MerchantRecipe
|
||||||
import com.willfp.eco.proxy.VillagerTradeProxy
|
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
|
|
||||||
class VillagerTrade : VillagerTradeProxy {
|
class VillagerTrade : VillagerTradeProxy {
|
||||||
private var handle: Field
|
private val handle: Field = CraftMerchantRecipe::class.java.getDeclaredField("handle")
|
||||||
|
|
||||||
override fun displayTrade(
|
override fun displayTrade(
|
||||||
recipe: MerchantRecipe,
|
recipe: MerchantRecipe,
|
||||||
@@ -17,7 +17,7 @@ class VillagerTrade : VillagerTradeProxy {
|
|||||||
): MerchantRecipe {
|
): MerchantRecipe {
|
||||||
val oldRecipe = recipe as CraftMerchantRecipe
|
val oldRecipe = recipe as CraftMerchantRecipe
|
||||||
val newRecipe = CraftMerchantRecipe(
|
val newRecipe = CraftMerchantRecipe(
|
||||||
Display.display(recipe.getResult().clone()),
|
Display.display(recipe.getResult().clone(), player),
|
||||||
recipe.getUses(),
|
recipe.getUses(),
|
||||||
recipe.getMaxUses(),
|
recipe.getMaxUses(),
|
||||||
recipe.hasExperienceReward(),
|
recipe.hasExperienceReward(),
|
||||||
@@ -32,21 +32,10 @@ class VillagerTrade : VillagerTradeProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getHandle(recipe: CraftMerchantRecipe): MerchantOffer {
|
private fun getHandle(recipe: CraftMerchantRecipe): MerchantOffer {
|
||||||
try {
|
return handle[recipe] as MerchantOffer
|
||||||
return handle[recipe] as MerchantOffer
|
|
||||||
} catch (e: IllegalAccessException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
throw IllegalArgumentException("Not CMR")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
try {
|
handle.isAccessible = true
|
||||||
handle = CraftMerchantRecipe::class.java.getDeclaredField("handle")
|
|
||||||
handle.isAccessible = true
|
|
||||||
} catch (e: NoSuchFieldException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
throw RuntimeException("Error!")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,19 +121,14 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun loadPacketAdapters(): List<AbstractPacketAdapter> {
|
override fun loadPacketAdapters(): List<AbstractPacketAdapter> {
|
||||||
val adapters = mutableListOf(
|
return listOf(
|
||||||
PacketAutoRecipe(this),
|
PacketAutoRecipe(this),
|
||||||
PacketChat(this),
|
PacketChat(this),
|
||||||
PacketSetCreativeSlot(this),
|
PacketSetCreativeSlot(this),
|
||||||
PacketSetSlot(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> {
|
override fun loadListeners(): List<Listener> {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# Options to fix villager bugs left behind from old (buggy) versions.
|
# Options to fix villager bugs left behind from old (buggy) versions.
|
||||||
disable-display-on-villagers: false
|
|
||||||
villager-display-fix: false
|
villager-display-fix: false
|
||||||
|
|
||||||
# DropQueue by default uses a faster collated queue system where all drops
|
# DropQueue by default uses a faster collated queue system where all drops
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
version = 6.6.0
|
version = 6.6.1
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
Reference in New Issue
Block a user