當前位置: 首頁>>代碼示例>>Java>>正文


Java Order.FIRST屬性代碼示例

本文整理匯總了Java中org.spongepowered.api.event.Order.FIRST屬性的典型用法代碼示例。如果您正苦於以下問題:Java Order.FIRST屬性的具體用法?Java Order.FIRST怎麽用?Java Order.FIRST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.spongepowered.api.event.Order的用法示例。


在下文中一共展示了Order.FIRST屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

@Listener(order=Order.FIRST)
public void init(GameInitializationEvent event) { instance = this; //myL=L.createLang(this);
	reload();

	Sponge.getServiceManager().setProvider(this, LanguageService.class, new LanguageServiceProvider());
	l("The LanguageService is now available!");
	
	Map<String, String> listMap = new HashMap<>();
	for (String al : available) listMap.put(al, al);
	Sponge.getCommandManager().register(this, CommandSpec.builder().arguments(GenericArguments.onlyOne(GenericArguments.choices(Text.of("Language"), listMap))).executor(new CommandExecutor() {
		@Override
		public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
			if (!(src instanceof Player)) { src.sendMessage(Text.of("Only available for players")); return CommandResult.success(); }
			Optional<String> la = args.<String>getOne("Language");
			if (!la.isPresent()) {
				src.sendMessage(Text.of(playerLang.get(((Player)src).getUniqueId()).toString()));
			} else {
				String lang = la.get();
				lang = lang.replace('_', '-'); //Locales toString used a underscore but the language tag requires a dash
				Locale locale = Locale.forLanguageTag(lang);
				playerChangedLang(((Player)src).getProfile(), locale);
			}
			return CommandResult.success();
		}
	}).build(), "language");
}
 
開發者ID:DosMike,項目名稱:LangSwitch,代碼行數:26,代碼來源:LangSwitch.java

示例2: joined

@Listener(order=Order.FIRST)
public void joined(ClientConnectionEvent.Join event) {
	Player player = event.getTargetEntity();
	
	Collection<ProfileProperty> props = player.getProfile().getPropertyMap().get("language");
	Locale checkload = null;
	for (ProfileProperty prop : props)
		if (prop.getName().equalsIgnoreCase("language")) { 
			playerLang.put(player.getProfile().getUniqueId(), checkload=Locale.forLanguageTag(prop.getValue().replace('_', '-')));
			break;
		}
	
	//use geo location in the future? player.getLocale seems to stick to en_US
	if (checkload==null)
		playerLang.put(player.getProfile().getUniqueId(), checkload=player.getLocale());
	
	loadLang(checkload);
}
 
開發者ID:DosMike,項目名稱:LangSwitch,代碼行數:18,代碼來源:LangSwitch.java

示例3: onClientLogin

