TradeControl
Automatically control or modify the trades that are offered by villagers. This plugin is intended for server owners who want to make sure that their players cannot exploit the trading system. This way, trading can stay enabled and provide a challenging and exciting experience that is fair to everyone.
Note The exploit that this plugin attempts to fix was fixed or at least considerably nerfed in Minecraft version 1.4. TradeControl still works however, and can be used to modify villager trades.
Preamble
Villager trading as introduced with Minecraft 1.3 has a couple of widely known exploits. The result is that players are able to produce great amounts of emeralds and trade them for valuable goods, thus breaking the game. TradeControl aims at filtering the existing trades of villagers and changing them in a configurable way.
The exploit
The exploit has three components
- The possibility to trade materials that are farmable with little to no effort for emeralds. The focus is on deals including paper.
- The unlimited availability of any trade. This is possible because players can continue a single trade without limitations by leaving the trading menu open.
- The possibility to trade emeralds for goods. Minecraft offers trades for food, glowstone, diamond tools and enchantments. This breaks the game.
The solution
TradeControl can filter the available trades of existing villagers and modify the undesirable ones by either deleting them or replacing them with other ones. Both filters and replacements are configurable.
Features
- Automatically modify naturally spawned villagers in an existing world.
- Define your own trades to replace existing ones you don't like.
- Get statistics of trades that are available in your world to make sure you don't miss anything.
- Performance-savvy: Villagers are by default only checked when a player interacts with them.
Shortcomings
- There is no trading API in Bukkit, so this plugin uses the CraftBukkit and Minecraft interfaces will break with most releases.
- Enchantments are currently ignored and cannot be specified. I can add this if people are interested.
Permissions
- tradecontrol.cmd Access to the /tradecontrol (or /tc) command. This should be given to no one but admins.
- tradecontrol.notify Receive a message whenever TradeControl modifies a villager.
Command
TradeControl has one ingame command: /tradecontrol or /tc with the following subcommands:
- /tc help Display help.
- /tc reload Reload the configuration file.
- /tc scan Scan all the villagers on your server and filter their trades. This may cause one lag spike.
- /tc list Display a list of all trades TradeControl has discovered on your server since the last boot.
- /tc dump Write the list of available trades to disk for later review.
Configuration
The default configuration replaces the emerald deals for paper and written books and replaces them with a large amount of books. Trading many books for emeralds is not considered exploitable since the leather takes some effort to farm, other than the sugar cane, the process of which can be fully automated. It also makes the deals for wheat a little more expensive since wheat is fairly easy to farm.
# TradeControl configuration file # # Sections: # filters: A list of trade filters # buy: A list patterns of items the villager buys. Must be one or two. # Only matching patterns will be processed. # type: The item type as in org.bukkit.Material. # damage: The item damage or data value. # minAmount: The minimum item amount to match. # minAmount: The maximum item amount to match. # amount: The exact amount to match. # sell: The pattern of the item the villager sells. # Details see filters.buy. # action: Either "delete" or "replace". # replacements: A list of replacements by name as specified in trades. # Only valid if action equals "replace". # trades: Named trade patterns for replacements. # Details see filters.buy. filters: - trade: buy: - type: paper sell: type: emerald action: replace replacements: [ manybooks ] - trade: buy: - type: written_book sell: type: emerald action: replace replacements: [ manybooks ] - trade: buy: - type: wheat maxamount: 23 sell: type: emerald action: replace replacements: [ muchwheat ] trades: manybooks: buy: - type: book minamount: 32 maxamount: 64 sell: type: emerald amount: 1 muchwheat: buy: - type: wheat minamount: 24 maxamount: 64 sell: type: emerald amount: 1
Someone has a version for 1.6.2 plz?
Version for Bukkit 1.5.2 >> [Removed unapproved link]
Can someone please make a turtorial? i dont really understand the configuration.
@KodekPL
Seems to be working alright. Thanks.
I am doing this mostly for myself so I don't upload any crap.
[Removed unapproved link]
@KodekPL
Was this tested at all or did it just break with 1.5.1?
Version updated for Minecraft 1.5 :) [Removed unapproved link]
@ProjectInfinity
Thanks :)
Is there any specific reason why this is compiled against JDK 1.7?
Here's an update for 1.4.7 since this plugin broke with it. Seeing as StarTux has not updated, why not share it.
[Removed unapproved link]
Use the 1.4.6's version sent by KodekPL
[Removed unapproved link]
I'm running CB 1.4.6-R0.3 (#2586) and got the following error when (I assume) someone tried to make a trade after I updated to TradeControl v0.2:
2013-01-03 14:52:56 [SEVERE] Could not pass event PlayerInteractEntityEvent to TradeControl v0.2 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477) at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462) at net.minecraft.server.v1_4_6.PlayerConnection.a(PlayerConnection.java:1096) at net.minecraft.server.v1_4_6.Packet7UseEntity.handle(SourceFile:36) at net.minecraft.server.v1_4_6.NetworkManager.b(NetworkManager.java:290) at net.minecraft.server.v1_4_6.PlayerConnection.d(PlayerConnection.java:112) at net.minecraft.server.v1_4_6.ServerConnection.b(SourceFile:39) at net.minecraft.server.v1_4_6.DedicatedServerConnection.b(SourceFile:30) at net.minecraft.server.v1_4_6.MinecraftServer.r(MinecraftServer.java:598) at net.minecraft.server.v1_4_6.DedicatedServer.r(DedicatedServer.java:224) at net.minecraft.server.v1_4_6.MinecraftServer.q(MinecraftServer.java:494) at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:427) at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849) Caused by: java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/v1_4_5/inventory/CraftItemStack at com.winthier.tradecontrol.Statistics.record(Statistics.java:52) at com.winthier.tradecontrol.PlayerListener.onPlayerInteractEntity(PlayerListener.java:48) at sun.reflect.GeneratedMethodAccessor210.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
Work fine on 1.4.6-R0.3
Hello, I installed v0.2 on my craftbukkit-1.4.6-R0.2 Server, and clicked on a villager, then it threw this in the log of the console:
23:53:09 [SEVERE] Could not pass event PlayerInteractEntityEvent to TradeControl v0.2 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477) at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462) at net.minecraft.server.v1_4_6.PlayerConnection.a(PlayerConnection.java:1096) at net.minecraft.server.v1_4_6.Packet7UseEntity.handle(SourceFile:36) at net.minecraft.server.v1_4_6.NetworkManager.b(NetworkManager.java:290) at net.minecraft.server.v1_4_6.PlayerConnection.d(PlayerConnection.java:112) at net.minecraft.server.v1_4_6.ServerConnection.b(SourceFile:39) at net.minecraft.server.v1_4_6.DedicatedServerConnection.b(SourceFile:30) at net.minecraft.server.v1_4_6.MinecraftServer.r(MinecraftServer.java:598) at net.minecraft.server.v1_4_6.DedicatedServer.r(DedicatedServer.java:224) at net.minecraft.server.v1_4_6.MinecraftServer.q(MinecraftServer.java:494) at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:427) at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849) Caused by: java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/v1_4_5/inventory/CraftItemStack at com.winthier.tradecontrol.Statistics.record(Statistics.java:52) at com.winthier.tradecontrol.PlayerListener.onPlayerInteractEntity(PlayerListener.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425) ... 14 more Caused by: java.lang.ClassNotFoundException: org.bukkit.craftbukkit.v1_4_5.inventory.CraftItemStack at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:70) at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 21 more
I hope you can fix this, as I cannot do anything with this happening. Thanks for reading. I will also try:
[Removed unapproved link]
@KodekPL
Thanks for 1.4.6's version :)
@KodekPL
Thank you, sir. :)
I don't know if StarTuxDev will update TradeControl for CraftBukkit 1.4.5-1.0 so I update it, glad he gives us source code :)
[Removed unapproved link]
EDIT:
[Removed unapproved link]
Works with CB 1.4.2-R0.2 It does the job. Minor caveat, it spams the console whenever someone interacts with a villager.
Hello there. I appreciate what you've done so far, but could anyone tell me how to replace existing wool trades with the defined ones? It seems not to work.
What's more, I've noticed that a minamount is always divided by 2, so if the amount is set to 64, it actually appears to be 32 in the game.
Is it possible to complete block enchantments from being traded? I'd like to do that.
It's still working, but it would be cool if replace offert do not reset "uses" counter.