for (String sign : config.getConfigurationSection("signs").getKeys(false))
{
double xcoord = config.getDouble("signs."+sign+".x");
double ycoord = config.getDouble("signs."+sign+".y");
double zcoord = config.getDouble("signs."+sign+".z");
Server s = Bukkit.getServer();
double cost = config.getDouble("signs."+sign+".price");
double onePercent = cost / 100;
double addToCost = onePercent * Integer.parseInt(args[1]);
double newCost = cost + addToCost;
config.set("signs."+sign+".price", newCost);
World world = s.getWorld(config.getString("signs."+sign+".world"));
Location loc = new Location(world, xcoord, ycoord, zcoord);
Sign newsign = (Sign) loc.getBlock().getState();
newsign.setLine(3, Double.toString(newCost));
newsign.update();
saveConfig();
}
Essentially, I have these economy buy signs, and to inflate the price of them, a user runs a command and it is supposed to update the prices and the signs automatically. The problem is, it will not let me update the sign - above I have this loop that loops through all of the signs in the config, and it is supposed to edit the price of the item on each sign. I keep on getting this error that says the following:
"The method setLine(int, String) is undefined for the type Sign"
I thought that setLine() is a method of Sign? From everything I have looked at, it appears that setLine() is used for that. Also, the update() method is not working, and getLine() and getLines(). Why are the Sign's method's not working properly?
By looking through the bukkit javadocs, there seems to be both a class and an interface both with the name of Sign. I believe that the Sign
class in your program is really utilizing org.bukkit.material.Sign
whereas it should be utilizing the org.bukkit.block.Sign
interface. Try replacing Sign in that specific line with its formal name like so:
org.bukkit.block.Sign newsign = (org.bukkit.block.Sign) loc.getBlock().getState();