forked from Upstream/VillagerTradeLimiter
Version 1.6.1:
* Added disabled professions feature * Added disabled trades feature (completely removes certain trades)
This commit is contained in:
parent
58d1b24ff0
commit
75df051d08
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.pretzel.dev</groupId>
|
||||
<artifactId>VillagerTradeLimiter</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<version>1.6.1</version>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
|
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.pretzel.dev</groupId>
|
||||
<artifactId>VillagerTradeLimiter</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<version>1.6.1</version>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
|
@ -4,15 +4,19 @@ import com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter;
|
||||
import com.pretzel.dev.villagertradelimiter.data.Cooldown;
|
||||
import com.pretzel.dev.villagertradelimiter.data.PlayerData;
|
||||
import com.pretzel.dev.villagertradelimiter.settings.Settings;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.VillagerAcquireTradeEvent;
|
||||
import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
||||
import org.bukkit.event.entity.VillagerReplenishTradeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VillagerListener implements Listener {
|
||||
@ -28,6 +32,41 @@ public class VillagerListener implements Listener {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
/** Handles villager promotions */
|
||||
@EventHandler
|
||||
public void onVillagerPromotion(final VillagerAcquireTradeEvent event) {
|
||||
//Gets the items in the trade
|
||||
final MerchantRecipe recipe = event.getRecipe();
|
||||
List<ItemStack> items = recipe.getIngredients();
|
||||
items.add(recipe.getResult());
|
||||
|
||||
//Gets the disabled item list from config
|
||||
List<String> disabledItems = instance.getCfg().getStringList("DisableItems");
|
||||
|
||||
//Checks each item if it should be removed from the trade list
|
||||
for(ItemStack item : items) {
|
||||
if(disabledItems.contains(item.getType().name().toLowerCase())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Handles villager profession change **/
|
||||
@EventHandler
|
||||
public void onVillagerChangeProfession(final VillagerCareerChangeEvent event) {
|
||||
//Gets the new profession
|
||||
final Villager.Profession profession = event.getProfession();
|
||||
|
||||
//Gets the disabled profession list from config
|
||||
List<String> disabledProfessions = instance.getCfg().getStringList("DisableProfessions");
|
||||
|
||||
//Changes the new profession to none if disabled in config
|
||||
if(disabledProfessions.contains(profession.name().toLowerCase())) {
|
||||
event.setProfession(Villager.Profession.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
/** Handles villager restocks */
|
||||
@EventHandler
|
||||
public void onVillagerRestock(final VillagerReplenishTradeEvent event) {
|
||||
|
@ -41,6 +41,13 @@ DisableTrading:
|
||||
- world_nether
|
||||
- world_the_end
|
||||
|
||||
# Add profession names that you want to prevent villagers from acquiring
|
||||
DisableProfessions: []
|
||||
|
||||
# Add item names that you want to prevent villagers from offering as trades.
|
||||
# This is a permanent change. The items can't be re-added to the villager's trades.
|
||||
DisableItems: []
|
||||
|
||||
# The maximum level of the "Hero of the Village" (HotV) effect that a player can have. This limits HotV price decreases.
|
||||
# * Set to -1 to disable this feature and keep vanilla behavior.
|
||||
# * Set to a number between 0 and 5 to set the maximum HotV effect level players can have
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: VillagerTradeLimiter
|
||||
author: PretzelJohn
|
||||
main: com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter
|
||||
version: 1.6.0
|
||||
version: 1.6.1
|
||||
api-version: 1.14
|
||||
|
||||
commands:
|
||||
|
Loading…
Reference in New Issue
Block a user