Initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
/.idea/
|
||||
*.iml
|
||||
/target/
|
||||
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>me.youhavetrouble</groupId>
|
||||
<artifactId>MendingBeGone</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MendingBeGone</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc-repo</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.14-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,7 @@
|
||||
# Mending-Be-Gone
|
||||
|
||||
Plugin that removes mending. **Permanently.** This means the actions taken by the plugin are **unrecoverable**.
|
||||
|
||||
- Any instance of enchanted item with mending will have mending replaced by Unbreaking 3
|
||||
- Any instance of enchanted book with mending will have mending replaced by Unbreaking 3
|
||||
- Any villagers will have mending trade removed
|
||||
@@ -0,0 +1,88 @@
|
||||
package me.youhavetrouble.mendingbegone;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Merchant;
|
||||
import org.bukkit.inventory.MerchantInventory;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class MendingBeGone extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("Mending enchantment will be replaced with unbreaking 3");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onMendingItemPickup(EntityPickupItemEvent event) {
|
||||
replaceMendingOnItem(event.getItem().getItemStack());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onInvOpen(InventoryOpenEvent event) {
|
||||
for (ItemStack itemStack : event.getInventory().getContents()) {
|
||||
replaceMendingOnItem(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onLogin(PlayerJoinEvent event) {
|
||||
for (ItemStack itemStack : event.getPlayer().getInventory()) {
|
||||
replaceMendingOnItem(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onInvClick(InventoryClickEvent event) {
|
||||
replaceMendingOnItem(event.getCurrentItem());
|
||||
replaceMendingOnItem(event.getCursor());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onVillagerJoinWorld(InventoryOpenEvent event) {
|
||||
if (!(event.getInventory() instanceof MerchantInventory)) return;
|
||||
MerchantInventory merchantInventory = (MerchantInventory) event.getInventory();
|
||||
removeMendingTrade(merchantInventory.getMerchant());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onVillagerJoinWorld(EntityAddToWorldEvent event) {
|
||||
if (!event.getEntityType().equals(EntityType.VILLAGER)) return;
|
||||
removeMendingTrade((Merchant) event.getEntity());
|
||||
}
|
||||
|
||||
private void replaceMendingOnItem(ItemStack itemStack) {
|
||||
if (itemStack == null) return;
|
||||
if (itemStack.containsEnchantment(Enchantment.MENDING)) {
|
||||
itemStack.removeEnchantment(Enchantment.MENDING);
|
||||
if (itemStack.containsEnchantment(Enchantment.DURABILITY))
|
||||
itemStack.removeEnchantment(Enchantment.DURABILITY);
|
||||
itemStack.addEnchantment(Enchantment.DURABILITY, 3);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeMendingTrade(Merchant merchant) {
|
||||
List<MerchantRecipe> trades = new ArrayList<>(merchant.getRecipes());
|
||||
trades.removeIf(recipe -> {
|
||||
if (!recipe.getResult().getType().equals(Material.ENCHANTED_BOOK)) return false;
|
||||
EnchantmentStorageMeta storage = (EnchantmentStorageMeta) recipe.getResult().getItemMeta();
|
||||
return storage.hasStoredEnchant(Enchantment.MENDING);
|
||||
});
|
||||
merchant.setRecipes(trades);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
name: MendingBeGone
|
||||
version: '${project.version}'
|
||||
main: me.youhavetrouble.mendingbegone.MendingBeGone
|
||||
authors: ["YouHaveTrouble"]
|
||||
description: Removes mending and replaces it with unbreaking
|
||||
api-version: 1.14
|
||||
folia-supported: true
|
||||
Reference in New Issue
Block a user