当前位置: 首页>>代码示例>>Java>>正文


Java ProtocolLibrary类代码示例

本文整理汇总了Java中com.comphenix.protocol.ProtocolLibrary的典型用法代码示例。如果您正苦于以下问题:Java ProtocolLibrary类的具体用法?Java ProtocolLibrary怎么用?Java ProtocolLibrary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProtocolLibrary类属于com.comphenix.protocol包,在下文中一共展示了ProtocolLibrary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listenPackets

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
public static void listenPackets() {
    ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(DynamicAC.instance, ListenerPriority.NORMAL, PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK) {
        @Override
        public void onPacketReceiving(PacketEvent e) {
            Player p = e.getPlayer();
            Location cur = e.getPlayer().getLocation();
            if(!MOVE_COUNT.containsKey(p)) {
                MOVE_COUNT.put(p, 1);
            } else {
                MOVE_COUNT.put(p, MOVE_COUNT.get(p) + 1);
                if(MOVE_COUNT.get(p) > MagicNumbers.BLINK_PACKET)  {
                    for(Player player : DynamicAC.instance.onlinestaff) {
                        player.sendMessage(DynamicAC.prefix + p.getName() + " failed Blink test, sent too many " +
                                "packets in one place!");
                    }
                    MOVE_COUNT.remove(p);
                    e.setCancelled(true);
                    e.getPlayer().teleport(cur);
                }
            }
        }
    });
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:24,代码来源:MovementListener.java

