Change for actions
This commit is contained in:
1 parent
b7a60f1352
commit
554dd8ad39
5 files changed
+8
-8
No files matched your search
@@ -16,7 +16,7 @@ public class ChatAction {
|
||||
|
||||
public ChatAction(ItemSlot slot, Player origin, ItemStack item) {
|
||||
this.slot = slot;
|
||||
this.item = item;
|
||||
this.item = item == null ? new ItemStack(Material.AIR) : item;
|
||||
this.origin = origin;
|
||||
this.isItem = true;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ChatEventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
ChatAction action = ChatManager.getChatAction(slot, p);
|
||||
if(!ChatManager.canUsePlaceholder(p, action.getItem(), slot, e))
|
||||
if(!ChatManager.canUsePlaceholder(p, action, slot, e))
|
||||
return;
|
||||
String s = slot.replacePlaceholdersToSeparator(e.getMessage());
|
||||
if (Utils.countMatches(s, Character.toString(ChatManager.SEPARATOR)) > getStorage().limit) {
|
||||
|
||||
@@ -283,7 +283,7 @@ public abstract class ChatManager {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static boolean canUsePlaceholder(Player p, ItemStack item, ItemSlot slot, @Nullable Cancellable e) {
|
||||
public static boolean canUsePlaceholder(Player p, ChatAction action, ItemSlot slot, @Nullable Cancellable e) {
|
||||
Storage c = ChatItem.getInstance().getStorage();
|
||||
if (c.permissionEnabled && !p.hasPermission(c.permissionName)) {
|
||||
if (!c.letMessageThrough) {
|
||||
@@ -295,7 +295,7 @@ public abstract class ChatManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (item != null && item.getType().equals(Material.AIR) && slot.isBasic()) {
|
||||
if (action.isItem() && action.getItem().getType().equals(Material.AIR) && slot.isBasic()) {
|
||||
if (slot.isDenyIfNoItem()) {
|
||||
if (e != null)
|
||||
e.setCancelled(true);
|
||||
@@ -328,9 +328,9 @@ public abstract class ChatManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item != null) {
|
||||
if (action.isItem()) {
|
||||
for (String ignored : c.ignoredItems) {
|
||||
if (item.getType().name().toLowerCase().contains(ignored.toLowerCase())) {
|
||||
if (action.getItem().getType().name().toLowerCase().contains(ignored.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ChatListener implements Listener {
|
||||
return;
|
||||
}
|
||||
ChatAction action = ChatManager.getChatAction(slot, p);
|
||||
if(!ChatManager.canUsePlaceholder(p, action.getItem(), slot, e))
|
||||
if(!ChatManager.canUsePlaceholder(p, action, slot, e))
|
||||
return;
|
||||
e.setCancelled(true);
|
||||
String format = e.getFormat().replace(targetReplace, slot.getPlaceholders().get(0));
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PaperListener implements Listener {
|
||||
if (slot == null) // if not found
|
||||
return;
|
||||
ChatAction action = ChatManager.getChatAction(slot, p);
|
||||
if (!ChatManager.canUsePlaceholder(p, action.getItem(), slot, e))
|
||||
if (!ChatManager.canUsePlaceholder(p, action, slot, e))
|
||||
return;
|
||||
HoverEventSource<?> hoverEvent = null;
|
||||
if(action.isItem()) {
|
||||
|
||||
Reference in new issue
Block a user