Added fake-join and fake-quit via custom VanishNoPacket events.

This commit is contained in:
cnaude 2015-02-13 13:22:09 -07:00
parent 3dbbeff597
commit f6df8a6d3f
9 changed files with 144 additions and 4 deletions

View File

@ -219,7 +219,7 @@
<dependency>
<groupId>com.cnaude.vanishnopacket</groupId>
<artifactId>VanishNoPacket</artifactId>
<version>3.19.1</version>
<version>3.19.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -181,7 +181,7 @@
<dependency>
<groupId>com.cnaude.vanishnopacket</groupId>
<artifactId>VanishNoPacket</artifactId>
<version>3.19.1</version>
<version>3.19.2-SNAPSHOT</version>
</dependency>
<!-- mcore -->

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2014 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.GameListeners;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.kitteh.vanish.event.VanishFakeJoinEvent;
import org.kitteh.vanish.event.VanishFakeQuitEvent;
/**
*
* @author cnaude
*/
public class VanishNoPacketListener implements Listener {
private final PurpleIRC plugin;
/**
*
* @param plugin
*/
public VanishNoPacketListener(PurpleIRC plugin) {
this.plugin = plugin;
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onVanishFakeQuitEvent(VanishFakeQuitEvent event) {
plugin.logDebug("onVanishFakeQuitEvent: " + event.getPlayer().getName());
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameFakeQuit(event.getPlayer(), event.getQuitMessage());
if (plugin.netPackets != null) {
plugin.netPackets.updateTabList(event.getPlayer());
}
}
}
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onVanishFakeJoinEvent(final VanishFakeJoinEvent event) {
plugin.logDebug("onVanishFakeJoinEvent: " + event.getPlayer().getDisplayName()
+ ": " + event.getPlayer().getCustomName());
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
plugin.clearHostCache(event.getPlayer());
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameFakeJoin(event.getPlayer(), event.getJoinMessage());
if (plugin.netPackets != null) {
plugin.netPackets.updateTabList(event.getPlayer());
}
}
plugin.updateDisplayNameCache(event.getPlayer());
plugin.updateUuidCache(event.getPlayer());
}
}, 20);
}
}

View File

@ -1459,6 +1459,50 @@ public final class PurpleBot {
}
}
}
/**
*
* @param player
* @param message
*/
public void gameFakeJoin(Player player, String message) {
if (!this.isConnected()) {
return;
}
for (String channelName : botChannels) {
if (isMessageEnabled(channelName, TemplateName.FAKE_JOIN)) {
if (!isPlayerInValidWorld(player, channelName)) {
return;
}
asyncIRCMessage(channelName, plugin.tokenizer
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
botNick, TemplateName.FAKE_JOIN), message));
} else {
plugin.logDebug("Not sending join message due to " + TemplateName.FAKE_JOIN + " being disabled");
}
}
}
/**
*
* @param player
* @param message
*/
public void gameFakeQuit(Player player, String message) {
if (!this.isConnected()) {
return;
}
for (String channelName : botChannels) {
if (isMessageEnabled(channelName, TemplateName.FAKE_QUIT)) {
if (!isPlayerInValidWorld(player, channelName)) {
return;
}
asyncIRCMessage(channelName, plugin.tokenizer
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
botNick, TemplateName.FAKE_QUIT), message));
}
}
}
/**
*

View File

@ -38,6 +38,7 @@ import com.cnaude.purpleirc.GameListeners.RedditStreamListener;
import com.cnaude.purpleirc.GameListeners.ReportRTSListener;
import com.cnaude.purpleirc.GameListeners.TitanChatListener;
import com.cnaude.purpleirc.GameListeners.TownyChatListener;
import com.cnaude.purpleirc.GameListeners.VanishNoPacketListener;
import com.cnaude.purpleirc.Hooks.AdminPrivateChatHook;
import com.cnaude.purpleirc.Hooks.DynmapHook;
import com.cnaude.purpleirc.Hooks.FactionChatHook;
@ -247,7 +248,7 @@ public class PurpleIRC extends JavaPlugin {
getServer().getPluginManager().registerEvents(new GamePlayerJoinListener(this), this);
getServer().getPluginManager().registerEvents(new GamePlayerKickListener(this), this);
getServer().getPluginManager().registerEvents(new GamePlayerQuitListener(this), this);
getServer().getPluginManager().registerEvents(new GameServerCommandListener(this), this);
getServer().getPluginManager().registerEvents(new GameServerCommandListener(this), this);
if (isPluginEnabled("Herochat")) {
logInfo("Enabling HeroChat support.");
getServer().getPluginManager().registerEvents(new HeroChatListener(this), this);
@ -365,7 +366,13 @@ public class PurpleIRC extends JavaPlugin {
} else {
logInfo("OreBroadcast not detected.");
}
vanishHook = new VanishHook(this);
vanishHook = new VanishHook(this);
if (isPluginEnabled("VanishNoPacket")) {
logInfo("Enabling VanishNoPacket support.");
getServer().getPluginManager().registerEvents(new VanishNoPacketListener(this), this);
} else {
logInfo("VanishNoPacket not detected.");
}
if (isPluginEnabled("SuperVanish")) {
logInfo("Enabling SuperVanish support.");
superVanishHook = new SuperVanishHook(this);

View File

@ -127,5 +127,8 @@ public class TemplateName {
public final static String IRC_A_RESPONSE = "irc-a-response";
public final static String GAME_A_CHAT = "game-a-chat";
public final static String FAKE_JOIN = "fake-join";
public final static String FAKE_QUIT = "fake-quit";
}

View File

@ -105,6 +105,8 @@ channels:
- game-kick
- game-join
- game-quit
- fake-join
- fake-quit
- game-mode
# Essentials helpop messages (/helpop /amsg /ac)
- ess-helpop

View File

@ -92,6 +92,8 @@ message-format:
game-kick: '[&2%WORLD%&r] %MESSAGE%: %REASON%'
game-join: '[&2%WORLD%&r] %NAME% joined the game.'
game-quit: '[&2%WORLD%&r] %NAME% left the game.'
fake-join: '[&2%WORLD%&r] %NAME% joined the game.'
fake-quit: '[&2%WORLD%&r] %NAME% left the game.'
game-command: '[&2%WORLD%&r] Command detected by %NAME%: %COMMAND% %PARAMS%'
# Message template for "/irc send" to IRC message
game-send: '[&2%WORLD%&r]<%NAME%> %MESSAGE%'

View File

@ -21,6 +21,7 @@ softdepend:
- RedditStream
- AdminPrivateChat
- SuperVanish
- VanishNoPacket
commands:
irc:
description: Various irc commands