You are not logged in.

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

xSeroCraftx

User / Kunde

  • "xSeroCraftx" started this thread

Posts: 3

  • Send private message

1

Sunday, June 25th 2017, 9:54pm

Unbekannter Fehler (Is It Up To Date?) = SkyWars Plugin

MAINKLASSE:


package me.devfx.main;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import me.devfx.commands.CMDsetspawn;
import me.devfx.commands.CMDstart;
import me.devfx.gamestates.GameState;
import me.devfx.gamestates.GameStateHandler;
import me.devfx.listener.EVENTjoin;
import me.devfx.listener.EVENTquit;
import me.devfx.methods.Var;
import me.devfx.methods.chest.ChestHandler;
import me.devfx.methods.chest.ChestItem;

public class Main extends JavaPlugin {

private static Main plugin;
private ChestHandler chestHandler;

public void onEnable(){
plugin = this;
new GameStateHandler();
GameStateHandler.setGameState(GameState.LOBBY_STATE);
init();
Bukkit.getConsoleSender().sendMessage(Var.pr + "§bCoded by Rummeln.");
}

private void init() {

loadChestHandler();

this.getCommand("start").setExecutor(new CMDstart());
this.getCommand("setspawn").setExecutor(new CMDsetspawn());

PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new EVENTjoin(), this);
pm.registerEvents(new EVENTquit(), this);

}

private void loadChestHandler(){
File file = new File(getDataFolder(), "items.yml");
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);

ArrayList<String> defaults = new ArrayList<>();
//ID:-SUBID-MIN-MAX-PROBABILITY
defaults.add("1-10-25");
defaults.add("18:3-5-10-10");

cfg.addDefault("Sachen", defaults);
cfg.options().copyDefaults(true);
try {
cfg.save(file);
} catch (IOException e) {
e.printStackTrace();
}

ArrayList<ChestItem> chestItems = new ArrayList<>();
ArrayList<String> items = (ArrayList<String>) cfg.getStringList("Sachen");
for(String item : items) {
String[] split = item.split("-");
String[] subid = split[0].split(":");
ItemStack itemStack = null;

int id = Integer.parseInt(subid[0]);
if(subid.length > 1){
short subID = (short) Integer.parseInt(subid[1]);
itemStack = new ItemStack(id, 0, subID);
} else {
itemStack = new ItemStack(id);
}
int min = Integer.parseInt(split[1]);
int max = Integer.parseInt(split[2]);
int prop = Integer.parseInt(split[3]);
chestItems.add(new ChestItem(itemStack, min, max, prop));
chestHandler = new ChestHandler(3, 7, chestItems);
}
}


public static Main getPlugin(){
return plugin;
}

}



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


FEHLERCODE:


[21:45:20] [Server thread/INFO]: [SkyWars] Loading SkyWars v1.2
[21:45:20] [Server thread/INFO]: [WorldEdit] Loading WorldEdit v6.1.7;dd00bb1
[21:45:20] [Server thread/INFO]: [Multiverse-Core] Loading Multiverse-Core v2.5.0-b727
[21:45:20] [Server thread/INFO]: [SkyWars] Enabling SkyWars v1.2
[21:45:20] [Server thread/ERROR]: Error occurred while enabling SkyWars v1.2 (Is it up to date?)
java.lang.ArrayIndexOutOfBoundsException: 3
at me.devfx.main.Main.loadChestHandler(Main.java:82) ~[?:?]
at me.devfx.main.Main.init(Main.java:38) ~[?:?]
at me.devfx.main.Main.onEnable(Main.java:32) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
[21:45:20] [Server thread/INFO]: [WorldEdit] Enabling WorldEdit v6.1.7;dd00bb1

BtoBastian

Moderator

  • "BtoBastian" is male

Posts: 3,612

Occupation: Softwareentwickler

  • Send private message

2

Monday, June 26th 2017, 6:48am


Empfohlene Lektüre: [Sonstiges] Leitfaden: Wie wird mir am schnellsten geholfen?
Standard Standart eines Flamingos ist einbeinig.

BlvckBytes

User / Kunde

  • "BlvckBytes" is male

Posts: 797

Location: (*blvckbytes).home

Occupation: Schüler -> HTL für Informationstechnologie und Netzwerktechnik

  • Send private message

3

Monday, June 26th 2017, 1:23pm

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[21:45:20] [Server thread/ERROR]: Error occurred while enabling SkyWars v1.2 (Is it up to date?)
------> java.lang.ArrayIndexOutOfBoundsException <------ : 3
at me.devfx.main.Main.loadChestHandler(Main.java:82) ~[?:?]
at me.devfx.main.Main.init(Main.java:38) ~[?:?]
at me.devfx.main.Main.onEnable(Main.java:32) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]


Das ist ja nicht der Fehler, der Fehler hat immer "Exception" drinnen, somit ist es die "ArrayIndexOutOfBoundsException", das bedeutet dass der Index vom Array nicht vorhanden ist.

LG BlvckBytes

Stuppsman

User / Kunde

Posts: 2,766

Thanks: 25

  • Send private message

4

Wednesday, June 28th 2017, 12:25am

Indizes fangen bei 0 an zu zählen, das wirst du bei dem Split ändern müssen.
Nein, ich hab kein Skype.. bei Interesse an einer privaten Unterrichtsstunde, wende dich bitte direkt an mein Team! 8)

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