You are not logged in.

  • Login

[Bukkit-Plugin] Hilfe beim einen ClanSystem

Bitte besucht unser neues Forum unter https://forum.nitrado.net | Please visit our new Forum at https://forum.nitrado.net

SkillCraftHD

User / Kunde

  • "SkillCraftHD" is male
  • "SkillCraftHD" started this thread

Posts: 22

Location: 127.0.0.1

Occupation: Developer

  • Send private message

1

Wednesday, November 18th 2015, 4:59pm

Hilfe beim einen ClanSystem

Guten Tag,

ich habe ein Problem wo ich jetzt schon 7 Tage aufgehalten werde. :thinking:
Was ist das Problem?

Beim Programmieren eines ClanSystems gibt er mir immer Fehler aus.


Code:

Spoiler Spoiler



  1. package clan;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandExecutor;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.configuration.file.FileConfiguration;
  8. import org.bukkit.configuration.file.YamlConfiguration;
  9. import org.bukkit.entity.Player;
  10. import pvp.pmain;
  11. public class clancmd implements CommandExecutor {
  12. private pmain plugin;
  13. public clancmd(pmain plugin) {
  14. this.plugin = plugin;
  15. }
  16. @Override
  17. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  18. if((sender instanceof Player)) {
  19. Player p = (Player)sender;
  20. String cp = "§8[§6Clans§8]§7 ";
  21. if(args.length == 0) {
  22. p.sendMessage("§8§m----------§r§8[§6CLANS§8]§8§m----------§r§8");
  23. //p.sendMessage("§cClans sind derzeit deaktiviert!");
  24. p.sendMessage("§7/" + label + " create §e<Clanname> §7Erstellt einen neuen Clan");
  25. p.sendMessage("§7/" + label + " §edelete §7Löscht deinen Clan");
  26. p.sendMessage("§7/" + label + " join §e<Clanname> §7Trete einen Clan bei");
  27. p.sendMessage("§7/" + label + " §eleave §7Verlasse deinen Clan");
  28. //p.sendMessage("§7/" + label + " chat §e<Nachricht> §7Schreibe deinen Clan eine Nachricht");
  29. p.sendMessage("§8§m----------------------------"); // --- = 26
  30. } else if(args[0].equalsIgnoreCase("create")) {
  31. if(args[1].length() <= 8) {
  32. File file = new File("plugins/SkillCrackPVP/", "clans.yml");
  33. FileConfiguration clancfg = YamlConfiguration.loadConfiguration(file);
  34. File file1 = new File("plugins/SkillCrackPVP/", "players.yml");
  35. FileConfiguration playercfg = YamlConfiguration.loadConfiguration(file1);
  36. if(playercfg.getString(p.getName() + ".clan").length() == 0) {
  37. if(clancfg.get(args[1]) == null) {
  38. clancfg.set(args[1] + ".name", args[1]);
  39. clancfg.set(args[1] + ".owner", p.getName());
  40. clancfg.set(args[1] + ".member", "");
  41. p.sendMessage(cp + "Der Clan §e" + args[1] + "§7 wurde erstellt!");
  42. playercfg.set(p.getName() + ".clan", args[1]);
  43. try {
  44. clancfg.save(file);
  45. } catch (IOException e) {
  46. e.printStackTrace();
  47. }
  48. try {
  49. playercfg.save(file1);
  50. } catch (IOException e) {
  51. e.printStackTrace();
  52. }
  53. } else {
  54. p.sendMessage(cp + "Dieser Clan existiert bereits!");
  55. }
  56. } else {
  57. p.sendMessage(cp + "Du musst deinen jetztigen Clan erst verlassen bevor du einen neuen Clan erstellen kannst!");
  58. }
  59. } else {
  60. p.sendMessage(cp + "Der Clan-Name ist zu lang!");
  61. }
  62. } else if(args[0].equalsIgnoreCase("leave")) {
  63. File file = new File("plugins/SkillCrackPVP/", "clans.yml");
  64. FileConfiguration clancfg = YamlConfiguration.loadConfiguration(file);
  65. File file1 = new File("plugins/SkillCrackPVP/", "players.yml");
  66. FileConfiguration playercfg = YamlConfiguration.loadConfiguration(file1);
  67. if(playercfg.getString(p.getName() + ".clan").isEmpty() == false) {
  68. String pc = playercfg.getString(p.getName() + ".clan");
  69. if(clancfg.getString(pc + ".owner").equalsIgnoreCase(p.getName())) {
  70. p.performCommand("clan delete");
  71. }
  72. p.sendMessage(cp + "Du hast den Clan §e" + playercfg.getString(p.getName() + ".clan") + "§7 verlassen!");
  73. playercfg.set(p.getName() + ".clan", "");
  74. try {
  75. playercfg.save(file1);
  76. } catch (IOException e) {
  77. e.printStackTrace();
  78. }
  79. } else {
  80. p.sendMessage(cp + "Du bist in keinen Clan!");
  81. }
  82. } else if(args[0].equalsIgnoreCase("delete")) {
  83. File file = new File("plugins/SkillCrackPVP/", "clans.yml");
  84. FileConfiguration clancfg = YamlConfiguration.loadConfiguration(file);
  85. File file1 = new File("plugins/SkillCrackPVP/", "players.yml");
  86. FileConfiguration playercfg = YamlConfiguration.loadConfiguration(file1);
  87. if(playercfg.getString(p.getName() + ".clan").isEmpty() == false) {
  88. String clan = playercfg.getString(p.getName() + ".clan");
  89. if(clancfg.getString(clan + ".owner").equalsIgnoreCase(p.getName())) {
  90. clancfg.set(clan, null);
  91. p.sendMessage(cp + "Dein Clan wurde gelöscht!");
  92. try {
  93. clancfg.save(file1);
  94. } catch (IOException e) {
  95. e.printStackTrace();
  96. }
  97. }
  98. } else {
  99. p.sendMessage(cp + "Du bist in keinen Clan!");
  100. }
  101. } else if(args[0].equalsIgnoreCase("join")) {
  102. File file = new File("plugins/SkillCrackPVP/", "clans.yml");
  103. FileConfiguration clancfg = YamlConfiguration.loadConfiguration(file);
  104. File file1 = new File("plugins/SkillCrackPVP/", "players.yml");
  105. FileConfiguration playercfg = YamlConfiguration.loadConfiguration(file1);
  106. if(playercfg.getString(p.getName() + ".clan").isEmpty() == true) {
  107. if(args[1].length() != 0) {
  108. if(clancfg.get(args[1]) == null) {
  109. p.sendMessage(cp + "Dieser Clan existiert nicht!");
  110. } else {
  111. playercfg.set(p.getName() + ".clan", args[1]);
  112. }
  113. } else {
  114. p.sendMessage(cp + "Du musst einen Clan-Namen eingeben!");
  115. }
  116. } else {
  117. p.sendMessage(cp + "Du musst deinen Clan erst verlassen bevor du einen anderen Clan beitreten kannst!");
  118. }
  119. }
  120. } else {
  121. sender.sendMessage("§cOnly player command.");
  122. }
  123. return true;
  124. }
  125. }




