mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-25 19:45:54 +01:00
Update for 1.12
This commit is contained in:
parent
ab0d4a2962
commit
09eabbfeb1
4
pom.xml
4
pom.xml
@ -6,13 +6,13 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<!-- Bukkit API Version, change if out dated -->
|
<!-- Bukkit API Version, change if out dated -->
|
||||||
<bukkit.version>1.11.2</bukkit.version>
|
<bukkit.version>1.12</bukkit.version>
|
||||||
<build.number>SNAPSHOT</build.number>
|
<build.number>SNAPSHOT</build.number>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<groupId>com.cnaude</groupId>
|
<groupId>com.cnaude</groupId>
|
||||||
<artifactId>PurpleIRC</artifactId>
|
<artifactId>PurpleIRC</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-${build.number}</version>
|
||||||
<name>PurpleIRC-spigot</name>
|
<name>PurpleIRC-spigot</name>
|
||||||
<description>Minecraft IRC integration for CraftBukkit/Spigot servers.</description>
|
<description>Minecraft IRC integration for CraftBukkit/Spigot servers.</description>
|
||||||
<url>http://www.spigotmc.org/resources/purpleirc.2836/</url>
|
<url>http://www.spigotmc.org/resources/purpleirc.2836/</url>
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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.bukkit.event.player.PlayerAdvancementDoneEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Chris Naude
|
||||||
|
*/
|
||||||
|
public class GamePlayerPlayerAdvancementDoneListener implements Listener {
|
||||||
|
|
||||||
|
private final PurpleIRC plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param plugin the PurpleIRC plugin
|
||||||
|
*/
|
||||||
|
public GamePlayerPlayerAdvancementDoneListener(PurpleIRC plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerAchievementAwardedEvent(PlayerAdvancementDoneEvent event) {
|
||||||
|
plugin.logDebug("ACHIEVEMENT: " + event.getPlayer().getName() + " => " + event.getAdvancement());
|
||||||
|
for (PurpleBot ircBot : plugin.ircBots.values()) {
|
||||||
|
ircBot.gameAdvancement(event.getPlayer(), event.getAdvancement());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -235,4 +235,10 @@ public class IRCCommandSender implements CommandSender {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Spigot spigot() {
|
||||||
|
plugin.logDebug("Spigot?");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -226,4 +226,10 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
|
|||||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Spigot spigot() {
|
||||||
|
plugin.logDebug("Spigot?");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@ import org.bukkit.Achievement;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.advancement.Advancement;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
@ -1889,6 +1890,26 @@ public final class PurpleBot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param advancement
|
||||||
|
*/
|
||||||
|
public void gameAdvancement(Player player, Advancement advancement) {
|
||||||
|
if (!this.isConnected() || advancement == null || player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String message = advancement.toString();
|
||||||
|
for (String channelName : botChannels) {
|
||||||
|
if (isMessageEnabled(channelName, TemplateName.GAME_ADVANCEMENT)
|
||||||
|
&& isPlayerInValidWorld(player, channelName)) {
|
||||||
|
asyncIRCMessage(channelName, plugin.tokenizer
|
||||||
|
.gameChatToIRCTokenizer(player, plugin
|
||||||
|
.getMessageTemplate(botNick, channelName, TemplateName.GAME_ADVANCEMENT), message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
|
@ -30,6 +30,7 @@ import com.cnaude.purpleirc.GameListeners.GamePlayerGameModeChangeListener;
|
|||||||
import com.cnaude.purpleirc.GameListeners.GamePlayerJoinListener;
|
import com.cnaude.purpleirc.GameListeners.GamePlayerJoinListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.GamePlayerKickListener;
|
import com.cnaude.purpleirc.GameListeners.GamePlayerKickListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.GamePlayerPlayerAchievementAwardedListener;
|
import com.cnaude.purpleirc.GameListeners.GamePlayerPlayerAchievementAwardedListener;
|
||||||
|
import com.cnaude.purpleirc.GameListeners.GamePlayerPlayerAdvancementDoneListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.GamePlayerQuitListener;
|
import com.cnaude.purpleirc.GameListeners.GamePlayerQuitListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.GameServerCommandListener;
|
import com.cnaude.purpleirc.GameListeners.GameServerCommandListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.HeroChatListener;
|
import com.cnaude.purpleirc.GameListeners.HeroChatListener;
|
||||||
@ -314,7 +315,11 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getServer().getPluginManager().registerEvents(new IRCMessageListener(this), this);
|
getServer().getPluginManager().registerEvents(new IRCMessageListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new GamePlayerPlayerAchievementAwardedListener(this), this);
|
if (getServer().getVersion().contains("MC: 1.12")) {
|
||||||
|
getServer().getPluginManager().registerEvents(new GamePlayerPlayerAdvancementDoneListener(this), this);
|
||||||
|
} else {
|
||||||
|
getServer().getPluginManager().registerEvents(new GamePlayerPlayerAchievementAwardedListener(this), this);
|
||||||
|
}
|
||||||
getServer().getPluginManager().registerEvents(new GamePlayerGameModeChangeListener(this), this);
|
getServer().getPluginManager().registerEvents(new GamePlayerGameModeChangeListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new GamePlayerChatListener(this), this);
|
getServer().getPluginManager().registerEvents(new GamePlayerChatListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new GamePlayerCommandPreprocessingListener(this), this);
|
getServer().getPluginManager().registerEvents(new GamePlayerCommandPreprocessingListener(this), this);
|
||||||
@ -1009,7 +1014,7 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
m = "Players on " + host + "("
|
m = "Players on " + host + "("
|
||||||
+ players.length
|
+ players.length
|
||||||
+ "): " + Joiner.on(", ")
|
+ "): " + Joiner.on(", ")
|
||||||
.join(players);
|
.join(players);
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
} else {
|
} else {
|
||||||
@ -1792,7 +1797,7 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
sender.sendMessage(header);
|
sender.sendMessage(header);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.stripColor(header));
|
sender.sendMessage(ChatColor.stripColor(header));
|
||||||
}
|
}
|
||||||
for (String s : hookList) {
|
for (String s : hookList) {
|
||||||
if (colors) {
|
if (colors) {
|
||||||
sender.sendMessage(s);
|
sender.sendMessage(s);
|
||||||
|
@ -23,6 +23,7 @@ package com.cnaude.purpleirc;
|
|||||||
public class TemplateName {
|
public class TemplateName {
|
||||||
|
|
||||||
public final static String GAME_ACHIEVEMENT = "game-achievement";
|
public final static String GAME_ACHIEVEMENT = "game-achievement";
|
||||||
|
public final static String GAME_ADVANCEMENT = "game-advancement";
|
||||||
public final static String GAME_ACTION = "game-action";
|
public final static String GAME_ACTION = "game-action";
|
||||||
public final static String GAME_AFK = "game-afk";
|
public final static String GAME_AFK = "game-afk";
|
||||||
public final static String GAME_CHAT = "game-chat";
|
public final static String GAME_CHAT = "game-chat";
|
||||||
|
@ -121,7 +121,7 @@ public class NetPackets {
|
|||||||
packet.getIntegers().write(1, 0);
|
packet.getIntegers().write(1, 0);
|
||||||
packet.getIntegers().write(2, 0);
|
packet.getIntegers().write(2, 0);
|
||||||
packet.getStrings().write(0, displayName);
|
packet.getStrings().write(0, displayName);
|
||||||
} catch (Exception ex) {
|
} catch (FieldAccessException ex) {
|
||||||
plugin.logError("tabPacket: " + ex.getMessage());
|
plugin.logError("tabPacket: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
} else if (version.contains("MC: 1.8.3")) {
|
} else if (version.contains("MC: 1.8.3")) {
|
||||||
|
@ -103,6 +103,7 @@ message-format:
|
|||||||
# Command sent notification. Blank this to disable this message.
|
# Command sent notification. Blank this to disable this message.
|
||||||
command-sent: 'Command sent: %COMMAND%'
|
command-sent: 'Command sent: %COMMAND%'
|
||||||
game-achievement: '[&2%WORLD%&r] %NAME% has just earned the achievement [%MESSAGE%]'
|
game-achievement: '[&2%WORLD%&r] %NAME% has just earned the achievement [%MESSAGE%]'
|
||||||
|
game-advancement: '[&2%WORLD%&r] %NAME% has just earned the advancement [%MESSAGE%]'
|
||||||
game-mode: '[&2%WORLD%&r] %NAME% has changed game mode: [%MESSAGE%]'
|
game-mode: '[&2%WORLD%&r] %NAME% has changed game mode: [%MESSAGE%]'
|
||||||
game-action: '[&2%WORLD%&r]***%NAME% %MESSAGE%'
|
game-action: '[&2%WORLD%&r]***%NAME% %MESSAGE%'
|
||||||
game-pchat: '[&2%WORLD%] <%NAME%> %MESSAGE%'
|
game-pchat: '[&2%WORLD%] <%NAME%> %MESSAGE%'
|
||||||
|
Loading…
Reference in New Issue
Block a user