Teleportation bug

Discussion in 'Plugin Help/Development/Requests' started by Zankz, Dec 11, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Zankz

    So i am making a CTF minigame and when ever i run this code:
    Code:
        if(cmd.getName().equalsIgnoreCase("ctf-start") && sender instanceof Player){
                Player player = (Player) sender;
                if(player.isOp()){
               
                countdown();
                    return true;
                }
                }
    
                public void countdown(){
                  if(gamestate == false){
                      for(Player nextp : Bukkit.getServer().getOnlinePlayers()){
                            if(nextplayertored == true)
                            {
                                nextp.teleport(new Location(Bukkit.getWorld("world"),-31,51,25));
                                nextplayertored = false;
                                giveitems(nextp,true);
                                nextp.sendMessage(ChatColor.RED + "You are on RED!");
                            }else{
                                nextp.teleport(new Location(Bukkit.getWorld("world"),31,51,25));
                                nextplayertored = true;
                                giveitems(nextp,false);
                                nextp.sendMessage(ChatColor.GREEN + "You are on GREEN!");
                            }
                        }
                       Bukkit.broadcastMessage(ChatColor.GREEN + "The game has started!");
                       gamestate = true;
                  }
    }
            
             public void giveitems(Player p,boolean isred)
             {
                 clearInv(p);
                 //Sword
                 ItemStack sword = new ItemStack(Material.STONE_SWORD);
                    sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
                    sword.addEnchantment(Enchantment.DURABILITY, 10);
                    ItemMeta swordmeta = sword.getItemMeta();
                    swordmeta.setLore(Arrays.asList("Use this sword to hit people","- Zankz"));
                    sword.setItemMeta(swordmeta);
                    p.getInventory().addItem(sword);
                   
                    //Bow
                    ItemStack bow = new ItemStack(Material.BOW);
                    bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5);
                    bow.addEnchantment(Enchantment.DURABILITY, 10);
                    bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
                    ItemMeta bowmeta = sword.getItemMeta();
                    bowmeta.setLore(Arrays.asList("Use this bow to shoot people","- Zankz"));
                    bow.setItemMeta(bowmeta);
                    p.getInventory().addItem(sword);
                   
                  //Grabber
                    ItemStack hoe = new ItemStack(Material.STONE_HOE);
                    ItemMeta hoemeta = sword.getItemMeta();
                    hoemeta.setLore(Arrays.asList("Use this grabber to grab the other teams flag","- Zankz"));
                    hoe.setItemMeta(hoemeta);
                    p.getInventory().addItem(hoe);
                   
                    //Arrow
                    ItemStack arrow = new ItemStack(Material.ARROW);
                    p.getInventory().addItem(arrow);
             }
            
             public static void clearInv(Player p)
                {
                for(int j=0; j<38; j++)
                {
                p.getInventory().setItem(j, null);
                }
                p.getInventory().setHelmet(null);
                p.getInventory().setChestplate(null);
                p.getInventory().setLeggings(null);
                p.getInventory().setBoots(null);
                }
             }
    
    I get teleported but then the server says "An internal error occured" in chat and this is my log:
    Code:
    [15:58:10] [Server thread/INFO]: Starting minecraft server version 1.7.10
    [15:58:10] [Server thread/WARN]: To start the server with more ram, launch it as "java -Xmx1024M -Xms1024M -jar minecraft_server.jar"
    [15:58:10] [Server thread/INFO]: Loading properties
    [15:58:10] [Server thread/INFO]: Default game type: SURVIVAL
    [15:58:11] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-1642 (MC: 1.7.10) (Implementing API version 1.7.10-R0.1-SNAPSHOT)
    [15:58:11] [Server thread/INFO]: Debug logging is disabled
    [15:58:11] [Server thread/INFO]: Server Ping Player Sample Count: 12
    [15:58:11] [Server thread/INFO]: Using 4 threads for Netty based IO
    [15:58:11] [Server thread/INFO]: Generating keypair
    [15:58:11] [Server thread/INFO]: Starting Minecraft server on *:25565
    [15:58:12] [Server thread/WARN]: Plugin `Join_Lock v1.0' uses the space-character (0x20) in its name `Join Lock' - this is discouraged
    [15:58:12] [Server thread/WARN]: Plugin `World_Portal v0.2.7.1' uses the space-character (0x20) in its name `World Portal' - this is discouraged
    [15:58:12] [Server thread/INFO]: Set PluginClassLoader as parallel capable
    [15:58:12] [Server thread/INFO]: [CTFBridge] Loading CTFBridge v1.0
    [15:58:12] [Server thread/INFO]: [WorldEdit] Loading WorldEdit v5.6.3
    [15:58:12] [Server thread/INFO]: [MagicSpells] Loading MagicSpells v3.3-release
    [15:58:12] [Server thread/INFO]: [World_Portal] Loading World_Portal v0.2.7.1
    [15:58:12] [Server thread/INFO]: [Join_Lock] Loading Join_Lock v1.0
    [15:58:12] [Server thread/INFO]: [Essentials] Loading Essentials v2.13.1
    [15:58:12] [Server thread/INFO]: [EssentialsChat] Loading EssentialsChat v2.13.1
    [15:58:12] [Server thread/INFO]: [EssentialsProtect] Loading EssentialsProtect v2.13.1
    [15:58:12] [Server thread/INFO]: [EssentialsSpawn] Loading EssentialsSpawn v2.13.1
    [15:58:12] [Server thread/INFO]: [EssentialsAntiBuild] Loading EssentialsAntiBuild v2.13.1
    [15:58:12] [Server thread/WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
    [15:58:12] [Server thread/WARN]: The server will make no attempt to authenticate usernames. Beware.
    [15:58:12] [Server thread/WARN]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
    [15:58:12] [Server thread/WARN]: To change this, set "online-mode" to "true" in the server.properties file.
    [15:58:12] [Server thread/INFO]: **** Beginning UUID conversion, this may take A LONG time ****
    [15:58:12] [Server thread/INFO]: Preparing level "world"
    [15:58:12] [Server thread/INFO]: -------- World Settings For [world] --------
    [15:58:12] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [15:58:12] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [15:58:12] [Server thread/INFO]: Clear tick list: false
    [15:58:12] [Server thread/INFO]: Experience Merge Radius: 3.0
    [15:58:12] [Server thread/INFO]: View Distance: 10
    [15:58:12] [Server thread/INFO]: Item Merge Radius: 2.5
    [15:58:12] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [15:58:12] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [15:58:12] [Server thread/INFO]: Item Despawn Rate: 6000
    [15:58:12] [Server thread/INFO]: Random Lighting Updates: false
    [15:58:12] [Server thread/INFO]: Anti X-Ray: true
    [15:58:12] [Server thread/INFO]:     Engine Mode: 1
    [15:58:12] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [15:58:12] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [15:58:12] [Server thread/INFO]: Alternative Hopper Ticking: false
    [15:58:12] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [15:58:12] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [15:58:12] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [15:58:12] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [15:58:12] [Server thread/INFO]: Cane Growth Modifier: 100%
    [15:58:12] [Server thread/INFO]: Melon Growth Modifier: 100%
    [15:58:12] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [15:58:12] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [15:58:12] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [15:58:12] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [15:58:12] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [15:58:12] [Server thread/INFO]: Mob Spawn Range: 4
    [15:58:12] [Server thread/INFO]: Max TNT Explosions: 100
    [15:58:12] [Server thread/INFO]: Max Entity Collisions: 8
    [15:58:12] [Server thread/INFO]: Structure Info Saving: true
    [15:58:12] [Server thread/INFO]: Sending up to 5 chunks per packet
    [15:58:12] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [15:58:13] [Server thread/INFO]: -------- World Settings For [world_nether] --------
    [15:58:13] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [15:58:13] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [15:58:13] [Server thread/INFO]: Clear tick list: false
    [15:58:13] [Server thread/INFO]: Experience Merge Radius: 3.0
    [15:58:13] [Server thread/INFO]: View Distance: 10
    [15:58:13] [Server thread/INFO]: Item Merge Radius: 2.5
    [15:58:13] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [15:58:13] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [15:58:13] [Server thread/INFO]: Item Despawn Rate: 6000
    [15:58:13] [Server thread/INFO]: Random Lighting Updates: false
    [15:58:13] [Server thread/INFO]: Anti X-Ray: true
    [15:58:13] [Server thread/INFO]:     Engine Mode: 1
    [15:58:13] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [15:58:13] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [15:58:13] [Server thread/INFO]: Alternative Hopper Ticking: false
    [15:58:13] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [15:58:13] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [15:58:13] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [15:58:13] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Cane Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Melon Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [15:58:13] [Server thread/INFO]: Mob Spawn Range: 4
    [15:58:13] [Server thread/INFO]: Max TNT Explosions: 100
    [15:58:13] [Server thread/INFO]: Max Entity Collisions: 8
    [15:58:13] [Server thread/INFO]: Structure Info Saving: true
    [15:58:13] [Server thread/INFO]: Sending up to 5 chunks per packet
    [15:58:13] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [15:58:13] [Server thread/INFO]: -------- World Settings For [world_the_end] --------
    [15:58:13] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [15:58:13] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [15:58:13] [Server thread/INFO]: Clear tick list: false
    [15:58:13] [Server thread/INFO]: Experience Merge Radius: 3.0
    [15:58:13] [Server thread/INFO]: View Distance: 10
    [15:58:13] [Server thread/INFO]: Item Merge Radius: 2.5
    [15:58:13] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [15:58:13] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [15:58:13] [Server thread/INFO]: Item Despawn Rate: 6000
    [15:58:13] [Server thread/INFO]: Random Lighting Updates: false
    [15:58:13] [Server thread/INFO]: Anti X-Ray: true
    [15:58:13] [Server thread/INFO]:     Engine Mode: 1
    [15:58:13] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [15:58:13] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [15:58:13] [Server thread/INFO]: Alternative Hopper Ticking: false
    [15:58:13] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [15:58:13] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [15:58:13] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [15:58:13] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Cane Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Melon Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [15:58:13] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [15:58:13] [Server thread/INFO]: Mob Spawn Range: 4
    [15:58:13] [Server thread/INFO]: Max TNT Explosions: 100
    [15:58:13] [Server thread/INFO]: Max Entity Collisions: 8
    [15:58:13] [Server thread/INFO]: Structure Info Saving: true
    [15:58:13] [Server thread/INFO]: Sending up to 5 chunks per packet
    [15:58:13] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [15:58:13] [Server thread/INFO]: Preparing start region for level 0 (Seed: -8994304951788497307)
    [15:58:13] [Server thread/INFO]: Preparing start region for level 1 (Seed: -3965610496731520325)
    [15:58:14] [Server thread/INFO]: Preparing spawn area: 45%
    [15:58:15] [Server thread/INFO]: Preparing start region for level 2 (Seed: -3965610496731520325)
    [15:58:15] [Server thread/INFO]: [CTFBridge] Enabling CTFBridge v1.0
    [15:58:15] [Server thread/INFO]: [CTFBridge] works!
    [15:58:15] [Server thread/INFO]: [WorldEdit] Enabling WorldEdit v5.6.3
    [15:58:16] [Server thread/INFO]: WEPIF: Using the Bukkit Permissions API.
    [15:58:16] [Server thread/INFO]: [MagicSpells] Enabling MagicSpells v3.3-release
    [15:58:16] [Server thread/WARN]: [MagicSpells] This MagicSpells version is not fully compatible with this server version.
    [15:58:16] [Server thread/WARN]: [MagicSpells] Some features have been disabled.
    [15:58:16] [Server thread/WARN]: [MagicSpells] See http://nisovin.com/magicspells/volatilefeatures for more information.
    [15:58:17] [Server thread/INFO]: [MagicSpells] Spells loaded: 88
    [15:58:17] [Server thread/INFO]: [World_Portal] Enabling World_Portal v0.2.7.1
    [15:58:17] [Server thread/INFO]: [World Portal] No Permissions system found! Permissions disabled!
    [15:58:17] [Server thread/INFO]: [World Portal] Loading World Portals...
    [15:58:17] [Server thread/INFO]: [World Portal] World Portals loaded
    [15:58:17] [Server thread/INFO]: [World Portal] World Portal v0.2.7.1 Started
    [15:58:17] [Server thread/INFO]: [Join_Lock] Enabling Join_Lock v1.0
    [15:58:17] [Server thread/INFO]: [Join_Lock]  works!
    [15:58:17] [Server thread/INFO]: [Essentials] Enabling Essentials v2.13.1
    [15:58:17] [Server thread/INFO]: Bukkit version format changed. Version not checked.
    [15:58:17] [Server thread/INFO]: git-Spigot-1642 (MC: 1.7.10)
    [15:58:17] [Server thread/INFO]: 1.7.10-R0.1-SNAPSHOT
    [15:58:17] [Server thread/INFO]: Essentials: Using config file enhanced permissions.
    [15:58:17] [Server thread/INFO]: Permissions listed in as player-commands will be given to all users.
    [15:58:17] [Server thread/INFO]: [EssentialsChat] Enabling EssentialsChat v2.13.1
    [15:58:17] [Server thread/INFO]: [EssentialsProtect] Enabling EssentialsProtect v2.13.1
    [15:58:17] [Server thread/INFO]: [EssentialsSpawn] Enabling EssentialsSpawn v2.13.1
    [15:58:17] [Server thread/INFO]: [EssentialsAntiBuild] Enabling EssentialsAntiBuild v2.13.1
    [15:58:17] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [15:58:18] [Server thread/INFO]: Done (5.769s)! For help, type "help" or "?"
    [16:00:37] [User Authenticator #1/INFO]: UUID of player markonasho44 is f4005a88-0815-3650-bf71-ebdc3869de9e
    [16:00:37] [Server thread/INFO]: markonasho44[/127.0.0.1:60152] logged in with entity id 39 at ([world] -8.923262163574687, 45.66486188801319, 26.68168449371312)
    [16:00:47] [Server thread/INFO]: markonasho44 issued server command: /ctf-start
    [16:00:47] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'ctf-start' in plugin CTFBridge v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Spigot-1642]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) ~[craftbukkit.jar:git-Spigot-1642]
        at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:767) ~[craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.PlayerConnection.handleCommand(PlayerConnection.java:1043) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:880) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat.handle(PacketPlayInChat.java:65) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:186) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:734) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [craftbukkit.jar:git-Spigot-1642]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Spigot-1642]
    Caused by: java.lang.IllegalArgumentException: Enchantment level is either too low or too high (given 10, bounds are 1 to 3)
        at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:430) ~[craftbukkit.jar:git-Spigot-1642]
        at io.github.zankz.bukkit.ctfbridge.Main.giveitems(Main.java:101) ~[?:?]
        at io.github.zankz.bukkit.ctfbridge.Main.countdown(Main.java:81) ~[?:?]
        at io.github.zankz.bukkit.ctfbridge.Main.onCommand(Main.java:37) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Spigot-1642]
        ... 13 more
    
    Thanks for the help!
    -Zankz
     
  2. Offline

    adam753

    @Zankz
    The issue is this:
    Code:
    sword.addEnchantment(Enchantment.DURABILITY, 10);
    Unbreaking can normally only go up to level 3. Try using addUnsafeEnchantment instead. (and the same for the bow just below that)
     
    Darkpicasa likes this.
  3. Offline

    Darkpicasa

    Yeah.
    Your issue is clearly stated in your Console:
    Code:
    Caused by: java.lang.IllegalArgumentException: Enchantment level is either too low or too high (given 10, bounds are 1 to 3)
        at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:430) ~[craftbukkit.jar:git-Spigot-1642]
    I definitely recommend reading up on Stack Traces, as it'll make something like this much easier to debug.
    Here's a useful link: http://bukkit.org/threads/how-to-re...ubleshoot-your-own-plugins-by-yourself.32457/

    Enjoy reading :)
     
  4. Offline

    mrCookieSlime

    Thread locked.

    We do not support offline mode servers!
     
    MooshViolet likes this.
Thread Status:
Not open for further replies.

Share This Page