ci_nna_mon f2bbf9ad1508452aa937ff2c1988b4be
게임버전 (JE) | 1.12.2 |
---|---|
게임버전 (BE) | 관련없음 |
Main.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | package plugin; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; import config.DataManager; public class Main extends JavaPlugin implements Listener { @Override public void onEnable() { System.out.println(ChatColor.YELLOW+"[ "+ChatColor.AQUA+"KMCS" +ChatColor.YELLOW+" ] " +"플러그인이 활성화되었습니다."); getConfig().options().copyDefaults(); DataManager.setup(); DataManager.get().addDefault("reloaddefault", "all"); DataManager.get().options().copyDefaults(true); DataManager.save(); } public void onDisable() { System.out.println(ChatColor.YELLOW+"[ "+ChatColor.AQUA+"KMCS" +ChatColor.YELLOW+" ] " +"플러그인이 비활성화되었습니다."); } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (label.equalsIgnoreCase("kmcs")) { Player player = (Player) sender; if (args.length == 0) { player.sendMessage(ChatColor.GOLD+"/kmcs help"+ChatColor.WHITE+": 도움말\n" +ChatColor.GOLD+"/kmcs reload (all/script/config)"+ChatColor.WHITE+": 스크립트 리로드(형식을 입력하지 않을시 기본적으로 모두 리로드됨)\n" + ChatColor.GOLD+"/kmcs version"+ChatColor.WHITE+": kmcs 플러그인 버전을 확인합니다."); } else if (args[0].equalsIgnoreCase("help")) { player.sendMessage(ChatColor.GOLD+"/kmcs help"+ChatColor.WHITE+": 도움말\n" +ChatColor.GOLD+"/kmcs reload (all/script/config)"+ChatColor.WHITE+": 스크립트 리로드(형식을 입력하지 않을시 기본적으로 모두 리로드됨)\n" + ChatColor.GOLD+"/kmcs version"+ChatColor.WHITE+": kmcs 플러그인 버전을 확인합니다."); } else if (args[0].equalsIgnoreCase("reload")) { if (args.length == 0) { player.sendMessage("모두 리로드!"); } else if (args[1].equalsIgnoreCase("all")) { player.sendMessage("모두 리로드!"); } else if (args[1].equalsIgnoreCase("script")) { player.sendMessage("스크립트 리로드!"); } else if (args[1].equalsIgnoreCase("config")) { player.sendMessage("콘피그 파일 리로드!"); } else { player.sendMessage(ChatColor.GOLD+"/kmcs reload (all/script/config)"); } } else if (args[0].equalsIgnoreCase("version")) { player.sendMessage("플러그인 버전:1.0\n마인크래프트 버전:1.12.2"); } } return true; } } | cs |
DataManager.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | package config; import java.io.File; import java.io.IOException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; public class DataManager { private static File file; private static FileConfiguration customFile; public static void setup() { file = new File(Bukkit.getServer().getPluginManager().getPlugin("config").getDataFolder(), "config.yml"); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { //none } } customFile = YamlConfiguration.loadConfiguration(file); } public static FileConfiguration get(){ return customFile; } public static void save() { try { customFile.save(file); } catch (IOException e) { System.out.println("Couldn't save file"); } } public static void reload() { customFile = YamlConfiguration.loadConfiguration(file); } } | cs |
plugin.yml
name: KMCS
version: 1.0
main: plugin.Main
commands:
kmcs:
description: "command about kmcs plugin"
오류
[15:39:25] [Server thread/ERROR]: Error occurred while enabling KMCS v1.0 (Is it up to date?)
java.lang.NullPointerException: null
at config.DataManager.setup(DataManager.java:16) ~[?:?]
at plugin.Main.onEnable(Main.java:18) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337)
[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403)
[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381)
[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330)
[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422)
[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383)
[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338)
[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272)
[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545)
[spigot.jar:git-Spigot-dcd1643-e60fc34]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_311]
어떻게 해결하나요?
허두
2021.11.22DataManager.setup() 16번째 줄의 getPlugin("config")를 getPlugin("KMCS")로 바꿔보시겠어요?