本文整理匯總了Java中org.spongepowered.api.event.Order.EARLY屬性的典型用法代碼示例。如果您正苦於以下問題:Java Order.EARLY屬性的具體用法?Java Order.EARLY怎麽用?Java Order.EARLY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.spongepowered.api.event.Order
的用法示例。
在下文中一共展示了Order.EARLY屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onFire
@Listener(order=Order.EARLY, beforeModifications = true)
public void onFire(ChangeBlockEvent event)
{
if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
{
return;
}
event
.getTransactions()
.stream()
.filter(trans -> trans.getFinal().getState().getType() == BlockTypes.FIRE)
.filter(trans -> {
Optional<Location<World>> optLoc = trans.getFinal().getLocation();
if (!optLoc.isPresent())
return false;
return !DataHandler.getFlag("fire", optLoc.get());
})
.forEach(trans -> trans.setValid(false));
}
示例2: onWorldLoad
@Listener(order = Order.EARLY, beforeModifications = true)
public void onWorldLoad(LoadWorldEvent event) {
if (!SpongeImpl.getServer().isServerRunning() || !GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetWorld().getProperties())) {
return;
}
GPTimings.WORLD_LOAD_EVENT.startTimingIfSync();
GriefPreventionPlugin.instance.dataStore.loadWorldData(event.getTargetWorld());
net.minecraft.world.World world = (net.minecraft.world.World) event.getTargetWorld();
world.addEventListener(new EntityRemovalListener());
GPTimings.WORLD_LOAD_EVENT.stopTimingIfSync();
if (!GriefPreventionPlugin.getActiveConfig(event.getTargetWorld().getProperties()).getConfig().claim.bankTaxSystem) {
return;
}
if (GriefPreventionPlugin.instance.economyService.isPresent()) {
// run tax task
TaxApplyTask taxTask = new TaxApplyTask(event.getTargetWorld().getProperties());
int taxHour = GriefPreventionPlugin.getActiveConfig(event.getTargetWorld().getProperties()).getConfig().claim.taxApplyHour;
long delay = TaskUtils.computeDelay(taxHour, 0, 0);
Sponge.getScheduler().createTaskBuilder().async().delay(delay, TimeUnit.SECONDS).interval(1, TimeUnit.DAYS).execute(taxTask).submit(GriefPreventionPlugin.instance);
}
}
示例3: onGamePreInitialization
@Listener(order = Order.EARLY)
public void onGamePreInitialization(@Nonnull final GamePreInitializationEvent event) {
if (this.configProfilesFile == null) {
LOGGER.error("Failed to properly load configuration profiles.", new IllegalStateException());
return;
}
this.configProfiles.clear();
for (final Map.Entry<Object, ? extends ConfigurationNode> entry : this.configProfilesFile.getNode().getChildrenMap().entrySet()) {
if (!entry.getValue().hasMapChildren()) {
continue;
}
final String key = "" + entry.getKey();
final ConfigurationNode config = entry.getValue();
final ConfigProfile profile = ConfigProfile.parse(key, config);
if (profile == null) {
continue;
}
LOGGER.info("Found \"{}\" profile, using \"{}\".", key,
profile.getStorage().getStorageType().toString());
this.configProfiles.put(key, profile);
}
if (!this.hasConfigProfile("default")) {
LOGGER.warn("Couldn't find a \"default\" configuration profile.");
}
}
示例4: onInteractItemPrimary
@Listener(order = Order.EARLY)
public void onInteractItemPrimary(InteractItemEvent.Primary event, @First Player player)
{
String name = "";
Optional<VirtualChestInventory> inventoryOptional = Optional.empty();
for (String inventoryName : this.dispatcher.listInventories())
{
VirtualChestInventory inventory = this.dispatcher.getInventory(inventoryName).get();
if (inventory.matchItemForOpeningWithPrimaryAction(event.getItemStack()))
{
if (player.hasPermission("virtualchest.open.self." + inventoryName))
{
name = inventoryName;
inventoryOptional = Optional.of(inventory);
event.setCancelled(true);
break;
}
}
}
if (inventoryOptional.isPresent())
{
try
{
this.logger.debug("Player {} tries to create the GUI ({}) by primary action", player.getName(), name);
SpongeUnimplemented.openInventory(player, inventoryOptional.get().createInventory(player), this);
}
catch (InvalidDataException e)
{
this.logger.error("There is something wrong with the GUI configuration (" + name + ")", e);
}
}
}
示例5: onInteractItemSecondary
@Listener(order = Order.EARLY)
public void onInteractItemSecondary(InteractItemEvent.Secondary event, @First Player player)
{
String name = "";
Optional<VirtualChestInventory> inventoryOptional = Optional.empty();
for (String inventoryName : this.dispatcher.listInventories())
{
VirtualChestInventory inventory = this.dispatcher.getInventory(inventoryName).get();
if (inventory.matchItemForOpeningWithSecondaryAction(event.getItemStack()))
{
if (player.hasPermission("virtualchest.open.self." + inventoryName))
{
name = inventoryName;
inventoryOptional = Optional.of(inventory);
event.setCancelled(true);
break;
}
}
}
if (inventoryOptional.isPresent())
{
try
{
this.logger.debug("Player {} tries to create the GUI ({}) by secondary action", player.getName(), name);
SpongeUnimplemented.openInventory(player, inventoryOptional.get().createInventory(player), this);
}
catch (InvalidDataException e)
{
this.logger.error("There is something wrong with the GUI configuration (" + name + ")", e);
}
}
}
示例6: onGamePreInitialization
@Listener(order = Order.EARLY)
public void onGamePreInitialization(GamePreInitializationEvent event) {
Scheduler scheduler = Sponge.getScheduler();
asyncExecutor = scheduler.createAsyncExecutor(this);
syncExecutor = scheduler.createSyncExecutor(this);
service = new MineskinServiceImpl().load();
Sponge.getServiceManager().setProvider(this, MineskinService.class, service);
MineskinCommands.register();
}
示例7: onClientAuth
@Listener(order = Order.EARLY)
@IsCancelled(Tristate.UNDEFINED)
public void onClientAuth(ClientConnectionEvent.Auth e) {
/* Called when the player first attempts a connection with the server.
Listening on AFTER_PRE priority to allow plugins to modify username / UUID data here. (auth plugins) */
final GameProfile p = e.getProfile();
final String username = p.getName().orElseThrow(() -> new RuntimeException("No username present for user " + p.getUniqueId()));
if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
this.plugin.getLog().info("Processing auth event for " + p.getUniqueId() + " - " + p.getName());
}
this.plugin.getUniqueConnections().add(p.getUniqueId());
/* Actually process the login for the connection.
We do this here to delay the login until the data is ready.
If the login gets cancelled later on, then this will be cleaned up.
This includes:
- loading uuid data
- loading permissions
- creating a user instance in the UserManager for this connection.
- setting up cached data. */
try {
User user = loadUser(p.getUniqueId(), username);
this.plugin.getEventFactory().handleUserLoginProcess(p.getUniqueId(), username, user);
} catch (Exception ex) {
this.plugin.getLog().severe("Exception occured whilst loading data for " + p.getUniqueId() + " - " + p.getName());
ex.printStackTrace();
this.deniedAsyncLogin.add(p.getUniqueId());
e.setCancelled(true);
e.setMessageCancelled(false);
//noinspection deprecation
e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
}
}
示例8: onConstructWorldProperties
@Listener(order = Order.EARLY)
public void onConstructWorldProperties(ConstructWorldPropertiesEvent event) {
if (!SpongeImpl.getServer().isServerRunning() || !GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getWorldProperties())) {
return;
}
GriefPreventionPlugin.instance.dataStore.registerWorld(event.getWorldProperties());
}
示例9: onPartyJoin
@Listener(order = Order.EARLY)
public void onPartyJoin(PartyJoinEvent event) {
if (PluginConfig.MAX_PARTY_SIZE > -1) {
if (event.getParty().getPlayers().size() > PluginConfig.MAX_PARTY_SIZE) {
event.setCancelled(true);
}
}
}
示例10: onGameConstruction
@Listener(order = Order.EARLY)
public void onGameConstruction(GameConstructionEvent event) {
instance = this;
}
示例11: onServerStop
@Listener(order = Order.EARLY)
public void onServerStop(GameStoppingServerEvent evt) {
ServerStopsScriptEvent event = (ServerStopsScriptEvent) clone();
event.internal = evt;
event.run();
}
示例12: onPlayerChat
@Listener(order = Order.EARLY)
public void onPlayerChat(MessageChannelEvent.Chat event) {
java.util.Optional<Player> player = event.getCause().first(Player.class);
if (!player.isPresent()) {
return;
}
for (Minigame mg : CommonCore.getMinigames().values()) {
IWizardManager wm = ((InfernoMinigame) mg).getLobbyWizardManager();
// check if the player is in a wizard
if (wm.hasPlayer(player.get().getUniqueId())) {
event.setCancelled(true);
// send the original message since the event is cancelled
player.get().sendMessage(Text.builder().append(Text.of("<"))
.append(player.get().getDisplayNameData().displayName().get()).append(Text.of("> "))
.append(event.getMessage()).build());
// feed the message to the wizard manager and get the response
String[] response = wm.accept(player.get().getUniqueId(), event.getMessage().toPlain());
CommonCore.getChatAgent().processAndSend(player.get().getUniqueId(), response);
return; // no need for further checks
}
if (!event.getChannel().isPresent()) {
return;
}
MessageChannel mutable = event.getChannel().get().asMutable();
Iterator<MessageReceiver> it = mutable.getMembers().iterator();
while (it.hasNext()) {
MessageReceiver recip = it.next();
if (!(recip instanceof Player)) {
return;
}
// check if the recipient is in a lobby wizard
if (((InfernoMinigame) mg).getLobbyWizardManager().hasPlayer(((Player) recip).getUniqueId())) {
((InfernoMinigame) mg).getLobbyWizardManager().withholdMessage(
((Player) recip).getUniqueId(),
player.get().getDisplayNameData().displayName().get().toPlain(),
event.getMessage().toPlain()
);
continue;
}
// check if a chat barrier exists between the sender and recipient
if (ChatHelper.isBarrierPresent(player.get().getUniqueId(), ((Player) recip).getUniqueId())) {
it.remove();
}
}
event.setChannel(mutable);
}
}
示例13: preInit
@Listener(order = Order.EARLY)
public void preInit(GamePreInitializationEvent event) {
this.logger.info("Initializing " + getContainer().getName());
setup();
}
示例14: onQPress
@Listener(order = Order.EARLY)
public void onQPress(DropItemEvent.Pre e, @Root Player player) {
IActiveCharacter character = characterService.getCharacter(player);
e.setCancelled(characterService.processUserAction(character, UserActionType.Q));
}
示例15: onInventoryOpen
@Listener(order = Order.EARLY)
public void onInventoryOpen(InteractInventoryEvent.Open e, @Root Player player) {
IActiveCharacter character = characterService.getCharacter(player);
e.setCancelled(characterService.processUserAction(character, UserActionType.E));
}