2
\$\begingroup\$

I am currently working on a minecraft plugin using spigot. It's a sort of a race between players where checkpoints validation is needed.

I have a minecraft map edited on MCEdit and I have severals signs already set on the map that serves as "checkpoints".

All I need is to find a way to distinguish the signs.
I would like to get x y z coordinates of each signs but I've thought that there could be map makers that wouldn't name their signs the same way I do, so I need to find another way to distinguish the signs.

I have a debut code but i don't have any ideas to get it forward.

@EventHandler
public void onClick(PlayerInteractEvent e){

        if(e.getItem().getType() == Material.SIGN){


            //I'll have to getlocation() the signs
            //And maybe store the locations in an array

            e.setCancelled(true);
        }

}

Any ideas?

\$\endgroup\$
4
  • \$\begingroup\$ there could be map makers that wouldn't name their signs the same way I do What? What does this even mean? Minecraft stores all signs the same way: a sign block and a sign tile entity. \$\endgroup\$ Commented Jul 18, 2017 at 14:07
  • \$\begingroup\$ This is exactly why I'm trying to find another approach to the problem, because i can't refer to the text on the signs that are on the map, if I want my plugin to be used by anyone. \$\endgroup\$
    – Himeji
    Commented Jul 18, 2017 at 15:17
  • \$\begingroup\$ Your problem is one of "I want to do like X, but someone else might want to do the same thing by doing Y, how do I allow for this?" You don't. Your plugin reads the text on signs, if the first line of text isn't what your plugin expects, ignore the sign. If someone else says, "BUT I WANNA USE SIGNS THAT READ DIFFERENT AND STILL GET DETECTED," screw them. You'r writing the plugin you get to decide the format. If they don't follow it, it's THEIR problem. \$\endgroup\$ Commented Jul 18, 2017 at 15:27
  • \$\begingroup\$ You got a point, and if there are really no solutions i'll impose a naming convention for the signs. \$\endgroup\$
    – Himeji
    Commented Jul 18, 2017 at 15:58

1 Answer 1

1
\$\begingroup\$

So I've bypassed the problem just by setting a new checkpoint on clicking on a sign. Here's the code in case it helps someday :

Location checkpoint;    

public void setcheckpoint(int x, int y, int z, Player p) {

    Location checkpoint = new Location(p.getWorld(), x, y, z);
    this.checkpoint = checkpoint;

}

@EventHandler
public void onClick(PlayerInteractEvent e) {
    Player p = e.getPlayer();
    if (e.hasBlock() && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (e.getClickedBlock().getType() == Material.SIGN) {
            setcheckpoint(e.getClickedBlock().getX(),e.getClickedBlock().getY(),e.getClickedBlock().getZ(),p);
        }

    }

}

The checkpoint the player clicked on gets it's coordinates stored into the checkpoint Location, which is much simpler.

Sorry on having taken your time and thanks for the help !

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .