Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Add game-mode messages.
Browse files Browse the repository at this point in the history
Adjust default message templates once again.
  • Loading branch information
cnaude committed May 26, 2014
1 parent c91cd0b commit 9c275c6
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 47 deletions.
2 changes: 0 additions & 2 deletions pom.xml
Expand Up @@ -17,8 +17,6 @@
<description>A CraftBukkit plugin for bridging game chat with IRC. Connect to any number of IRC servers and channels simultaneously.</description>
<url>http://dev.bukkit.org/server-mods/purpleirc/</url>



<repositories>
<repository>
<id>sonatype-nexus-public</id>
Expand Down
@@ -0,0 +1,37 @@
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.bukkit.event.player.PlayerGameModeChangeEvent;

/**
*
* @author cnaude
*/
public class GamePlayerGameModeChangeListener implements Listener {

private final PurpleIRC plugin;

/**
*
* @param plugin
*/
public GamePlayerGameModeChangeListener(PurpleIRC plugin) {
this.plugin = plugin;
}

/**
*
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerGameModeChangeEvent(PlayerGameModeChangeEvent event) {
plugin.logDebug("GAMEMODE: " + event.getPlayer().getName() + " => " + event.getNewGameMode());
for (PurpleBot ircBot : plugin.ircBots.values()) {
ircBot.gameModeChange(event.getPlayer(), event.getNewGameMode());
}
}
}
@@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.cnaude.purpleirc.GameListeners;

import com.cnaude.purpleirc.PurpleBot;
Expand Down
@@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.cnaude.purpleirc.GameListeners;

import com.cnaude.purpleirc.PurpleBot;
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/cnaude/purpleirc/PurpleBot.java
Expand Up @@ -36,6 +36,7 @@
import java.nio.charset.Charset;
import org.bukkit.Achievement;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
Expand Down Expand Up @@ -1288,6 +1289,28 @@ public void gameAchievement(Player player, Achievement achievement) {
}
}
}

/**
*
* @param player
* @param gameMode
*/
public void gameModeChange(Player player, GameMode gameMode) {
if (!this.isConnected()) {
return;
}
String message = gameMode.toString();
for (String channelName : botChannels) {
if (isMessageEnabled(channelName,TemplateName.GAME_MODE)) {
if (!isPlayerInValidWorld(player, channelName)) {
return;
}
asyncIRCMessage(channelName, plugin.tokenizer
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
botNick, TemplateName.GAME_MODE), message));
}
}
}

