本文整理汇总了Java中org.bukkit.entity.Tameable.getOwner方法的典型用法代码示例。如果您正苦于以下问题:Java Tameable.getOwner方法的具体用法?Java Tameable.getOwner怎么用?Java Tameable.getOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Tameable
的用法示例。
在下文中一共展示了Tameable.getOwner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInteractEvent
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler
public void onInteractEvent(PlayerInteractEntityEvent e){
RedProtect.get().logger.debug("RPEntityListener - Is PlayerInteractEntityEvent");
if (e.isCancelled()) {
return;
}
Player p = e.getPlayer();
if (p == null){
return;
}
Location l = e.getRightClicked().getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
Entity et = e.getRightClicked();
if (r != null && !r.canInteractPassives(p) && (et instanceof Animals || et instanceof Villager || et instanceof Golem)) {
if (et instanceof Tameable){
Tameable tam = (Tameable) et;
if (tam.isTamed() && tam.getOwner() != null && tam.getOwner().getName().equals(p.getName())){
return;
}
}
e.setCancelled(true);
RPLang.sendMessage(p, "entitylistener.region.cantinteract");
}
}
示例2: ownerConfliction
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
/**
* Checks if there is an owner confliction in this EggTrackerEntry.
* @param entry - The EggTrackerEntry to test.
* @return True if a confliction is present, false if not.
*/
public boolean ownerConfliction(EggTrackerEntry entry) {
if (entry.getEntity() instanceof Tameable) {
Tameable tameable = (Tameable) entry.getEntity();
// Order in the below statements is important. Owner override must be first, otherwise it will never be hit.
if (tameable.getOwner() != null) {
if (entry.getPlayer().hasPermission("SimpleEgg.owner-override")) {
if (entry.getPlayer().hasPermission("SimpleEgg.steal")) {
tameable.setOwner(entry.getPlayer());
}
return false;
}
} else if (entry.getPlayer().hasPermission("SimpleEgg.auto-tame")) {
tameable.setOwner(entry.getPlayer());
}
if (tameable.getOwner() != null && tameable.getOwner() != entry.getPlayer()) {
return true;
}
}
return false;
}
示例3: handleEntityInteraction
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
void handleEntityInteraction(final PlayerInteractEntityEvent event, final Menu menu) {
if (!this.module.getState().isEnabled()) { return; }
if (Utility.getItemInHand(event.getPlayer()).isPresent() || !event.getPlayer().isSneaking()) { return; }
if (event.getRightClicked().getType().equals(EntityType.PLAYER)) { return; }
if (!(event.getRightClicked() instanceof Tameable)) { return; }
final Tameable entity = (Tameable) event.getRightClicked();
final Player player = event.getPlayer();
if (entity.getOwner() == null) { return; }
if (!entity.getOwner().getUniqueId().equals(player.getUniqueId())) { return; }
menu.addItem(this.ownershipItem.build(), clickEvent -> {
clickEvent.getPlayer().closeInventory();
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1.0f, 1.75f);
this.openOwnerTransferWindow(player, entity);
});
}
示例4: onPlayerInteractEntity
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (event.getRightClicked() instanceof Horse) {
Horse horse = (Horse) event.getRightClicked();
if (horse.isTamed()) {
if (horse.getOwner() != event.getPlayer()) {
event.setCancelled(true);
}
}
}
if (plugin.isUntaming(event.getPlayer())) {
if (event.getRightClicked() instanceof Tameable) {
Tameable tameable = (Tameable) event.getRightClicked();
if (tameable.getOwner() == event.getPlayer() || event.getPlayer().hasPermission("wayward.travel.untame.any")) {
tameable.setTamed(false);
event.getPlayer().sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Your tameable creature was untamed.");
} else {
event.getPlayer().sendMessage(plugin.getPrefix() + ChatColor.RED + "That tameable creature is not yours!");
}
} else {
event.getPlayer().sendMessage(plugin.getPrefix() + ChatColor.RED + "That entity is not tameable!");
}
plugin.setUntaming(event.getPlayer(), false);
}
}
示例5: onPetDeath
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler
public void onPetDeath(EntityDeathEvent event) {
if (!(event.getEntity() instanceof Tameable)) {
return;
}
Tameable petEntity = (Tameable) event.getEntity();
final OfflinePlayer player;
if (!petEntity.isTamed() || (player = (OfflinePlayer) petEntity.getOwner()) == null || !player.isOnline()) {
return;
}
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
PlayerWrapper playerWrapper = InventoryManager.get(player);
if (petEntity == playerWrapper.getPet()) {
Inventory inventory = playerWrapper.getInventory();
final ItemStack petItem = inventory.getItem(PetManager.getPetSlotId());
PetType petType = PetManager.getPetFromItem(petItem);
if (petType != null && petType.isRevival()) {
PetManager.saveDeathTime(petItem);
PetManager.saveHealth(petItem, 0);
inventory.setItem(PetManager.getPetSlotId(), petItem);
PetManager.startCooldownTimer(player.getPlayer(), petItem);
} else {
inventory.setItem(PetManager.getPetSlotId(), null);
}
event.getDrops().clear();
playerWrapper.setPet(null);
}
}
示例6: onEntityDamage
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event)
{
Entity entity = event.getEntity();
if(!(entity instanceof Tameable)) return;
Tameable tameable = (Tameable)entity;
if(!tameable.isTamed() || tameable.getOwner() == null) return;
Flag flag = this.GetFlagInstanceAtLocation(entity.getLocation(), null);
if(flag != null)
{
event.setCancelled(true);
}
}
示例7: alarm
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@Override
public void alarm(Integer key) {
// kill our summon
Entity e = getEntity();
if (e == null) {
QuestManagerPlugin.logger.warning("Unable to locate and remove "
+ "summon!");
} else {
if (entity instanceof Tameable) {
Tameable me = (Tameable) entity;
AnimalTamer tamer = me.getOwner();
if (tamer instanceof Player) {
QuestPlayer qp = QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(
(Player) tamer);
if (qp.getOptions().getOption(PlayerOptions.Key.CHAT_PET_DISMISSAL)) {
((Player) tamer).sendMessage(DEATH_MESSAGE);
}
}
}
e.getLocation().getChunk().load();
e.remove();
playDeathEffect(e.getLocation());
}
effect.stop();
QuestManagerPlugin.questManagerPlugin.getSummonManager().unregisterSummon(this);
}
示例8: onEntityDeath
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
if (e.getEntity().getUniqueId().equals(entityID)) {
//is summon entity
effect.stop();
if (Alarm.getScheduler().unregister(this)) {
QuestManagerPlugin.questManagerPlugin.getSummonManager().unregisterSummon(this);
if (entity instanceof Tameable) {
Tameable me = (Tameable) entity;
AnimalTamer tamer = me.getOwner();
if (tamer instanceof Player) {
QuestPlayer qp = QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(
(Player) tamer);
if (qp.getOptions().getOption(PlayerOptions.Key.CHAT_PET_DISMISSAL)) {
((Player) tamer).sendMessage(DEATH_MESSAGE);
}
}
}
}
return;
}
}
示例9: getWolves
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
/**
* Gets player's tamed wolves
* @return
*/
public List<Wolf> getWolves() {
List<Wolf> entities = new ArrayList<Wolf>();
for (Entity e : player.getNearbyEntities(ATTACK_RANGE, ATTACK_RANGE, ATTACK_RANGE)) {
if (e instanceof Wolf && e instanceof Tameable) {
Tameable t = (Tameable) e;
if (t.isTamed() && t.getOwner() == this.player) {
entities.add((Wolf) e);
}
}
}
return entities;
}
示例10: beastLore
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
/**
* Handle the Beast Lore ability.
*
* @param target The entity to examine
*/
public void beastLore(LivingEntity target) {
Player player = getPlayer();
Tameable beast = (Tameable) target;
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
if (beast.isTamed() && beast.getOwner() != null) {
message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", beast.getOwner().getName()) + " ");
}
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth()));
player.sendMessage(message);
}
示例11: isFriendlyPet
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
/**
* Checks to see if an entity is currently friendly toward a given player.
*
* @param attacker The player to check.
* @param pet The entity to check.
* @return true if the entity is friendly, false otherwise
*/
public static boolean isFriendlyPet(Player attacker, Tameable pet) {
if (pet.isTamed()) {
AnimalTamer tamer = pet.getOwner();
if (tamer instanceof Player) {
Player owner = (Player) tamer;
return (owner == attacker || PartyManager.inSameParty(attacker, owner) || PartyManager.areAllies(attacker, owner));
}
}
return false;
}
示例12: onEntityDeath
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
LivingEntity entity = event.getEntity();
Player killer = entity.getKiller();
// Capitalize first letter of mob type and replace underscores with spaces.
String entityType = entity.getType().toString().substring(0, 1).toUpperCase() + entity.getType().toString().substring(1).toLowerCase();
entityType = entityType.replace('_', ' ');
if (entity instanceof Player || killer == null) {
return;
}
if (entity instanceof Tameable) {
Tameable tameable = (Tameable) entity;
if (tameable.getOwner() != null) {
String owner = tameable.getOwner().getName();
if (entity.getCustomName() == null) {
getServer().broadcastMessage(killer.getDisplayName() + " killed " + owner + "'s " + entityType + ".");
} else {
getServer().broadcastMessage(killer.getDisplayName() + " killed " + entity.getCustomName() + ", " + owner + "'s " + entityType + ".");
}
return;
}
}
if (entity.getCustomName() != null) {
String message = killer.getDisplayName() + " killed " + entity.getCustomName() + " the " + entityType + ".";
getServer().broadcastMessage(message);
}
}
示例13: TameableAnimal
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
public TameableAnimal (Entity entity) {
PreCon.notNull(entity);
PreCon.isValid(entity instanceof Tameable, "entity meust be an instance of Tameable");
Tameable tameable = (Tameable)entity;
_isTamed = tameable.isTamed();
if (tameable.getOwner() != null)
_ownerId = tameable.getOwner().getUniqueId();
}
示例14: entityDeathCondition
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler
public boolean entityDeathCondition(EntityDeathEvent e) {
if (!(e.getEntity() instanceof LivingEntity))
return false;
LivingEntity el = e.getEntity();
if (!(el.getLastDamageCause() instanceof EntityDamageByEntityEvent))
return false;
EntityDamageByEntityEvent edbee = (EntityDamageByEntityEvent) el.getLastDamageCause();
Player p = null;
if (edbee.getDamager() instanceof Player)
p = (Player) edbee.getDamager();
else if (edbee.getDamager() instanceof Projectile) {
Projectile projectile = (Projectile) edbee.getDamager();
if (projectile.getShooter() instanceof Player)
p = (Player) projectile.getShooter();
} else if (edbee.getDamager() instanceof Tameable) {
Tameable tameable = (Tameable) edbee.getDamager();
if (tameable.getOwner() instanceof Player)
p = (Player) tameable.getOwner();
}
if (p == null)
return false;
Group g = Managers.getGroupManager().get(getQuest());
List<MQPlayer> team = g.getMembers();
if (team.contains(p))
if (currentKills.containsKey(el.getType())) {
int count = currentKills.get(el.getType());
currentKills.put(el.getType(), count + 1);
} else
currentKills.put(el.getType(), 1);
return false;
}
示例15: onPotionSplash
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPotionSplash (PotionSplashEvent event)
{
//ignore potions not thrown by players
ThrownPotion potion = event.getPotion();
ProjectileSource projectileSource = potion.getShooter();
if(projectileSource == null || !(projectileSource instanceof Player)) return;
Player thrower = (Player)projectileSource;
//ignore positive potions
Collection<PotionEffect> effects = potion.getEffects();
boolean hasNegativeEffect = false;
for(PotionEffect effect : effects)
{
if(!EntityEventHandler.positiveEffects.contains(effect.getType()))
{
hasNegativeEffect = true;
break;
}
}
if(!hasNegativeEffect) return;
//if not in a no-pvp world, we don't care
WorldSettings settings = this.settingsManager.Get(potion.getWorld());
if(!settings.pvpRequiresClaimFlag) return;
//ignore potions not effecting players or pets
boolean hasProtectableTarget = false;
for(LivingEntity effected : event.getAffectedEntities())
{
if(effected instanceof Player && effected != thrower)
{
hasProtectableTarget = true;
break;
}
else if(effected instanceof Tameable)
{
Tameable pet = (Tameable)effected;
if(pet.isTamed() && pet.getOwner() != null)
{
hasProtectableTarget = true;
break;
}
}
}
if(!hasProtectableTarget) return;
//if in a flagged-for-pvp area, allow
Flag flag = this.GetFlagInstanceAtLocation(thrower.getLocation(), thrower);
if(flag != null) return;
//otherwise disallow
event.setCancelled(true);
GPFlags.sendMessage(thrower, TextMode.Err, settings.pvpDeniedMessage);
}