本文整理汇总了Java中org.bukkit.event.entity.EntityTameEvent类的典型用法代码示例。如果您正苦于以下问题:Java EntityTameEvent类的具体用法?Java EntityTameEvent怎么用?Java EntityTameEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityTameEvent类属于org.bukkit.event.entity包,在下文中一共展示了EntityTameEvent类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) {
// Return if the damaged entity is not a tameable entity.
if (!(event.getEntity() instanceof Tameable))
return;
Player player = (Player) event.getOwner();
Animals animal = (Animals) event.getEntity();
String name = animal.getType().name().toLowerCase();
// Don't cancel if the player has the appropriate permission
if (player.hasPermission("stablemaster.tame." + name))
return;
event.setCancelled(true);
new LangString("error.cannot-tame", getAnimal(animal.getType())).send(player);
}
示例2: onTame
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler
public void onTame(EntityTameEvent e) {
if (e.isCancelled()) {
return;
}
if (QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getAllowTaming()) {
return;
}
String worldname = e.getEntity().getWorld().getName();
if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds().contains(worldname)) {
return;
}
if (e.getOwner() instanceof Player) {
((Player) e.getOwner()).sendMessage(ChatColor.DARK_PURPLE + "Taming is not allowed here!" + ChatColor.RESET);
}
e.setCancelled(true);
}
示例3: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
/**
* Monitor EntityTame events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) {
if (event instanceof FakeEntityTameEvent) {
return;
}
Player player = (Player) event.getOwner();
LivingEntity entity = event.getEntity();
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
return;
}
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity);
}
示例4: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityTame(EntityTameEvent event){
if(enableEventTame) {
try {
Player player = (Player) event.getOwner();
if(!player.hasPermission("googleanalyticsplugin.ignore")) {
Entity entity = event.getEntity();
plugin.getTracker().TrackAction(getClientName(plugin, player), getClientId(player), getClientIP(player.getAddress().getAddress()), player.getName(), "Tamed", getEntityName(entity));
}
}
catch(Exception e) {
plugin.getLogger().warning("Event Listener Error: " + e.getMessage());
}
}
}
示例5: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler
public void onEntityTame(EntityTameEvent event) {
if (!plugin.getConfig().getBoolean("events.tamed")) {
return;
}
AnimalTamer owner = event.getOwner();
if (!(owner instanceof Player)) {
return;
}
Player player = (Player) owner;
message.sendMessage(event.getEntity(), player, Message.EventType.tamed);
}
示例6: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler
public void onEntityTame(EntityTameEvent event){
Player player = (Player)event.getOwner();
EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId());
List<EpicQuestTask> taskList = epicPlayer.getTasksByType(TaskTypes.TAME_MOB);
for(EpicQuestTask task : taskList){
//Check if correct entity was tamed
String entitytamed = event.getEntityType().name();
String entityneeded = task.getTaskID();
if(entitytamed.equalsIgnoreCase(entityneeded)){
task.ProgressTask(1, epicPlayer, true);
}
}
}
示例7: onPlayerTame
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTame(EntityTameEvent event) {
if (!(event.getOwner() instanceof Player)) {
return;
}
Player player = (Player) event.getOwner();
NormalAchievements category = NormalAchievements.TAMES;
if (!shouldIncreaseBeTakenIntoAccount(player, category)) {
return;
}
updateStatisticAndAwardAchievementsIfAvailable(player, category, 1);
}
示例8: onTaming
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler
public void onTaming(EntityTameEvent event) {
if (event.getOwner() instanceof Player) {
String playerID = PlayerConverter.getID((Player) event.getOwner());
if (!dataMap.containsKey(playerID)) {
return;
}
LivingEntity entity = event.getEntity();
TameData playerData = (TameData) dataMap.get(playerID);
switch (type) {
case WOLF:
if (entity.getType().equals(EntityType.WOLF) && checkConditions(playerID)) {
playerData.subtract();
}
break;
case OCELOT:
if (entity.getType().equals(EntityType.OCELOT) && checkConditions(playerID)) {
playerData.subtract();
}
break;
case HORSE:
if (entity.getType().equals(EntityType.HORSE) && checkConditions(playerID)) {
playerData.subtract();
}
break;
default:
break;
}
if (playerData.isZero()) {
completeObjective(playerID);
}
}
}
示例9: horseTameEvent
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler
public void horseTameEvent(EntityTameEvent event){
if(event.getEntityType() == EntityType.HORSE){
Player p = (Player)event.getOwner();
p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GOLD + " You have succesfully protected this horse!");
p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GREEN + " To unclaim your horse, use /horseunclaim");
}
}
示例10: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityTame(EntityTameEvent event) {
this.module.getStatSystem().increment("taming." + event.getEntity().getType().name().toLowerCase(), event.getOwner().getName());
}
示例11: PoreEntityTameEvent
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
public PoreEntityTameEvent(org.spongepowered.api.event.entity.EntityTameEvent handle) {
super(null, null);
this.handle = checkNotNull(handle, "handle");
checkState(handle.getEntity() instanceof Living, "Bad entity type");
}
示例12: getHandle
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
public org.spongepowered.api.event.entity.EntityTameEvent getHandle() {
return this.handle;
}
示例13: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入依赖的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")));
}
}
}
}
}