Adding location of sign to the config

Discussion in 'Plugin Development' started by mouz_, Dec 5, 2015.

Thread Status:
Not open for further replies.
  1. Hi, I have problems with adding the location of sign to the config and updating it. I had location in the config, but it was something like this:
    But it was deleting my whole config. (

    On enable I have something like this to update the signs:
            locations = (List<Location>) config.get("signs");
            if (locations == null) {
                locations = new ArrayList<Location>();
            BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
            scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    for (Location loc: locations) {
                        if (loc.getBlock().getType().equals(Material.WALL_SIGN)) {
                            Sign sign = (Sign) loc.getBlock().getState();
    then there is code to update lines of the sign.

    I'm adding the sing like that:
        public void onSignChange(final SignChangeEvent e) {
            Player p = e.getPlayer();
            if (!p.hasPermission("castlewars.admin")) {
            final FileConfiguration config = this.getConfig();
            Block sign = e.getBlock();
            config.set("signs", locations);
    How to add location of signs to the config, loop through and update them?

    Youu copy the defaults after you set the value in the config. PLEASE LEARN JAVA, YOU'RE WASTING YOUR TIME CURRENTLY. (Caps lock used to make the sentence more noticable, I'm not screaming)
    Last edited by a moderator: Dec 5, 2015
  2. Offline


    Location is an object, not a string.
    World is an object, not a string.

    You need to put the location into string form yourself, and get the name of the world before storing

    Can't believe you're posting this for the 4th time when we've told you time and again you need to learn more
  3. Offline


    I've cleaned up this thread of the useless posts. Lets keep it on topic. Mouz_ they have told you were your issues are, work on those.
  4. Offline


    Do you have permission from castlewars author, to edit their plugin?
  5. Offline


    Also, is your plugin seriously called "x"?

    And your package is x.x.x?

    Seriously? WTF?
  6. Offline



    If you look at the recent posts, he's had 3 threads of this same issue locked. This one should be as well.


    You can't serialize Locations in 1.7.4

    And you still haven't shown us the entire class. Almost like you're hiding something.
  7. Offline


    The error message literally shows you the problems root 3 times.

    This config not just wouldn't work, but why would you need so much information about the location? I'm pretty sure you only need 6 data

    @ZeldoKavira As mythbusterma said, he had a thread, that had about 75 posts, and O swear, the last 50 was there, because ihe dodn't pay attention to what we say. Then he started a new thread, and it got locked because of obvious reason, then again.
  8. Offline


    He doesn't need to hide anything, it's not his plugin to begin with.
    Not only that, but we are all aware that he doesn't know much, if any Java.

    Also, I didn't think you could serialize Locations in 1.8 either? They didn't implement serializable in the 1.8.8 Spigot.jar I was running off

    The reason Kavira came here is because I reported this thread. Not the response I was looking for..
  9. Of course I have the permission, otherwise I wouldn't post here about this plugin.

    Ok, I need only 6 data, but how do I get it from the location and how to loop through them? You guys are not really good at explaining something. It's hard for me, that's why I'm asking for help. In my previous and first thread only ONE answer was helpful. I don't know what @Scimiguy is looking for in my threads, clearly he doesn't want to help me at all.
  10. Offline



    Still haven't posted the entire class, and still haven't stopped trying to serialise locations. I've already told you what was wrong.

    Also, the fact you lack basic debugging skills, that doesn't help.
  11. Offline


    Oh really? That's weird, I could have sworn I replied before anyone else did, and gave you not 1, but two fixes
  12. Why do you want my entire class? Do I want to serialise anything? I'm just asking for help. What do you want to debug then?

    How many of your posts are like "learn java", "learn bukkit", "lock this thread", "I said that", "He said that"?
  13. Offline


    Many, because people don't listen.

    How many of them are valid answers? Even more, because people didn't listen when I told them the first time
  14. Offline


    A lot, because you have a library, of how you need to do this. Create a small plugin, and leave this alone. please learn
  15. I don't want answers like this, I would like to see you guys give useful posts here. :)
  16. Offline


    You gotta give useful posts to get useful posts.
    Honestly, if this didn't work the first three times you posted it, I'm not sure why you think a fourth attempt is worthwhile. The local residents certainly don't seem to think so.
  17. Offline

    timtower Administrator Administrator Moderator

    @mouz_ Could you do what is asked then?
  18. Well, this post is just spam, because my previous threads have nothing to do with problem in this thread.

    I asked something too.
  19. Offline

    timtower Administrator Administrator Moderator

    @mouz_ because we can't help if we don't know what you have and how you work.
    Write your own methods for serializing and deserializing locations.
  20. Code:
        public String getLocation(final Player player) {
            final Location loc = player.getLocation();
            final String location = String.valueOf(player.getWorld().getName()) + "/" + (int)loc.getX() + "/" + (int)loc.getY() + "/" + (int)loc.getZ() + "/" + loc.getYaw() + "/" + loc.getPitch();
            return location;
        public Location toLocation(final String location) {
            final String[] pos = location.split("/");
            final double x = Double.parseDouble(pos[1]);
            final double y = Double.parseDouble(pos[2]);
            final double z = Double.parseDouble(pos[3]);
            final float yaw = Float.parseFloat(pos[4]);
            final float pitch = Float.parseFloat(pos[5]);
            final World world = Bukkit.getWorld(pos[0]);
            return new Location(world, x, y, z, yaw, pitch);
  21. Offline

    timtower Administrator Administrator Moderator

    @mouz_ Could you now try to write your own?
  22. I could try, but if I have it already done why should I? The thread is not about creating methods to serialize locations.
  23. Offline

    timtower Administrator Administrator Moderator

    @mouz_ It actually is.
    The error is that your config gets reset right? That is because it isn't able to serialize and deserialize locations, so that is what you just got.
    Now, in the onEnable, loop through the string list, deserialize them, add them to locations.
    In onDisable, loop through locations, serialize them, add them to the config.
    mythbusterma likes this.
  24. Ok, now I need just little help to handle and create all this code.
  25. Offline


    What problem do you have? Nobody will spoonfeed to you. You have everything you need
    Last edited by a moderator: Dec 6, 2015
  26. Offline



    [1]Create a locationToString method:
    1. Identify a char you want to act as a "splitter" (a letter or sequence of letters that mean "the thing before this is not the same thing as the thing after this"). I would suggest using something like "#@^" or something so it is easily identifiable.
    2. Create a string with the following format (World's Name, Splitter, X ,Splitter, Y ,Splitter ,Z,)
    3. Return that string.
    And thats how you turn a location into a String
    [2] Save the locationToString into the config
    • You should know how to do this.
    [3]Create a stringToLocation method
    1. Get that "Splitter" char from before.
    2. get the String from the config.
    3. Use String#split(input); to split the one string into an array of strings, the input would be the splitter.
    4. Now that you have the array, create a New location with the following: new Location(StringArray[1],StringArray[2],StringArray[3],StringArray[4]);
    • NOTE: You have to parse the X,Y,Z Strings to integers. Just use the Integer ParseInt method.
    Last edited by a moderator: Dec 6, 2015
    timtower and mythbusterma like this.
  27. Offline


    I followed your threads very curiously, but now i feel like i want to hit my head on the desk as hard as i can.
    This guys here really know what they are talking about, they gave you good advices how to solve your "problems", even after the 20. stupid answer they got from you. They told you that they wont write the code for you many times, but they described how to do it in so simple terms that everybody who has the slightest experience in java could do it. After all the work they done trying to help you, all you say is
    "I don't want answers like this"
    "I would like to see you guys give useful posts here"
    "You guys are not really good at explaining something"
    "this post is just spam"

    and finally... again just begging for code?
    Please lock this thread...
    Here is what youre looking for!
    Zombie_Striker, adam753 and timtower like this.
Thread Status:
Not open for further replies.

Share This Page