I'm making a plugin. 1.I want to read the config of other plugin.Like read groupmanager's config. 2.how can my plugin get server's world level name? Thanks.(Smile)
Google is your friend: 1 2 3 Not here to spoonfeed when there are a multitude of threads online. Code (Text): List<World> worlds = Bukkit.getWorlds(); String world = worlds.get(0).getName(); //Overworld String nether = worlds.get(1).getName(); String end = worlds.get(2).getName(); Found online, haven't checked if it works but try it, as you have not shown any effort or attempts you've made so far (not saying you haven't tried, you just haven't shown you've tried).
In your class where you need it enter: Code (Java): File file = new File(getDataFolder().getDataFolder().toString().replace("ENTER YOUR FOLDER ex. AuthMe", ""); FileConfiguration config = YamlConfiguration.loadConfiguration(file);
I have another problem. I have the player's name such as Bob, I want to check does Bob have permission 'perm.perm'. How can i do it?
Bukkit.getPlayer("Bob").hasPermission("perm.perm") if the player is online it's gonna return null though
[13:26:34 WARN]: Exception in thread "Timer-5" [13:26:34 WARN]: java.lang.NullPointerException [13:26:34 WARN]: at cn.sharkmc.GUI.PlayerRanks$1.run(PlayerRanks.java:42) [13:26:34 WARN]: at java.util.TimerThread.mainLoop(Unknown Source) [13:26:34 WARN]: at java.util.TimerThread.run(Unknown Source) for(String player : Main.cfgm.getPlayers().getConfigurationSection("Players").getKeys(false)) { List list = new ArrayList(Main.cfgm.getPlayers().getConfigurationSection("Players." + player + ".ranks").getKeys(false)); for(int i = list.size() - 1;i >= 0;i--) { if(!Main.cfgm.getPlayers().getString("Players." + player + ".ranks." + list.get(i)).equals("expired")) { if(!Bukkit.getPlayer("Bob").hasPermission("perm.admin")) { Bukkit.getConsoleSender().sendMessage(Utils.Chat("noooooo")); } //System.out.println(list.get(i)); } } } I'm making a storage that save player name, and i want to check the player has permission "perm.admin".
if(!Bukkit.getPlayer("Bob").hasPermission("perm.admin")) { The player is not online I made a timer task to check the permission
You shouldn't make a compound statement when the secondary operation hangs off something that could be invalid. If "Bob" isn't online, the return from getPlayer will be null and when you try to hasPermission on that, the plugin pukes.
How can i make this??? permissions: - bw.cmd - bw.setup - bw.vip - cjm.basic - essentials,ban - essentials.ban - essentials.ban.* - essentials.ban.notify - essentials.ban.others