本文整理汇总了Java中org.spongepowered.api.event.cause.Cause.of方法的典型用法代码示例。如果您正苦于以下问题:Java Cause.of方法的具体用法?Java Cause.of怎么用?Java Cause.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.cause.Cause
的用法示例。
在下文中一共展示了Cause.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reload
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
public void reload() {
deleteHolograms();
created_managers.clear();
config.reload();
language_config.reload();
virtual_cases_config.reload();
virtual_keys_config.reload();
timed_cases_delays_config.reload();
timed_keys_delays_config.reload();
saved_super_objects_config.reload();
super_objects.clear();
saved_super_objects.clear();
loadConfigValues();
default_cause = Cause.of(EventContext.empty(), plugin_container);
register();
optional_economy_service = Optional.empty();
optional_holograms_service = Optional.empty();
loadEconomy();
loadHologramsService();
loadSavedSuperObjects();
loadManagers();
if (check_updates) {
checkUpdates();
}
logger.info("Plugin has been reloaded.");
}
示例2: execute
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args)
throws CommandException {
if (!(src instanceof LocatedSource)) {
src.sendMessage(Texts
.of("Must be an in-world source to use this command."));
return CommandResult.success();
}
Cause cause = Cause.of(src,
// SpawnCause.builder().type(SpawnTypes.PLUGIN).build(),
APlugin.getInstance());
Location<World> loc = ((LocatedSource) src).getLocation();
int count = args.<Integer> getOne(TIMES).orElse(1);
Object groupKey = new Object();
startGroup(groupKey, count, src);
IntStream.range(0, count)
.forEach(x -> createExplosion(groupKey, x, cause, loc));
return CommandResult.success();
}
示例3: preventExplosion
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
private void preventExplosion(ExplosionEvent.Pre event) {
//"Clone" explosion, as we cannot change the existing one?
Explosion old = event.getExplosion();
Explosion newExplosion = Explosion.builder()
.from(old)
.shouldBreakBlocks(config.BREAK_BLOCKS)
.shouldPlaySmoke(config.SHOW_PARTICLES)
.sourceExplosive(null) //Do not check for a creeper in next Event listener Iteration
.build();
//Cancel default event...
event.setCancelled(true);
//...but trigger new event
Cause genericCause = Cause.of(NamedCause.owner(container));
newExplosion.getWorld().triggerExplosion(newExplosion, genericCause);
//Remove the creeper (as the default event is canceled);
((Creeper) event.getCause().root()).remove();
}
示例4: ClanCreateEvent
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
public ClanCreateEvent(String clanTag, String clanName, ClanPlayer owner) {
super("Clan creation cancelled by an external plugin", Cause.of(NamedCause.owner(owner)));
this.clanTag = clanTag;
this.clanName = clanName;
this.owner = owner;
}
示例5: commandSuicide
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
private CompletableFuture<Boolean> commandSuicide(final EPlayer player) {
// Event cancel
if(!player.setHealth(0)) {
EEMessages.SUICIDE_CANCEL.sender()
.replace("{player}", player.getName())
.sendTo(player);
return CompletableFuture.completedFuture(false);
}
final MessageEvent.MessageFormatter formatter = new MessageEvent.MessageFormatter();
MessageChannel originalChannel;
MessageChannel channel;
boolean messageCancelled = false;
originalChannel = player.getMessageChannel();
channel = player.getMessageChannel();
messageCancelled = !EEMessages.SUICIDE_DEATH_MESSAGE.getMessage().getChat().isPresent();
formatter.getBody().add(new MessageEvent.DefaultBodyApplier(EEMessages.SUICIDE_DEATH_MESSAGE.getFormat().toText(player.getReplaces())));
List<NamedCause> causes = new ArrayList<NamedCause>();
causes.add(NamedCause.of("Command", "kill"));
causes.add(NamedCause.owner(player));
Cause cause = Cause.of(causes);
DestructEntityEvent.Death event = SpongeEventFactory.createDestructEntityEventDeath(cause, originalChannel, Optional.of(channel), formatter, player, messageCancelled);
this.plugin.getGame().getEventManager().post(event);
if (!event.isMessageCancelled() && !event.getMessage().isEmpty()) {
event.getChannel().ifPresent(eventChannel -> eventChannel.send(player, event.getMessage()));
} else {
EEMessages.SUICIDE_PLAYER.sender()
.replace("{player}", player.getName())
.sendTo(player);
}
return CompletableFuture.completedFuture(true);
}
示例6: BlockOperation
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
public BlockOperation(ICachedWorld world, Vector3i min, Vector3i max) {
super(null);
this.blockService = WebAPI.getBlockService();
this.uuid = UUID.randomUUID();
this.world = world;
this.min = min;
this.max = max;
this.size = max.sub(min).add(1, 1, 1);
this.cause = Cause.of(EventContext.empty(), WebAPI.getContainer());
this.totalBlocks = size.getX() * size.getY() * size.getZ();
}
示例7: ClanPlayerKillEvent
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
public ClanPlayerKillEvent(ClanPlayerImpl killer, ClanPlayerImpl victim) {
super(Cause.of(NamedCause.source(killer)));
this.killer = killer;
this.victim = victim;
}
示例8: ClanDisbandEvent
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
private ClanDisbandEvent(Clan clan) {
super("Clan disband cancelled by an external plugin", Cause.of(NamedCause.owner(clan.getOwner())));
this.clan = clan;
}
示例9: ClanMemberLeaveEvent
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
private ClanMemberLeaveEvent(Clan clan, ClanPlayer clanMember) {
super("Member leaving the clan cancelled by an external plugin", Cause.of(NamedCause.source(clanMember)));
this.clan = clan;
this.clanMember = clanMember;
}
示例10: ClanOwnerChangeEvent
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
private ClanOwnerChangeEvent(Clan clan, ClanPlayer previousOwner, ClanPlayer newOwner) {
super("Clan owner change cancelled by an external plugin", Cause.of(NamedCause.owner(newOwner)));
this.clan = clan;
this.previousOwner = previousOwner;
this.newOwner = newOwner;
}
示例11: ClanHomeTeleportEvent
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
public ClanHomeTeleportEvent(Clan clan, ClanPlayer clanPlayer) {
super("Clan home teleport cancelled by an external plugin", Cause.of(NamedCause.owner(clanPlayer)));
this.clan = clan;
this.clanPlayer = clanPlayer;
}
示例12: User
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
public User(ClanPlayer clanPlayer, Clan clan, Location<World> location) {
super(Cause.of(NamedCause.source(clanPlayer)), clan, location);
this.clanPlayer = clanPlayer;
}
示例13: Admin
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
public Admin(CommandSource commandSource, Clan clan, Location<World> location) {
super(Cause.of(NamedCause.source(commandSource)), clan, location);
}
示例14: Plugin
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
public Plugin(Clan clan, Location<World> location) {
super(Cause.of(NamedCause.source(location)), clan, location);
}
示例15: ClanMemberJoinEvent
import org.spongepowered.api.event.cause.Cause; //导入方法依赖的package包/类
public ClanMemberJoinEvent(Clan clan, ClanPlayer clanMember) {
super("Member joining the clan cancelled by an external plugin", Cause.of(NamedCause.source(clanMember)));
this.clan = clan;
this.clanMember = clanMember;
}