"BUG" Player visibility

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

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

    mortnaix

    Help! how to see the players and mobs
    Code:
    public class Dimension {
        public static void setDimension(Plugin plugin, String world, int dimension, WorldType type) {
            WrapperPlayServerRespawn wp = new WrapperPlayServerRespawn();
            wp.setLevelType(type);
            wp.setDimension(dimension);
            wp.setGameMode(NativeGameMode.ADVENTURE);
            wp.setDifficulty(Difficulty.HARD);
    
            for (Player p : Bukkit.getOnlinePlayers()) {
    
                Location location = p.getLocation();
                int viewDistance = plugin.getServer().getViewDistance();
    
                int xMin = location.getChunk().getX() - viewDistance;
                int xMax = location.getChunk().getX() + viewDistance;
                int zMin = location.getChunk().getZ() - viewDistance;
                int zMax = location.getChunk().getZ() + viewDistance;
                wp.setGameMode(getGamemode(p.getGameMode()));
                wp.sendPacket(p);
                for (int x = xMin; x < xMax; ++x) {
                    for (int z = zMin; z < zMax; ++z) {
                        Bukkit.getWorld(world).refreshChunk(x, z);
    
                    }
                }
                p.updateInventory();
    
            }
        }
    
        public static void setDimensionOnPlayer(Plugin plugin2, String world2, int dimension2, WorldType type2, Player player2) {
    
            WrapperPlayServerRespawn wp1 = new WrapperPlayServerRespawn();
            wp1.setLevelType(type2);
            wp1.setDimension(dimension2);
            wp1.setGameMode(NativeGameMode.ADVENTURE);
            wp1.setDifficulty(Difficulty.HARD);
    
            wp1.setGameMode(getGamemode(player2.getGameMode()));
            Location location = player2.getLocation();
            int viewDistance = plugin2.getServer().getViewDistance();
    
            int xMin = location.getChunk().getX() - viewDistance;
            int xMax = location.getChunk().getX() + viewDistance;
            int zMin = location.getChunk().getZ() - viewDistance;
            int zMax = location.getChunk().getZ() + viewDistance;
    
            wp1.sendPacket(player2);
            for (int x = xMin; x < xMax; ++x) {
                for (int z = zMin; z < zMax; ++z) {
                    Bukkit.getWorld(world2).refreshChunk(x, z);
    
                }
            }
            player2.updateInventory();
    
        }
    
        public static NativeGameMode getGamemode(GameMode gm) {
    
            NativeGameMode gamemode = NativeGameMode.SURVIVAL;
            if (gm.equals(GameMode.ADVENTURE)) {
                gamemode = NativeGameMode.ADVENTURE;
            }
            if (gm.equals(GameMode.CREATIVE)) {
                gamemode = NativeGameMode.CREATIVE;
            }
            if (gm.equals(GameMode.SURVIVAL)) {
                gamemode = NativeGameMode.SURVIVAL;
            }
    
            return gamemode;
        }
    }
    
    
    I see not players and mobs... >_<
     
  2. Offline

    mythbusterma

Thread Status:
Not open for further replies.

Share This Page