Created
March 5, 2017 05:19
-
-
Save heinrichquirit/4965e0ba9a609e8bc2a7f2592598b565 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="ArtifactManager"> | |
<artifact type="jar" name="SupportTickets"> | |
<output-path>$USER_HOME$/Desktop/Spigot/Server/plugins</output-path> | |
<root id="archive" name="SupportTickets.jar"> | |
<element id="module-output" name="SupportTickets" /> | |
</root> | |
</artifact> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="CompilerConfiguration"> | |
<wildcardResourcePatterns> | |
<entry name="!?*.java" /> | |
<entry name="!?*.form" /> | |
<entry name="!?*.class" /> | |
<entry name="!?*.groovy" /> | |
<entry name="!?*.scala" /> | |
<entry name="!?*.flex" /> | |
<entry name="!?*.kt" /> | |
<entry name="!?*.clj" /> | |
</wildcardResourcePatterns> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="CopyrightManager" default=""> | |
<module2copyright /> | |
</component> | |
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.7" project-jdk-type="JavaSDK"> | |
<output url="file://$PROJECT_DIR$/out" /> | |
</component> | |
<component name="SvnConfiguration" maxAnnotateRevisions="500" myUseAcceleration="nothing" myAutoUpdateAfterCommit="false" cleanupOnStartRun="false" SSL_PROTOCOLS="all"> | |
<option name="USER" value="" /> | |
<option name="PASSWORD" value="" /> | |
<option name="mySSHConnectionTimeout" value="30000" /> | |
<option name="mySSHReadTimeout" value="30000" /> | |
<option name="LAST_MERGED_REVISION" /> | |
<option name="MERGE_DRY_RUN" value="false" /> | |
<option name="MERGE_DIFF_USE_ANCESTRY" value="true" /> | |
<option name="UPDATE_LOCK_ON_DEMAND" value="false" /> | |
<option name="IGNORE_SPACES_IN_MERGE" value="false" /> | |
<option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" /> | |
<option name="IGNORE_SPACES_IN_ANNOTATE" value="true" /> | |
<option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" /> | |
<option name="FORCE_UPDATE" value="false" /> | |
<option name="IGNORE_EXTERNALS" value="false" /> | |
<myIsUseDefaultProxy>false</myIsUseDefaultProxy> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/SupportTickets.iml" filepath="$PROJECT_DIR$/SupportTickets.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="Palette2"> | |
<group name="Swing"> | |
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> | |
</item> | |
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> | |
</item> | |
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> | |
</item> | |
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> | |
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> | |
</item> | |
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> | |
<initial-values> | |
<property name="text" value="Button" /> | |
</initial-values> | |
</item> | |
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> | |
<initial-values> | |
<property name="text" value="RadioButton" /> | |
</initial-values> | |
</item> | |
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> | |
<initial-values> | |
<property name="text" value="CheckBox" /> | |
</initial-values> | |
</item> | |
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> | |
<initial-values> | |
<property name="text" value="Label" /> | |
</initial-values> | |
</item> | |
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | |
<preferred-size width="150" height="-1" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | |
<preferred-size width="150" height="-1" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | |
<preferred-size width="150" height="-1" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |
<preferred-size width="150" height="50" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |
<preferred-size width="150" height="50" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |
<preferred-size width="150" height="50" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> | |
</item> | |
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |
<preferred-size width="150" height="50" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> | |
<preferred-size width="150" height="50" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |
<preferred-size width="150" height="50" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> | |
<preferred-size width="200" height="200" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> | |
<preferred-size width="200" height="200" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> | |
</item> | |
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> | |
</item> | |
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> | |
</item> | |
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> | |
</item> | |
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> | |
<preferred-size width="-1" height="20" /> | |
</default-constraints> | |
</item> | |
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> | |
</item> | |
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> | |
</item> | |
</group> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set this to true if you want tickets briefly displayed in the sidebar | |
# Requires API: SidebarAPI | |
# Download: https://www.spigotmc.org/resources/scoreboard-sidebar-api.21042/ | |
enable-sidebar: false | |
# How often you want to update the sidebar in seconds | |
sidebar-update-frequency: 3 | |
ticket-message-format: '&3[&bStaffTickets&3] &b%name&3: %message' | |
# Append words that you want the system to record the sentences that contain these words | |
trigger-words: | |
- 'fire' | |
- 'water' | |
- 'lava' | |
- 'grief' | |
- 'mod' | |
- 'portal' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.commands; | |
import org.bukkit.command.Command; | |
import org.bukkit.entity.Player; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/19/2017 | |
* Time: 6:08 PM | |
*/ | |
public abstract class BaseCommand { | |
public abstract void execute(Player player, Command cmd, String[] args); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.commands; | |
import io.github.heinrichquirit.supporttickets.SupportTicketsPlugin; | |
import io.github.heinrichquirit.supporttickets.utils.Utils; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandExecutor; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.entity.Player; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/19/2017 | |
* Time: 6:32 PM | |
*/ | |
public class CommandManager implements CommandExecutor { | |
/* Initialize command classes to prevent new maps being erased when a new instance of the object is called */ | |
private Map<String, BaseCommand> commands = new HashMap<String, BaseCommand>(); | |
private SupportTicketsPlugin plugin; | |
public CommandManager(SupportTicketsPlugin plugin) { | |
this.plugin = plugin; | |
loadCommands(); | |
} | |
public boolean onCommand(CommandSender sender, Command cmd, String lbl, String[] args) { | |
if (!(sender instanceof Player)) { | |
sender.sendMessage("[SupportTickets] Please use this command in game!"); | |
return true; | |
} | |
Player p = (Player) sender; | |
if (Utils.validArg(cmd.getName(), "supporttickets")) { | |
if (args.length == 1) { | |
if (Utils.validArg(args[0], "info", "i")) { | |
commands.get("info").execute(p, cmd, args); | |
} | |
else if (Utils.validArg(args[0], "view", "v")) { | |
Utils.makeMessage(p, "Incorrect syntax, usage: /st view sidebar | /st view chat"); | |
} | |
else if (Utils.validArg(args[0], "remove", "rem", "r")) { | |
Utils.makeMessage(p, "Incorrect syntax, usage: /st remove <id>"); | |
} | |
} | |
else if (args.length == 2) { | |
if (Utils.validArg(args[0], "view", "v")) { | |
if (Utils.validArg(args[1], "sidebar", "sb")) { | |
commands.get("sidebar").execute(p, cmd, args); | |
} | |
else if (Utils.validArg(args[1], "chat", "c")) { | |
commands.get("chat").execute(p, cmd, args); | |
} | |
} | |
else if (Utils.validArg(args[0], "remove", "rem", "r")) { | |
commands.get("remove").execute(p, cmd, args); | |
} | |
} | |
} | |
return true; | |
} | |
private void loadCommands() { | |
commands.put("info", new InfoCommand()); | |
commands.put("sidebar", new ViewSidebarCommand(plugin)); | |
commands.put("chat", new ViewChatCommand(plugin)); | |
commands.put("remove", new RemoveCommand()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.commands; | |
import io.github.heinrichquirit.supporttickets.utils.CommandText; | |
import io.github.heinrichquirit.supporttickets.utils.Utils; | |
import net.md_5.bungee.api.ChatColor; | |
import net.md_5.bungee.api.chat.ComponentBuilder; | |
import net.md_5.bungee.api.chat.HoverEvent; | |
import net.md_5.bungee.api.chat.TextComponent; | |
import org.bukkit.command.Command; | |
import org.bukkit.entity.Player; | |
import java.util.*; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 2/2/2017 | |
* Time: 10:45 PM | |
*/ | |
public class InfoCommand extends BaseCommand { | |
private Set<TextComponent> set = new HashSet<TextComponent>(); | |
public InfoCommand() { | |
TextComponent infoCmd = new TextComponent((CommandText.INFO)); | |
TextComponent removeCmd = new TextComponent((CommandText.REMOVE)); | |
TextComponent viewChatCmd = new TextComponent((CommandText.VIEW_CHAT)); | |
TextComponent viewSidebarCmd = new TextComponent((CommandText.VIEW_SIDEBAR)); | |
set.add(infoCmd); | |
set.add(removeCmd); | |
set.add(viewChatCmd); | |
set.add(viewSidebarCmd); | |
} | |
public void execute(Player player, Command cmd, String[] args) { | |
Utils.beautifyCommands(player, set); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.commands; | |
import io.github.heinrichquirit.supporttickets.managers.SidebarManager; | |
import io.github.heinrichquirit.supporttickets.managers.TicketManager; | |
import io.github.heinrichquirit.supporttickets.utils.Utils; | |
import org.bukkit.command.Command; | |
import org.bukkit.entity.Player; | |
import java.util.UUID; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/31/2017 | |
* Time: 2:09 PM | |
*/ | |
public class RemoveCommand extends BaseCommand { | |
public void execute(Player player, Command cmd, String[] args) { | |
UUID uuid = player.getUniqueId(); | |
if (!Utils.isInteger(args[1])) { | |
Utils.makeMessage(player, "The third argument must be a number!"); | |
return; | |
} | |
int id = Utils.parseInt(args[1]); | |
if (!TicketManager.getInstance().containsID(id)) { | |
Utils.makeMessage(player, "Ticket with an id of '" + id + "' does not exist!"); | |
return; | |
} | |
// Refreshes the deleted changes of the sidebar | |
SidebarManager.getInstance().setup(); | |
TicketManager.getInstance().deleteTicketByID(id); | |
SidebarManager.getInstance().updateSidebar(player); | |
Utils.makeMessage(player, "Removed ticket with an id of '" + id + "'."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.commands; | |
import io.github.heinrichquirit.supporttickets.SupportTicketsPlugin; | |
import org.bukkit.command.Command; | |
import org.bukkit.entity.Player; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/22/2017 | |
* Time: 3:01 AM | |
*/ | |
public class ViewChatCommand extends BaseCommand { | |
private SupportTicketsPlugin plugin; | |
public ViewChatCommand(SupportTicketsPlugin plugin) { | |
this.plugin = plugin; | |
} | |
public void execute(Player player, Command cmd, String[] args) { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.listeners; | |
import io.github.heinrichquirit.supporttickets.managers.TicketManager; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.PlayerQuitEvent; | |
import java.util.UUID; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/29/2017 | |
* Time: 9:28 PM | |
*/ | |
public class DeleteOnLeaveListener implements Listener { | |
@EventHandler | |
public void onLeave(PlayerQuitEvent e) { | |
UUID uuid = e.getPlayer().getUniqueId(); | |
if (TicketManager.getInstance().containsUUID(uuid)) { | |
TicketManager.getInstance().deleteTicketByUUID(uuid); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.listeners; | |
import io.github.heinrichquirit.supporttickets.SupportTicketsPlugin; | |
import io.github.heinrichquirit.supporttickets.managers.TicketManager; | |
import io.github.heinrichquirit.supporttickets.utils.Ticket; | |
import io.github.heinrichquirit.supporttickets.utils.TicketStatus; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.EventPriority; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.AsyncPlayerChatEvent; | |
import org.bukkit.event.player.PlayerCommandPreprocessEvent; | |
import java.util.UUID; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/20/2017 | |
* Time: 3:32 PM | |
*/ | |
public class TriggerWordsListener implements Listener { | |
private SupportTicketsPlugin plugin; | |
public TriggerWordsListener(SupportTicketsPlugin plugin) { | |
this.plugin = plugin; | |
} | |
/* Listens into the chat if it contains a trigger word */ | |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) | |
public void onChat(AsyncPlayerChatEvent e) { | |
UUID playerID = e.getPlayer().getUniqueId(); | |
String message = e.getMessage(); | |
for (String word : plugin.triggerWords) { | |
if (message.contains(word)) { | |
TicketManager.getInstance().createTicket(new Ticket(playerID, message, "none", TicketStatus.PENDING)); | |
// Use return to stop ticket duplication! | |
return; | |
} | |
} | |
} | |
/* Record a ticket if player uses /helpop */ | |
@EventHandler | |
public void onHelpop(PlayerCommandPreprocessEvent e) { | |
UUID playerID = e.getPlayer().getUniqueId(); | |
String message = e.getMessage(); | |
if (message.length() >= 9) { | |
if (message.substring(0, 7).equalsIgnoreCase("/helpop")) { | |
String trimmedMsg = message.substring(8, message.length()); | |
// Need to create helpop ticket | |
TicketManager.getInstance().createTicket(new Ticket(playerID, trimmedMsg, "none", TicketStatus.PENDING)); | |
// Let the player know that they have created a ticket - Display /ticket view | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.managers; | |
import io.github.heinrichquirit.supporttickets.utils.Ticket; | |
import org.bukkit.entity.Player; | |
import java.util.*; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/19/2017 | |
* Time: 6:43 PM | |
*/ | |
public class TicketManager { | |
private static TicketManager instance; | |
private Map<Integer, Ticket> tickets = new HashMap<Integer, Ticket>(); | |
public TicketManager() { | |
instance = this; | |
} | |
public static TicketManager getInstance() { | |
return instance; | |
} | |
public void createTicket(Ticket ticket) { | |
if (tickets.size() == 0) { | |
tickets.put(1, ticket); | |
} else { | |
tickets.put(tickets.size() + 1, ticket); | |
} | |
} | |
public void deleteTicketByID(int id) { | |
tickets.remove(id); | |
} | |
public boolean containsID(int id) { | |
return tickets.containsKey(id); | |
} | |
public void deleteTicketByUUID(UUID uuid) { | |
} | |
public Map<Integer, Ticket> getTickets() { | |
return tickets; | |
} | |
public boolean containsUUID(UUID uuid) { | |
for (Map.Entry<Integer, Ticket> map : tickets.entrySet()) { | |
Ticket t = map.getValue(); | |
if (t.getRequesterID().equals(uuid)) { | |
return true; | |
} | |
return false; | |
} | |
return false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets; | |
import io.github.heinrichquirit.supporttickets.commands.CommandManager; | |
import io.github.heinrichquirit.supporttickets.listeners.DeleteOnLeaveListener; | |
import io.github.heinrichquirit.supporttickets.listeners.TriggerWordsListener; | |
import io.github.heinrichquirit.supporttickets.managers.SidebarManager; | |
import io.github.heinrichquirit.supporttickets.managers.TicketManager; | |
import io.github.heinrichquirit.supporttickets.utils.ConfigPath; | |
import io.github.heinrichquirit.supporttickets.utils.Ticket; | |
import io.github.heinrichquirit.supporttickets.utils.Utils; | |
import org.bukkit.Bukkit; | |
import org.bukkit.plugin.PluginManager; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import java.util.List; | |
import java.util.logging.Level; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/19/2017 | |
* Time: 5:58 PM | |
*/ | |
public class SupportTicketsPlugin extends JavaPlugin { | |
public boolean sidebarStatus; | |
public int sidebarUpdateFrequency; | |
public String ticketMsgFormat; | |
public List<String> triggerWords; | |
public void onEnable() { | |
saveDefaultConfig(); | |
loadPaths(); | |
registerListeners(); | |
registerCommands(); | |
checkDependency(); | |
/* Initialize instance of manager */ | |
new TicketManager(); | |
new SidebarManager(this); | |
} | |
public void onDisable() { | |
// Clear maps and shit | |
TicketManager.getInstance().getTickets().clear(); | |
} | |
private void loadPaths() { | |
sidebarStatus = getConfig().getBoolean(ConfigPath.SIDEBAR_STATUS); | |
sidebarUpdateFrequency = getConfig().getInt(ConfigPath.SIDEBAR_UPDATE_FREQ); | |
ticketMsgFormat = getConfig().getString(ConfigPath.TICKET_MSG_FORMAT); | |
triggerWords = getConfig().getStringList(ConfigPath.TRIGGER_WORDS); | |
} | |
private void registerListeners() { | |
PluginManager pm = getServer().getPluginManager(); | |
pm.registerEvents(new TriggerWordsListener(this), this); | |
pm.registerEvents(new DeleteOnLeaveListener(), this); | |
} | |
private void registerCommands() { | |
getCommand("supporttickets").setExecutor(new CommandManager(this)); | |
} | |
private void checkDependency() { | |
PluginManager pm = Bukkit.getPluginManager(); | |
String plugName = "SidebarAPI"; | |
if (sidebarStatus == true && pm.getPlugin(plugName) == null) { | |
Utils.log(Level.WARNING, "Sidebar enabled, but SidebarAPI plugin cannot be found! Please fix your configuration settings!"); | |
sidebarStatus = false; | |
} | |
else if (sidebarStatus == false && pm.getPlugin(plugName) != null) { | |
Utils.log(Level.INFO, "SidebarAPI plugin found, but sidebar is disabled. You can enable it if you want to."); | |
sidebarStatus = false; | |
} | |
else if (sidebarStatus == true && pm.getPlugin(plugName) != null) { | |
Utils.log(Level.INFO, "SidebarAPI plugin found, enabling the sidebar."); | |
sidebarStatus = true; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.utils; | |
import static net.md_5.bungee.api.ChatColor.AQUA; | |
import static net.md_5.bungee.api.ChatColor.DARK_AQUA; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 2/7/2017 | |
* Time: 11:52 PM | |
*/ | |
public class CommandDecorator { | |
public static final String HEADER = DARK_AQUA + "+" + AQUA + "-------------------------------------------" + DARK_AQUA + "+"; | |
public static final String HEADING = DARK_AQUA + "[" + AQUA + "SupportTickets" + DARK_AQUA + "]"; | |
public static final String FOOTER = DARK_AQUA + "+" + AQUA + "-------------------------------------------" + DARK_AQUA + "+"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.utils; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 2/3/2017 | |
* Time: 5:15 PM | |
*/ | |
public class CommandText { | |
public static final String INFO = "/supporttickets info"; | |
public static final String REMOVE = "/supporttickets remove <id>"; | |
public static final String VIEW_CHAT = "/supporttickets view chat"; | |
public static final String VIEW_SIDEBAR = "/supporttickets view sidebar"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.utils; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/20/2017 | |
* Time: 3:34 PM | |
*/ | |
public class ConfigPath { | |
public static String SIDEBAR_STATUS = "enable-sidebar"; | |
public static String SIDEBAR_UPDATE_FREQ = "sidebar-update-frequency"; | |
public static String TICKET_MSG_FORMAT = "ticket-message-format"; | |
public static String TRIGGER_WORDS = "trigger-words"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.utils; | |
import java.util.UUID; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/19/2017 | |
* Time: 6:46 PM | |
*/ | |
public class Ticket { | |
private UUID requesterID; | |
private String message; | |
private String handler; | |
private TicketStatus status; | |
public Ticket() { | |
setRequesterID(null); | |
setMessage(""); | |
setHandler(""); | |
setStatus(null); | |
} | |
public Ticket(UUID requester, String message, String handler, TicketStatus status) { | |
setRequesterID(requester); | |
setMessage(message); | |
setHandler(handler); | |
setStatus(status); | |
} | |
public void setRequesterID(UUID requesterID) { | |
this.requesterID = requesterID; | |
} | |
public UUID getRequesterID() { | |
return requesterID; | |
} | |
public void setMessage(String message) { | |
this.message = message; | |
} | |
public String getMessage() { | |
return message; | |
} | |
public void setHandler(String handler) { | |
this.handler = handler; | |
} | |
public String getHandler() { | |
return handler; | |
} | |
public void setStatus(TicketStatus status) { | |
this.status = status; | |
} | |
public TicketStatus getStatus() { | |
return status; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.utils; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/20/2017 | |
* Time: 3:40 PM | |
*/ | |
public enum TicketStatus { | |
PENDING("Open"), CLAIMED("Claimed"); | |
private final String status; | |
TicketStatus(final String status) { | |
this.status = status; | |
} | |
public String toString() { | |
return status; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.supporttickets.utils; | |
import net.md_5.bungee.api.ChatColor; | |
import static net.md_5.bungee.api.ChatColor.AQUA; | |
import static net.md_5.bungee.api.ChatColor.DARK_AQUA; | |
import net.md_5.bungee.api.chat.ComponentBuilder; | |
import net.md_5.bungee.api.chat.HoverEvent; | |
import net.md_5.bungee.api.chat.TextComponent; | |
import org.bukkit.Bukkit; | |
import org.bukkit.entity.Player; | |
import java.util.HashSet; | |
import java.util.Set; | |
import java.util.logging.Level; | |
import static net.md_5.bungee.api.ChatColor.*; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/20/2017 | |
* Time: 3:34 PM | |
*/ | |
public class Utils { | |
public static void debug(String message) { | |
Bukkit.broadcastMessage(message); | |
} | |
public static boolean validArg(String arg1, String... arguments) { | |
Set<String> args = new HashSet<String>(); | |
for (String j : arguments) { | |
args.add(j); | |
} | |
return args.contains(arg1); | |
} | |
public static void makeMessage(Player player, String message) { | |
player.sendMessage(DARK_AQUA + "[" + AQUA + "SupportTickets" + DARK_AQUA + "] " + DARK_AQUA + message + RESET); | |
} | |
public static void log(Level level, String message) { | |
Bukkit.getLogger().log(level, "[SupportTickets] " + message); | |
} | |
public static int parseInt(String string) { | |
try { | |
return Integer.parseInt(string); | |
} catch (NumberFormatException e) { | |
e.printStackTrace(); | |
return 0; | |
} | |
} | |
public static boolean isInteger(String string) { | |
try { | |
Integer.parseInt(string); | |
return true; | |
} catch (NumberFormatException e) { | |
e.printStackTrace(); | |
return false; | |
} | |
} | |
public static String colorize(ChatColor color, String string) { | |
switch(color) { | |
case AQUA: return AQUA + string + RESET; | |
case DARK_AQUA: return DARK_AQUA + string + RESET; | |
case RESET: return RESET + string + RESET; | |
case BLACK: return BLACK + string + RESET; | |
case BLUE: return BLUE + string + RESET; | |
case BOLD: return BOLD + string + RESET; | |
case DARK_BLUE: return DARK_BLUE + string + RESET; | |
case DARK_GRAY: return DARK_GRAY + string + RESET; | |
case DARK_GREEN: return DARK_GREEN + string + RESET; | |
case DARK_PURPLE: return DARK_PURPLE + string + RESET; | |
case DARK_RED: return DARK_RED + string + RESET; | |
case GOLD: return GOLD + string + RESET; | |
case GRAY: return GRAY + string + RESET; | |
case GREEN: return GREEN + string + RESET; | |
case ITALIC: return ITALIC + string + RESET; | |
case LIGHT_PURPLE: return LIGHT_PURPLE + string + RESET; | |
case MAGIC: return MAGIC + string + RESET; | |
case RED: return RED + string + RESET; | |
case STRIKETHROUGH: return STRIKETHROUGH + string + RESET; | |
case UNDERLINE: return UNDERLINE + string + RESET; | |
case WHITE: return WHITE + string + RESET; | |
case YELLOW: return YELLOW + string + RESET; | |
default: return string + RESET; | |
} | |
} | |
public static String formatMessage(String string, Object... args) { | |
return (String.format(string + "\n", args)); | |
} | |
public static void beautifyCommands(Player player, Set<TextComponent> set) { | |
player.sendMessage(CommandDecorator.HEADER); | |
player.sendMessage(""); | |
player.sendMessage(formatMessage("%10s", CommandDecorator.HEADING)); | |
for (TextComponent component : set) { | |
player.spigot().sendMessage(setHover(component)); | |
} | |
player.sendMessage(""); | |
player.sendMessage(formatMessage("%s", CommandDecorator.HEADING)); | |
} | |
private static TextComponent setHover(TextComponent textComp) { | |
switch(textComp.getText()) { | |
case CommandText.INFO: | |
textComp.setText(Utils.colorize(AQUA, " " + textComp.getText())); | |
textComp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Displays the commands.").create())); | |
return textComp; | |
case CommandText.REMOVE: | |
textComp.setText(Utils.colorize(AQUA, " " + textComp.getText())); | |
textComp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Removes a specified ticket.").create())); | |
return textComp; | |
case CommandText.VIEW_CHAT: | |
textComp.setText(Utils.colorize(AQUA, " " + textComp.getText())); | |
textComp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("View all tickets in the chat.").create())); | |
return textComp; | |
case CommandText.VIEW_SIDEBAR: | |
textComp.setText(Utils.colorize(AQUA, " " + textComp.getText())); | |
textComp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("View all tickets in the sidebar.").create())); | |
return textComp; | |
default: | |
return null; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SupportTickets | |
main: io.github.heinrichquirit.supporttickets.SupportTicketsPlugin | |
version: 1.0 | |
author: BigBadHenz | |
softdepend: [SidebarAPI] | |
commands: | |
supporttickets: | |
description: The main command for the staff tickets system. | |
aliases: st |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="JAVA_MODULE" version="4"> | |
<component name="NewModuleRootManager" inherit-compiler-output="true"> | |
<exclude-output /> | |
<content url="file://$MODULE_DIR$"> | |
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | |
</content> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
<orderEntry type="module-library"> | |
<library> | |
<CLASSES> | |
<root url="jar://$USER_HOME$/Desktop/Spigot/Development/API's/spigot-api-1.10-R0.1-20160609.015154-1-shaded.jar!/" /> | |
</CLASSES> | |
<JAVADOC /> | |
<SOURCES /> | |
</library> | |
</orderEntry> | |
<orderEntry type="module-library"> | |
<library> | |
<CLASSES> | |
<root url="jar://$USER_HOME$/Desktop/Spigot/Development/API's/SidebarAPI.jar!/" /> | |
</CLASSES> | |
<JAVADOC> | |
<root url="jar://$USER_HOME$/Desktop/Spigot/Development/API's/SidebarAPI.jar!/doc" /> | |
</JAVADOC> | |
<SOURCES> | |
<root url="jar://$USER_HOME$/Desktop/Spigot/Development/API's/SidebarAPI.jar!/" /> | |
</SOURCES> | |
</library> | |
</orderEntry> | |
</component> | |
</module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment