Not work, Not Error, BlockBreakEvent

Discussion in 'Plugin Development' started by nyanneko0113, Sep 18, 2020.

  1. Offline

    nyanneko0113

    Help not work, not error, blockbreakevent

    Code:
    https://pastebin.com/YaUMwfLL

    do:
    ・endstone break (Location)→Send Message

    amendment:
    player.sendMessage(String.valueOf(loc.equals(red)));

    false
     
  2. Offline

    Kars

    What is it you want? I can't tell.
     
    Xp10d3 likes this.
  3. Offline

    Xp10d3

    Please read this.
     
  4. Online

    JavaNoob

    What exactly do you want to happen when you break endstone?
     
  5. Offline

    nyanneko0113

    endstone break → scoreboard timer remove → sound
     
  6. Offline

    Shqep

    PHP:
    public class onBreakingEvent implements Listener {

        private 
    Main instance;
        public 
    onBreakingEvent(Main instance) {
            
    this.instance instance;
        }

        
    ScoreboardAPI sc = new ScoreboardAPI();

        @
    EventHandler
        
    public void BreakingEvent(BlockBreakEvent e) {
            
    Player player e.getPlayer();
            
    World world player.getWorld();
            
    Location loc e.getBlock().getLocation();

            
    FileConfiguration config instance.getConfig();

            
    Location red = new Location(world12095152);
            
    Location red1 = new Location(worldconfig.getDouble("nexus.red.x"), config.getDouble("nexus.red.y"), config.getDouble("nexus.red.z"));
            
    Location blue = new Location(worldconfig.getDouble("nexus.blue.x"), config.getDouble("nexus.blue.y"), config.getDouble("nexus.blue.z"));
            
    Location yellow = new Location(worldconfig.getDouble("nexus.yellow.x"), config.getDouble("nexus.yellow.y"), config.getDouble("nexus.yellow.z"));
            
    Location green = new Location(worldconfig.getDouble("nexus.green.x"), config.getDouble("nexus.green.y"), config.getDouble("nexus.green.z"));

            if (
    e.getBlock().getType() == Material.ENDER_STONE) {
                if (
    loc.equals(red)) {
                    
    e.setCancelled(true);
                    for (
    Player pBukkit.getOnlinePlayers()) {
                        if (
    sc.redcore <= 0) {
                            
    world.getBlockAt(red).setType(Material.BEDROCK);
                            
    p.sendMessage("終了");
                        }
                        else {
                            
    sc.redcore--;
                            
    sc.anni.getScoreboard().resetScores(ChatColor.RED "赤: " String.valueOf(sc.redcore+1));
                            
    sc.anni.getScore((ChatColor.RED  "赤: " String.valueOf(sc.redcore))).setScore(4);
                            
    p.sendMessage(ChatColor.RED  "Coreが破壊されました 残り:" String.valueOf(sc.redcore));
                        }
                    }
                }
                else if (
    loc.equals(blue)) {
                    for (
    Player pBukkit.getOnlinePlayers()) {
                        if (
    sc.bluecore <= 0) {
                            
    world.getBlockAt(blue).setType(Material.BEDROCK);
                            
    p.sendMessage("終了");
                        }
                        else {
                            
    sc.bluecore--;
                            
    sc.anni.getScoreboard().resetScores(ChatColor.BLUE "青: " String.valueOf(sc.bluecore+1));
                            
    sc.anni.getScore((ChatColor.BLUE  "赤: " String.valueOf(sc.bluecore))).setScore(3);
                            
    p.sendMessage(ChatColor.BLUE  "Coreが破壊されました 残り:" String.valueOf(sc.bluecore));
                        }
                    }
                }

            }
        }
    }
    Here's the reformatted code for easier reading. Couldn't use java syntax because it ate all the formatting I swear.

    I'm gonna assume it's supposed to be a minigame where you have to break teams' end stone blocks as there are supposedly teams names like "Red" and "Blue".

    PHP:
    sc.bluecore--;
    sc.anni.getScoreboard().resetScores(ChatColor.BLUE "青: " String.valueOf(sc.bluecore+1));
    sc.anni.getScore((ChatColor.BLUE  "赤: " String.valueOf(sc.bluecore))).setScore(3); //It's supposed to say "blue" here by the way but they put "red".
    p.sendMessage(ChatColor.BLUE  "Coreが破壊されました 残り:" String.valueOf(sc.bluecore));
    We can't really say what goes on with the Scoreboard because we don't have access to the ScoreboardAPI which was used in this.

    There's a problem that I don't see any lines that should produce a sound to users when the block breaks. It may exist in ScoreboardAPI's methods but again, we can't say with certainty.

    Another thing that might be a problem I could make out is that: the scoreboard codes are run not once, but for every online player, and judging from the code, it seems like they are accessing universal variables?

    There are so many questions that need answering before others can help properly.

    No offense but they should have learnt or used proper English so others could help though.
     
    Xp10d3 likes this.

Share This Page