Hey Guys! I am currently developing a plugin, that will mimic money printers from GMod using signs. Code:java @EventHandler public Object onSignChange(SignChangeEvent event){ if(event.getLine(0).equalsIgnoreCase("[bprinter]")){ //Checks the top line of sign for "[bprinter]" Double playerBalance = plugin.econ.getBalance(event.getPlayer().getName()); //Gets the balance of the player if(playerBalance <= 250){ //checks if their balance is high enough event.setLine(0, ChatColor.GOLD + "[Printer"); //sets the sign up event.setLine(1, ChatColor.GOLD + "Bronze"); event.setLine(2, ChatColor.GOLD + "Owned by %OWNER%"); event.setLine(3, ChatColor.GOLD + "Storage: %STORED%"); plugin.econ.withdrawPlayer(event.getPlayer().getName(), 250); //takes money from players account event.getPlayer().sendMessage(ChatColor.GOLD + "[MP]" + ChatColor.WHITE + "You have created a Bronze Printer!"); //Sends them a message return event.getBlock.getX().getY().getZ(); } else{ event.getPlayer().sendMessage(ChatColor.RED + "[MP]You do not have enough money to create that printer!"); //Sends them an error message } } } This shows the method i use to update the signs to my liking, and i what i need to do now is to get the X,Y,Z, of the sign, and then log that permenantly. How would i do this? Thanks, Anerdson.
Do you want the locations of the signs in a text file, like a list? or do you want to be able to get the locations of the signs again and use them in your plugin?
You could use a config and store the signs, then get their coordinates and whatever other information you want to store with it.
To get the sign's location, use Code:java Integer x = event.getBlock().getX();Integer y = event.getBlock().getY();Integer z = event.getBlock().getZ(); then you can look here: http://wiki.bukkit.org/Configuration_API_Reference for info on setting up the config and adding values to it
You should store the world name too. Might as well start with multiworld compatibility, your going to want it eventually. EDIT: Or better still, store the World UUID.
Yeah, world names can change (though it's a bit difficult you can do it), UUIDs will not change. http://jd.bukkit.org/rb/apidocs/org/bukkit/World.html#getUID()
Soo, Code:java int x = event.getBlock().getX();int y = event.getBlock().getY();int z = event.getBlock().getZ();UUID world = event.getBlock().getLocation().getWorld().getUID(); p.getConfig().set("Sign.Location" + x + y + z + world); u mean like this?
Yes, but you need some kind of separator or you will never be able to extract it later. Code:java p.getConfig().set("Sign.Location", x + "," + y + "," + z + "," + world); Later Code:java String[] location = p.getConfig().getString("Sign.Location").split(",");