示例2: sendTabListAddPacket

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
@Override
public void sendTabListAddPacket(Player playerToAdd, GameProfileWrapper newProfile, Player seer) {
    PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
    int ping = (int) ReflectUtil.getFieldValue(ReflectUtil.invokeMethod(playerToAdd, GET_HANDLE).getOrThrow(), PING).getOrThrow();
    packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
    PlayerInfoData playerInfoData = new PlayerInfoData(getProtocolLibProfileWrapper(newProfile), ping, EnumWrappers.NativeGameMode.fromBukkit(playerToAdd.getGameMode()), WrappedChatComponent.fromText(playerToAdd.getPlayerListName()));
    packet.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(seer, packet);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:14,代码来源:ProtocolLibPacketHandler.java

示例3: sendNamedEntitySpawnPacket

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
@Override
public void sendNamedEntitySpawnPacket(Player playerToSpawn, Player seer) {
    PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
    packet.getIntegers().write(0, playerToSpawn.getEntityId());
    packet.getUUIDs().write(0, playerToSpawn.getUniqueId());
    if (ReflectUtil.isVersionHigherThan(1, 8, 8)) {
        packet.getDoubles().write(0, playerToSpawn.getLocation().getX());
        packet.getDoubles().write(1, playerToSpawn.getLocation().getY());
        packet.getDoubles().write(2, playerToSpawn.getLocation().getZ());
    } else {
        packet.getIntegers().write(0, (int) Math.floor(playerToSpawn.getLocation().getX() * 32D));
        packet.getIntegers().write(1, (int) Math.floor(playerToSpawn.getLocation().getY() * 32D));
        packet.getIntegers().write(2, (int) Math.floor(playerToSpawn.getLocation().getZ() * 32D));
    }
    packet.getBytes().write(0, (byte) (playerToSpawn.getLocation().getYaw() * 256F / 360F));
    packet.getBytes().write(1, (byte) (playerToSpawn.getLocation().getPitch() * 256F / 360F));
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(seer, packet);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:23,代码来源:ProtocolLibPacketHandler.java

示例4: sendScoreboardRemovePacket

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
@Override
public void sendScoreboardRemovePacket(String playerToRemove, Player seer, String team) {
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(seer, getScoreboardPacket(team, playerToRemove, LEAVE_SCOREBOARD_TEAM_MODE));
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:9,代码来源:ProtocolLibPacketHandler.java

示例5: playParticles

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
private static void playParticles(Player player, EnumWrappers.Particle particle, int particleNum, Location location, Vector direction) {
    WrapperPlayServerWorldParticles particles = new WrapperPlayServerWorldParticles();
    particles.setParticleType(particle);
    particles.setNumberOfParticles(particleNum);
    particles.setX((float) location.getX());
    particles.setY((float) location.getY());
    particles.setZ((float) location.getZ());
    particles.setOffsetX((float) direction.getX());
    particles.setOffsetY((float) direction.getY());
    particles.setOffsetZ((float) direction.getZ());

    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(player, particles.getHandle());
    } catch (InvocationTargetException e) {
        throw new IllegalStateException("Unable to send packet", e);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:18,代码来源:EffectUtils.java

示例6: init

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
public static boolean init(RPGInventory instance) {
    MemorySection config = (MemorySection) Config.getConfig().get("craft");
    if (!config.getBoolean("enabled") || !config.contains("extensions")) {
        return false;
    }

    try {
        capItem = ItemUtils.getTexturedItem(config.getString("extendable"));

        Set<String> extensionNames = config.getConfigurationSection("extensions").getKeys(false);
        for (String extensionName : extensionNames) {
            EXTENSIONS.add(new CraftExtension(extensionName, config.getConfigurationSection("extensions." + extensionName)));
        }
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }

    // Register listeners
    ProtocolLibrary.getProtocolManager().addPacketListener(new CraftListener(instance));
    return true;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:23,代码来源:CraftManager.java

示例7: ManagerHandler

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
public ManagerHandler(Plugin plugin) {
    config = new PracticeConfiguration();
    storageBackend = new StorageBackend(new DatabaseCredentials(config.getRootConfig().getConfig().getString("database.host"), config.getRootConfig().getConfig().getInt("database.port"), config.getRootConfig().getConfig().getString("database.user"), config.getRootConfig().getConfig().getString("database.pass"), config.getRootConfig().getConfig().getString("database.dbName")));
    playerManager = new PlayerManager();
    partyManager = new PartyManager();
    playtimeManager = new PlayTimeManager();
    ladderManager = new LadderManager();
    arenaManager = new ArenaManager();
    matchManager = new MatchManager();
    queueManager = new QueueManager();
    spectateManager = new SpectateManager();
    kitEditManager = new KitEditManager();
    scoreboardHandler = new ScoreboardHandler();
    protocolManager = ProtocolLibrary.getProtocolManager();
    entityHider = new EntityHider(plugin, EntityHider.Policy.BLACKLIST);
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:17,代码来源:ManagerHandler.java

示例8: get

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
@Override
protected Entity[] get(Event event) {
    PacketContainer packet = packetContainerExpression.getSingle(event);
    World world = worldExpression.getSingle(event);
    int index = this.index.getSingle(event).intValue();
    if (isSingle) {
        return new Entity[]{packet.getEntityModifier(world).readSafely(index)};
    } else {
        int[] entityIDs = packet.getIntegerArrays().readSafely(index);
        Entity[] result = new Entity[entityIDs.length];
        for (int i = 0; i < entityIDs.length; i++) {
            result[i] = ProtocolLibrary.getProtocolManager().getEntityFromID(world, entityIDs[i]);
        }
        return result;
    }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:17,代码来源:ExprEntityOfPacket.java

示例9: enableScores

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
public void enableScores() {
    if (!areScoresEnabled()) {
        scoresEnabled = true;

        PacketContainer createPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE); //Used to get some defaults
        createPacket.getStrings().writeSafely(0, OBJECTIVE_NAME);
        createPacket.getStrings().writeSafely(1, OBJECTIVE_NAME);
        createPacket.getIntegers().writeSafely(0, 0);
        PacketManager.sendPacket(createPacket, this, target);

        PacketContainer displayPacket = new PacketContainer(PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE);
        displayPacket.getIntegers().writeSafely(0, 0);
        displayPacket.getStrings().writeSafely(0, OBJECTIVE_NAME);
        PacketManager.sendPacket(displayPacket, this, target);
    }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:17,代码来源:Tablist.java

示例10: onEnable

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
/**
 * @see org.bukkit.plugin.java.JavaPlugin#onEnable()
 */
@Override
public void onEnable() {
    saveDefaultConfig();
    CONFIG = new Configuration(this);
    CONFIG.reload();

    _protocolManager = ProtocolLibrary.getProtocolManager();
    _protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.UPDATE_TIME) {
        @Override
        public void onPacketSending(PacketEvent event) {
            if (event.getPacketType() == PacketType.Play.Server.UPDATE_TIME &&
                _ignoringTime.contains(event.getPlayer()) &&
                event.getPacket().getLongs().read(1) >= 0) {
                event.setCancelled(true);
            }
        }
    });
}
 
开发者ID:NerdNu,项目名称:NerdMoods,代码行数:22,代码来源:NerdMoods.java

示例11: send

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
public static void send(UUID u) {
	if (active && listPlayers != null) {
		try {
			PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
			
			List<PlayerInfoData> list = new ArrayList<PlayerInfoData>();
			for (Entry<UUID, PlayerInfoData> e : listPlayers.entrySet()) {
				list.add(e.getValue());
			}
			packet.getPlayerInfoDataLists().write(0, list);
			packet.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER);
			
			ProtocolLibrary.getProtocolManager().sendServerPacket(Bukkit.getPlayer(u), packet);
		} catch (InvocationTargetException ex) {
			LogHandler.printError("ProtocolHandler error at send(): " + ex.getMessage());
		}
	}
}
 
开发者ID:AlessioDP,项目名称:Parties,代码行数:19,代码来源:ProtocolHandler.java

示例12: register

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
public void register() {
    ProtocolLibrary.getProtocolManager().addPacketListener(
            new PacketAdapter(this, WrapperPlayClientUseEntity.TYPE) {
                @Override
                public void onPacketReceiving(PacketEvent event) {
                    if (event.getPacketType() == WrapperPlayClientUseEntity.TYPE) {
                        WrapperPlayClientUseEntity packet = new WrapperPlayClientUseEntity(event.getPacket());
                        int entID = packet.getTarget();
                        if (running.containsKey(event.getPlayer().getUniqueId()) && packet.getType() == EntityUseAction.ATTACK) {
                            running.get(event.getPlayer().getUniqueId()).markAsKilled(entID);
                        }
                    }
                }

            });
    this.isRegistered = true;
}
 
开发者ID:TechzoneMC,项目名称:SimpleAntiAura,代码行数:18,代码来源:AntiAura.java

示例13: reload

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
public static void reload(CommandSender sender) {
    ChatItem obj = getInstance();
    obj.pm = ProtocolLibrary.getProtocolManager();
    obj.saveDefaultConfig();
    obj.reloadConfig();
    obj.storage = new Storage(obj.getConfig());
    obj.packetListener.setStorage(obj.storage);
    obj.packetValidator.setStorage(obj.storage);
    obj.chatEventListener.setStorage(obj.storage);
    obj.filter.setStorage(obj.storage);
    APIImplementation api = (APIImplementation) Bukkit.getServicesManager().getRegistration(ChatItemAPI.class).getProvider();
    api.setStorage(obj.storage);
    api.updateLogger();
    if (!obj.storage.RELOAD_MESSAGE.isEmpty())
        sender.sendMessage(obj.storage.RELOAD_MESSAGE);
}
 
开发者ID:dadus33,项目名称:ChatItem,代码行数:17,代码来源:ChatItem.java

示例14: onEnable

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
@Override
public void onEnable() {
    this.getServer().getPluginManager().registerEvents(this, this);
    protocolManager = ProtocolLibrary.getProtocolManager();

    Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
        @Override
        public void run() {
            if (Bukkit.getOnlinePlayers().size() != 0) {
                int index = 0;
                if (Bukkit.getOnlinePlayers().size() > 1) {
                    index = random.nextInt(Bukkit.getOnlinePlayers().size() - 1);
                }
                Player[] players = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
                Player p = players[index];
                checkPlayer(p, "");
            }
        }
    }, 20, 20 * 20);
    this.getCommand("sprawdz").setExecutor(this);
}
 
开发者ID:grzegorz2047,项目名称:ControlCheaters,代码行数:22,代码来源:ControlCheaters.java

示例15: sendAddPotionEffect

import com.comphenix.protocol.ProtocolLibrary; //导入依赖的package包/类
private void sendAddPotionEffect(Player p, PotionEffect effect) {
    PacketContainer packet = new PacketContainer(ENTITY_EFFECT);
    //noinspection deprecation
    int effectID = effect.getType().getId();
    int amplifier = effect.getAmplifier();
    int duration = effect.getDuration();
    int entityID = p.getEntityId();
    packet.getIntegers().write(0, entityID);
    packet.getBytes().write(0, (byte) effectID);
    packet.getBytes().write(1, (byte) amplifier);
    packet.getIntegers().write(1, duration);
    // hide particles in 1.9
    packet.getBytes().write(2, (byte) 0);
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(p, packet);
    } catch (InvocationTargetException e) {
        throw new RuntimeException("Cannot send packet", e);
    }
}
 
开发者ID:MyzelYam,项目名称:SuperVanish,代码行数:20,代码来源:NightVision.java


注:本文中的com.comphenix.protocol.ProtocolLibrary类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。