mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-29 05:26:19 +01:00
Initial SimpleTicketManager support. #9
This commit is contained in:
parent
666b94b502
commit
33cad8d3fb
@ -341,6 +341,12 @@
|
|||||||
<version>5.0.1</version>
|
<version>5.0.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cnaude.simpleticketmanager</groupId>
|
||||||
|
<artifactId>SimpleTicketManager</artifactId>
|
||||||
|
<version>2.0.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cnaude.griefprevention</groupId>
|
<groupId>com.cnaude.griefprevention</groupId>
|
||||||
<artifactId>GriefPrevention</artifactId>
|
<artifactId>GriefPrevention</artifactId>
|
||||||
|
7
pom.xml
7
pom.xml
@ -339,6 +339,13 @@
|
|||||||
<version>5.0.1</version>
|
<version>5.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SimpleTicketManager -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cnaude.simpleticketmanager</groupId>
|
||||||
|
<artifactId>SimpleTicketManager</artifactId>
|
||||||
|
<version>2.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- GriefPrevention -->
|
<!-- GriefPrevention -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cnaude.griefprevention</groupId>
|
<groupId>com.cnaude.griefprevention</groupId>
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.util.UUID;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import uk.co.joshuawoolley.simpleticketmanager.events.SimpleTicketEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Chris Naude
|
||||||
|
*/
|
||||||
|
public class SimpleTicketManagerListener implements Listener {
|
||||||
|
|
||||||
|
private final PurpleIRC plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param plugin the PurpleIRC plugin
|
||||||
|
*/
|
||||||
|
public SimpleTicketManagerListener(PurpleIRC plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void onSimpleTicketEvent(SimpleTicketEvent event) {
|
||||||
|
plugin.logDebug("STM: " + event.getAction());
|
||||||
|
for (PurpleBot ircBot : plugin.ircBots.values()) {
|
||||||
|
ircBot.simpleTicketNotify(UUID.fromString(event.getTicket().getReportingPlayer()),
|
||||||
|
event.getTicket(), ircBot.botNick, "stm-" + event.getAction());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -54,6 +54,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
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;
|
||||||
@ -1395,16 +1396,38 @@ public final class PurpleBot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called from ReportRTS event
|
/**
|
||||||
|
* Called from SimpleTicketEvent
|
||||||
|
*
|
||||||
|
* @param uuid
|
||||||
|
* @param ticket
|
||||||
|
* @param botNick
|
||||||
|
* @param messageType
|
||||||
|
*/
|
||||||
|
public void simpleTicketNotify(UUID uuid,
|
||||||
|
uk.co.joshuawoolley.simpleticketmanager.ticketsystem.Ticket ticket,
|
||||||
|
String botNick, String messageType) {
|
||||||
|
if (!this.isConnected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (String channelName : botChannels) {
|
||||||
|
if (isMessageEnabled(channelName, messageType)) {
|
||||||
|
asyncIRCMessage(channelName, plugin.tokenizer
|
||||||
|
.simpleTicketTokenizer(uuid, plugin
|
||||||
|
.getMessageTemplate(botNick, channelName, messageType), ticket));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Called from ReportRTS event
|
||||||
*
|
*
|
||||||
* @param pName
|
* @param pName
|
||||||
* @param ticket
|
* @param ticket
|
||||||
* @param botNick
|
* @param botNick
|
||||||
* @param messageType
|
* @param messageType
|
||||||
*/
|
*/
|
||||||
public void reportRTSNotify(String pName, Ticket ticket,
|
public void reportRTSNotify(String pName, Ticket ticket, String botNick, String messageType) {
|
||||||
String botNick, String messageType) {
|
|
||||||
if (!this.isConnected()) {
|
if (!this.isConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ import com.cnaude.purpleirc.GameListeners.OreBroadcastListener;
|
|||||||
import com.cnaude.purpleirc.GameListeners.PrismListener;
|
import com.cnaude.purpleirc.GameListeners.PrismListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.RedditStreamListener;
|
import com.cnaude.purpleirc.GameListeners.RedditStreamListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.ReportRTSListener;
|
import com.cnaude.purpleirc.GameListeners.ReportRTSListener;
|
||||||
|
import com.cnaude.purpleirc.GameListeners.SimpleTicketManagerListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.TitanChatListener;
|
import com.cnaude.purpleirc.GameListeners.TitanChatListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.TownyChatListener;
|
import com.cnaude.purpleirc.GameListeners.TownyChatListener;
|
||||||
import com.cnaude.purpleirc.GameListeners.VanishNoPacketListener;
|
import com.cnaude.purpleirc.GameListeners.VanishNoPacketListener;
|
||||||
@ -213,6 +214,7 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
|
|
||||||
final String PL_ESSENTIALS = "Essentials";
|
final String PL_ESSENTIALS = "Essentials";
|
||||||
final String PL_REPORTRTS = "ReportRTS";
|
final String PL_REPORTRTS = "ReportRTS";
|
||||||
|
final String PL_SIMPLETICKET = "SimpleTicketManager";
|
||||||
final String PL_NTHE_END_AGAIN = "NTheEndAgain";
|
final String PL_NTHE_END_AGAIN = "NTheEndAgain";
|
||||||
final String PL_SUPERVANISH = "SuperVanish";
|
final String PL_SUPERVANISH = "SuperVanish";
|
||||||
final String PL_VANISHNOPACKET = "VanishNoPacket";
|
final String PL_VANISHNOPACKET = "VanishNoPacket";
|
||||||
@ -1696,6 +1698,12 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
hookList.add(hookFormat(PL_REPORTRTS, false));
|
hookList.add(hookFormat(PL_REPORTRTS, false));
|
||||||
}
|
}
|
||||||
|
if (isPluginEnabled(PL_SIMPLETICKET)) {
|
||||||
|
hookList.add(hookFormat(PL_SIMPLETICKET, true));
|
||||||
|
getServer().getPluginManager().registerEvents(new SimpleTicketManagerListener(this), this);
|
||||||
|
} else {
|
||||||
|
hookList.add(hookFormat(PL_SIMPLETICKET, false));
|
||||||
|
}
|
||||||
if (isPluginEnabled(PL_NTHE_END_AGAIN)) {
|
if (isPluginEnabled(PL_NTHE_END_AGAIN)) {
|
||||||
hookList.add(hookFormat(PL_NTHE_END_AGAIN, true));
|
hookList.add(hookFormat(PL_NTHE_END_AGAIN, true));
|
||||||
getServer().getPluginManager().registerEvents(new NTheEndAgainListener(this), this);
|
getServer().getPluginManager().registerEvents(new NTheEndAgainListener(this), this);
|
||||||
|
@ -24,6 +24,8 @@ import com.dthielke.herochat.ChannelManager;
|
|||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.nyancraft.reportrts.data.Ticket;
|
import com.nyancraft.reportrts.data.Ticket;
|
||||||
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -670,6 +672,76 @@ public class ChatTokenizer {
|
|||||||
.replace("%RTSWORLD%", world));
|
.replace("%RTSWORLD%", world));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SimpleTicketManager notifications to IRC
|
||||||
|
*
|
||||||
|
* @param uuid
|
||||||
|
* @param template
|
||||||
|
* @param ticket
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String simpleTicketTokenizer(UUID uuid, String template,
|
||||||
|
uk.co.joshuawoolley.simpleticketmanager.ticketsystem.Ticket ticket) {
|
||||||
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
|
String playerName;
|
||||||
|
String displayName;
|
||||||
|
if (player == null) {
|
||||||
|
playerName = uuid.toString();
|
||||||
|
displayName = uuid.toString();
|
||||||
|
} else {
|
||||||
|
playerName = player.getName();
|
||||||
|
displayName = player.getCustomName();
|
||||||
|
}
|
||||||
|
String description = ticket.getDescription();
|
||||||
|
String reason = ticket.getReason();
|
||||||
|
String modUUID = ticket.getAssignedTo();
|
||||||
|
String modName;
|
||||||
|
String displayModName;
|
||||||
|
String name = ticket.getReportingPlayer();
|
||||||
|
String world = ticket.getWorld();
|
||||||
|
String modComment = "";
|
||||||
|
int id = ticket.getTicketId();
|
||||||
|
if (description == null) {
|
||||||
|
description = "";
|
||||||
|
}
|
||||||
|
Player modPlayer = null;
|
||||||
|
if (modUUID != null) {
|
||||||
|
modPlayer = Bukkit.getPlayer(UUID.fromString(modUUID));
|
||||||
|
}
|
||||||
|
if (modPlayer != null) {
|
||||||
|
modName = modPlayer.getName();
|
||||||
|
displayModName = modPlayer.getDisplayName();
|
||||||
|
} else {
|
||||||
|
modName = modUUID;
|
||||||
|
displayModName = modName;
|
||||||
|
}
|
||||||
|
if (name == null) {
|
||||||
|
name = "";
|
||||||
|
}
|
||||||
|
if (world == null) {
|
||||||
|
world = "";
|
||||||
|
}
|
||||||
|
if (modComment == null) {
|
||||||
|
modComment = "";
|
||||||
|
}
|
||||||
|
if (modName == null) {
|
||||||
|
modName = "";
|
||||||
|
}
|
||||||
|
if (displayModName == null) {
|
||||||
|
displayModName = "";
|
||||||
|
}
|
||||||
|
return plugin.colorConverter.gameColorsToIrc(playerTokenizer(playerName, template)
|
||||||
|
.replace("%MESSAGE%", description)
|
||||||
|
.replace("%MODNAME%", modName)
|
||||||
|
.replace("%DISPLAYMODNAME%", displayModName)
|
||||||
|
.replace("%MODCOMMENT%", modComment)
|
||||||
|
.replace("%TICKETNUMBER%", String.valueOf(id))
|
||||||
|
.replace("%NAME%", name)
|
||||||
|
.replace("%DISPLAYNAME%", displayName)
|
||||||
|
.replace("%REASON%", reason)
|
||||||
|
.replace("%WORLD%", world));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param sender
|
* @param sender
|
||||||
|
@ -189,6 +189,11 @@ message-format:
|
|||||||
rts-held: '[RTS:Held] #%TICKETNUMBER% <%NAME%> %MESSAGE%'
|
rts-held: '[RTS:Held] #%TICKETNUMBER% <%NAME%> %MESSAGE%'
|
||||||
rts-assign: '[RTS:Assign] #%TICKETNUMBER% <%NAME%> %MESSAGE%'
|
rts-assign: '[RTS:Assign] #%TICKETNUMBER% <%NAME%> %MESSAGE%'
|
||||||
rts-reopen: '[RTS:Reopen] #%TICKETNUMBER% <%NAME%> %MESSAGE%'
|
rts-reopen: '[RTS:Reopen] #%TICKETNUMBER% <%NAME%> %MESSAGE%'
|
||||||
|
# SimpleTicketManager
|
||||||
|
stm-create: '[STM] Ticket #%TICKETNUMBER% created by %NAME%: %REASON% %MESSAGE%'
|
||||||
|
stm-claim: '[STM] Ticket #%TICKETNUMBER% claim by %MODNAME%: %REASON% %MESSAGE%'
|
||||||
|
stm-close: '[STM] Ticket #%TICKETNUMBER% closed by %MODNAME%: %REASON% %MESSAGE%'
|
||||||
|
stm-comment: '[STM] Ticket #%TICKETNUMBER% new comment by %MODNAME%: %REASON% %MESSAGE%'
|
||||||
# Dynmap Web Chat to IRC
|
# Dynmap Web Chat to IRC
|
||||||
dynmap-web-chat: '[Dynmap] <%NAME%> %MESSAGE%'
|
dynmap-web-chat: '[Dynmap] <%NAME%> %MESSAGE%'
|
||||||
# IRC to Dynmap Chat
|
# IRC to Dynmap Chat
|
||||||
|
Loading…
Reference in New Issue
Block a user