mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-24 00:41:23 +01:00
Updated to beta30
This commit is contained in:
parent
7d4bc32f48
commit
64813ab8c3
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user