/**
*
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cnaude/purpleirc/PurpleIRC.java
Expand Up @@ -7,6 +7,7 @@
import com.cnaude.purpleirc.GameListeners.GamePlayerChatListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerCommandPreprocessingListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerDeathListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerGameModeChangeListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerJoinListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerKickListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerPlayerAchievementAwardedListener;
Expand Down Expand Up @@ -177,6 +178,7 @@ public void onEnable() {
}
}
getServer().getPluginManager().registerEvents(new GamePlayerPlayerAchievementAwardedListener(this), this);
getServer().getPluginManager().registerEvents(new GamePlayerGameModeChangeListener(this), this);
getServer().getPluginManager().registerEvents(new GamePlayerChatListener(this), this);
getServer().getPluginManager().registerEvents(new GamePlayerCommandPreprocessingListener(this), this);
getServer().getPluginManager().registerEvents(new GamePlayerDeathListener(this), this);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/cnaude/purpleirc/TemplateName.java
Expand Up @@ -17,6 +17,7 @@ public class TemplateName {
public final static String GAME_QUIT = "game-quit";
public final static String GAME_KICK = "game-kick";
public final static String GAME_COMMAND = "game-command";
public final static String GAME_MODE = "game-mode";

public final static String DYNMAP_WEB_CHAT = "dynmap-web-chat";
public final static String IRC_DYNMAP_WEB_CHAT = "irc-dynmap-web-chat";
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/SampleBot.yml
Expand Up @@ -93,6 +93,7 @@ channels:
- game-kick
- game-join
- game-quit
- game-mode
# The game-afk message type is not functional yet.
#- game-afk
# These messages are sent from IRC to game (see permissions)
Expand Down
75 changes: 38 additions & 37 deletions src/main/resources/config.yml
Expand Up @@ -41,63 +41,64 @@ channel-check-interval: 100
# %JOBS% - Player jobs shortened
message-format:
# Message templates for game to IRC messages
console-chat: '[&5Server] %MESSAGE%'
game-achievement: '[&2%WORLD%] %NAME% has just earned the achievement [%MESSAGE%]'
game-action: '[&2%WORLD%] ***%NAME% %MESSAGE%'
game-pchat: '[&2%WORLD%]<%NAME%> %MESSAGE%'
console-chat: '[&dServer&r] %MESSAGE%'
game-achievement: '[&2%WORLD%&r] %NAME% has just earned the achievement [%MESSAGE%]'
game-mode: '[&2%WORLD%&r] %NAME% has changed game mode: [%MESSAGE%]'
game-action: '[&2%WORLD%&r]***%NAME% %MESSAGE%'
game-pchat: '[&2%WORLD%] <%NAME%> %MESSAGE%'
# death-messages - http://dev.bukkit.org/bukkit-plugins/death-messages
death-messages: '[&2%WORLD%] %MESSAGE%'
death-messages: '[&2%WORLD%&r]%MESSAGE%'
# Notification to player when sending a private message to an IRC user
game-pchat-response: ' &6-> &7%TARGET%: %MESSAGE%'
game-chat: '[&2%WORLD%]<%NAME%> %MESSAGE%'
game-death: '[&2%WORLD%] %MESSAGE%'
game-kick: '[&2%WORLD%] %MESSAGE%: %REASON%'
game-join: '[&2%WORLD%] %MESSAGE%'
game-quit: '[&2%WORLD%] %MESSAGE%'
game-command: '[&2%WORLD%] Command detected by %NAME%: %COMMAND% %PARAMS%'
game-chat: '[&2%WORLD%&r] <%NAME%> %MESSAGE%'
game-death: '[&2%WORLD%&r] %MESSAGE%'
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.'
game-command: '[&2%WORLD%&r] Command detected by %NAME%: %COMMAND% %PARAMS%'
# Message template for "/irc send" to IRC message
game-send: '[&2%WORLD%]<%NAME%> %MESSAGE%'
game-send: '[&2%WORLD%&r]<%NAME%> %MESSAGE%'
# Essentials messages
ess-player-afk: '[&2%WORLD%] %NAME% is now AFK'
ess-player-not-afk: '[&2%WORLD%] %NAME% is no longer AFK'
ess-player-afk: '[&2%WORLD%&r] %NAME% is now AFK'
ess-player-not-afk: '[&2%WORLD%&r] %NAME% is no longer AFK'
# Message templates for IRC to game messages
irc-action: '[&4IRC] ***%NAME% %MESSAGE%'
irc-action: '[&4IRC&r] ***%NAME% %MESSAGE%'
irc-chat: '[&4IRC]<%NAME%> %MESSAGE%'
irc-pchat: '&dPrivate message: [&4IRC]<%NAME%> %MESSAGE%'
# Notification to user when sending a private message to a player
irc-pchat-response: ' &6-> &7%TARGET%: %MESSAGE%'
# Notification to user when sending a message to a specific hero channel
irc-hchat-response: ' &6-> &7%TARGET%: %MESSAGE%'
irc-join: '[&4IRC] %NAME% has joined %CHANNEL%.'
irc-kick: '[&4IRC] %NAME% was kicked from %CHANNEL% by %KICKER%. (Reason- %REASON%)'
irc-part: '[&4IRC] %NAME% has left %CHANNEL%.'
irc-quit: '[&4IRC] %NAME% has left %CHANNEL%. (Reason: %REASON%)'
irc-topic: '[&4IRC] Topic changed by %NAME%: %TOPIC%.'
irc-nickchange: '[&4IRC] %OLDNICK% is now known as %NEWNICK%.'
irc-mode: '[&4IRC] %NAME% %MODE% on %CHANNEL%'
irc-join: '[&4IRC&r] %NAME% has joined %CHANNEL%.'
irc-kick: '[&4IRC&r] %NAME% was kicked from %CHANNEL% by %KICKER%. (Reason- %REASON%)'
irc-part: '[&4IRC&r] %NAME% has left %CHANNEL%.'
irc-quit: '[&4IRC&r] %NAME% has left %CHANNEL%. (Reason: %REASON%)'
irc-topic: '[&4IRC&r] Topic changed by %NAME%: %TOPIC%.'
irc-nickchange: '[&4IRC&r] %OLDNICK% is now known as %NEWNICK%.'
irc-mode: '[&4IRC&r] %NAME% %MODE% on %CHANNEL%'
irc-console-chat: '&f[&5IRC&f]&r<%NAME%> %MESSAGE%'
irc-notice: '[&4IRC] [notice(%CHANNEL%)] %NOTICE% '
irc-notice: '[&4IRC&r] [notice(%CHANNEL%)] %NOTICE% '
# Message template for Clevernotch bot to IRC messages
clever-send: '[&4BOT]<%NAME%> %MESSAGE%'
# Message templates for mcMMO to IRC messages
mcmmo-admin-chat: '[admin:%WORLD%]<%NAME%> %MESSAGE%'
mcmmo-party-chat: '[party:%PARTY%]<%NAME%> %MESSAGE%'
mcmmo-chat: '[mcMMO]<%NAME%> %MESSAGE%'
# Message templates for FactionChat to IRC messages
faction-public-chat: '[%FACTIONMODE%] [%FACTIONTAG%]<%NAME%> %MESSAGE%'
faction-ally-chat: '[%FACTIONMODE%] [%FACTIONTAG%]<%NAME%> %MESSAGE%'
faction-enemy-chat: '[%FACTIONMODE%] [%FACTIONTAG%]<%NAME%> %MESSAGE%'
faction-public-chat: '[%FACTIONMODE%&r][%FACTIONTAG%]<%NAME%> %MESSAGE%'
faction-ally-chat: '[%FACTIONMODE%&r][%FACTIONTAG%]<%NAME%> %MESSAGE%'
faction-enemy-chat: '[%FACTIONMODE%&r][%FACTIONTAG%]<%NAME%> %MESSAGE%'
# Message template for Herochat to IRC messages
hero-chat: '[%CHANNEL%]<%NAME%> %MESSAGE%'
hero-action: '[&2%CHANNEL%] ***%NAME% %MESSAGE%'
hero-action: '[&2%CHANNEL%&r]***%NAME% %MESSAGE%'
# Message templates for IRC to Herochat messages
irc-hero-action: '[&3IRC] ***%NAME% %MESSAGE%'
irc-hero-action: '[&3IRC&r] ***%NAME% %MESSAGE%'
irc-hero-chat: '[&3IRC]<%NAME%> %MESSAGE%'
irc-hero-join: '[&3IRC] %NAME% has joined %CHANNEL%.'
irc-hero-kick: '[&3IRC] %NAME% was kicked from %CHANNEL% by %KICKER%. (Reason- %REASON%)'
irc-hero-part: '[&3IRC] %NAME% has left %CHANNEL%.'
irc-hero-quit: '[&3IRC] %NAME% has left %CHANNEL%.'
irc-hero-topic: '[&3IRC] Topic changed by %NAME%: %TOPIC%.'
irc-hero-join: '[&3IRC&r] %NAME% has joined %CHANNEL%.'
irc-hero-kick: '[&3IRC&r] %NAME% was kicked from %CHANNEL% by %KICKER%. (Reason- %REASON%)'
irc-hero-part: '[&3IRC&r] %NAME% has left %CHANNEL%.'
irc-hero-quit: '[&3IRC&r] %NAME% has left %CHANNEL%.'
irc-hero-topic: '[&3IRC&r] Topic changed by %NAME%: %TOPIC%.'
# Message template for TitanChat to IRC messages
titan-chat: '[%CHANNEL%]<%NAME%> %MESSAGE%'
# Message templates for IRC to TitanChat messages
Expand Down Expand Up @@ -128,11 +129,11 @@ message-format:
Global: '[%CHANNEL%]<%NAME%> %MESSAGE%'
# Emote message format per hero channel. From game to IRC. Overrides hero-action template.
hero-action-channels:
Global: '[&2%CHANNEL%] ***%NAME% %MESSAGE%'
Global: '[&2%CHANNEL%&r]***%NAME% %MESSAGE%'
# Message templates for Towny to IRC messages
towny-channel-chat: '%TOWNYCHANNELTAG%[%TOWNYCHANNEL%]<%NAME%> %MESSAGE%'
# Message templates for IRC to Towny messages
irc-towny-chat: '[&3IRC]<%NAME%> %MESSAGE%'
irc-towny-chat: '[&3IRC&r]<%NAME%> %MESSAGE%'
# Message format per towny channel. From IRC to game.
irc-towny-channels:
irc: '[IRC]%PLAYERPREFIX%%NAME% %MESSAGE%'
Expand All @@ -146,7 +147,7 @@ message-format:
default-player-world: 'world'
default-player-group: ''
# Format for the @list command in IRC
list-format: '[&9Minecraft] Online (%COUNT%/%MAX%): %PLAYERS%'
list-format: '[&9Minecraft&r] &2Online &r(%COUNT%/%MAX%): %PLAYERS%'
list-separator: ', '
list-player: '%GROUPPREFIX%%NAME%'
# Sort playerlist by %NAME% and not by list-player format
Expand All @@ -160,7 +161,7 @@ strip-irc-bg-colors: true
# Add IRC names to in-game tab list
custom-tab-list: false
# Nothing to see here
custom-tab-prefix: '[IRC] '
custom-tab-prefix: '[I] '
# IRC nick must be an exact match to a player name for token expanding
nick-exact-match: true
# IRC nick prefixes (can include & color codes)
Expand Down

0 comments on commit 9c275c6

Please sign in to comment.