Solved Plugin Error

Discussion in 'Plugin Development' started by HONHART, Jan 23, 2015.

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

    Infuzion

    @HONHART
    You would use:
    Code:
            //To add a default:
            getConfig().addDefault("Name.Of.Path", "Value");
            //To get the value:
            String worldName = getConfig().getString("Name.Of.Path");
            //To set a value:
            getConfig().set("Name.Of.Path", "Value");
           
            //To load the world from the string name
            World w = Bukkit.getWorld(worldName);
    
    Java docs are here.
     
    HONHART likes this.
  2. Offline

    HONHART

    Okay guys, looking for a little approval here, this is probably not how you guys would have gone about it, but I changed the code to get the current world "regardless of worlds name". If you have any suggestions for the new code I've put together, that would be great.

    So I changed the original code from

    Code:
        Player me = (Player) sender;
        Location loc = me.getLocation();
        World w = Bukkit.getServer().getWorld("world");
            double y = loc.getY();
            double x = loc.getX();
            double z = loc.getZ();
        Location sight = new Location(w,x,y,z);{
            if (cmd.getName().equalsIgnoreCase("skeleton")) {
                if(sender.hasPermission("skeleton.spawn") || !(sender instanceof Player)){
                Creature entity = (Creature) Bukkit.getWorld("world").spawnEntity(sight, EntityType.SKELETON);
    And Changed it to:

    Code:
        Player me = (Player) sender;
        Location sight = me.getLocation();
        World world = me.getWorld();
    
            if (cmd.getName().equalsIgnoreCase("skeleton")) {
                if(sender.hasPermission("skeleton.spawn") || !(sender instanceof Player)){
                Creature entity = (Creature) world.spawnEntity(sight, EntityType.SKELETON);
    Seems to work on both machines and in both worlds that have different names.

    @Skionz
    I'm going to do some reading on creating a separate file.


    Thanks, I appreciate everyone's input.

    @Infuzion
    Sweet, thank you very much!!!!
     
    Last edited by a moderator: Feb 1, 2015
  3. Offline

    WinX64

    You can also use Bukkit.getWorlds().get(0), it will always return your main world.
     
    Konato_K and HONHART like this.
  4. Offline

    HONHART

    @WinX64
    Perfect, thank you very much, I really appreciate your input.

    @Infuzion
    I decided to upgrade the Java version on my Primary Server as well, not sure if this had anything to do with the Plugin working, I probably should have tried the updated code first to rule out anything.

    Thanks again for your help.
     
    Last edited by a moderator: Feb 1, 2015
  5. Offline

    BaconStripzMan

    Set the title to Solved please!
     
Thread Status:
Not open for further replies.

Share This Page