Solved BlockBreak and config issue

Discussion in 'Plugin Development' started by MrPmiguelP, Nov 7, 2012.

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

    MrPmiguelP

    Hi there!
    I've a thing that has been bothering me for the last hours. I can't get this simple piece of code to work... It does work as soon as I set the locations, but it doesn't work anymore when I reload the server or restart the server:
    Code:
    @EventHandler
        public void onBlockBreak(BlockBreakEvent event) {
            Player p = event.getPlayer();
            int redX = Main.ctf.getConfig().getInt("Red.X");
            int redY = Main.ctf.getConfig().getInt("Red.Y");
            int redZ = Main.ctf.getConfig().getInt("Red.Z");
            String redW = Main.ctf.getConfig().getString("Red.World");
            String w = p.getWorld().getName();
            Main.ctf.reloadConfig();
            //System.out.println(event.getBlock().getX() + " " + redX + " " + event.getBlock().getY() + " " + redY + " " + event.getBlock().getZ() + " " + redZ + " " + redW + " " + w);
            if(event.getBlock().getX() == redX && event.getBlock().getY() == redY && event.getBlock().getZ() == redZ && redW == w) {
                -snip-
                Main.ctf.getServer().getScheduler().scheduleSyncDelayedTask(Main.ctf, new Runnable() {
                    public void run() {
                      -snip-
            }
        }
    Thanks in advance!

    Miguel
     
  2. Offline

    fireblast709

    like... any errors (stack-trace please)? Or just not doing anything?
     
  3. Offline

    MrPmiguelP

    Just nothing. When I make an else statement the else statement is triggered. However, this should work just fine. I did a System.out.println() to see if the coords matched each other and they did.

    thanks.
     
  4. Offline

    fireblast709

    try
    Code:java
    1. redW.equals(w)

    instead of just comparing strings. == will check if they refer the same object, which will always be false (unless you check if x == x)
     
    xDeeKay and MrPmiguelP like this.
  5. Offline

    MrPmiguelP

    Thanks. This worked for me. I'm still confused why it did work before a server reload/restart. Thanks anyways!

    Miguel
     
Thread Status:
Not open for further replies.

Share This Page