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


Java EnumWrappers类代码示例

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


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

示例1: playParticles

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的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

示例2: onPacketReceiving

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
@Override
public void onPacketReceiving(PacketEvent packetEvent) {
    Player p = packetEvent.getPlayer();
    PacketContainer packet = packetEvent.getPacket();
    if (packet.getType().equals(PacketType.Play.Client.USE_ENTITY)) {
        UUID u = tagMap.get(packet.getIntegers().read(0));
        if (u == null) return;
        Entity e = p.getNearbyEntities(8, 8, 8).stream().filter(entity -> entity.getUniqueId().equals(u)).findAny
                ().orElse(null);
        if (e == null) return;
        if (!HitboxUtil.isLookingAt(p, e)) return;
        packet.getIntegers().write(0, e.getEntityId());
        if (e.getType() == EntityType.ARMOR_STAND)
            packet.getEntityUseActions().write(0, EnumWrappers.EntityUseAction.ATTACK);
    }
}
 
开发者ID:iso2013,项目名称:MultiLineAPI,代码行数:17,代码来源:PacketListener.java

示例3: respawnPlayer

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
private static void respawnPlayer(Player player) {
    PacketManager.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER), SkinManager.class, player);
    PacketManager.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.ADD_PLAYER), SkinManager.class, player);

    Location playerLoc = new WorldLockedLocation(player.getLocation());
    Logging.debug(SkinManager.class, "playerLoc1 = " + playerLoc);
    try {
        Logging.debug(SkinManager.class, "DEDICATED_PLAYER_LIST_MOVE_TO_WORLD: " + DEDICATED_PLAYER_LIST_MOVE_TO_WORLD);
        Logging.debug(SkinManager.class, "NMS_SERVER: " + DEDICATED_PLAYER_LIST_MOVE_TO_WORLD);
        Logging.debug(SkinManager.class, "DEDICATED_PLAYER_LIST_MOVE_TO_WORLD: " + DEDICATED_PLAYER_LIST_MOVE_TO_WORLD);
        DEDICATED_PLAYER_LIST_MOVE_TO_WORLD.invoke(Reflection.NMS_SERVER, CRAFT_PLAYER_GET_HANDLE.invoke(player), convertDimension(player.getWorld().getEnvironment()), true, playerLoc, true);
    } catch (Exception e) {
        Logging.debug(SkinManager.class, "Failed to make player see his skin change: " + player.getName());
        Logging.reportException(SkinManager.class, e);
    }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:17,代码来源:SkinManager.java

示例4: showPlayer

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
public void showPlayer(Player player) {
    if (!tabs.isPresent()) {
        tabs = Optional.of(new HashMap<>());
        tabs.ifPresent(map -> {
            for (Player player1 : Bukkit.getOnlinePlayers()) {
                map.put(player1, Optional.empty());
            }
        });
    }
    tabs.ifPresent(map -> map.computeIfPresent(player, (__, tabOptional) -> {
        if (!tabOptional.isPresent()) {
            PacketManager.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.ADD_PLAYER), PlayerTablist.class, tablist.target);
            return null;
        }
        return tabOptional;
    }));
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:18,代码来源:PlayerTablist.java

示例5: clearModifications

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
public void clearModifications() {
    MundoUtil.consumeOptional(tabs, map -> {
        map.forEach((player, tabOptional) -> {
            MundoUtil.consumeOptional(tabOptional, tab -> {
                if (tab.getDisplayName() != null) {
                    tab.setDisplayName(null);
                }
                if (tab.getLatency() != null) {
                    tab.setLatency(null);
                }
                if (tab.getScore() != null) {
                    tab.setScore(null);
                }
            }, () -> PacketManager.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.ADD_PLAYER), this, tablist.target));
        });
        map.clear();
    }, this::showAllPlayers);
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:19,代码来源:PlayerTablist.java

