Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Thedarklord197.RelaxedChat;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.entity.Player;
- public class ChannelManager {
- public Map<Player, Channel> channel = new HashMap<Player, Channel>();
- public List<Channel> channels = new ArrayList<Channel>();
- public FileConfiguration config = Main.getInstance().getConfig();
- public static ChannelManager cdm;
- public static ChannelManager getManager() {
- if (cdm == null) {
- cdm = new ChannelManager();
- }
- return cdm;
- }
- public void loadChannels() {
- for (String s : config.getConfigurationSection("channels.defined-channels").getKeys(false)) {
- String p = config.getString("channels.defined-channels." + s + ".permission");
- String f = config.getString("channels.defined-channels." + s + ".format");
- System.out.println("DEBUG: " + s); // DEBUG Returns channel name: "Global" (OK)
- createChannel(s, p, f);
- }
- }
- public Channel getChannel(String name) {
- for (Channel c : channels) {
- if (c.getName() == name) return c;
- }
- return null;
- }
- public void createChannel(String name, String permission, String format) {
- Channel c = new Channel(name, permission, format);
- channels.add(c);
- System.out.println("Channel name: " + c.getName()); // DEBUG NullPointerException/Null?
- }
- public Channel getChannel(Player player) {
- for (Channel c : channels) {
- if (c.players.contains(player)) return c;
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement