本文整理汇总了Java中org.spongepowered.api.entity.EntityTypes.PLAYER属性的典型用法代码示例。如果您正苦于以下问题:Java EntityTypes.PLAYER属性的具体用法?Java EntityTypes.PLAYER怎么用?Java EntityTypes.PLAYER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spongepowered.api.entity.EntityTypes
的用法示例。
在下文中一共展示了EntityTypes.PLAYER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
}
示例2: onEntityTeleport
@Listener(order = Order.LAST)
public void onEntityTeleport(MoveEntityEvent.Teleport event) {
if (event.getTargetEntity().getType() != EntityTypes.PLAYER) {
return; // not a player
}
if (event.getFromTransform().getPosition().equals(event.getToTransform().getPosition())) {
return; // player hasn't moved
}
Optional<Challenger> chal = CommonCore.getChallenger(event.getTargetEntity().getUniqueId());
if (chal.isPresent() && !((CommonChallenger) chal.get()).isLeaving()) {
Boundary bound = chal.get().getRound().getArena().getBoundary();
if (!bound.contains(LocationConverter.of(event.getToTransform().getPosition()))) {
if (chal.get().getRound().getConfigValue(ConfigNode.ALLOW_EXIT_BOUNDARY)) {
chal.get().removeFromRound();;
} else {
event.setCancelled(true);
}
}
}
}
示例3: updateHealth
private void updateHealth(double maxHealth, double newHealth, Entity targetEntity) {
Text healthMessage = generateHealthMessage(newHealth, maxHealth);
if (targetEntity.getType() == EntityTypes.PLAYER) {
Player targetPlayer = (Player) targetEntity;
String playerName = targetPlayer.getName();
Scoreboard playerScoreboard = targetPlayer.getScoreboard();
if (playerScoreboard.equals(server.getServerScoreboard().orElse(null))) {
//does the player have still a global scoreboard -> we don't want to overrid eothers
setBelownameHealth(playerScoreboard, newHealth, playerName);
setNametagHealth(playerScoreboard, playerName, healthMessage);
}
} else if (settings.getConfig().isEnabledMob() && targetEntity.supports(Keys.DISPLAY_NAME)) {
//mobs have only support for this
targetEntity.offer(Keys.DISPLAY_NAME, healthMessage);
}
}
示例4: canDamage
public static boolean canDamage(IActiveCharacter character, Living l) {
if (character.getPlayer() == l) {
return false;
}
if (l.getType() == EntityTypes.PLAYER) {
if (character.hasParty()) {
IActiveCharacter c = globalScope.characterService.getCharacter(l.getUniqueId());
if (character.getParty().getPlayers().contains(c)) {
return false;
}
}
}
DamageSource build = new SpongeDamageSourceBuilder()
.type(NDamageType.DAMAGE_CHECK)
.absolute()
.build();
return l.damage(0, build);
}
示例5: get
public IEntity get(Entity id) {
if (id.getType() == EntityTypes.PLAYER) {
return service.getCharacter(id.getUniqueId());
}
IMob iEntity = entityHashMap.get(id.getUniqueId());
if (iEntity == null) {
iEntity = new NEntity();
iEntity.setExperiences(-1);
iEntity.attach((Living) id);
entityHashMap.put(id.getUniqueId(), iEntity);
if (!PluginConfig.OVERRIDE_MOBS) {
id.offer(Keys.MAX_HEALTH, entityHealth.get(id.getType()));
id.offer(Keys.HEALTH, entityHealth.get(id.getType()));
}
}
return iEntity;
}
示例6: onItemDrop
@Listener
public void onItemDrop(DropItemEvent event, @Root Entity entity) {
if (entity.getType() != EntityTypes.PLAYER)
return;
IActiveCharacter character = characterService.getCharacter(entity.getUniqueId());
if (character.isStub())
return;
if (character.hasOpenInventory()) {
return;
}
Hotbar hotbar = character.getPlayer().getInventory().query(Hotbar.class);
HotbarObject hotbarObject = character.getHotbar()[hotbar.getSelectedSlotIndex()];
if (hotbarObject == HotbarObject.EMPTYHAND_OR_CONSUMABLE) {
return;
}
inventoryService.initializeHotbar(character, hotbar.getSelectedSlotIndex());
}
示例7: onEntityMovement
@Listener
public void onEntityMovement(MoveEntityEvent e) {
Transform<World> f = e.getFromTransform();
Transform<World> t = e.getToTransform();
if (f.getLocation().getBlockX() == t.getLocation().getBlockX() &&
t.getLocation().getBlockZ() == f.getLocation().getBlockZ()) {
return;
}
int x = t.getLocation().getBlockX();
int z = t.getLocation().getBlockZ();
if (x == (x >> 4) << 4 && z == (z >> 4) << 4) {
EntityType type = e.getTargetEntity().getType();
if (type == EntityTypes.PLAYER) {
Citizen citizen = playerService.getCitizen(e.getTargetEntity().getUniqueId());
ClaimedArea nextArea = worldService.getClaimedArea(t.getLocation());
worldService.handleChunkChange(citizen, nextArea);
}
}
}
示例8: onEntityDamage
@Listener(order = Order.LAST)
public void onEntityDamage(DamageEntityEvent event) {
if (event.isCancelled() || event.getFinalDamage() == 0) {
return;
}
if (event.getTargetEntity().getType() == EntityTypes.PLAYER) {
UUID id = event.getTargetEntity().getUniqueId();
IActiveCharacter character = characterService.getCharacter(id);
IEffectContainer container = character.getEffect(name);
if (container == null)
return;
if (!event.getCause().first(SoulBindEffect.class).isPresent()) {
event.setBaseDamage(event.getBaseDamage() * .5);
SoulBindEffect effect = (SoulBindEffect) container;
SkillDamageSourceBuilder builder = new SkillDamageSourceBuilder();
if (effect.getConsumer() == character) {
effect.getTarget().getEntity().damage(event.getBaseDamage(), builder.build());
} else {
effect.getConsumer().getEntity().damage(event.getBaseDamage(), builder.build());
}
}
}
}
示例9: onDamageEntity
@Listener
public void onDamageEntity(DamageEntityEvent event) {
if (event.getTargetEntity().getType() == EntityTypes.PLAYER) {
if (Main.getMinigame().getChallenger(event.getTargetEntity().getUniqueId()).isPresent()) {
event.setCancelled(true);
}
}
}
示例10: onTargetEntity
@Listener(order = Order.POST)
public void onTargetEntity(TargetEntityEvent event) {
if (event instanceof MoveEntityEvent) {
return; // listening to move events is not f*cking necessary
}
if (event.getTargetEntity().getType() != EntityTypes.PLAYER) {
InfernoRollbackAgent.checkEntityChange(event.getTargetEntity());
}
}
示例11: onDamageEntity
@Listener
public void onDamageEntity(DamageEntityEvent event, @First EntityDamageSource source) {
// Optional<IndirectEntityDamageSource> secondSource = event.getCause().first(IndirectEntityDamageSource.class);
ConfigurationNode node = PlayerList.getInstance().getNode();
Entity entityTarget = event.getTargetEntity();
if (source.getSource().getType() == EntityTypes.PLAYER || (source.getSource().getType() == EntityTypes.ARROW
&& event.getCause().first(IndirectEntityDamageSource.class).get().getIndirectSource().getType() == EntityTypes.PLAYER)) {
Player cause = null;
if (source.getSource().getType() == EntityTypes.PLAYER) {
cause = (Player) source.getSource();
} else {
cause = (Player) event.getCause().first(IndirectEntityDamageSource.class).get().getIndirectSource();
}
if (!node.getNode("players", cause.getUniqueId(), "pvp").getBoolean()) {
if (entityTarget.getType() == EntityTypes.PLAYER) {
event.setCancelled(true);
cause.sendMessage(TranslationHelper.t("text.player.attacker", cause.getLocale()));
cause.sendMessage(TranslationHelper.t("text.player.toggle", cause.getLocale()));
return;
}
} else if (entityTarget.getType() == EntityTypes.PLAYER) {
Player target = (Player) entityTarget;
if (!node.getNode("players", target.getUniqueId(), "pvp").getBoolean()) {
event.setCancelled(true);
cause.sendMessage(TranslationHelper.t("text.player.target", cause.getLocale()));
target.sendMessage(TranslationHelper.t("text.player.attacked", cause.getLocale()));
return;
}
}
}
}
示例12: makeFilter
private Predicate<Entity> makeFilter() {
// for easier reading
final Selector sel = this.selector;
final Vector3d position = getPositionOrDefault(this.position, ArgumentTypes.POSITION);
final List<Predicate<Entity>> filters = new ArrayList<>();
addTypeFilters(filters);
addDimensionFilters(position, filters);
addRadiusFilters(position, filters);
addLevelFilters(filters);
addGamemodeFilters(filters);
addNameFilters(filters);
addRotationFilters(filters);
addTeamFilters(filters);
addScoreFilters(filters);
SelectorType selectorType = sel.getType();
final Optional<Argument.Invertible<EntityType>> type = sel.getArgument(ArgumentTypes.ENTITY_TYPE);
// isn't an ALL_ENTITIES selector or it is a RANDOM selector for only players
final boolean isPlayerOnlySelector =
selectorType == SelectorTypes.ALL_PLAYERS || selectorType == SelectorTypes.NEAREST_PLAYER
|| (selectorType == SelectorTypes.RANDOM && type.isPresent() && !type.get().isInverted()
&& type.get().getValue() != EntityTypes.PLAYER);
if (isPlayerOnlySelector) {
// insert at the start so it applies first
filters.add(0, requireTypePredicate(Entity.class, Player.class));
}
return Functional.predicateAnd(filters);
}
示例13: onEntityDeath
@Listener
public void onEntityDeath(DestructEntityEvent.Death deathEntityEvent) {
Living targetEntity = deathEntityEvent.getTargetEntity();
if (!deathEntityEvent.isMessageCancelled()) {
//clear entity properties
if (targetEntity.getType() == EntityTypes.PLAYER) {
Player targetPlayer = (Player) targetEntity;
Scoreboard playerScoreboard = targetPlayer.getScoreboard();
String playerName = targetPlayer.getName();
playerScoreboard.getTeam(playerName).ifPresent(Team::unregister);
} else if (targetEntity.supports(Keys.DISPLAY_NAME)) {
targetEntity.remove(Keys.DISPLAY_NAME);
}
//clean message
Text oldMessage = deathEntityEvent.getMessage();
Builder newMessageBuilder = Text.builder(oldMessage, "");
for (Text child : oldMessage.getChildren()) {
if (child instanceof LiteralText) {
String content = ((LiteralText) child).getContent();
String newContent = content.replace(String.valueOf(settings.getConfig().getDisplayChar()), "");
newMessageBuilder.append(Text.builder(child, newContent).build());
continue;
}
newMessageBuilder.append(child);
}
deathEntityEvent.setMessage(newMessageBuilder.build());
}
}
示例14: onApply
@Override
public void onApply() {
getConsumer().setProperty(DefaultProperties.weapon_damage_bonus,
getConsumer().getProperty(DefaultProperties.weapon_damage_bonus) + bonusDamage);
if (getConsumer().getEntity().getType() == EntityTypes.PLAYER) {
getGlobalScope().damageService.recalculateCharacterWeaponDamage((IActiveCharacter) getConsumer());
}
}
示例15: onRemove
@Override
public void onRemove() {
getConsumer().setProperty(DefaultProperties.weapon_damage_bonus,
getConsumer().getProperty(DefaultProperties.weapon_damage_bonus) - bonusDamage);
if (getConsumer().getEntity().getType() == EntityTypes.PLAYER) {
getGlobalScope().damageService.recalculateCharacterWeaponDamage((IActiveCharacter) getConsumer());
}
}