示例6: UseEntity

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
@EventHandler
public void UseEntity(PacketUseEntityEvent e) {
    if (e.getAction() != EnumWrappers.EntityUseAction.ATTACK) {
        return;
    }
    if (!(e.getAttacked() instanceof Player)) {
        return;
    }
    Player player = e.getAttacker();
    int Count = 0;
    long Time = System.currentTimeMillis();
    if (this.attackTicks.containsKey(player.getUniqueId())) {
        Count = this.attackTicks.get(player.getUniqueId()).getKey();
        Time = this.attackTicks.get(player.getUniqueId()).getValue();
    }
    ++Count;
    if (this.attackTicks.containsKey(player.getUniqueId()) && UtilTime.elapsed(Time, 1000)) {
        if (Count > 19) {
            this.getJanitor().logCheat(this, player, null, String.valueOf(Count) + " ap/s");
        }
        Count = 0;
        Time = UtilTime.nowlong();
    }
    this.attackTicks.put(player.getUniqueId(), new AbstractMap.SimpleEntry<Integer, Long>(Count, Time));
}
 
开发者ID:cumpe,项目名称:Janitor,代码行数:26,代码来源:AttackSpeed.java

示例7: sendPlayerInfoChangeGameModePacket

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
private void sendPlayerInfoChangeGameModePacket(Player p, Player change, boolean spectator) {
    PacketContainer packet = new PacketContainer(PLAYER_INFO);
    packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
    List<PlayerInfoData> data = new ArrayList<>();
    int ping = ThreadLocalRandom.current().nextInt(20) + 15;
    data.add(new PlayerInfoData(WrappedGameProfile.fromPlayer(change), ping,
            spectator ? EnumWrappers.NativeGameMode.SPECTATOR
                    : EnumWrappers.NativeGameMode.fromBukkit(change.getGameMode()),
            WrappedChatComponent.fromText(change.getPlayerListName())));
    packet.getPlayerInfoDataLists().write(0, data);
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(p, packet);
    } catch (InvocationTargetException e) {
        throw new RuntimeException("Cannot send packet", e);
    }
}
 
开发者ID:MyzelYam,项目名称:SuperVanish,代码行数:17,代码来源:VanishIndication.java

