本文整理汇总了Java中org.spongepowered.api.util.Tristate.FALSE属性的典型用法代码示例。如果您正苦于以下问题:Java Tristate.FALSE属性的具体用法?Java Tristate.FALSE怎么用?Java Tristate.FALSE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spongepowered.api.util.Tristate
的用法示例。
在下文中一共展示了Tristate.FALSE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerTeleportPreEvent
@Listener(order = Order.LATE)
@IsCancelled(Tristate.FALSE)
@Include(PlayerTeleportEvent.Pre.class)
public void onPlayerTeleportPreEvent(PlayerTeleportEvent event) {
Player player = event.getTargetEntity();
PlayerEntity playerEntity = PlayerCache.instance.get(player);
for (BackEntity backEntity : playerEntity.getBacks()) {
if (backEntity.getLocation().getWorld().getIdentifier().equals(event.getLocation().getExtent().getUniqueId().toString())) {
playerEntity.getBacks().remove(backEntity);
}
}
playerEntity.getBacks().add(new BackEntity(new LocationEntity(event.getLocation(), event.getRotation())));
playerEntity = PlayerRepository.instance.save(playerEntity);
PlayerCache.instance.set(player, playerEntity);
}
示例2: onPlayerTeleportEvent
@Listener(order = Order.LATE)
@IsCancelled(Tristate.FALSE)
@Exclude(PlayerTeleportEvent.Pre.class)
public void onPlayerTeleportEvent(PlayerTeleportEvent event) {
Optional<SleepingData> optional = event.getTargetEntity().get(SleepingData.class);
if (optional.isPresent() && optional.get().asImmutable().sleeping().get()) {
event.getTargetEntity().sendMessage(MessagesUtil.get(event.getTargetEntity(), "teleport.sleep"));
return;
}
if (event.getRotation() == null) {
event.getTargetEntity().setLocationSafely(event.getLocation());
} else {
event.getTargetEntity().setLocationAndRotationSafely(event.getLocation(), event.getRotation());
}
}
示例3: onEntityExplosionDetonate
@Listener(order = Order.FIRST, beforeModifications = true)
public void onEntityExplosionDetonate(ExplosionEvent.Detonate event) {
if (!GPFlags.EXPLOSION || !GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetWorld().getProperties())) {
return;
}
GPTimings.ENTITY_EXPLOSION_DETONATE_EVENT.startTimingIfSync();
final User user = CauseContextHelper.getEventUser(event);
Iterator<Entity> iterator = event.getEntities().iterator();
GPClaim targetClaim = null;
while (iterator.hasNext()) {
Entity entity = iterator.next();
targetClaim = GriefPreventionPlugin.instance.dataStore.getClaimAt(entity.getLocation(), targetClaim);
if (GPPermissionHandler.getClaimPermission(event, entity.getLocation(), targetClaim, GPPermissions.ENTITY_DAMAGE, event.getCause().root(), entity, user) == Tristate.FALSE) {
iterator.remove();
}
}
GPTimings.ENTITY_EXPLOSION_DETONATE_EVENT.stopTimingIfSync();
}
示例4: createFlagConsumer
public static Consumer<CommandSource> createFlagConsumer(CommandSource src, Subject subject, String subjectName, Set<Context> contexts, GPClaim claim, String flagPermission, Tristate flagValue, String source) {
return consumer -> {
String target = flagPermission.replace(GPPermissions.FLAG_BASE + ".", "");
if (target.isEmpty()) {
target = "any";
}
Tristate newValue = Tristate.UNDEFINED;
if (flagValue == Tristate.TRUE) {
newValue = Tristate.FALSE;
} else if (flagValue == Tristate.UNDEFINED) {
newValue = Tristate.TRUE;
}
CommandHelper.applyFlagPermission(src, subject, subjectName, claim, flagPermission, source, target, newValue, null, FlagType.GROUP);
};
}
示例5: parseCommand
public static List<String> parseCommand(String commandSequence)
{
StringBuilder stringBuilder = new StringBuilder();
List<String> commands = new LinkedList<>();
Tristate isCommandFinished = Tristate.TRUE;
for (char c : commandSequence.toCharArray())
{
if (c != SEQUENCE_SPLITTER)
{
if (isCommandFinished == Tristate.UNDEFINED)
{
commands.add(stringBuilder.toString());
stringBuilder.setLength(0);
}
if (isCommandFinished != Tristate.FALSE && Character.isWhitespace(c))
{
isCommandFinished = Tristate.TRUE;
continue;
}
}
else if (isCommandFinished != Tristate.UNDEFINED)
{
isCommandFinished = Tristate.UNDEFINED;
continue;
}
isCommandFinished = Tristate.FALSE;
stringBuilder.append(c);
}
commands.add(stringBuilder.toString());
return commands;
}
示例6: setPermission
@Override
public boolean setPermission(Player player, Subject subject, Set<Context> contexts, String permission, Tristate value) {
Boolean perm = subject.getSubjectData().getPermissions(contexts).get(permission);
if ((perm == null && value == Tristate.UNDEFINED)
|| (perm == Boolean.TRUE && value == Tristate.TRUE)
|| (perm == Boolean.FALSE && value == Tristate.FALSE)) {
return true;
}
return subject.getSubjectData().setPermission(contexts, permission, value);
}
示例7: onClientConnectionEventLogin
@Listener
@IsCancelled(Tristate.FALSE)
public void onClientConnectionEventLogin(ClientConnectionEvent.Login event) {
Optional<Player> optionalPlayer = event.getTargetUser().getPlayer();
if (optionalPlayer.isPresent()) {
Player player = optionalPlayer.get();
PlayerEntity playerEntity = PlayerCache.instance.get(player);
if (!playerEntity.getName().equals(player.getName())) {
playerEntity.setName(player.getName());
playerEntity = PlayerRepository.instance.save(playerEntity);
PlayerCache.instance.set(player, playerEntity);
}
}
}
示例8: onManaDrain
@Listener(order = Order.LAST)
@IsCancelled(Tristate.FALSE)
public void onManaDrain(ManaDrainEvent mde) {
IReservable mana = mde.getTarget().getMana();
double k = mana.getValue() - mde.getAmountDrained() <= 0 ? 0 : mana.getValue() - mde.getAmountDrained();
mana.setValue(k);
}
示例9: onSleepingEvent
@Listener
@IsCancelled(Tristate.FALSE)
public void onSleepingEvent(SleepingEvent.Pre event) {
if (!(event.getTargetEntity() instanceof Player)) {
return;
}
Player player = (Player) event.getTargetEntity();
PlayerEntity playerEntity = PlayerCache.instance.get(player);
BlockSnapshot blockSnapshot = event.getBed();
Optional<Location<World>> optional = blockSnapshot.getLocation();
if (!optional.isPresent()) {
return;
}
Location<World> location = optional.get();
for (BedEntity bed : playerEntity.getBeds()) {
if (bed.getLocation().getWorld().getIdentifier().equals(player.getWorld().getUniqueId().toString())) {
Location<World> bedLocation = bed.getLocation().getLocation();
if (location.getBlockPosition().equals(bedLocation.getBlockPosition())) {
bed.setLastUse(new Timestamp(new Date().getTime()));
playerEntity = PlayerRepository.instance.save(playerEntity);
PlayerCache.instance.set(player, playerEntity);
return;
}
}
}
playerEntity.getBeds().add(new BedEntity(new LocationEntity(location)));
playerEntity = PlayerRepository.instance.save(playerEntity);
PlayerCache.instance.set(player, playerEntity);
}
示例10: onProjectileImpactEntity
@Listener(order = Order.FIRST, beforeModifications = true)
public void onProjectileImpactEntity(CollideEntityEvent.Impact event) {
if (!GPFlags.PROJECTILE_IMPACT_ENTITY) {
return;
}
final User user = CauseContextHelper.getEventUser(event);
if (user == null || !GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getImpactPoint().getExtent().getProperties())) {
return;
}
GPTimings.PROJECTILE_IMPACT_ENTITY_EVENT.startTimingIfSync();
Object source = event.getCause().root();
Location<World> impactPoint = event.getImpactPoint();
GPClaim targetClaim = null;
for (Entity entity : event.getEntities()) {
targetClaim = this.dataStore.getClaimAt(impactPoint, targetClaim);
final Tristate result = GPPermissionHandler.getClaimPermission(event, impactPoint, targetClaim, GPPermissions.PROJECTILE_IMPACT_ENTITY, source, entity, user, TrustType.ACCESSOR, true);
if (result == Tristate.FALSE) {
if (GPPermissionHandler.getClaimPermission(event, impactPoint, targetClaim, GPPermissions.PROJECTILE_IMPACT_ENTITY, source, entity, user) == Tristate.TRUE) {
GPTimings.PROJECTILE_IMPACT_ENTITY_EVENT.stopTimingIfSync();
return;
}
event.setCancelled(true);
}
}
GPTimings.PROJECTILE_IMPACT_ENTITY_EVENT.stopTimingIfSync();
}
示例11: onPlayerInteractInventoryOpen
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerInteractInventoryOpen(InteractInventoryEvent.Open event, @First Player player) {
if (!GPFlags.INTERACT_INVENTORY || !GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) {
return;
}
GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.startTimingIfSync();
final Cause cause = event.getCause();
final EventContext context = cause.getContext();
final BlockSnapshot blockSnapshot = context.get(EventContextKeys.BLOCK_HIT).orElse(BlockSnapshot.NONE);
if (blockSnapshot == BlockSnapshot.NONE) {
GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.stopTimingIfSync();
return;
}
final Location<World> location = blockSnapshot.getLocation().get();
final GPClaim claim = this.dataStore.getClaimAt(location);
final GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
if (playerData.lastInteractItemBlockResult == Tristate.TRUE) {
GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.stopTimingIfSync();
return;
}
final Tristate result = GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.INVENTORY_OPEN, player, blockSnapshot, player, TrustType.CONTAINER, true);
if (result == Tristate.FALSE) {
Text message = GriefPreventionPlugin.instance.messageData.permissionInventoryOpen
.apply(ImmutableMap.of(
"owner", claim.getOwnerName(),
"block", blockSnapshot.getState().getType().getId())).build();
GriefPreventionPlugin.sendClaimDenyMessage(claim, player, message);
((EntityPlayerMP) player).closeScreen();
event.setCancelled(true);
}
GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.stopTimingIfSync();
}
示例12: onPlayerInteractEntity
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerInteractEntity(InteractEntityEvent.Primary event, @First Player player) {
if (!GPFlags.INTERACT_ENTITY_PRIMARY || !GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) {
return;
}
final Entity targetEntity = event.getTargetEntity();
GPTimings.PLAYER_INTERACT_ENTITY_PRIMARY_EVENT.startTimingIfSync();
Location<World> location = targetEntity.getLocation();
GPClaim claim = this.dataStore.getClaimAt(location);
GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
if (playerData.lastInteractItemBlockResult == Tristate.TRUE || playerData.lastInteractItemEntityResult == Tristate.TRUE) {
GPTimings.PLAYER_INTERACT_ENTITY_PRIMARY_EVENT.stopTimingIfSync();
return;
}
Tristate result = GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.INTERACT_ENTITY_PRIMARY, player, targetEntity, player, TrustType.ACCESSOR, true);
if (result == Tristate.FALSE) {
final Text message = GriefPreventionPlugin.instance.messageData.claimProtectedEntity
.apply(ImmutableMap.of(
"owner", claim.getOwnerName())).build();
GriefPreventionPlugin.sendMessage(player, message);
event.setCancelled(true);
GPTimings.PLAYER_INTERACT_ENTITY_PRIMARY_EVENT.stopTimingIfSync();
return;
}
}
示例13: onPlayerPickupItem
@Listener(order = Order.LAST, beforeModifications = true)
public void onPlayerPickupItem(ChangeInventoryEvent.Pickup.Pre event, @Root Player player) {
if (!GPFlags.ITEM_PICKUP || !GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) {
return;
}
GPTimings.PLAYER_PICKUP_ITEM_EVENT.startTimingIfSync();
final World world = player.getWorld();
GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(world, player.getUniqueId());
Location<World> location = player.getLocation();
GPClaim claim = this.dataStore.getClaimAtPlayer(playerData, location);
if (GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.ITEM_PICKUP, player, event.getTargetEntity(), player, true) == Tristate.FALSE) {
event.setCancelled(true);
GPTimings.PLAYER_USE_ITEM_EVENT.stopTimingIfSync();
return;
}
// the rest of this code is specific to pvp worlds
if (claim.pvpRulesApply()) {
// if we're preventing spawn camping and the player was previously empty handed...
if (GriefPreventionPlugin.getActiveConfig(world.getProperties()).getConfig().pvp.protectFreshSpawns && PlayerUtils.hasItemInOneHand(player, ItemTypes.NONE)) {
// if that player is currently immune to pvp
if (playerData.pvpImmune) {
// if it's been less than 10 seconds since the last time he spawned, don't pick up the item
long now = Calendar.getInstance().getTimeInMillis();
long elapsedSinceLastSpawn = now - playerData.lastSpawn;
if (elapsedSinceLastSpawn < 10000) {
event.setCancelled(true);
GPTimings.PLAYER_PICKUP_ITEM_EVENT.stopTimingIfSync();
return;
}
// otherwise take away his immunity. he may be armed now. at least, he's worth killing for some loot
playerData.pvpImmune = false;
GriefPreventionPlugin.sendMessage(player, GriefPreventionPlugin.instance.messageData.pvpImmunityEnd.toText());
}
}
}
GPTimings.PLAYER_PICKUP_ITEM_EVENT.stopTimingIfSync();
}
示例14: onPlayerInteractBlockPrimary
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerInteractBlockPrimary(InteractBlockEvent.Primary.MainHand event, @First Player player) {
if (!GPFlags.INTERACT_BLOCK_PRIMARY || !GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) {
return;
}
GPTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.startTimingIfSync();
final BlockSnapshot clickedBlock = event.getTargetBlock();
final Location<World> location = clickedBlock.getLocation().orElse(null);
if (location == null) {
GPTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync();
return;
}
final GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(location.getExtent(), player.getUniqueId());
if (playerData.lastInteractItemBlockResult == Tristate.TRUE || playerData.lastInteractItemEntityResult == Tristate.TRUE) {
GPTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync();
return;
}
final GPClaim claim = this.dataStore.getClaimAt(location);
final Tristate result = GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.INTERACT_BLOCK_PRIMARY, player, clickedBlock.getState(), player, TrustType.BUILDER, true);
if (result == Tristate.FALSE) {
if (GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.BLOCK_BREAK, player, clickedBlock.getState(), player, TrustType.BUILDER, true) == Tristate.TRUE) {
GPTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync();
playerData.setLastInteractData(claim);
return;
}
final Text message = GriefPreventionPlugin.instance.messageData.permissionAccess
.apply(ImmutableMap.of(
"player", Text.of(claim.getOwnerName()))).build();
GriefPreventionPlugin.sendClaimDenyMessage(claim, player, message);
event.setCancelled(true);
GPTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync();
return;
}
playerData.setLastInteractData(claim);
GPTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync();
}
示例15: onProjectileImpactBlock
@Listener(order = Order.FIRST, beforeModifications = true)
public void onProjectileImpactBlock(CollideBlockEvent.Impact event) {
if (!GPFlags.PROJECTILE_IMPACT_BLOCK) {
return;
}
final User user = CauseContextHelper.getEventUser(event);
if (user == null) {
return;
}
if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getImpactPoint().getExtent().getProperties())) {
return;
}
GPTimings.PROJECTILE_IMPACT_BLOCK_EVENT.startTimingIfSync();
final Cause cause = event.getCause();
Object source = cause.root();
Location<World> impactPoint = event.getImpactPoint();
GPClaim targetClaim = null;
GPPlayerData playerData = null;
if (user instanceof Player) {
playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(event.getTargetLocation().getExtent(), user.getUniqueId());
targetClaim = this.dataStore.getClaimAtPlayer(playerData, impactPoint);
} else {
targetClaim = this.dataStore.getClaimAt(impactPoint);
}
Tristate result = GPPermissionHandler.getClaimPermission(event, impactPoint, targetClaim, GPPermissions.PROJECTILE_IMPACT_BLOCK, source, event.getTargetBlock(), user, TrustType.ACCESSOR, true);
if (result == Tristate.FALSE) {
event.setCancelled(true);
GPTimings.PROJECTILE_IMPACT_BLOCK_EVENT.stopTimingIfSync();
return;
}
GPTimings.PROJECTILE_IMPACT_BLOCK_EVENT.stopTimingIfSync();
}