Gå til innhold

Minecraft - PvpSystem plugin problemer


Anbefalte innlegg

Ingenting vil funke uten om /pvp som gir deg hjelpemenyen.

Er ikke sikker hva som er feil.

 

 

package no.Mikael;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.java.JavaPlugin;
public class Arena extends JavaPlugin implements CommandExecutor, Listener{
public PvP plugin;
public Arena(PvP pl) {
 plugin=pl;
 }
public Arena() {
 // TODO Auto-generated constructor stub
}
@SuppressWarnings("unchecked")
public boolean onCommand(CommandSender Sender, Command command, String commandLabel, String[] args){
 if(Sender instanceof Player){
}
 Player p = (Player) Sender;
  if(command.getName().equalsIgnoreCase("pvp")){
if(args.length==0){
 p.sendMessage(ChatColor.GREEN + "========== PvP-arena system v1.2 ==========");
 p.sendMessage(ChatColor.GREEN + "= "+ ChatColor.DARK_RED +"/"+ ChatColor.RED +"pvp join "+ ChatColor.BLUE +"-"+ ChatColor.YELLOW +" Telporterer deg til lobbyen" + ChatColor.GREEN + " =");
 p.sendMessage(ChatColor.GREEN + "= "+ ChatColor.DARK_RED +"/"+ ChatColor.RED +"pvp setlobby "+ ChatColor.BLUE +"-"+ ChatColor.YELLOW +" setter lobby punktet"+ ChatColor.GREEN +"	=");
 p.sendMessage(ChatColor.GREEN + "= "+ ChatColor.DARK_RED +"/"+ ChatColor.RED +"pvp "+ ChatColor.BLUE +"-"+ ChatColor.YELLOW +" gir deg hjelpemenyen"+ ChatColor.GREEN +"			 =");
 p.sendMessage(ChatColor.GREEN + "= "+ ChatColor.DARK_RED +"/"+ ChatColor.RED +"pvp leavearenanow "+ ChatColor.BLUE +"-"+ ChatColor.YELLOW +" Forlater arenaen"+ ChatColor.GREEN +"   =");
 p.sendMessage(ChatColor.GREEN + "===========================================");
}
 if (args[0].equalsIgnoreCase("setlobby")){
  if (p.isOp());
  plugin.getConfig().set("lobby.x", p.getLocation().getBlockX());
  plugin.getConfig().set("lobby.y", p.getLocation().getBlockY());
  plugin.getConfig().set("lobby.z", p.getLocation().getBlockZ());
  plugin.saveConfig();
  p.sendMessage(ChatColor.GREEN + "Satte posisjon for lobby");
  return true;
  }else{
   p.sendMessage(ChatColor.RED + "Du har ikke tilatelse til denne kommandoen!");
  }
  if (args[0].equalsIgnoreCase("join")){
  int x = plugin.getConfig().getInt("lobby.x");
  int y = plugin.getConfig().getInt("lobby.y");
  int z = plugin.getConfig().getInt("lobby.z");
  p.sendMessage(ChatColor.GREEN + "Hopp på en preassure plate for å komme til pvp-arenaen");
		   ItemStack itemstack1 = new ItemStack(Material.STONE_SWORD, 1);
		   p.getInventory().addItem(new ItemStack(Material.BOW, 1));
		   ItemStack itemstack2 = new ItemStack(Material.ARROW, 1);
		   PlayerInventory inv = p.getInventory();
		   inv.addItem(new ItemStack[] { itemstack1 });
		   inv.addItem(new ItemStack[] { itemstack2 });
  p.teleport(new Location(p.getWorld(), x,y,z),TeleportCause.PLUGIN);
		   ItemStack itemstackH = new ItemStack(Material.IRON_HELMET, 1);
		   ItemStack itemstackC = new ItemStack(Material.IRON_CHESTPLATE, 1);
		   ItemStack itemstackL = new ItemStack(Material.IRON_LEGGINGS, 1);
		   ItemStack itemstackB = new ItemStack(Material.IRON_BOOTS, 1);
  p.getInventory().setBoots(itemstackB);
  p.getInventory().setLeggings(itemstackL);
  p.getInventory().setChestplate(itemstackC);
  p.getInventory().setHelmet(itemstackH);
  ItemStack b = p.getInventory().getItem(inv.first(Material.BOW));
  b.addEnchantments((Map<Enchantment, Integer>) Enchantment.ARROW_INFINITE);
  return true;
 }else if (args[0].equalsIgnoreCase("leavearenanow")){
  p.getInventory().clear();
  p.teleport(p.getWorld().getSpawnLocation());
  p.sendMessage(ChatColor.GREEN + "Du forlot arenaen!");
  p.setHealth(20);
 }
}
  return false;
}
}

Error melding

12:01:13 [sEVERE] null

org.bukkit.command.CommandException: Unhandled exception executing command 'pvp' in p

lugin PvPSystem v1.2

at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)

at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:189)

at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServer.jav

a:523)

at net.minecraft.server.v1_6_R2.PlayerConnection.handleCommand(PlayerConnecti

on.java:964)

at net.minecraft.server.v1_6_R2.PlayerConnection.chat(PlayerConnection.java:8

82)

at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java:839)

at net.minecraft.server.v1_6_R2.Packet3Chat.handle(SourceFile:49)

at net.minecraft.server.v1_6_R2.NetworkManager.b(NetworkManager.java:296)

at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java:118)

at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37)

at net.minecraft.server.v1_6_R2.DedicatedServerConnection.b(SourceFile:30)

at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:590)

at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)

at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)

at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)

at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)

Caused by: java.lang.ArrayIndexOutOfBoundsException: 0

at no.Mikael.Arena.onCommand(Arena.java:44)

at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)

... 15 more

Lenke til kommentar
Videoannonse
Annonse

Caused by: java.lang.ArrayIndexOutOfBoundsException: 0

at no.Mikael.Arena.onCommand(Arena.java:44)

 

Testen

if (args[0].equalsIgnoreCase("setlobby")){ 

feiler fordi args-arrayet ikke er så langt (dvs det er tomt). Du sjekker om args.length == 0 litt lengre oppe, men har ingen else rundt koden som baserer seg på at args[0] finnes.

 

(Du bør også sjekke om args[0] er null eller ha teksten først og variabelen sist i equals testene)

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...