Created
May 30, 2017 18:44
-
-
Save Zyraun/4e2f03eba7c987d7ca835ada788ccbd0 to your computer and use it in GitHub Desktop.
Quickly manage multiple chat channels for Minecraft. Advanced server tool.
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="StaffChannel:jar"> | |
<output-path>$USER_HOME$/Documents/Server/plugins</output-path> | |
<root id="archive" name="StaffChannel.jar"> | |
<element id="module-output" name="StaffChannel" /> | |
</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
<component name="libraryTable"> | |
<library name="spigot"> | |
<CLASSES> | |
<root url="jar://$USER_HOME$/Documents/Server/spigot.jar!/" /> | |
</CLASSES> | |
<JAVADOC /> | |
<SOURCES> | |
<root url="jar://$USER_HOME$/Documents/Server/spigot.jar!/" /> | |
</SOURCES> | |
</library> | |
</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="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |
<output url="file://$PROJECT_DIR$/out" /> | |
</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$/StaffChannel.iml" filepath="$PROJECT_DIR$/StaffChannel.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
channelverse: | |
enabled: true | |
preferences: | |
default-channel: 'global' | |
basic-permission: 'channelverse.use' | |
channels: | |
Global: | |
permission: '' | |
chat-format: '' | |
prefix: '&2[G] &r' | |
do-prefix: true | |
maximum-members: 0 | |
operator: | |
Private: | |
permission: 'channelverse.use.private' | |
chat-format: '&e%name% &7%message%' | |
prefix: '&b[P] &r' | |
do-prefix: true | |
maximum-members: 8 | |
operator: 'Zyraun' |
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 me.zyraun.utility.staffchannel.commands; | |
import me.zyraun.utility.staffchannel.Main; | |
import me.zyraun.utility.staffchannel.function.ChannelManager; | |
import org.bukkit.Sound; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandExecutor; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.entity.Player; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class ChannelverseCommand implements CommandExecutor { | |
@Override | |
public boolean onCommand(CommandSender s, Command cmd, String label, String[] args) { | |
if (cmd.getName().equalsIgnoreCase("channelverse")) { | |
if (!(s instanceof Player)) { s.sendMessage("§cSorry, console. This is a player-only plugin."); return false; } | |
Player player = (Player) s; | |
if (!player.hasPermission(Main.getInstance().getConfig().getString("channelverse.preferences.basic-permission"))) { | |
player.sendMessage("§4Sorry! §cYou lack the permissions to perform this."); | |
player.playSound(player.getLocation(), Sound.NOTE_BASS, 8, 8); | |
return false; | |
} | |
player.openInventory(ChannelManager.getMenu(player)); | |
} | |
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 me.zyraun.utility.staffchannel.events; | |
import me.zyraun.utility.staffchannel.function.ChatChannel; | |
import org.bukkit.event.Event; | |
import org.bukkit.event.HandlerList; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class ChannelCreateEvent extends Event { | |
private static final HandlerList handlers = new HandlerList(); | |
private ChatChannel eventChannel; | |
private boolean cancelled = false; | |
public ChannelCreateEvent(ChatChannel channel) { | |
eventChannel = channel; | |
} | |
public HandlerList getHandlers() { | |
return handlers; | |
} | |
public static HandlerList getHandlerList() { | |
return handlers; | |
} | |
public ChatChannel getChannel() { | |
return eventChannel; | |
} | |
public boolean isCancelled() { return cancelled; } | |
public void setCancelled(boolean value) { cancelled = 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 me.zyraun.utility.staffchannel.events; | |
import me.zyraun.utility.staffchannel.function.ChatChannel; | |
import org.bukkit.event.Event; | |
import org.bukkit.event.HandlerList; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class ChannelDeleteEvent extends Event { | |
private static final HandlerList handlers = new HandlerList(); | |
private ChatChannel eventChannel; | |
private boolean cancelled = false; | |
public ChannelDeleteEvent(ChatChannel channel) { | |
eventChannel = channel; | |
} | |
public HandlerList getHandlers() { | |
return handlers; | |
} | |
public static HandlerList getHandlerList() { | |
return handlers; | |
} | |
public ChatChannel getChannel() { | |
return eventChannel; | |
} | |
public boolean isCancelled() { return cancelled; } | |
public void setCancelled(boolean value) { cancelled = 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 me.zyraun.utility.staffchannel.events; | |
import me.zyraun.utility.staffchannel.function.ChatChannel; | |
import org.bukkit.event.Event; | |
import org.bukkit.event.HandlerList; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class ChannelMuteEvent extends Event { | |
private static final HandlerList handlers = new HandlerList(); | |
private ChatChannel eventChannel; | |
private boolean cancelled = false; | |
public ChannelMuteEvent(ChatChannel channel) { | |
eventChannel = channel; | |
} | |
public HandlerList getHandlers() { | |
return handlers; | |
} | |
public static HandlerList getHandlerList() { | |
return handlers; | |
} | |
public ChatChannel getChannel() { | |
return eventChannel; | |
} | |
public boolean isCancelled() { return cancelled; } | |
public void setCancelled(boolean value) { cancelled = 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 me.zyraun.utility.staffchannel.events; | |
import me.zyraun.utility.staffchannel.function.ChatChannel; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.Event; | |
import org.bukkit.event.HandlerList; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class PlayerJoinChannelEvent extends Event { | |
private static final HandlerList handlers = new HandlerList(); | |
private ChatChannel eventChannel; | |
private Player eventPlayer; | |
private boolean cancelled = false; | |
public PlayerJoinChannelEvent(Player player, ChatChannel channel) { | |
eventChannel = channel; | |
eventPlayer = player; | |
} | |
public HandlerList getHandlers() { | |
return handlers; | |
} | |
public static HandlerList getHandlerList() { | |
return handlers; | |
} | |
public ChatChannel getChannel() { | |
return eventChannel; | |
} | |
public Player getPlayer() { | |
return eventPlayer; | |
} | |
public boolean isCancelled() { return cancelled; } | |
public void setCancelled(boolean value) { cancelled = 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 me.zyraun.utility.staffchannel.events; | |
import me.zyraun.utility.staffchannel.function.ChatChannel; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.Event; | |
import org.bukkit.event.HandlerList; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class PlayerKickedFromChannelEvent extends Event { | |
private static final HandlerList handlers = new HandlerList(); | |
private ChatChannel eventChannel; | |
private Player eventPlayer; | |
private String kickReason; | |
private boolean cancelled = false; | |
public PlayerKickedFromChannelEvent(Player player, ChatChannel channel) { | |
eventChannel = channel; | |
eventPlayer = player; | |
} | |
public PlayerKickedFromChannelEvent(Player player, ChatChannel channel, String reason) { | |
eventChannel = channel; | |
eventPlayer = player; | |
kickReason = reason; | |
} | |
public HandlerList getHandlers() { | |
return handlers; | |
} | |
public static HandlerList getHandlerList() { | |
return handlers; | |
} | |
public ChatChannel getChannel() { | |
return eventChannel; | |
} | |
public Player getPlayer() { | |
return eventPlayer; | |
} | |
public String getKickReason() { return kickReason; } | |
public boolean isCancelled() { return cancelled; } | |
public void setCancelled(boolean value) { cancelled = 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 me.zyraun.utility.staffchannel.events; | |
import me.zyraun.utility.staffchannel.function.ChatChannel; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.Event; | |
import org.bukkit.event.HandlerList; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class PlayerLeaveChannelEvent extends Event { | |
private static final HandlerList handlers = new HandlerList(); | |
private ChatChannel eventChannel; | |
private Player eventPlayer; | |
private boolean cancelled = false; | |
public PlayerLeaveChannelEvent(Player player, ChatChannel channel) { | |
eventChannel = channel; | |
eventPlayer = player; | |
} | |
public HandlerList getHandlers() { | |
return handlers; | |
} | |
public static HandlerList getHandlerList() { | |
return handlers; | |
} | |
public ChatChannel getChannel() { | |
return eventChannel; | |
} | |
public Player getPlayer() { | |
return eventPlayer; | |
} | |
public boolean isCancelled() { return cancelled; } | |
public void setCancelled(boolean value) { cancelled = 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 me.zyraun.utility.staffchannel.events; | |
import me.zyraun.utility.staffchannel.function.ChatChannel; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.Event; | |
import org.bukkit.event.HandlerList; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class PlayerSpeakInChannelEvent extends Event { | |
private static final HandlerList handlers = new HandlerList(); | |
private ChatChannel eventChannel; | |
private Player eventPlayer; | |
private String eventMessage; | |
private boolean cancelled = false; | |
public PlayerSpeakInChannelEvent(Player player, ChatChannel channel) { | |
eventChannel = channel; | |
eventPlayer = player; | |
} | |
public PlayerSpeakInChannelEvent(Player player, ChatChannel channel, String message) { | |
eventChannel = channel; | |
eventPlayer = player; | |
eventMessage = message; | |
} | |
public HandlerList getHandlers() { | |
return handlers; | |
} | |
public static HandlerList getHandlerList() { | |
return handlers; | |
} | |
public ChatChannel getChannel() { | |
return eventChannel; | |
} | |
public Player getPlayer() { | |
return eventPlayer; | |
} | |
public String getMessage() { | |
return eventMessage; | |
} | |
public boolean isCancelled() { return cancelled; } | |
public void setCancelled(boolean value) { cancelled = 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 me.zyraun.utility.staffchannel.function; | |
import me.zyraun.utility.staffchannel.events.PlayerJoinChannelEvent; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class ChannelHandler implements Listener { | |
@EventHandler | |
public void onChannelJoin(PlayerJoinChannelEvent e) { | |
Player player = e.getPlayer(); | |
if (ChannelManager.getChannel(player) != null) { | |
ChannelManager.getChannel(player).kickMember(player.getName()); | |
} | |
} | |
} |
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 me.zyraun.utility.staffchannel.function; | |
import me.zyraun.utility.staffchannel.util.ItemStackBuilder; | |
import org.bukkit.Bukkit; | |
import org.bukkit.Material; | |
import org.bukkit.entity.Player; | |
import org.bukkit.inventory.Inventory; | |
import org.bukkit.inventory.ItemStack; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class ChannelManager { | |
private static List<ChatChannel> channels = new ArrayList<>(); | |
public static List<ChatChannel> getChannels() { return channels; } | |
public static boolean channelIsRegistered(ChatChannel channel) { | |
return getChannels().contains(channel); | |
} | |
public static void registerChannel(ChatChannel channel) { | |
if (!channelIsRegistered(channel)) | |
channels.add(channel); | |
} | |
public static void unregisterChannel(ChatChannel channel) { | |
if (channelIsRegistered(channel)) | |
channels.remove(channel); | |
} | |
public static ChatChannel getChannel(Player player) { | |
for (ChatChannel channel : getChannels()) { | |
if (channel.hasMember(player.getName())) return channel; | |
} | |
return null; | |
} | |
public static ChatChannel getChannel(String channelName) { | |
for (ChatChannel channel : getChannels()) { | |
if (channel.getChannelName().equalsIgnoreCase(channelName)) return channel; | |
} | |
return null; | |
} | |
public static Inventory getMenu(Player player) { | |
Inventory inv = Bukkit.createInventory(null, 36, "§8Channelverse"); | |
for (ChatChannel channel : getChannels()) { | |
Material type = Material.EMERALD_BLOCK; | |
if (channel.hasMember(player.getName())) type = Material.GOLD_BLOCK; | |
if (!player.hasPermission(channel.getAccessPermission())) type = Material.LAPIS_BLOCK; | |
if ((channel.getChannelMembers().size() >= channel.getMaximumMembers()) && channel.getMaximumMembers() != 0) type = Material.REDSTONE_BLOCK; | |
String[] lore; | |
String operator; | |
if (channel.getChannelOperator() == null || channel.getChannelOperator() == "") operator = "Console"; | |
else operator = channel.getChannelOperator(); | |
boolean access = false; | |
if (player.hasPermission(channel.getAccessPermission())) access = true; | |
String accessTicket = ""; | |
if (access) accessTicket = "§3You can access this channel."; | |
if (!access) accessTicket = "§cThis channel is private. Blocked."; | |
lore = new String[]{ "§8Click to join channel!", "", accessTicket, "§6" + channel.getChannelMembers().size() + " §e/ §6" + channel.getMaximumMembers() + " §eplayer(s) connected", "", "§7Channel owned by " + operator }; | |
ItemStack icon = new ItemStackBuilder(Material.STAINED_CLAY) | |
.withType(type) | |
.withName("§b" + channel.getChannelName()) | |
.withLore(lore) | |
.build(); | |
inv.addItem(icon); | |
} | |
return inv; | |
} | |
} |
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 me.zyraun.utility.staffchannel.function; | |
import me.zyraun.utility.staffchannel.Main; | |
import me.zyraun.utility.staffchannel.events.PlayerJoinChannelEvent; | |
import me.zyraun.utility.staffchannel.events.PlayerKickedFromChannelEvent; | |
import me.zyraun.utility.staffchannel.events.PlayerLeaveChannelEvent; | |
import org.bukkit.Bukkit; | |
import org.bukkit.plugin.Plugin; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class ChatChannel { | |
private String name; | |
private String path; | |
private String permission; | |
private String chatFormat; | |
private String prefix; | |
private int maxMembers; | |
private String channelOperator; | |
private List<String> channelMembers = new ArrayList<>(); | |
private boolean doPrefix; | |
public ChatChannel(String channelName, String channelPath) { | |
Plugin plugin = Main.getInstance(); | |
name = channelName; | |
path = channelPath; | |
permission = plugin.getConfig().getString(channelPath + ".permission"); | |
chatFormat = plugin.getConfig().getString(channelPath + ".chat-format").replace("&", "§"); | |
prefix = plugin.getConfig().getString(channelPath + ".prefix").replace("&", "§"); | |
maxMembers = plugin.getConfig().getInt(channelPath + ".maximum-members"); | |
channelOperator = plugin.getConfig().getString(channelPath + ".operator"); | |
doPrefix = plugin.getConfig().getBoolean(channelPath + ".do-prefix"); | |
} | |
public String getConfigurationPath() { return path; } | |
public String getChannelName() { return name; } | |
public String getAccessPermission() { return permission; } | |
public String getChatFormat() { return chatFormat; } | |
public String getPrefix() { return prefix; } | |
public int getMaximumMembers() { return maxMembers; } | |
public String getChannelOperator() { return channelOperator; } | |
public boolean canDoPrefix() { return doPrefix; } | |
public boolean hasMember(String name) { return channelMembers.contains(name); } | |
public List<String> getChannelMembers() { return channelMembers; }; | |
public void addMember(String name) { | |
if (!hasMember(name)) { | |
PlayerJoinChannelEvent event = new PlayerJoinChannelEvent(Bukkit.getPlayer(name), this); | |
Bukkit.getPluginManager().callEvent(event); | |
channelMembers.add(name); | |
} | |
} | |
public void kickMember(String name) { | |
if (hasMember(name)) { | |
PlayerLeaveChannelEvent event = new PlayerLeaveChannelEvent(Bukkit.getPlayer(name), this); | |
Bukkit.getPluginManager().callEvent(event); | |
channelMembers.remove(name); | |
} | |
} | |
public void kickMember(String name, String reason) { | |
if (hasMember(name)) { | |
PlayerKickedFromChannelEvent event = new PlayerKickedFromChannelEvent(Bukkit.getPlayer(name), this, reason); | |
Bukkit.getPluginManager().callEvent(event); | |
channelMembers.remove(name); | |
} | |
} | |
public void sendMessage(String text) { | |
for (String s : getChannelMembers()) { | |
Bukkit.getPlayer(s).sendMessage(text); | |
} | |
} | |
} |
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 me.zyraun.utility.staffchannel.function; | |
import me.zyraun.utility.staffchannel.Main; | |
import me.zyraun.utility.staffchannel.events.PlayerSpeakInChannelEvent; | |
import org.bukkit.Bukkit; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.AsyncPlayerChatEvent; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class ChatListener implements Listener { | |
@EventHandler | |
public void onChat(AsyncPlayerChatEvent e) { | |
Player player = e.getPlayer(); | |
String message = e.getMessage(); | |
ChatChannel channel = ChannelManager.getChannel(player); | |
if (!Main.enabled()) return; | |
e.setCancelled(true); | |
if (channel.canDoPrefix()) e.setFormat(channel.getPrefix() + e.getFormat()); | |
String finalized = e.getFormat().replace("%1$s", player.getName()).replace("%2$s", message); | |
PlayerSpeakInChannelEvent event = new PlayerSpeakInChannelEvent(player, channel, message); | |
Bukkit.getPluginManager().callEvent(event); | |
channel.sendMessage(finalized); | |
} | |
} |
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 me.zyraun.utility.staffchannel; | |
import me.zyraun.utility.staffchannel.commands.ChannelverseCommand; | |
import me.zyraun.utility.staffchannel.function.*; | |
import org.bukkit.plugin.Plugin; | |
import org.bukkit.plugin.java.JavaPlugin; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class Main extends JavaPlugin { | |
private static Plugin main; | |
public static Plugin getInstance() { return main; } | |
@Override | |
public void onEnable() { | |
main = this; | |
getConfig().options().copyDefaults(true); | |
saveConfig(); | |
getCommand("channelverse").setExecutor(new ChannelverseCommand()); | |
getServer().getPluginManager().registerEvents(new ChatListener(), this); | |
getServer().getPluginManager().registerEvents(new MenuListener(), this); | |
getServer().getPluginManager().registerEvents(new ChannelHandler(), this); | |
initializeChannels(); | |
ChannelManager.getChannel("Global").addMember("Zyraun"); | |
} | |
@Override | |
public void onDisable() { | |
} | |
public void initializeChannels() { | |
for (String c : getConfig().getConfigurationSection("channelverse.channels").getKeys(false)) { | |
ChatChannel channel = new ChatChannel(c,"channelverse.channels." + c); | |
ChannelManager.registerChannel(channel); | |
} | |
} | |
public static boolean enabled() { | |
return getInstance().getConfig().getBoolean("channelverse.enabled"); | |
} | |
} |
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 me.zyraun.utility.staffchannel.util; | |
import org.bukkit.Color; | |
import org.bukkit.Material; | |
import org.bukkit.enchantments.Enchantment; | |
import org.bukkit.inventory.ItemStack; | |
import org.bukkit.inventory.meta.ItemMeta; | |
import org.bukkit.inventory.meta.LeatherArmorMeta; | |
import org.bukkit.material.MaterialData; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Original plugin creation by Zyraun. | |
* All rights reserved. Last update: May 29th, 2017. | |
*/ | |
public class ItemStackBuilder { | |
private final ItemStack ITEM_STACK; | |
public ItemStackBuilder(Material mat) { | |
ITEM_STACK = new ItemStack(mat); | |
} | |
public ItemStackBuilder(ItemStack item) { | |
ITEM_STACK = item; | |
} | |
public ItemStackBuilder withAmount(int amount) { | |
ITEM_STACK.setAmount(amount); | |
return this; | |
} | |
public ItemStackBuilder withName(String name) { | |
final ItemMeta meta = ITEM_STACK.getItemMeta(); | |
meta.setDisplayName(name); | |
ITEM_STACK.setItemMeta(meta); | |
return this; | |
} | |
public ItemStackBuilder withLore(String name) { | |
final ItemMeta meta = ITEM_STACK.getItemMeta(); | |
List<String> lore = meta.getLore(); | |
if (lore == null) { | |
lore = new ArrayList<>(); | |
} | |
lore.add(name); | |
meta.setLore(lore); | |
ITEM_STACK.setItemMeta(meta); | |
return this; | |
} | |
public ItemStackBuilder withLore(String[] name) { | |
final ItemMeta meta = ITEM_STACK.getItemMeta(); | |
List<String> lore = meta.getLore(); | |
if (lore == null) { | |
lore = new ArrayList<>(); | |
} | |
for (String s : name) | |
lore.add(s); | |
meta.setLore(lore); | |
ITEM_STACK.setItemMeta(meta); | |
return this; | |
} | |
public ItemStackBuilder withDurability(int durability) { | |
ITEM_STACK.setDurability((short) durability); | |
return this; | |
} | |
@SuppressWarnings("deprecation") | |
public ItemStackBuilder withData(int data) { | |
ITEM_STACK.setData(new MaterialData(ITEM_STACK.getType(), (byte) data)); | |
return this; | |
} | |
public ItemStackBuilder withEnchantment(Enchantment enchantment, final int level) { | |
ITEM_STACK.addUnsafeEnchantment(enchantment, level); | |
return this; | |
} | |
public ItemStackBuilder withEnchantment(Enchantment enchantment) { | |
ITEM_STACK.addUnsafeEnchantment(enchantment, 1); | |
return this; | |
} | |
public ItemStackBuilder withType(Material material) { | |
ITEM_STACK.setType(material); | |
return this; | |
} | |
public ItemStackBuilder clearLore() { | |
final ItemMeta meta = ITEM_STACK.getItemMeta(); | |
meta.setLore(new ArrayList<String>()); | |
ITEM_STACK.setItemMeta(meta); | |
return this; | |
} | |
public ItemStackBuilder clearEnchantments() { | |
for (Enchantment enchantment : ITEM_STACK.getEnchantments().keySet()) { | |
ITEM_STACK.removeEnchantment(enchantment); | |
} | |
return this; | |
} | |
public ItemStackBuilder withColor(Color color) { | |
Material type = ITEM_STACK.getType(); | |
if (type == Material.LEATHER_BOOTS || type == Material.LEATHER_CHESTPLATE || type == Material.LEATHER_HELMET | |
|| type == Material.LEATHER_LEGGINGS) { | |
LeatherArmorMeta meta = (LeatherArmorMeta) ITEM_STACK.getItemMeta(); | |
meta.setColor(color); | |
ITEM_STACK.setItemMeta(meta); | |
return this; | |
} else { | |
throw new IllegalArgumentException("withColor is only applicable for leather armor!"); | |
} | |
} | |
public ItemStack build() { | |
return ITEM_STACK; | |
} | |
} |
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 me.zyraun.utility.staffchannel.util; | |
import net.minecraft.server.v1_8_R1.ChatSerializer; | |
import net.minecraft.server.v1_8_R1.PacketPlayOutChat; | |
import org.bukkit.Bukkit; | |
import org.bukkit.ChatColor; | |
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; | |
import org.bukkit.entity.Player; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.regex.Pattern; | |
public class JsonBuilder { | |
public enum ClickAction { | |
RUN_COMMAND, SUGGEST_COMMAND, OPEN_URL | |
} | |
public enum HoverAction { | |
SHOW_TEXT | |
} | |
private List<String> extras = new ArrayList<String>(); | |
public JsonBuilder(String... text) { | |
for (String extra : text) | |
parse(extra); | |
} | |
public JsonBuilder parse(String text) { | |
String regex = "[&�]{1}([a-fA-Fl-oL-O0-9]){1}"; | |
text = text.replaceAll(regex, "�$1"); | |
if (!Pattern.compile(regex).matcher(text).find()) { | |
withText(text); | |
return this; | |
} | |
String[] words = text.split(regex); | |
int index = words[0].length(); | |
for (String word : words) { | |
try { | |
if (index != words[0].length()) | |
withText(word).withColor("�" + text.charAt(index - 1)); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
index += word.length() + 2; | |
} | |
return this; | |
} | |
public JsonBuilder withText(String text) { | |
extras.add("{text:\"" + text + "\"}"); | |
return this; | |
} | |
public JsonBuilder withColor(ChatColor color) { | |
String c = color.name().toLowerCase(); | |
addSegment(color.isColor() ? "color:" + c : c + ":true"); | |
return this; | |
} | |
public JsonBuilder withColor(String color) { | |
while (color.length() != 1) | |
color = color.substring(1).trim(); | |
withColor(ChatColor.getByChar(color)); | |
return this; | |
} | |
public JsonBuilder withClickEvent(ClickAction action, String value) { | |
addSegment("clickEvent:{action:" + action.toString().toLowerCase() + ",value:\"" + value + "\"}"); | |
return this; | |
} | |
public JsonBuilder withHoverEvent(HoverAction action, String value) { | |
addSegment("hoverEvent:{action:" + action.toString().toLowerCase() + ",value:\"" + value + "\"}"); | |
return this; | |
} | |
private void addSegment(String segment) { | |
String lastText = extras.get(extras.size() - 1); | |
lastText = lastText.substring(0, lastText.length() - 1) + "," + segment + "}"; | |
extras.remove(extras.size() - 1); | |
extras.add(lastText); | |
} | |
public String toString() { | |
if (extras.size() <= 1) | |
return extras.size() == 0 ? "{text:\"\"}" : extras.get(0); | |
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",extra:["; | |
extras.remove(0); | |
; | |
for (String extra : extras) | |
text = text + extra + ","; | |
text = text.substring(0, text.length() - 1) + "]}"; | |
return text; | |
} | |
public void sendJson(Player p) { | |
((CraftPlayer) p).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a(toString()))); | |
} | |
public void sendAllJson() { | |
for (Player p : Bukkit.getOnlinePlayers()) | |
sendJson(p); | |
} | |
} |
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
Manifest-Version: 1.0 | |
Main-Class: me.zyraun.utility.staffchannel.Main | |
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: Channelverse | |
version: 1.0 | |
description: Quickly manage multiple chat channels. Advanced, yet simple. | |
author: Zyraun | |
main: me.zyraun.utility.staffchannel.Main | |
commands: | |
channelverse: | |
description: Core command for Channelverse plugin. | |
aliases: [cv, channel, cverse, channelv, channels, chanverse] |
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="library" name="spigot" level="project" /> | |
</component> | |
</module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment