mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Add blacklist option for grindstone
This commit is contained in:
@@ -80,6 +80,27 @@ update-perms-on-world-change
|
||||
* **default**: false
|
||||
* **description:** When a player changes worlds the server recalculates their permissions and resends their available commands. This can be laggy, so the option is disabled by default
|
||||
|
||||
grindstone
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
* disallow-placement
|
||||
- **default**: true
|
||||
- **description**: Disallow placing blacklisted items into the grindstone UI slots
|
||||
|
||||
* returns-zero-exp
|
||||
- **default**: true
|
||||
- **description**: Return 0 exp for blacklisted items in the grindstone
|
||||
|
||||
* blacklisted-items
|
||||
- **default**: {}
|
||||
- **description**: List of blacklisted items for grindstone
|
||||
|
||||
.. note::
|
||||
Example of blacklisted-items:
|
||||
* blacklisted-items:
|
||||
- minecraft:tripwire_hook
|
||||
- minecraft:stone
|
||||
- minecraft:grass_block
|
||||
|
||||
logger
|
||||
~~~~~~
|
||||
* show-duplicate-entity-uuid-errors
|
||||
|
||||
102
patches/server/0056-Add-blacklist-option-for-grindstone.patch
Normal file
102
patches/server/0056-Add-blacklist-option-for-grindstone.patch
Normal file
@@ -0,0 +1,102 @@
|
||||
From 7f40cc38f5f6150023d2fddfe85838a04ae17059 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Thu, 1 Aug 2019 19:15:12 -0500
|
||||
Subject: [PATCH] Add blacklist option for grindstone
|
||||
|
||||
---
|
||||
.../minecraft/server/ContainerGrindstone.java | 17 +++++++++++++++++
|
||||
.../java/net/minecraft/server/ItemStack.java | 6 ++++++
|
||||
src/main/java/net/pl3x/purpur/PurpurConfig.java | 12 ++++++++++++
|
||||
3 files changed, 35 insertions(+)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerGrindstone.java b/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
||||
index ed88e208..0a5abd2e 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
||||
@@ -57,12 +57,24 @@ public class ContainerGrindstone extends Container {
|
||||
this.a(new Slot(this.craftInventory, 0, 49, 19) {
|
||||
@Override
|
||||
public boolean isAllowed(ItemStack itemstack) {
|
||||
+ // Purpur start
|
||||
+ if (net.pl3x.purpur.PurpurConfig.grindstoneBlacklistDisallowPlacement && net.pl3x.purpur.PurpurConfig.grindstoneBlacklist.contains(itemstack.getId())) {
|
||||
+ getBukkitView().getTopInventory().getViewers().forEach(viewer -> ((Player) viewer).updateInventory());
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
return itemstack.e() || itemstack.getItem() == Items.ENCHANTED_BOOK || itemstack.hasEnchantments();
|
||||
}
|
||||
});
|
||||
this.a(new Slot(this.craftInventory, 1, 49, 40) {
|
||||
@Override
|
||||
public boolean isAllowed(ItemStack itemstack) {
|
||||
+ // Purpur start
|
||||
+ if (net.pl3x.purpur.PurpurConfig.grindstoneBlacklistDisallowPlacement && net.pl3x.purpur.PurpurConfig.grindstoneBlacklist.contains(itemstack.getId())) {
|
||||
+ getBukkitView().getTopInventory().getViewers().forEach(viewer -> ((Player) viewer).updateInventory());
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
return itemstack.e() || itemstack.getItem() == Items.ENCHANTED_BOOK || itemstack.hasEnchantments();
|
||||
}
|
||||
});
|
||||
@@ -106,6 +118,11 @@ public class ContainerGrindstone extends Container {
|
||||
}
|
||||
|
||||
private int e(ItemStack itemstack) {
|
||||
+ // Purpur start
|
||||
+ if (net.pl3x.purpur.PurpurConfig.grindstoneBlacklistReturnsZeroExp && net.pl3x.purpur.PurpurConfig.grindstoneBlacklist.contains(itemstack.getId())) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
int j = 0;
|
||||
Map<Enchantment, Integer> map = EnchantmentManager.a(itemstack);
|
||||
Iterator iterator = map.entrySet().iterator();
|
||||
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
index 43e89b99..e538ba39 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
@@ -538,6 +538,12 @@ public final class ItemStack {
|
||||
return !this.e() ? this.doMaterialsMatch(itemstack) : !itemstack.isEmpty() && this.getItem() == itemstack.getItem();
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ public String getId() {
|
||||
+ return IRegistry.ITEM.getKey(getItem()).toString();
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
public String j() {
|
||||
return this.getItem().f(this);
|
||||
}
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
||||
index 20231143..ee83df5c 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.pl3x.purpur;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
+import com.google.common.collect.Lists;
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.IRegistry;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
@@ -171,6 +172,17 @@ public class PurpurConfig {
|
||||
updatePermissionsOnWorldChange = getBoolean("settings.update-perms-on-world-change", updatePermissionsOnWorldChange);
|
||||
}
|
||||
|
||||
+ public static boolean grindstoneBlacklistDisallowPlacement = true;
|
||||
+ public static boolean grindstoneBlacklistReturnsZeroExp = true;
|
||||
+ public static List<String> grindstoneBlacklist = Lists.newArrayList("minecraft:tripwire_hook");
|
||||
+ private static void grindstoneBlacklist() {
|
||||
+ grindstoneBlacklistDisallowPlacement = getBoolean("settings.grindstone.disallow-placement", grindstoneBlacklistDisallowPlacement);
|
||||
+ grindstoneBlacklistReturnsZeroExp = getBoolean("settings.grindstone.returns-zero-exp", grindstoneBlacklistReturnsZeroExp);
|
||||
+ List<String> blacklist = getList("settings.grindstone.blacklisted-items", grindstoneBlacklist);
|
||||
+ grindstoneBlacklist.clear();
|
||||
+ grindstoneBlacklist.addAll(blacklist);
|
||||
+ }
|
||||
+
|
||||
public static boolean requireShiftToMount = true;
|
||||
private static void requireShiftToMount() {
|
||||
requireShiftToMount = getBoolean("settings.mobs.require-shift-to-mount", requireShiftToMount);
|
||||
--
|
||||
2.20.1
|
||||
|
||||
Reference in New Issue
Block a user