Updated to beta30

This commit is contained in:
Auxilor 2020-10-19 15:51:00 +01:00
parent 7d4bc32f48
commit 64813ab8c3
8 changed files with 24 additions and 27 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>5.0.0-beta29</version>
<version>5.0.0-beta30</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>5.0.0-beta29</version>
<version>5.0.0-beta30</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>5.0.0-beta29</version>
<version>5.0.0-beta30</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>5.0.0-beta29</version>
<version>5.0.0-beta30</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>5.0.0-beta29</version>
<version>5.0.0-beta30</version>
</parent>
<artifactId>plugin</artifactId>

View File

@ -4,12 +4,12 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.willfp.ecoenchants.display.AbstractPacketAdapter;
import com.willfp.ecoenchants.display.EnchantDisplay;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
import java.util.List;
import java.util.stream.Collectors;
@SuppressWarnings("unchecked")
public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
public PacketOpenWindowMerchant() {
super(PacketType.Play.Server.OPEN_WINDOW_MERCHANT);
@ -17,26 +17,21 @@ public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
@Override
public void onSend(PacketContainer packet) {
List<MerchantRecipe> merchantRecipes = packet.getMerchantRecipeLists().readSafely(0);
if(merchantRecipes == null)
return;
List<MerchantRecipe> recipes = packet.getMerchantRecipeLists().readSafely(0);
List<MerchantRecipe> newList =
merchantRecipes.stream().map(oldRecipe -> {
MerchantRecipe recipe =
new MerchantRecipe(EnchantDisplay.displayEnchantments(oldRecipe.getResult()),
oldRecipe.getUses(),
oldRecipe.getMaxUses(),
oldRecipe.hasExperienceReward(),
oldRecipe.getVillagerExperience(),
oldRecipe.getPriceMultiplier());
List<ItemStack> ingredients = oldRecipe.getIngredients();
recipe.setPriceMultiplier(oldRecipe.getPriceMultiplier()); // idk either, no idea why it doesn't work
ingredients.forEach(EnchantDisplay::displayEnchantments);
recipe.setIngredients(ingredients);
return recipe;
}).collect(Collectors.toList());
recipes = recipes.stream().map(merchantRecipe -> {
MerchantRecipe newRecipe = new MerchantRecipe(
EnchantDisplay.displayEnchantments(merchantRecipe.getResult()),
merchantRecipe.getUses(),
merchantRecipe.getMaxUses(),
merchantRecipe.hasExperienceReward(),
merchantRecipe.getVillagerExperience(),
merchantRecipe.getPriceMultiplier()
);
newRecipe.setIngredients(merchantRecipe.getIngredients().stream().map(EnchantDisplay::displayEnchantments).collect(Collectors.toList()));
return newRecipe;
}).collect(Collectors.toList());
packet.getMerchantRecipeLists().writeSafely(0, newList);
packet.getMerchantRecipeLists().writeSafely(0, recipes);
}
}

View File

@ -85,7 +85,9 @@ public class Loader {
Logger.info("Loading ProtocolLib...");
EcoEnchantsPlugin.getInstance().protocolManager = ProtocolLibrary.getProtocolManager();
new PacketOpenWindowMerchant().register();
if(ConfigManager.getConfig().getBool("villager.enabled")) {
new PacketOpenWindowMerchant().register();
}
new PacketSetCreativeSlot().register();
new PacketSetSlot().register();
new PacketWindowItems().register();

View File

@ -6,7 +6,7 @@
<groupId>com.willfp.ecoenchants</groupId>
<artifactId>parent</artifactId>
<version>5.0.0-beta29</version>
<version>5.0.0-beta30</version>
<packaging>pom</packaging>
<name>EcoEnchants Parent</name>