本文整理汇总了Java中org.bukkit.entity.Tameable.setOwner方法的典型用法代码示例。如果您正苦于以下问题:Java Tameable.setOwner方法的具体用法?Java Tameable.setOwner怎么用?Java Tameable.setOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Tameable
的用法示例。
在下文中一共展示了Tameable.setOwner方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: changeOwner
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
/**
* Change the owner of a pet.
*
* @param event
* @param oldOwner
* @param newOwner
*/
private void changeOwner(PlayerInteractEntityEvent event, AnimalTamer oldOwner, Player newOwner) {
if (chargePrice(event.getPlayer(), changeOwnerPrice)) {
Tameable tameableAnimal = (Tameable) event.getRightClicked();
// Change owner.
tameableAnimal.setOwner(newOwner);
event.getPlayer().sendMessage(plugin.getChatHeader()
+ plugin.getPluginLang().getString("owner-changed", "This pet was given to a new owner!"));
newOwner.sendMessage(plugin.getChatHeader()
+ plugin.getPluginLang().getString("new-owner", "Player PLAYER gave you ownership of a pet!")
.replace("PLAYER", event.getPlayer().getName()));
// Create new event to allow other plugins to be aware of the ownership change.
PlayerChangeAnimalOwnershipEvent playerChangeAnimalOwnershipEvent = new PlayerChangeAnimalOwnershipEvent(
oldOwner, newOwner, tameableAnimal);
Bukkit.getServer().getPluginManager().callEvent(playerChangeAnimalOwnershipEvent);
}
}
示例3: apply
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@Override
public boolean apply(Entity entity) {
PreCon.notNull(entity);
PreCon.isValid(entity instanceof Tameable, "entity meust be an instance of Tameable");
Tameable tameable = (Tameable)entity;
tameable.setTamed(_isTamed);
if (_ownerId != null) {
Player player = PlayerUtils.getPlayer(_ownerId);
tameable.setOwner(player);
}
else {
tameable.setOwner(null);
}
return true;
}
示例4: restoreTameable
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
private void restoreTameable(final Tameable entity) {
if (this.tamed.tamed) {
if (this.tamed.owner != null) {
entity.setTamed(true);
entity.setOwner(this.tamed.owner);
}
}
}
示例5: handleInteract
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
public void handleInteract(Stable stable, Player player, Tameable animal) {
OfflinePlayer newOwner = giveQueue.get(player);
removeFromQueue(player);
if (animal instanceof AbstractHorse) {
AbstractHorse horse = (AbstractHorse) animal;
Stable newStable = StableMaster.getStable(newOwner);
stable.removeHorse(horse);
newStable.addHorse(horse);
}
animal.setOwner(newOwner);
new LangString("command.give.given", getAnimal(((Animals) animal).getType()), newOwner.getName()).send(player);
}
示例6: restoreTameable
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
private void restoreTameable(Tameable entity) {
if (this.tamed.tamed) {
if (this.tamed.owner != null) {
entity.setTamed(true);
entity.setOwner(this.tamed.owner);
}
}
}
示例7: apply
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@Override
public void apply(Entity e, MagicUser cause) {
if (!(cause.getEntity() instanceof AnimalTamer)) {
QuestManagerPlugin.logger.warning("Unable to summon tamed "
+ "entity to caster, because they aren't an AnimalTamer: " + cause.getEntity().getCustomName());
return;
}
SummonManager manager = QuestManagerPlugin.questManagerPlugin.getSummonManager();
Location tmp = e.getLocation().clone();
tmp.add(0, 1.5, 0);
tmp.add(e.getLocation().getDirection().normalize().multiply(2));
Entity ent = tmp.getWorld().spawnEntity(tmp, type);
if (!(ent instanceof Tameable)) {
QuestManagerPlugin.logger.warning("Unable to summon tamed"
+ " entity, as entity type is not tameable: [" + type + "]");
ent.remove();
return;
}
Summon s = new Summon(cause.getEntity().getUniqueId(), ent, duration);
if (cause instanceof Player) {
if (!manager.registerSummon((Player) cause, s)) {
s.remove();
cause.getEntity().sendMessage(SUMMON_DENIAL);
return;
}
} else {
manager.registerSummon(s);
}
Tameable tame = (Tameable) ent;
tame.setTamed(true);
tame.setOwner((AnimalTamer) cause.getEntity());
ent.setCustomName(cause.getEntity().getName() + "'s " + name);
ent.setCustomNameVisible(true);
if (ent instanceof LivingEntity) {
LivingEntity live = (LivingEntity) ent;
live.setRemoveWhenFarAway(false);
if (hp > 0) {
live.setMaxHealth(hp);
live.setHealth(hp);
}
}
}
示例8: onEntityTame
import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event)
{
AnimalTamer owner = event.getOwner();
if (owner instanceof Player)
{
Player player = (Player) owner;
if (! plugin.isDisabledWorld(player))
{
// XP Gain
String mobname = FormatUtil.getFriendlyName(event.getEntity().getType());
String article = FormatUtil.getArticle(mobname);
String message = plugin.getPrefix() +
FormatUtil.format(plugin.getMessage("taming_gain"), xpGain, article, mobname);
plugin.getExperienceHandler().handleXpGain(player, xpGain, message);
// Wolf/Ocelot's Pal
PlayerData data = plugin.getPlayerDataCache().getData(player);
int level = data.getLevel(50);
if (Util.random(150 / level) == 0)
{
if (event.getEntity() instanceof Wolf)
{
Wolf wolf = (Wolf) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.WOLF);
wolf.setOwner(player);
}
else if (event.getEntity() instanceof Ocelot)
{
Ocelot ocelot = (Ocelot) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.OCELOT);
ocelot.setOwner(player);
}
}
// Taming Bomb!
if (Util.random(150 / level) == 0)
{
boolean sendMessage = false;
List<Entity> entities = player.getNearbyEntities(10, 10, 10);
if (entities.size() > 0)
{
for (Entity entity : entities)
{
if (entity != null && entity instanceof Tameable)
{
Tameable tameable = (Tameable) entity;
if (! tameable.isTamed())
{
tameable.setOwner(player);
sendMessage = true;
}
}
}
}
if (sendMessage)
{
player.sendMessage(plugin.getPrefix() + FormatUtil.format(plugin.getMessage("tame_bomb")));
}
}
}
}
}