개인 자료란 (JE)

  서버 커뮤니티

Profile 시_나_몬 대표칭호 없음

ci_nna_mon f2bbf9ad1508452aa937ff2c1988b4be

Profile

질문하기 플러그인

마인크래프트 플러그인 오류

2021.11.22 조회 수 274 추천 수 0
게임버전 (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]

어떻게 해결하나요?

1개의 댓글

허두
2021.11.22

DataManager.setup() 16번째 줄의 getPlugin("config")를 getPlugin("KMCS")로 바꿔보시겠어요?

뉴스 및 창작물
/files/thumbnails/115/774/003/262x150.crop.jpg?20240424234825

업데이트

마인크래프트 1.20.5 정식 업데이트

학교가기싫다

2024-04-24

0

/files/thumbnails/762/770/003/262x150.crop.jpg?20240418073724

레드스톤

T.B.H (고민중독) | 노트블럭 버전 | NoteBlock Cover [한국어 영어 중국어 가사 추가]

노트블럭전문가

2024-04-18

0

/files/thumbnails/218/767/003/262x150.crop.jpg?20240412130213

레드스톤

우리의 꿈 - 원피스 오프닝

노트블럭전문가

2024-04-12

0

/files/thumbnails/505/766/003/262x150.crop.jpg?20240411122306

레드스톤

기동전사 건담 수성의 마녀 | 노트블럭 커버 1

노트블럭전문가

2024-04-11

1

/files/thumbnails/932/765/003/262x150.crop.jpg?20240410124459

레드스톤

마인크래프트 노트블록으로 만든 『 밤양갱 (Bam Yang Gang) 』

노트블럭전문가

2024-04-10

0