More error catching around vault.

This commit is contained in:
cnaude 2015-03-13 07:35:54 -07:00
parent 0dfad43aeb
commit 7885a2597e
4 changed files with 58 additions and 58 deletions

View File

@ -19,6 +19,8 @@ package com.cnaude.purpleirc;
import com.cnaude.purpleirc.Events.IRCCommandEvent; import com.cnaude.purpleirc.Events.IRCCommandEvent;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import net.minecraft.server.v1_8_R2.RemoteControlCommandListener;
import static org.bukkit.Bukkit.getServer;
import org.bukkit.command.CommandException; import org.bukkit.command.CommandException;
/** /**
@ -63,7 +65,7 @@ public class CommandQueueWatcher {
} }
if (plugin.getServer().getVersion().contains("MC: 1.8") && plugin.getServer().getPluginCommand(cmd) == null if (plugin.getServer().getVersion().contains("MC: 1.8") && plugin.getServer().getPluginCommand(cmd) == null
&& !isCommandBookCommand) { && !isCommandBookCommand) {
plugin.logDebug("Dispatching command as ConsoleSender: " + ircCommand.getGameCommand()); plugin.logDebug("Dispatching command as ConsoleSender: " + ircCommand.getGameCommand());
plugin.getServer().dispatchCommand(ircCommand.getIRCConsoleCommandSender(), ircCommand.getGameCommand()); plugin.getServer().dispatchCommand(ircCommand.getIRCConsoleCommandSender(), ircCommand.getGameCommand());
ircCommand.getIRCConsoleCommandSender().sendMessage("Command sent: " + ircCommand.getGameCommand()); ircCommand.getIRCConsoleCommandSender().sendMessage("Command sent: " + ircCommand.getGameCommand());

View File

@ -150,7 +150,7 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
public boolean isPermissionSet(final Permission arg0) { public boolean isPermissionSet(final Permission arg0) {
return true; return true;
} }
@Override @Override
public void sendRawMessage(String string) { public void sendRawMessage(String string) {
plugin.logDebug("sendRawMessage: " + string); plugin.logDebug("sendRawMessage: " + string);

View File

@ -55,8 +55,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import me.botsko.prism.actionlibs.QueryParameters; import me.botsko.prism.actionlibs.QueryParameters;
import me.botsko.prism.events.BlockStateChange; import me.botsko.prism.events.BlockStateChange;
import org.bukkit.Achievement; import org.bukkit.Achievement;
@ -165,7 +163,7 @@ public final class PurpleBot {
String version; String version;
String finger; String finger;
private int reconnectCount; private int reconnectCount;
private ReadWriteLock rwl; private final ReadWriteLock rwl;
private final Lock wl; private final Lock wl;
/** /**

View File

@ -247,7 +247,7 @@ public class PurpleIRC extends JavaPlugin {
getServer().getPluginManager().registerEvents(new GamePlayerJoinListener(this), this); getServer().getPluginManager().registerEvents(new GamePlayerJoinListener(this), this);
getServer().getPluginManager().registerEvents(new GamePlayerKickListener(this), this); getServer().getPluginManager().registerEvents(new GamePlayerKickListener(this), this);
getServer().getPluginManager().registerEvents(new GamePlayerQuitListener(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")) { if (isPluginEnabled("Herochat")) {
logInfo("Enabling HeroChat support."); logInfo("Enabling HeroChat support.");
getServer().getPluginManager().registerEvents(new HeroChatListener(this), this); getServer().getPluginManager().registerEvents(new HeroChatListener(this), this);
@ -322,7 +322,7 @@ public class PurpleIRC extends JavaPlugin {
} }
if (isPluginEnabled("CommandBook")) { if (isPluginEnabled("CommandBook")) {
logInfo("Enabling CommandBook support."); logInfo("Enabling CommandBook support.");
commandBookHook = new CommandBookHook(this); commandBookHook = new CommandBookHook(this);
} else { } else {
logInfo("CommandBook not detected."); logInfo("CommandBook not detected.");
} }
@ -362,7 +362,7 @@ public class PurpleIRC extends JavaPlugin {
} else { } else {
logInfo("OreBroadcast not detected."); logInfo("OreBroadcast not detected.");
} }
vanishHook = new VanishHook(this); vanishHook = new VanishHook(this);
if (isPluginEnabled("VanishNoPacket")) { if (isPluginEnabled("VanishNoPacket")) {
logInfo("Enabling VanishNoPacket support."); logInfo("Enabling VanishNoPacket support.");
getServer().getPluginManager().registerEvents(new VanishNoPacketListener(this), this); getServer().getPluginManager().registerEvents(new VanishNoPacketListener(this), this);
@ -719,7 +719,7 @@ public class PurpleIRC extends JavaPlugin {
logInfo("Loaded bot: " + file.getName() + " [" + ircBot.botNick + "]"); logInfo("Loaded bot: " + file.getName() + " [" + ircBot.botNick + "]");
} else { } else {
logError("Bot not loaded: " + file.getName()); logError("Bot not loaded: " + file.getName());
} }
} }
} }
} }
@ -837,7 +837,7 @@ public class PurpleIRC extends JavaPlugin {
public void logInfo(String message) { public void logInfo(String message) {
log.log(Level.INFO, String.format("%s %s", LOG_HEADER, message)); log.log(Level.INFO, String.format("%s %s", LOG_HEADER, message));
} }
/** /**
* *
* @param message * @param message
@ -965,14 +965,14 @@ public class PurpleIRC extends JavaPlugin {
*/ */
public String getPlayerGroup(Player player) { public String getPlayerGroup(Player player) {
String groupName = ""; String groupName = "";
if (vaultHelpers != null) { try {
if (vaultHelpers.permission != null) { if (vaultHelpers != null) {
try { if (vaultHelpers.permission != null && vaultHelpers.permission != null) {
groupName = vaultHelpers.permission.getPrimaryGroup(player); groupName = vaultHelpers.permission.getPrimaryGroup(player);
} catch (Exception ex) {
logDebug("Problem with primary group (" + player.getName() + "): " + ex.getMessage());
} }
} }
} catch (Exception ex) {
logDebug("Problem with primary group (" + player.getName() + "): " + ex.getMessage());
} }
if (groupName == null) { if (groupName == null) {
groupName = ""; groupName = "";
@ -1000,18 +1000,18 @@ public class PurpleIRC extends JavaPlugin {
*/ */
public String getPlayerGroup(String worldName, String player) { public String getPlayerGroup(String worldName, String player) {
String groupName = ""; String groupName = "";
UUID uuid = getPlayerUuid(player); try {
if (vaultHelpers != null && uuid != null) { UUID uuid = getPlayerUuid(player);
if (vaultHelpers.permission != null) { if (vaultHelpers != null && uuid != null) {
OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid); if (vaultHelpers.permission != null && vaultHelpers.permission != null) {
if (offlinePlayer != null) { OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid);
try { if (offlinePlayer != null) {
groupName = vaultHelpers.permission.getPrimaryGroup(worldName, offlinePlayer); groupName = vaultHelpers.permission.getPrimaryGroup(worldName, offlinePlayer);
} catch (Exception ex) {
logDebug("getPlayerGroup (" + player + "): " + ex.getMessage());
} }
} }
} }
} catch (Exception ex) {
logDebug("getPlayerGroup (" + player + "): " + ex.getMessage());
} }
if (groupName == null) { if (groupName == null) {
groupName = ""; groupName = "";
@ -1045,18 +1045,18 @@ public class PurpleIRC extends JavaPlugin {
*/ */
public String getPlayerPrefix(String worldName, String player) { public String getPlayerPrefix(String worldName, String player) {
String prefix = ""; String prefix = "";
UUID uuid = getPlayerUuid(player); try {
if (vaultHelpers != null && uuid != null) { UUID uuid = getPlayerUuid(player);
if (vaultHelpers.chat != null) { if (vaultHelpers != null && uuid != null) {
OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid); if (vaultHelpers.chat != null) {
if (offlinePlayer != null) { OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid);
try { if (offlinePlayer != null) {
prefix = vaultHelpers.chat.getPlayerPrefix(worldName, offlinePlayer); prefix = vaultHelpers.chat.getPlayerPrefix(worldName, offlinePlayer);
} catch (Exception ex) {
logDebug("getPlayerPrefix (" + player + "): " + ex.getMessage());
} }
} }
} }
} catch (Exception ex) {
logDebug("getPlayerPrefix (" + player + "): " + ex.getMessage());
} }
if (prefix == null) { if (prefix == null) {
prefix = ""; prefix = "";
@ -1090,18 +1090,18 @@ public class PurpleIRC extends JavaPlugin {
*/ */
public String getPlayerSuffix(String worldName, String player) { public String getPlayerSuffix(String worldName, String player) {
String suffix = ""; String suffix = "";
UUID uuid = getPlayerUuid(player); try {
if (vaultHelpers != null && uuid != null) { UUID uuid = getPlayerUuid(player);
if (vaultHelpers.chat != null) { if (vaultHelpers != null && uuid != null) {
OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid); if (vaultHelpers.chat != null) {
if (offlinePlayer != null) { OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid);
try { if (offlinePlayer != null) {
suffix = vaultHelpers.chat.getPlayerSuffix(worldName, offlinePlayer); suffix = vaultHelpers.chat.getPlayerSuffix(worldName, offlinePlayer);
} catch (Exception ex) {
logDebug("getPlayerSuffix (" + player + "): " + ex.getMessage());
} }
} }
} }
} catch (Exception ex) {
logDebug("getPlayerSuffix (" + player + "): " + ex.getMessage());
} }
if (suffix == null) { if (suffix == null) {
suffix = ""; suffix = "";
@ -1178,7 +1178,7 @@ public class PurpleIRC extends JavaPlugin {
public String getGroupPrefix(Player player) { public String getGroupPrefix(Player player) {
String prefix = ""; String prefix = "";
if (vaultHelpers != null) { if (vaultHelpers != null) {
if (vaultHelpers.chat != null) { if (vaultHelpers.chat != null && vaultHelpers.permission != null) {
String group = ""; String group = "";
try { try {
group = vaultHelpers.permission.getPrimaryGroup(player); group = vaultHelpers.permission.getPrimaryGroup(player);
@ -1205,26 +1205,26 @@ public class PurpleIRC extends JavaPlugin {
*/ */
public String getGroupPrefix(String worldName, String player) { public String getGroupPrefix(String worldName, String player) {
String prefix = ""; String prefix = "";
UUID uuid = getPlayerUuid(player); try {
if (vaultHelpers != null && uuid != null) { UUID uuid = getPlayerUuid(player);
if (vaultHelpers.chat != null) { if (vaultHelpers != null && uuid != null) {
String group = ""; if (vaultHelpers.chat != null && vaultHelpers.permission != null) {
OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid); String group = "";
if (offlinePlayer != null) { OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid);
try { if (offlinePlayer != null) {
group = vaultHelpers.permission.getPrimaryGroup(worldName, offlinePlayer); group = vaultHelpers.permission.getPrimaryGroup(worldName, offlinePlayer);
} catch (Exception ex) {
logDebug("getGroupPrefix (" + player + "): " + ex.getMessage());
} }
if (group == null) {
group = "";
}
prefix = vaultHelpers.chat.getGroupPrefix(worldName, group);
} }
if (group == null) {
group = "";
}
prefix = vaultHelpers.chat.getGroupPrefix(worldName, group);
} }
} if (prefix == null) {
if (prefix == null) { prefix = "";
prefix = ""; }
} catch (Exception ex) {
logDebug("getGroupPrefix (" + player + "): " + ex.getMessage());
} }
return ChatColor.translateAlternateColorCodes('&', prefix); return ChatColor.translateAlternateColorCodes('&', prefix);
} }
@ -1260,7 +1260,7 @@ public class PurpleIRC extends JavaPlugin {
public String getGroupSuffix(Player player) { public String getGroupSuffix(Player player) {
String suffix = ""; String suffix = "";
if (vaultHelpers != null) { if (vaultHelpers != null) {
if (vaultHelpers.chat != null) { if (vaultHelpers.chat != null && vaultHelpers.permission != null) {
String group = ""; String group = "";
try { try {
group = vaultHelpers.permission.getPrimaryGroup(player); group = vaultHelpers.permission.getPrimaryGroup(player);
@ -1289,7 +1289,7 @@ public class PurpleIRC extends JavaPlugin {
String suffix = ""; String suffix = "";
UUID uuid = getPlayerUuid(player); UUID uuid = getPlayerUuid(player);
if (vaultHelpers != null && uuid != null) { if (vaultHelpers != null && uuid != null) {
if (vaultHelpers.chat != null) { if (vaultHelpers.chat != null && vaultHelpers.permission != null) {
String group = ""; String group = "";
OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid); OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid);
try { try {