Compare commits

...

2 Commits

Author SHA1 Message Date
PretzelJohn e066603ce5 Version 2.0.1:
* Added temporary fix for a bug where discounts are invisible on some servers, due to a race condition. See the new "TradeDelay" option in config.yml
* Added config option to allow multiple players to trade with the same villager at the same time
2022-09-09 23:44:26 -04:00
PretzelJohn 40a237adc1 Version 2.0.1:
* Added temporary fix for a bug where discounts are invisible on some servers, due to a race condition. See the new "TradeDelay" option in config.yml
2022-09-09 23:32:49 -04:00
7 changed files with 26 additions and 6 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.pretzel.dev</groupId>
<artifactId>VillagerTradeLimiter</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.pretzel.dev</groupId>
<artifactId>VillagerTradeLimiter</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<properties>
<java.version>17</java.version>

View File

@ -1,7 +1,6 @@
package com.pretzel.dev.villagertradelimiter.data;
import com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter;
import com.pretzel.dev.villagertradelimiter.lib.Util;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.ItemStack;

View File

@ -124,10 +124,19 @@ public class PlayerListener implements Listener {
}
customRecipes.put(villager, recipes);
player.openMerchant(villager, false);
//Opens the trading window
boolean multipleTraders = instance.getSettings().getMultipleTraders();
int delay = instance.getSettings().getTradeDelay();
if(delay >= 0) {
Bukkit.getScheduler().runTaskLater(instance, () -> player.openMerchant(villager, multipleTraders), delay);
} else {
player.openMerchant(villager, multipleTraders);
}
//Updates the prices
for(int i = 0; i < villager.getRecipes().size(); i++) {
villager.getRecipe(i).setSpecialPrice(recipes.get(i).getDiscount(totalReputation, hotvDiscount));
int discount = recipes.get(i).getDiscount(totalReputation, hotvDiscount);
villager.getRecipe(i).setSpecialPrice(discount);
}
}

View File

@ -17,6 +17,8 @@ public class Config {
private final List<String> disableTrading;
private final List<String> disableProfessions;
private final String restock;
private final boolean multipleTraders;
private final int tradeDelay;
public Config(final ConfigurationSection config) {
this.database = config.getConfigurationSection("Database");
@ -28,6 +30,8 @@ public class Config {
this.disableTrading = config.getStringList("DisableTrading");
this.disableProfessions = config.getStringList("DisableProfessions");
this.restock = config.getString("Restock", "0h");
this.multipleTraders = config.getBoolean("MultipleTraders", false);
this.tradeDelay = config.getInt("TradeDelay", -1);
}
/**
@ -51,4 +55,6 @@ public class Config {
public List<String> getDisableTrading() { return this.disableTrading; }
public List<String> getDisableProfessions() { return this.disableProfessions; }
public String getRestock() { return this.restock; }
public boolean getMultipleTraders() { return this.multipleTraders; }
public int getTradeDelay() { return this.tradeDelay; }
}

View File

@ -51,3 +51,9 @@ DisableProfessions: []
# d = days ("3d" = 3 days)
# w = weeks ("2w" = 2 weeks)
Restock: 0h
# Set this to true to allow multiple players to trade with the same villager at the same time
MultipleTraders: false
# Setting this to 0 or 1 may fix some issues with discounts not showing up. Set to -1 to disable
TradeDelay: -1

View File

@ -1,7 +1,7 @@
name: VillagerTradeLimiter
author: PretzelJohn
main: com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter
version: 2.0.0
version: 2.0.1
api-version: 1.14
commands: