mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2025-01-23 16:01:29 +01:00
IRCMessageEvent now obeys cancel orders.
This commit is contained in:
parent
e975975688
commit
dda8c31780
@ -86,9 +86,7 @@ public class CommandQueueWatcher {
|
||||
plugin.logError("Error running command: " + ce.getMessage());
|
||||
}
|
||||
IRCCommandEvent event = new IRCCommandEvent(ircCommand);
|
||||
if (!event.isCancelled()) {
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,10 @@ public class IRCMessageListener implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onIRCMessageEvent(IRCMessageEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
plugin.logDebug("onIRCMessageEvent cancelled");
|
||||
return;
|
||||
}
|
||||
String permission = event.getPermission();
|
||||
String message = event.getMessage();
|
||||
Player player = event.getPlayer();
|
||||
|
@ -19,6 +19,7 @@ package com.cnaude.purpleirc.Hooks;
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.kitteh.vanish.staticaccess.VanishNoPacket;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -45,10 +46,12 @@ public class VanishHook {
|
||||
// Try SuperVanish first
|
||||
if (plugin.superVanishHook != null) {
|
||||
return plugin.superVanishHook.isVanished(player);
|
||||
} else if (plugin.vanishNoPacketHook != null) {
|
||||
return plugin.vanishNoPacketHook.isVanished(player);
|
||||
} else {
|
||||
// Fallback to other Vanish
|
||||
if (player.hasMetadata("vanished")) {
|
||||
plugin.logDebug("Player " + player.getName() + " has vanished metadata.");
|
||||
plugin.logDebug("Player " + player.getName() + " has vanished metadata" + player.getMetadata("vanished").get(0).asString());
|
||||
MetadataValue md = player.getMetadata("vanished").get(0);
|
||||
if (md.asBoolean()) {
|
||||
plugin.logDebug("Player " + player.getName() + " is vanished.");
|
||||
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2017 cnaude
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.cnaude.purpleirc.Hooks;
|
||||
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.kitteh.vanish.staticaccess.VanishNoPacket;
|
||||
import org.kitteh.vanish.staticaccess.VanishNotLoadedException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cnaude
|
||||
*/
|
||||
public class VanishNoPacketHook {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin the PurpleIRC plugin
|
||||
*/
|
||||
public VanishNoPacketHook(PurpleIRC plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
public boolean isVanished(Player player) {
|
||||
try {
|
||||
if (VanishNoPacket.isVanished(player.getName())) {
|
||||
plugin.logDebug("Player " + player.getName() + " is vanished.");
|
||||
return true;
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is NOT vanished.");
|
||||
return false;
|
||||
}
|
||||
} catch (VanishNotLoadedException ex) {
|
||||
plugin.logError("VanishNoPacketHook: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -63,6 +63,7 @@ import com.cnaude.purpleirc.Hooks.ShortifyHook;
|
||||
import com.cnaude.purpleirc.Hooks.SuperVanishHook;
|
||||
import com.cnaude.purpleirc.Hooks.TownyChatHook;
|
||||
import com.cnaude.purpleirc.Hooks.VanishHook;
|
||||
import com.cnaude.purpleirc.Hooks.VanishNoPacketHook;
|
||||
import com.cnaude.purpleirc.Hooks.VaultHook;
|
||||
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
|
||||
import com.cnaude.purpleirc.Utilities.ChatTokenizer;
|
||||
@ -224,6 +225,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
public VaultHook vaultHelpers;
|
||||
public VanishHook vanishHook;
|
||||
public SuperVanishHook superVanishHook;
|
||||
public VanishNoPacketHook vanishNoPacketHook;
|
||||
private YamlConfiguration heroConfig;
|
||||
private final File cacheFile;
|
||||
private final File uuidCacheFile;
|
||||
@ -1726,6 +1728,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
if (isPluginEnabled(PL_VANISHNOPACKET)) {
|
||||
hookList.add(hookFormat(PL_VANISHNOPACKET, true));
|
||||
getServer().getPluginManager().registerEvents(new VanishNoPacketListener(this), this);
|
||||
vanishNoPacketHook = new VanishNoPacketHook(this);
|
||||
} else {
|
||||
hookList.add(hookFormat(PL_VANISHNOPACKET, false));
|
||||
}
|
||||
@ -1815,16 +1818,12 @@ public class PurpleIRC extends JavaPlugin {
|
||||
|
||||
public void broadcastToGame(final String message, final String channel, final String permission) {
|
||||
IRCMessageEvent event = new IRCMessageEvent(message, channel, permission);
|
||||
if (!event.isCancelled()) {
|
||||
getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
public void broadcastToPlayer(final String message, final String channel, final String permission, final Player player) {
|
||||
IRCMessageEvent event = new IRCMessageEvent(message, channel, permission, player);
|
||||
if (!event.isCancelled()) {
|
||||
getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user