Plugin not able to read this configuration file

Discussion in 'Plugin Development' started by @DriftCoder, Aug 20, 2015.

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

    @DriftCoder

    Well, after I changed version of my plugin and stopped reading the configuration file which is where data is stored, whenever I try to get into the right server he would teleport me to a certain place but I keep falling into the void and me returns this error on the console:

    I already analyzed this error and as far as I know there's nothing wrong with my method to fetch the data it in the configuration file, but anyway here is the code he's pointing to error:

    EventPlayerMove.java:

    Code:
    package br.driftracingpvp.events.player;
    
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerMoveEvent;
    
    import br.driftracingpvp.libs.GetSpectator;
    import br.driftracingpvp.libs.PlayerTeleportLobby;
    import br.driftracingpvp.match.MatchManager;
    
    public class EventPlayerMove implements Listener {
       
        public br.driftracingpvp.Main plugin;
        public EventPlayerMove(br.driftracingpvp.Main plugin) {
            this.plugin = plugin;
        }
       
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent e) {
            Player p = e.getPlayer();
           
            if(MatchManager.matchStatus == false) {
                if(p.getLocation().getY() < 0) {
                    p.teleport(PlayerTeleportLobby.getLocationConfigLobby());
                }
            } else {
                if((MatchManager.players.contains(p.getPlayer())) && (p.getLocation().getY() < 0)) {
                    if (MatchManager.end == false) {
                        p.setHealth(0);
                    } else {
                        p.teleport(PlayerTeleportLobby.getLocationConfigLobby());
                    }
                } else if ((MatchManager.spectator.contains(p.getPlayer())) && (p.getLocation().getY() < 0)) {
                    p.teleport(GetSpectator.getLocationSpectator());
                }
            }
        }
    }
    
    PlayerTeleportLobby.java:

    Code:
    package br.driftracingpvp.libs;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    
    public class PlayerTeleportLobby {
       
        public br.driftracingpvp.Main plugin;
        public PlayerTeleportLobby(br.driftracingpvp.Main plugin) {
            this.plugin = plugin;
        }
       
        public static Location getLocationConfigLobby() {
            Location loc = (Location) Bukkit.getPluginManager().getPlugin("SkyWars").getConfig().get("Locations.Lobby");
            return loc;
        }
    }
    
    My configuration file where the coordinates of the positions stored station:

    the little knowledge I have in java and analyzing the error he is returning null when you try to search it in the configuration file! someone help me?
     
  2. @@DriftCoder
    Try serialializing it to a string instead of writing the object, e.g:
    Saving:
    Code:
    JavaPlugin#getConfig().set(<path>, location.getWorld.getName() + "," + location.getX() + "," + location.getY() etc.);
    Loading:
    Code:
    String[] split = JavaPlugin#getConfig().getString(<path>);
    Location location = new Location(Bukkit.getWorld(split[0]), Double.parseDouble(split[1]) etc.);
     
  3. Offline

    mythbusterma

  4. Offline

    @DriftCoder

  5. Offline

    mythbusterma

    @@DriftCoder

    You can use set and get with it, just cast it to LocationSerializable after you get it from config.

    Also make sure to register it with the server.
     
  6. Offline

    @DriftCoder

    @mythbusterma your using this method, as I picked up my location?
     
  7. Offline

    mythbusterma

  8. Offline

    @DriftCoder

    @mythbusterma I am new to java, explain to me how to implement your solution to my plugin or direct me to a tutorial?
     
  9. Offline

    mythbusterma

Thread Status:
Not open for further replies.

Share This Page