本文整理匯總了Java中org.spongepowered.api.event.Order類的典型用法代碼示例。如果您正苦於以下問題:Java Order類的具體用法?Java Order怎麽用?Java Order使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Order類屬於org.spongepowered.api.event包,在下文中一共展示了Order類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMessageChannelChat
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@Listener(order = Order.LATE)
public void onMessageChannelChat(MessageChannelEvent.Chat event) {
if (event.isCancelled()) {
return;
}
Optional<Player> playerOpt = event.getCause().first(Player.class);
if (!playerOpt.isPresent()) {
return;
}
Player player = playerOpt.get();
ClanPlayerImpl clanPlayer = ClansImpl.getInstance().getClanPlayer(player.getUniqueId());
if (clanPlayer != null && clanPlayer.getClan() != null) {
PlayerChatState chatState = clanPlayer.getChatState();
PlayerChatState tempChatState = clanPlayer.getTempChatState();
if (tempChatState == null) {
handleChat(player, clanPlayer, chatState, event);
} else {
handleChat(player, clanPlayer, tempChatState, event);
clanPlayer.setTempChatState(null);
}
}
}
示例2: onDamageEntity
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@Listener(order = Order.LATE)
public void onDamageEntity(DamageEntityEvent event) {
if (event.isCancelled()) {
return;
}
if (!(event.getTargetEntity() instanceof Player)) {
return;
}
Optional<Player> damagerOpt = event.getCause().first(Player.class);
if (!damagerOpt.isPresent()) {
return;
}
Player victim = (Player) event.getTargetEntity();
Player damager = damagerOpt.get();
ClanPlayerImpl victimClanPlayer = ClansImpl.getInstance().getClanPlayer(victim.getUniqueId());
if (victimClanPlayer == null) {
victimClanPlayer = ClansImpl.getInstance().createClanPlayer(victim.getUniqueId(), victim.getName());
}
victimClanPlayer.setLastPlayerDamage(damager.getUniqueId());
}
示例3: onLiquidFlow
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@Listener(order = Order.POST)
public void onLiquidFlow(ChangeBlockEvent.Pre e) {
if (e.getLocations().isEmpty()) return;
Location<World> loc = e.getLocations().get(0);
BlockSnapshot snapshot = loc.getExtent().createSnapshot(loc.getBlockPosition());
Optional<MatterProperty> matter = snapshot.getState().getProperty(MatterProperty.class);
if (matter.isPresent() && matter.get().getValue() == Matter.LIQUID) {
String name = "Water";
BlockType type = snapshot.getState().getType();
if (type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA)
name = "Lava";
db.addToQueue(new BlockQueueEntry(snapshot, ActionType.FLOW, name, new Date().getTime()));
}
}
示例4: init
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@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");
}
示例5: joined
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@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);
}
示例6: onClientAuthMonitor
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@Listener(order = Order.LAST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientAuthMonitor(ClientConnectionEvent.Auth e) {
/* Listen to see if the event was cancelled after we initially handled the connection
If the connection was cancelled here, we need to do something to clean up the data that was loaded. */
// Check to see if this connection was denied at LOW.
if (this.deniedAsyncLogin.remove(e.getProfile().getUniqueId())) {
// This is a problem, as they were denied at low priority, but are now being allowed.
if (e.isCancelled()) {
this.plugin.getLog().severe("Player connection was re-allowed for " + e.getProfile().getUniqueId());
e.setCancelled(true);
}
}
}
示例7: onClientLogin
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@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())));
}
}
示例8: onMessageChannelEventChat
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@Listener(order = Order.LAST)
public void onMessageChannelEventChat(MessageChannelEvent.Chat event, @First Player player) {
String mode = ConfigManager.get().getConfig().getNode("mode").getString();
Text tag;
if (mode.equalsIgnoreCase("default")) {
tag = defaultTag(player);
} else if (mode.equalsIgnoreCase("advanced")) {
tag = advancedTag(player);
} else {
return;
}
MessageFormatter formatter = event.getFormatter();
Text prefix = Text.join(tag, formatter.getHeader().toText());
formatter.setHeader(TextTemplate.of(prefix));
}
示例9: onPlayerRightClick
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@Listener(order=Order.AFTER_PRE, beforeModifications = true)
public void onPlayerRightClick(InteractBlockEvent.Secondary.MainHand event, @First Player player)
{
Optional<Location<World>> optLoc = event.getTargetBlock().getLocation();
if (!optLoc.isPresent())
return;
Optional<List<Shop>> shops = ShopsData.getShops(optLoc.get());
if (shops.isPresent()) {
shops.get().forEach((shop) -> {
if (shop.getLocation().equals(optLoc.get())) {
shop.trigger(player);
Sponge.getScheduler().createTaskBuilder().delayTicks(4).execute(
task -> {
shop.update();
task.cancel();
}).submit(CarrotShop.getInstance());
}
});
}
}
示例10: onPlayerLeftClickProtect
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@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);
}
}
}
示例11: onPlayerChangeBlock
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@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;
}
}
}
示例12: onPlayerPlacesBlock
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@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) {}
}
}));
}
示例13: onPlayerBreaksBlock
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@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) {}
}
}));
}
示例14: onSignChanged
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@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);
}
}
示例15: onEntitySpawn
import org.spongepowered.api.event.Order; //導入依賴的package包/類
@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) {}
}
}