示例8: playerInfoPacket

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
public static PacketContainer playerInfoPacket(
        String displayName,
        Integer latency,
        GameMode gameMode,
        String name,
        UUID uuid,
        Skin skin,
        EnumWrappers.PlayerInfoAction action
) {
    PacketContainer result = new PacketContainer(PLAYER_INFO);
    WrappedGameProfile profile = new WrappedGameProfile(uuid, name);
    if (action == EnumWrappers.PlayerInfoAction.ADD_PLAYER) {
        if (skin == null) {
            skin = Tablist.DEFAULT_SKIN_TEXTURE;
        }
        profile.getProperties().put(Skin.MULTIMAP_KEY, skin.toWrappedSignedProperty());
    }
    PlayerInfoData playerInfoData = new PlayerInfoData(
            profile,
            Optional.ofNullable(latency).map(PacketUtil::getPossibleLatency).orElse(0),
            Optional.ofNullable(gameMode).map(EnumWrappers.NativeGameMode::fromBukkit).orElse(EnumWrappers.NativeGameMode.NOT_SET),
            WrappedChatComponent.fromText(Optional.ofNullable(displayName).orElse(""))
    );
    result.getPlayerInfoDataLists().writeSafely(0, Collections.singletonList(playerInfoData));
    result.getPlayerInfoAction().writeSafely(0, action);
    return result;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:28,代码来源:PacketUtil.java

示例9: scorePacket

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
public static PacketContainer scorePacket(String scoreName, String objectiveName, Integer score, EnumWrappers.ScoreboardAction action) {
    PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_SCORE);
    packet.getStrings().writeSafely(0, scoreName);
    packet.getStrings().writeSafely(1, objectiveName);
    packet.getIntegers().writeSafely(0, Optional.ofNullable(score).orElse(0));
    packet.getScoreboardActions().writeSafely(0, action);
    return packet;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:9,代码来源:PacketUtil.java

示例10: addTabs

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
private void addTabs(int columnMin, int columnMax, int rowMin, int rowMax) {
    Logging.debug(this, "Adding Tabs, columnMin = " + columnMin + ", columnMax = " + columnMax + ", rowMin = " + rowMin + ", rowMax = " + rowMax);
    for (int column = columnMin; column <= columnMax; column++)
        for (int row = rowMin; row <= rowMax; row++) {
            Logging.debug(this, "Adding Tab, column = " + column + ", row = " + row);
            Tab tab = createTab(column, row);
            tab.sendPacket(tab.playerInfoPacket(EnumWrappers.PlayerInfoAction.ADD_PLAYER));
            setTab(column, row, tab);
        }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:11,代码来源:ArrayTablist.java

示例11: removeTabs

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
private void removeTabs(int columnMin, int columnMax, int rowMin, int rowMax) {
    Logging.debug(this, "Removing Tabs, columnMin = " + columnMin + ", columnMax = " + columnMax + ", rowMin = " + rowMin + ", rowMax = " + rowMax);
    for (int column = columnMin; column <= columnMax; column++)
        for (int row = rowMin; row <= rowMax; row++) {
            Logging.debug(this, "Removing Tab, column = " + column + ", row = " + row);
            Tab tab = getTab(column, row);
            tab.sendPacket(tab.playerInfoPacket(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER));
            tab.setScore(null);
            setTab(column, row, null);
        }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:12,代码来源:ArrayTablist.java

示例12: hidePlayer

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
public void hidePlayer(Player player) {
    tabs.ifPresent(map -> map.compute(player, (__, tabOptional) -> {
        if (tabOptional == null || tabOptional.isPresent()) {
            PacketManager.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER), this, tablist.target);
        }
        return Optional.empty();
    }));
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:9,代码来源:PlayerTablist.java

示例13: hideAllPlayers

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
public void hideAllPlayers() {
    tabs.ifPresent(map -> {
        for (Player player : Bukkit.getOnlinePlayers()) {
            Optional<Tab> playerTabOptional = map.get(player);
            if (playerTabOptional == null || playerTabOptional.isPresent()) {
                PacketManager.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER), this, tablist.target);
            }
        }
        tabs = Optional.empty();
    });
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:12,代码来源:PlayerTablist.java

示例14: createTab

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
public Tab createTab(String id, String displayName, Integer latency, Skin icon, Integer score) {
    if (id == null || id.length() > 12) {
        throw new IllegalArgumentException("Invalid id = " + id);
    }
    return tabs.compute(id, (__, oldTab) -> {
        if (oldTab != null) {
            oldTab.sendPacket(oldTab.playerInfoPacket(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER));
        }
        Tab newTab = new Tab(tablist.target, id + "-MSK", UUID.nameUUIDFromBytes(("MundoSKTablist::" + id).getBytes(UTF_8)), displayName, latency, icon, score);
        newTab.sendPacket(newTab.playerInfoPacket(EnumWrappers.PlayerInfoAction.ADD_PLAYER));
        return newTab;
    });
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:14,代码来源:SimpleTablist.java

示例15: UseEntity

import com.comphenix.protocol.wrappers.EnumWrappers; //导入依赖的package包/类
@EventHandler
public void UseEntity(PacketUseEntityEvent e) {
    if (e.getAction() != EnumWrappers.EntityUseAction.ATTACK) {
        return;
    }
    if (!(e.getAttacked() instanceof Player)) {
        return;
    }
    Player damager = e.getAttacker();
    Long first = 0;
    Long second =  0;
    if (this.LastMSCPS.containsKey(damager.getUniqueId())) {
        first = this.LastMSCPS.get(damager.getUniqueId())[0];
        second = this.LastMSCPS.get(damager.getUniqueId())[1];
    }
    if (first == 0) {
        first = System.currentTimeMillis();
    } else if (second == 0) {
        second = System.currentTimeMillis();
        first = System.currentTimeMillis() - first;
    } else {
        second = System.currentTimeMillis() - second;
        if (first > 50 && second == 0) {
            this.getJanitor().logCheat(this, damager, null, new String[0]);
        }
        first = 0;
        second = 0;
    }
    this.LastMSCPS.put(damager.getUniqueId(), new Long[]{first, second});
}
 
开发者ID:cumpe,项目名称:Janitor,代码行数:31,代码来源:DoubleClick.java


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