Error


Spoiler Spoiler



  1. [16:49:09] [Server thread/INFO]: SkillCraftHD issued server command: /clan create Test
  2. [16:49:09] [Server thread/ERROR]: null
  3. org.bukkit.command.CommandException: Unhandled exception executing command 'clan' in plugin SkillCrackPVP v1.0
  4. at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  5. at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  6. at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:642) ~[minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  7. at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1135) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  8. at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:970) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  9. at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  10. at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  11. at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  12. at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_79]
  13. at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_79]
  14. at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:19) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  15. at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:718) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  16. at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:367) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  17. at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:657) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  18. at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:560) [minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  19. at java.lang.Thread.run(Thread.java:745) [?:1.7.0_79]
  20. Caused by: java.lang.NullPointerException
  21. at clan.clancmd.onCommand(clancmd.java:51) ~[?:?]
  22. at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[minecraft_server.jar:git-Spigot-f928e7a-e91aed8]
  23. ... 15 more




Minecraft-Version: 1.8 (1.8.7)

Arbeitsspeicher/RAM: 2 GB (von 32GB)

installierte Plugins:
SkillCrackPVP (mein Plugin)
SkillCrackNameTagsFix(mein Plugin)
TitanPVP (mein Plugin)
WorldEdit
Worldguard
Vault
1.8Tags
OnlyProxyJoin
ColoredSigns
PermissionsEx
HolographicDisplays
ClearLag
LWC
Warp
VoxelSniper



-------------------------------------------------------------------------------------------------


Bitte um schnelle Antwort!
MFG Til

This post has been edited 14 times, last edit by "SkillCraftHD" (Nov 26th 2015, 9:14pm)


Gebauer_01

User / Kunde

Posts: 2,304

  • Send private message

2

Wednesday, November 18th 2015, 5:08pm

Bitte versuche, dass die Formatierung deiner Spoiler korrekt ist.

SkillCraftHD

User / Kunde

  • "SkillCraftHD" is male
  • "SkillCraftHD" started this thread

Posts: 22

Location: 127.0.0.1

Occupation: Developer

  • Send private message

3

Wednesday, November 18th 2015, 5:30pm

Format geändert.

Format geändert.
MFG Til

SirSwagon

User / Kunde

  • "SirSwagon" is male

Posts: 21

  • Send private message

4

Wednesday, November 18th 2015, 6:24pm

Der Fehler ist folgender:
Du musst beim clan erstellen Teil
NICHT:

Source code

1
if(clancfg.get(args[1]) == null)

schreiben, sondern:

Source code

1
if(!clancfg.contains(args[1]))

Ich hoffe ich konnte dir helfen ;)

SkillCraftHD

User / Kunde

  • "SkillCraftHD" is male
  • "SkillCraftHD" started this thread

Posts: 22

Location: 127.0.0.1

Occupation: Developer

  • Send private message

5

Wednesday, November 18th 2015, 7:22pm

Danke für deine Hilfe! Leider funktioniert es nicht!
MFG Til

KingFabi2805

User / Kunde

Posts: 53

  • Send private message

6

Wednesday, November 18th 2015, 7:36pm

Schau dir doch mal den Code von z.B GermanClans an, so mache ich es immer wenn ich nicht weiter weiß



Und warum schreibst du alles in einer klasse

SkillCraftHD

User / Kunde

  • "SkillCraftHD" is male
  • "SkillCraftHD" started this thread

Posts: 22

Location: 127.0.0.1

Occupation: Developer

  • Send private message

7

Wednesday, November 18th 2015, 7:38pm

Das ist nur die Command Klasse, ich habe noch andere Klassen! Und ich schau mir jetzt mal das Plugin GermanClans an! :)
MFG Til

Bitte besucht unser neues Forum unter https://forum.nitrado.net| Please visit our new Forum at https://forum.nitrado.net