Update for 1.12

This commit is contained in:
cnaude 2017-05-23 18:57:26 -07:00
parent ab0d4a2962
commit 09eabbfeb1
9 changed files with 99 additions and 6 deletions

View File

@ -6,13 +6,13 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- 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>
</properties>
<groupId>com.cnaude</groupId>
<artifactId>PurpleIRC</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0-${build.number}</version>
<name>PurpleIRC-spigot</name>
<description>Minecraft IRC integration for CraftBukkit/Spigot servers.</description>
<url>http://www.spigotmc.org/resources/purpleirc.2836/</url>

View File

@ -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());
}
}
}

View File

@ -235,4 +235,10 @@ public class IRCCommandSender implements CommandSender {
return null;
}
@Override
public Spigot spigot() {
plugin.logDebug("Spigot?");
return null;
}
}

View File

@ -226,4 +226,10 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Spigot spigot() {
plugin.logDebug("Spigot?");
return null;
}
}

View File

@ -70,6 +70,7 @@ import org.bukkit.Achievement;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.advancement.Advancement;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
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

View File

@ -30,6 +30,7 @@ import com.cnaude.purpleirc.GameListeners.GamePlayerGameModeChangeListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerJoinListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerKickListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerPlayerAchievementAwardedListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerPlayerAdvancementDoneListener;
import com.cnaude.purpleirc.GameListeners.GamePlayerQuitListener;
import com.cnaude.purpleirc.GameListeners.GameServerCommandListener;
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 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 GamePlayerChatListener(this), this);
getServer().getPluginManager().registerEvents(new GamePlayerCommandPreprocessingListener(this), this);
@ -1009,7 +1014,7 @@ public class PurpleIRC extends JavaPlugin {
m = "Players on " + host + "("
+ players.length
+ "): " + Joiner.on(", ")
.join(players);
.join(players);
}
return m;
} else {
@ -1792,7 +1797,7 @@ public class PurpleIRC extends JavaPlugin {
sender.sendMessage(header);
} else {
sender.sendMessage(ChatColor.stripColor(header));
}
}
for (String s : hookList) {
if (colors) {
sender.sendMessage(s);

View File

@ -23,6 +23,7 @@ package com.cnaude.purpleirc;
public class TemplateName {
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_AFK = "game-afk";
public final static String GAME_CHAT = "game-chat";

View File

@ -121,7 +121,7 @@ public class NetPackets {
packet.getIntegers().write(1, 0);
packet.getIntegers().write(2, 0);
packet.getStrings().write(0, displayName);
} catch (Exception ex) {
} catch (FieldAccessException ex) {
plugin.logError("tabPacket: " + ex.getMessage());
}
} else if (version.contains("MC: 1.8.3")) {

View File

@ -103,6 +103,7 @@ message-format:
# Command sent notification. Blank this to disable this message.
command-sent: 'Command sent: %COMMAND%'
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-action: '[&2%WORLD%&r]***%NAME% %MESSAGE%'
game-pchat: '[&2%WORLD%] <%NAME%> %MESSAGE%'