本文整理匯總了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");
}
示例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);
}
示例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())));
}
}
示例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);
}
}
}
示例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;
}
}
}
示例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) {}
}
}));
}
示例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) {}
}
}));
}
示例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);
}
}
示例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) {}
}
}
示例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());*/
}
}
示例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));
}
});
}
示例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;
}
}
}
示例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());
}
}
示例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()));
});
}
示例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()));
}