@Listener(order = Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientLogin(ClientConnectionEvent.Login e) {
    /* Called when the player starts logging into the server.
       At this point, the users data should be present and loaded.
       Listening on LOW priority to allow plugins to further modify data here. (auth plugins, etc.) */

    final GameProfile player = e.getProfile();

    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLog().info("Processing login event for " + player.getUniqueId() + " - " + player.getName());
    }

    final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId()));

    /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */
    if (user == null) {
        this.deniedLogin.add(player.getUniqueId());

        this.plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login.");
        e.setCancelled(true);
        e.setMessageCancelled(false);
        //noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:26,代碼來源:SpongeConnectionListener.java

示例4: onPlayerLeftClickProtect

@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerLeftClickProtect(InteractBlockEvent.Primary.MainHand event, @First Player player)
{
	if (!player.gameMode().get().equals(GameModes.CREATIVE))
		return;

	Optional<Location<World>> optLoc = event.getTargetBlock().getLocation();
	if (!optLoc.isPresent())
		return;

	Optional<List<Shop>> shop = ShopsData.getShops(optLoc.get());
	if (shop.isPresent()) {
		Optional<ItemStack> optItem = player.getItemInHand(HandTypes.MAIN_HAND);

		if (!optItem.isPresent() || (!optItem.get().getItem().equals(ItemTypes.BEDROCK) && !optItem.get().getItem().equals(ItemTypes.REDSTONE) && !optItem.get().getItem().equals(ItemTypes.STICK))) {
			event.setCancelled(true);
		}
	}
}
 
開發者ID:TheoKah,項目名稱:CarrotShop,代碼行數:19,代碼來源:PlayerClickListener.java

示例5: onPlayerChangeBlock

@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerChangeBlock(ChangeBlockEvent.Pre event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	for (Location<World> loc : event.getLocations()) {
		if (!ConfigHandler.isWhitelisted("break", loc.getBlock().getId())
				&& !DataHandler.getPerm("build", player.getUniqueId(), loc))
		{
			event.setCancelled(true);
			try {
				player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
			} catch (Exception e) {}
			return;
		}
	}
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:23,代碼來源:BuildPermListener.java

示例6: onPlayerPlacesBlock

@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerPlacesBlock(ChangeBlockEvent.Place event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	event
	.getTransactions()
	.stream()
	.forEach(trans -> trans.getOriginal().getLocation().ifPresent(loc -> {
		if (!ConfigHandler.isWhitelisted("build", trans.getFinal().getState().getType().getId())
				&& !DataHandler.getPerm("build", player.getUniqueId(), loc))
		{
			trans.setValid(false);
			try {
				player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
			} catch (Exception e) {}
		}
	}));
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:25,代碼來源:BuildPermListener.java

示例7: onPlayerBreaksBlock

@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerBreaksBlock(ChangeBlockEvent.Break event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	event
	.getTransactions()
	.stream()
	.forEach(trans -> trans.getOriginal().getLocation().ifPresent(loc -> {
		if (!ConfigHandler.isWhitelisted("break", trans.getFinal().getState().getType().getId())
				&& !DataHandler.getPerm("build", player.getUniqueId(), loc))
		{
			trans.setValid(false);
			try {
				player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
			} catch (Exception e) {}
		}
	}));
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:25,代碼來源:BuildPermListener.java

示例8: onSignChanged

@Listener(order = Order.FIRST, beforeModifications = true)
public void onSignChanged(ChangeSignEvent event, @First User player)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetTile().getLocation().getExtent().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetTile().getLocation()))
	{
		event.setCancelled(true);
	}
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:16,代碼來源:BuildPermListener.java

示例9: onEntitySpawn

@Listener(order=Order.FIRST, beforeModifications = true)
public void onEntitySpawn(SpawnEntityEvent event, @First Player player, @First EntitySpawnCause entitySpawnCause)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	if (entitySpawnCause.getType() == SpawnTypes.PLACEMENT)
	{
		try {
			if (!DataHandler.getPerm("build", player.getUniqueId(), event.getEntities().get(0).getLocation()))
				event.setCancelled(true);
		} catch (IndexOutOfBoundsException e) {}
	}
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:19,代碼來源:BuildPermListener.java

示例10: onExplosion

@Listener(order=Order.FIRST, beforeModifications = true)
public void onExplosion(ExplosionEvent.Pre event)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (!DataHandler.getFlag("explosions", event.getExplosion().getLocation()))
	{
		event.setCancelled(true);
		/*event.setExplosion(Sponge.getRegistry().createBuilder(Explosion.Builder.class)
				.from(event.getExplosion())
				.canCauseFire(canCauseFire)
				.shouldBreakBlocks(canBreakBlocks)
				.build());*/
	}
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:17,代碼來源:ExplosionListener.java

示例11: onInteract

@Listener(order=Order.FIRST, beforeModifications = true)
public void onInteract(InteractBlockEvent event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.interact"))
	{
		return;
	}
	Optional<ItemStack> optItem = player.getItemInHand(HandTypes.MAIN_HAND);
	if (optItem.isPresent() && (ConfigHandler.isWhitelisted("use", optItem.get().getItem().getId()) || optItem.get().getItem().equals(ItemTypes.GOLDEN_AXE) && ConfigHandler.getNode("others", "enableGoldenAxe").getBoolean(true)))
		return;
	event.getTargetBlock().getLocation().ifPresent(loc -> {
		if (!DataHandler.getPerm("interact", player.getUniqueId(), loc))
		{
			event.setCancelled(true);
			if (loc.getBlockType() != BlockTypes.STANDING_SIGN && loc.getBlockType() != BlockTypes.WALL_SIGN)
				player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT));
		}
	});
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:23,代碼來源:InteractPermListener.java

示例12: onEntityDamagedByPlayer

@Listener(order=Order.FIRST, beforeModifications = true)
public void onEntityDamagedByPlayer(DamageEntityEvent event, @All(ignoreEmpty=false) EntityDamageSource[] sources)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetEntity().getWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	Entity attacker = null;
	for (int i = 0; i < sources.length; i++)
	{
		if (sources[i].getSource().getType() == EntityTypes.PLAYER
				|| (sources[i] instanceof IndirectEntityDamageSource && ((IndirectEntityDamageSource) sources[i]).getIndirectSource().getType() == EntityTypes.PLAYER))
		{
			attacker = sources[i].getSource();
		}
	}
	if (attacker != null && event.getTargetEntity().getType() == EntityTypes.PLAYER)
	{
		if (!DataHandler.getFlag("pvp", attacker.getLocation()) || !DataHandler.getFlag("pvp", event.getTargetEntity().getLocation()))
		{
			event.setCancelled(true);
			return;
		}
	}
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:25,代碼來源:PvpListener.java

示例13: onPlayerJoin

@Listener(order=Order.FIRST)
public void onPlayerJoin(final ClientConnectionEvent.Join event) {		
	EPlayer player = this.plugin.getEServer().getEPlayer(event.getTargetEntity());
	
	// Corrige bug
	player.sendTitle(Title.CLEAR);
	player.getTabList().setHeaderAndFooter(null, null);
	
	this.plugin.getManagerService().getEScoreBoard().addPlayer(player);

	// Newbie
	if (player.getFirstDatePlayed() == player.getLastDatePlayed()) {
		player.setSpawnNewbie(true);
		player.setTransform(player.getSpawn());
	}
}
 
開發者ID:EverCraft,項目名稱:EverAPI,代碼行數:16,代碼來源:EAListener.java

示例14: onChangeBlock

@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onChangeBlock(ChangeBlockEvent.Place event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	event.getTransactions().forEach(transaction -> {
		player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Type: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getState().getId()));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Owner: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getCreator()));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Notifier: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getNotifier()));
	});
}
 
開發者ID:EverCraft,項目名稱:EverAPI,代碼行數:18,代碼來源:EAInfo.java

示例15: onInteractBlock

@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onInteractBlock(InteractBlockEvent.Primary event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Type: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getState().getId()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Owner: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getCreator()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Notifier: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getNotifier()));
}
 
開發者ID:EverCraft,項目名稱:EverAPI,代碼行數:16,代碼來源:EAInfo.java


注:本文中的org.spongepowered.api.event.Order.FIRST屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。