help! getKickPlayer

Discussion in 'Plugin Development' started by mortnaix, Sep 3, 2015.

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

    mortnaix

    Here's the code:
    Code:
    if (plugin.getServer().getWorld(world).getBlockAt(cx, 0, cz).getType() != Material.REDSTONE_BLOCK) {
    
                    p.damage(999999.0D);
                    p.isDead();
                    p.kickPlayer("You Died!");
    
            }
    
    kick those who have died...
     
  2. And your problem is/you need help with what?
     
  3. Offline

    mortnaix

    check deads and kick players
     
  4. Offline

    JasonDL13

    Wow okay let's fix this.

    p.damage(999999.0D); - This is honestly the worst way to do this. Besides bad practice this can cause a god mode glitch/bug. Do p.setHealth(0);. Also if you're kicking the player does he really have to be dead anyways?

    p.isDead(); - This returns a boolean and is useless. Remove it.

    p.kickPlayer("You Died!"); - This is good.
     
  5. Offline

    mortnaix

    killing players - р.damage(999999.0D):
    Code:
    public class CheckLocation
    {
        static int num;
        static int x = 0;
        static int cx;
        static int cz;
      
    
        public static void checkLocation(Plugin plugin) {
            x = 0;
            String world = plugin.getConfig().getString("ejection.world");
            plugin.getServer().getScheduler().cancelAllTasks();
    
            for (Player p : Bukkit.getOnlinePlayers()) {
    
                cx = p.getLocation().getBlockX();
                cz = p.getLocation().getBlockZ();
    
                if (plugin.getServer().getWorld(world).getBlockAt(cx, 0, cz).getType() != Material.REDSTONE_BLOCK) {
    
                    p.damage(999999.0D);
                    p.isDead();
                    p.kickPlayer("You Died!");
    
    
     
    Last edited: Sep 3, 2015
  6. Offline

    Zombie_Striker

    @mortnaix
    1. I don't assume that the configs "ejection world" will change between the times this method will run, so you could save it outside of the method.
    2. You're asking for all the players online, but getting the block in the ejection world which the player might not be in. Unless you meant for this, I would think you wanted to use World.getPlayers.
    3. x is never set to anything besides 0, and never used. Why is it there?
    4. Also, you're not checking if that block is null, or if the world is null. There is not one null check in your code.
    5. As Jason pointed out, set their health to 0. The player's health could NEVER be over 20F, so why damage them with almost 10 million points of damage.
    6. p.isDead is a boolean. That line is useless unless you meant to use it as an If statement.
    7. And the close brackets (which I assume is already there)
     
Thread Status:
Not open for further replies.

Share This Page