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

    bjsnow

    Code:
        getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    @Override
        public void run() {
        String world1 = getConfig().getString("MCom1.world");
                                            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");
            goldsword.setItemMeta(splashmundane1);
                                            
                                            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

    Eats_Rainbows

    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

    bjsnow

    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

    bjsnow

    Any ideas? anyone?
     
  5. Offline

    Pink__Slime

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

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


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


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

    bjsnow

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

Share This Page