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


Java ListenerPriority类代码示例

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


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

示例1: listenPackets

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的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: onEnable

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

示例3: MOTDPacketListener

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
public MOTDPacketListener(Main plugin, ProtocolManager pm) throws Throwable {
    this.plugin = plugin;
    this.pm = pm;

    this.sendingWhitelist = ListeningWhitelist.newBuilder()
            .priority(ListenerPriority.NORMAL)
            .types(PacketType.Status.Server.OUT_SERVER_INFO) //监听PacketStatusOutServerInfo包
            .gamePhase(GamePhase.LOGIN)
            .options(new ListenerOptions[]{ListenerOptions.ASYNC})
            .build();
    this.receivingWhitelist = ListeningWhitelist.newBuilder()
            .priority(ListenerPriority.NORMAL)
            .types(PacketType.Status.Client.IN_PING) //监听PacketStatusInPing包
            .gamePhase(GamePhase.LOGIN)
            .options(new ListenerOptions[]{ListenerOptions.ASYNC})
            .build();
    new Timer("ColorMOTDAnimThread", true).scheduleAtFixedRate(this, 0, config.globalFrameRate);
}
 
开发者ID:andylizi,项目名称:AnimColorMOTD,代码行数:19,代码来源:MOTDPacketListener.java

示例4: init

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
@Override
public void init(Plugin plugin) {
	ProtocolLibrary.getProtocolManager().addPacketListener(
			new PacketAdapter(PacketAdapter
					.params(plugin, PacketType.Play.Server.SET_SLOT,
							PacketType.Play.Server.WINDOW_ITEMS)
							.serverSide().listenerPriority(ListenerPriority.HIGH)) {

				@Override
				public void onPacketSending(PacketEvent event) {
					if (event.getPacketType().equals(PacketType.Play.Server.SET_SLOT)) {
						addGlow(new ItemStack[] { event.getPacket().getItemModifier().read(0) });
					} else {
						addGlow(event.getPacket().getItemArrayModifier().read(0));
					}
				}
			});
	
	_signManager = new ProtocolLibSignGUI(plugin);
	
	Bukkit.getServicesManager().register(SignGUI.class, _signManager, plugin, ServicePriority.Highest);
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:23,代码来源:ProtocolLibUtilImplementation.java

示例5: enable

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
public void enable() {
	ProtocolLibrary.getProtocolManager().addPacketListener(
			new PacketAdapter(plugin, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, new Integer[] {
					Integer.valueOf(130) 
			})
			{
				public void onPacketSending(PacketEvent event) {
					if (event.getPacketID() == 130)
						try {
							event.setPacket(modify(event.getPacket(), event.getPlayer().getName()));
						} catch (FieldAccessException e) {
							plugin.getLogger().log(Level.SEVERE, "Couldn't access field.", e);
						}
				}
			});
	log("Enabled");
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:18,代码来源:JailSigns.java

示例6: registerPacketListeners

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
public void registerPacketListeners() {
	final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
	for (PacketType packetType : new PacketType[] { PacketType.Play.Client.POSITION }) {
		protocolManager
				.addPacketListener(new PacketAdapter(Crescent.getInstance(), ListenerPriority.NORMAL, packetType) {
					@Override
					public void onPacketReceiving(PacketEvent event) {
						if (event.getPacketType() == packetType) {
							Bukkit.getPluginManager()
									.callEvent(new PlayerPacketEvent(event.getPlayer(), event.getPacket()));
						}
					}
				});
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:16,代码来源:BehaviourListeners.java

示例7: SignLoginWindow

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
public SignLoginWindow(ProtocolManager protocolManager, Plugin plugin) {
	super(protocolManager, plugin);
	protocolManager.addPacketListener(
			new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.UPDATE_SIGN) {
				@Override
				public void onPacketReceiving(PacketEvent event) {
					if (event.getPacketType() != PacketType.Play.Client.UPDATE_SIGN) {
						return;
					}
					if (AuthMeApi.getInstance().isAuthenticated(event.getPlayer())) {
						return;
					}
					PacketContainer packet = event.getPacket();
					String[] strings = packet.getStringArrays().read(0);
					if (strings[Variables.signLoginLine - 1].isEmpty()) {
						return;
					}
					boolean registered = AuthMeApi.getInstance().isRegistered(event.getPlayer().getName());
					String password = strings[Variables.signLoginLine - 1].substring(SignLoginWindow.this
							.getInfoFor(event.getPlayer(), Variables.signInfo.get(Variables.signLoginLine - 1))
							.length());
					if (!registered & !password.isEmpty()) {
						AuthMeApi.getInstance().registerPlayer(event.getPlayer().getName(), password);
					}
					Bukkit.getPluginCommand("login").execute(event.getPlayer(), "login", new String[] { password });
				}
			});
}
 
开发者ID:lj2000lj,项目名称:AuthMeGUI,代码行数:29,代码来源:SignLoginWindow.java

示例8: hook

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
/**
 * Hooks ProtocolLibrary into a {@link JavaPlugin}.
 *
 * @param kairos
 *            the plugin to hook into
 */
public static void hook(HCF kairos) {
    ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
    protocolManager.addPacketListener(new PacketAdapter(kairos, ListenerPriority.NORMAL, PacketType.Play.Client.BLOCK_DIG) {
        @Override
        public void onPacketReceiving(PacketEvent event) {
            PacketContainer packet = event.getPacket();
            StructureModifier<Integer> modifier = packet.getIntegers();
            Player player = event.getPlayer();

            try {
                int status = modifier.read(4);
                // int face = modifier.read(3);
                if (status == STARTED_DIGGING || status == FINISHED_DIGGING) {
                    int x, y, z;
                    Location location = new Location(player.getWorld(), x = modifier.read(0), y = modifier.read(1), z = modifier.read(2));

                    // Validation
                    VisualBlock visualBlock = kairos.getVisualiseHandler().getVisualBlockAt(player, location);
                    if (visualBlock == null)
                        return;

                    event.setCancelled(true);
                    VisualBlockData data = visualBlock.getBlockData();
                    if (status == FINISHED_DIGGING) {
                        player.sendBlockChange(location, data.getBlockType(), data.getData());
                    } else if (status == STARTED_DIGGING) { // we check this because Blocks that broke pretty much straight away do not send a FINISHED for some weird reason.
                        EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
                        if (player.getGameMode() == GameMode.CREATIVE
                                || net.minecraft.server.v1_7_R4.Block.getById(data.getItemTypeId()).getDamage(entityPlayer, entityPlayer.world, x, y, z) > 1.0F) {

                            player.sendBlockChange(location, data.getBlockType(), data.getData());
                        }
                    }
                }
            } catch (FieldAccessException ignored) {
            }
        }
    });
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:46,代码来源:ProtocolLibHook.java

示例9: AntiBypassThread

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
public AntiBypassThread() {
	ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL,
			PacketType.Play.Client.LOOK, PacketType.Play.Client.POSITION_LOOK) {
		@Override
		public void onPacketReceiving(PacketEvent event) {
			PacketContainer packet = event.getPacket();
			float yaw = packet.getFloat().read(0);
			updatePlayer(event.getPlayer().getUniqueId(), yaw);
		}
	});
}
 
开发者ID:TealNerd,项目名称:RadarJammer,代码行数:12,代码来源:VisibilityManager.java

示例10: ChatPacketListener

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
public ChatPacketListener(Plugin plugin, ListenerPriority listenerPriority, Storage s, PacketType... types) {
    super(plugin, listenerPriority, types);
    if(ChatItem.supportsShulkerBoxes()){
        SHULKER_BOXES.addAll(Arrays.asList(Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX,
                Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX,
                Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX,
                Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.SILVER_SHULKER_BOX,
                Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX));
    }
    c = s;
}
 
开发者ID:dadus33,项目名称:ChatItem,代码行数:12,代码来源:ChatPacketListener.java

示例11: listenForPackets

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
private void listenForPackets()
{
	this.packetAdapter = new PacketAdapter(AnimulusLib.getInstance().getPlugin(), ListenerPriority.NORMAL,
			PacketType.Play.Client.USE_ENTITY)
	{
		@Override public void onPacketReceiving(PacketEvent packetEvent)
		{
			// taken from PacketWrapper
			EntityUseAction action = packetEvent.getPacket().getEntityUseActions().read(0);
			if(action == EntityUseAction.INTERACT_AT)
				return;

			Player player = packetEvent.getPlayer();
			int entityId = packetEvent.getPacket().getIntegers().read(0);
			StateNPC npc = AnimulusLib.getNPCManager().getNPC(entityId);

			// clicked actual player
			if(npc == null)
				return;

			if(action == EntityUseAction.INTERACT)
				npc.playerRightClick(player);
			else
				npc.playerLeftClick(player);
		}
	};

	ProtocolLibrary.getProtocolManager().addPacketListener(this.packetAdapter);
}
 
开发者ID:domisum,项目名称:AnimulusLib,代码行数:30,代码来源:NPCInteractPacketListener.java

示例12: onEnable

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
@Override
public void onEnable() {
    ProtocolLibrary.getProtocolManager().addPacketListener(
            new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO) {
                @Override
                public void onPacketSending(PacketEvent event) {
                    // multiple events share same packet object
                    event.setPacket(event.getPacket().shallowClone());
                    List<PlayerInfoData> infoDataList = new ArrayList<>(
                            event.getPacket().getPlayerInfoDataLists().read(0));
                    Player receiver = event.getPlayer();
                    for (PlayerInfoData infoData : ImmutableList.copyOf(infoDataList)) {
                        if (!VanishIndication.this.plugin.getVisibilityChanger().getHider()
                                .isHidden(infoData.getProfile().getUUID(), receiver)
                                && VanishIndication.this.plugin.getVanishStateMgr()
                                .isVanished(infoData.getProfile().getUUID())) {
                            if (!receiver.getUniqueId().equals(infoData.getProfile().getUUID()))
                                if (infoData.getGameMode() != EnumWrappers.NativeGameMode.SPECTATOR) {
                                    int latency;
                                    try {
                                        latency = infoData.getLatency();
                                    } catch (NoSuchMethodError e) {
                                        latency = 21;
                                    }
                                    if (event.getPacket().getPlayerInfoAction().read(0)
                                            != EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE) {
                                        continue;
                                    }
                                    PlayerInfoData newData = new PlayerInfoData(infoData.getProfile(),
                                            latency, EnumWrappers.NativeGameMode.SPECTATOR,
                                            infoData.getDisplayName());
                                    infoDataList.remove(infoData);
                                    infoDataList.add(newData);
                                }
                        }
                    }
                    event.getPacket().getPlayerInfoDataLists().write(0, infoDataList);
                }
            });
}
 
开发者ID:MyzelYam,项目名称:SuperVanish,代码行数:41,代码来源:VanishIndication.java

示例13: getSendingWhitelist

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
@Override
public ListeningWhitelist getSendingWhitelist() {
	return ListeningWhitelist.newBuilder().
		priority(ListenerPriority.LOW).
		types(PacketType.Play.Server.SPAWN_ENTITY).
		gamePhase(GamePhase.BOTH).
		options(new ListenerOptions[0]).
		build();
}
 
开发者ID:Howaner,项目名称:FramePicture,代码行数:10,代码来源:FramePacketListener.java

示例14: getReceivingWhitelist

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
@Override
public ListeningWhitelist getReceivingWhitelist() {
	return ListeningWhitelist.newBuilder().
			priority(ListenerPriority.NORMAL).
			types(PacketType.Play.Client.USE_ENTITY).
			gamePhase(GamePhase.PLAYING).
			options(new ListenerOptions[0]).
			build();
}
 
开发者ID:Howaner,项目名称:FakeMobs,代码行数:10,代码来源:ProtocolListener.java

示例15: onPacketEvent

import com.comphenix.protocol.events.ListenerPriority; //导入依赖的package包/类
public static void onPacketEvent(PacketType packetType, Consumer<PacketEvent> handler) {
    onPacketEvent(packetType, ListenerPriority.NORMAL, handler);
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:4,代码来源:PacketManager.java


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