Spawning an Item at a location

Discussion in 'Plugin Development' started by bjsnow, May 21, 2013.

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


        getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
        public void run() {
        String world1 = getConfig().getString("");
                                            String x1 = getConfig().getString("MCom1.x");
                                            String y1 = getConfig().getString("MCom1.y");
                                            String z1 = getConfig().getString("MCom1.z");
                                            double xd1 = Double.parseDouble(x1);
                                            double yd1 = Double.parseDouble(y1);
                                            double zd1 = Double.parseDouble(z1);
                                            Location Lobby = new Location(Bukkit.getWorld(world1), xd1,
                                                            yd1, zd1);
       ItemStack goldsword = new ItemStack(Material.GOLD_SWORD, 1);
            ItemMeta splashmundane1 = goldsword.getItemMeta();
            splashmundane1.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Wraith Of Bjsnow");
                                            getServer().getWorld("world").dropItem(Lobby, new ItemStack(goldsword));
    }, 100L, 1000L);
    This code spawns 250 gold swords but I cant figure out how to make it spawn only one.
  2. Offline


    Your scheduler is most likely repeating its self 250 times... Why do you have a repeating task anyway?

    Plus your code is pretty messy which makes it for most of us pretty hard to read.
  3. Offline


    Sorry for the messy code Its just a quick test to see if I can get an item to spawn at a location every 5 minutes I need it for something Im making. any idea how to fix my scheduler?
  4. Offline


    Any ideas? anyone?
  5. Offline


    Just off topic slightly, this line bugs me...

    1. getServer().getWorld("world").dropItem(Lobby, new ItemStack(goldsword));
    2. }

    It should only be
    1. getServer().getWorld("world").dropItem(Lobby, goldsword);
    2. }

    You created the itemstack so you didn't have to 'recreate' it.
  6. Offline


    Yeh I know.
Thread Status:
Not open for further replies.

Share This Page