mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
Finish mcMMO addon
This commit is contained in:
1 parent
f54a71a25b
commit
0bb3c5b232
5 files changed
+75
-51
No files matched your search
@@ -5,14 +5,15 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import net.draycia.simplechat.SimpleChat;
|
||||
import net.draycia.simplechat.channels.impls.SimpleChatChannel;
|
||||
import net.draycia.simplechat.storage.ChatUser;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PartyChatChannel extends SimpleChatChannel implements Listener {
|
||||
|
||||
public PartyChatChannel(String name, SimpleChat simpleChat) {
|
||||
super(name, simpleChat);
|
||||
public PartyChatChannel(String name, SimpleChat simpleChat, ConfigurationSection config) {
|
||||
super(name, simpleChat, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,25 +1,44 @@
|
||||
package net.draycia.simplechatmcmmo;
|
||||
|
||||
import net.draycia.simplechat.events.ChannelRegisterEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import net.draycia.simplechat.SimpleChat;
|
||||
import net.draycia.simplechat.channels.ChatChannel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class SimpleChatMCMMO extends JavaPlugin {
|
||||
|
||||
private SimpleChat simpleChat;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
simpleChat = (SimpleChat) Bukkit.getPluginManager().getPlugin("SimpleChat");
|
||||
|
||||
for (String key : getConfig().getConfigurationSection("channels").getKeys(false)) {
|
||||
ConfigurationSection section = getConfig().getConfigurationSection("channels").getConfigurationSection(key);
|
||||
|
||||
ChatChannel channel = loadChannel(key, section);
|
||||
|
||||
if (channel != null) {
|
||||
if (simpleChat.getChannelManager().registerChannel(channel)) {
|
||||
getLogger().info("Registering channel: " + channel.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
}
|
||||
public ChatChannel loadChannel(String key, ConfigurationSection section) {
|
||||
ChatChannel channel = new PartyChatChannel(key, simpleChat, section);
|
||||
|
||||
@EventHandler
|
||||
public void onChannelRegister(ChannelRegisterEvent event) {
|
||||
String name = section.getString("name");
|
||||
|
||||
if (name != null && name.length() > 16) {
|
||||
getLogger().warning("Channel name [" + name + "] too long! Max length: 16.");
|
||||
getLogger().warning("Skipping channel, please check your settings!");
|
||||
return null;
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
channels:
|
||||
Reference in new issue
Block a user