当前位置: 首页>>代码示例>>Java>>正文


Java Monster类代码示例

本文整理汇总了Java中org.bukkit.entity.Monster的典型用法代码示例。如果您正苦于以下问题:Java Monster类的具体用法?Java Monster怎么用?Java Monster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Monster类属于org.bukkit.entity包,在下文中一共展示了Monster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEntityDeath

import org.bukkit.entity.Monster; //导入依赖的package包/类
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
    if (e.getEntity() instanceof Monster && e.getEntity().getKiller() instanceof Player) {
        TOAUser u = TOA.getPlayer(e.getEntity().getKiller());
        String name = e.getEntity().getCustomName().split(" ")[1];
        int level = Utils.isInt(name) ? Integer.parseInt(name) : 0;

        new Experience(u).addExp(Mob.getXP(level));

        e.getDrops().clear();
        e.setDroppedExp(0);

        Drop.drop(MobType.parseMobType(e.getEntityType()), u.getUserData().getKit()).forEach(d -> {
            BagEvents.addItem(u, d);
            u.sendSound(Sounds.ITEM_PICKUP);
        });

        if (plugin.getSpawnTask().getCount() == 0) return;
        plugin.getSpawnTask().setCount(plugin.getSpawnTask().getCount() - 1);
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:22,代码来源:GameEvents.java

示例2: play

import org.bukkit.entity.Monster; //导入依赖的package包/类
public void play(TOAUser u){
    if (!canUse(u)) return;
    if (isInCooldown(u, getName())) return;
    int lvl = u.getUserData().getLvl();

    for (int x = 0; x < r.nextInt(4) + 2; x++) {
        final Item d1 = u.getLoc().getWorld().dropItemNaturally(u.getLoc(), new ItemStack(Material.IRON_SWORD));

        d1.setVelocity(u.getPlayer().getVelocity().multiply(2));

        plugin.getServer().getScheduler().runTaskTimer(plugin, () -> {
            World w = d1.getLocation().getWorld();

            w.getNearbyEntities(d1.getLocation(), 1, 1, 1).stream()
                    .filter(en -> !en.getType().equals(EntityType.PLAYER)).forEach(en -> {
                if (en instanceof Monster) ((Monster) en).damage(40 + (lvl * 0.7));
                d1.remove();
            });
        }, 0, 20);
    }
    cool.setOnCooldown(getName());
}
 
开发者ID:cadox8,项目名称:PA,代码行数:23,代码来源:Dagas.java

示例3: BreakBlockSession

import org.bukkit.entity.Monster; //导入依赖的package包/类
public BreakBlockSession(Location l, Material m, double r, int qty, String monsters) {
	_locations = l;
	_material = m;
	_radius = r;
	_qty = qty;
	_monsters = monsters;
	_zone = new WorldZone(l, r);
	_world = l.getWorld();
	_spawnedMonsters = new ArrayList<Monster>();
	_blockBroken = true;
	_isCooldownActive = false;
	_coolDownTime = 0;
	_header = ChatColor.LIGHT_PURPLE + "[" + ChatColor.DARK_PURPLE + "Obsidian" + ChatColor.LIGHT_PURPLE + "] ";
	_resetWhenPlayerLeaving = false;
	_players = new ArrayList<Player>();
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:17,代码来源:BreakBlockSession.java

示例4: activateBreakingZone

import org.bukkit.entity.Monster; //导入依赖的package包/类
public void activateBreakingZone() {
	if (!_isCooldownActive && _blockBroken) {
		_logger.info("activting");
		for (int i = 0; i < _qty; i++) {
			Location loc = _locations.clone();
			loc.setY(loc.getY() + 2);
			EntityType t = EntityHelper.getRandomEntity(_monsters);
			Entity l = _world.spawnCreature(loc, t);
			if (l instanceof Monster) {
				_spawnedMonsters.add((Monster)l);
				_logger.info(l.getEntityId() + " spawned at " + l.getLocation());
			}
		}
		
		org.bukkit.block.Block b = _world.getBlockAt(_locations);
		b.setType(_material);		
		_blockBroken = false;
	}
	else {
		_logger.info("not activting");	
	}
	
	
	
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:27,代码来源:BreakBlockSession.java

示例5: timeHasCome

import org.bukkit.entity.Monster; //导入依赖的package包/类
@Override
public void timeHasCome(long time) {
	if (_monsterSpawned.size() < _maxMonster) {
		Location random = _spawningZone.getRandomLocation(_spawningLocation.getWorld());
		EntityType creature = EntityUtilities.getEntityType(_monsters[RandomUtil.getRandomInt(_monsters.length)]);
		Monster m = (Monster)ScenarioService.getInstance().spawnCreature(_spawningLocation.getWorld(), random, creature, _healthModifier, _burn);
		m.setTarget(_players.get(RandomUtil.getRandomInt(_players.size())));
		
		ScenarioPlugin.logger.fine("Spawner at: " + _spawningLocation.getX() + "," + _spawningLocation.getZ() + " high: " + _spawningLocation.getY() + " - " + creature.toString() + " -> " + m.getTarget().getEntityId());
		
		_monsterSpawned.add(m);
		TimeServer.getInstance().addListener(this, _delayBetweenMonster);
	}
	
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:17,代码来源:FixedSpawner.java

示例6: spawnWave

import org.bukkit.entity.Monster; //导入依赖的package包/类
@Override
public void spawnWave() {
	if (_scenario.isActive() && _locations != null && _locations.size() > 0 && 
		_arrayPossibleMonster.length > 0 && getNbOfEntities() < _maxMonster) {
		
		for (Location l : _locations) {
			
			if (getNbOfEntities() < _maxMonster) {
				EntityType c = EntityUtilities.getEntityType(_arrayPossibleMonster[RandomUtil.getRandomInt(_arrayPossibleMonster.length)]);
				Entity e = ScenarioService.getInstance().spawnCreature(l.getWorld(), l, c, _healthModifier, false);
				_monsters.add(e);
				if (e instanceof Monster) {
					Monster m = (Monster)e;
					m.setTarget(_scenario.pickRandomPlayer());
				}
			}
		}
		
		if (_timeBetweenSpawn > 50) {
			TimeServer.getInstance().addListener(this, _timeBetweenSpawn);
		}
		
	}
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:26,代码来源:RegularSpawnWave.java

示例7: processEntityDeath

import org.bukkit.entity.Monster; //导入依赖的package包/类
@Override
public void processEntityDeath(Entity e) {
	if (_scenario.isActive()) {
		if (e instanceof Monster) {
			_monsters.remove((LivingEntity)e);
			
			if (_scenario.getEventListener() != null) {
				_scenario.getEventListener().monsterDied(e, _monsters.size());
			}
		}
		
		if (_monsters.size() == 0) {
			TimeServer.getInstance().removeListener(this);
			_scenario.waveIsDone();
		}
	}
			
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:20,代码来源:RegularSpawnWave.java

示例8: spawnWave

import org.bukkit.entity.Monster; //导入依赖的package包/类
public void spawnWave() {
	if (_scenario.isActive()) {
		for (int i = 0; i < _nbMonsters; i++) {
			// creation de la location et du monstre
			Location loc = _scenario.getWorldZone().getRandomLocationOutsideThisZone(_scenario.getWorld(), _exclude);
			EntityType type = EntityUtilities.getEntityType(possibleMonsters[RandomUtil.getRandomInt(possibleMonsters.length)]);			
			Entity living = _scenario.getWorld().spawnEntity(loc, type);
			
			if (living instanceof Monster) {
				Monster m = (Monster)living;
				m.setTarget(_scenario.pickRandomPlayer());
			}
			
			// adding to the table
			_monstersTable.add(living);
		}
	}
	
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:21,代码来源:BasicMonsterWave.java

示例9: monsterDies

import org.bukkit.entity.Monster; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void monsterDies(EntityDeathEvent event) {
	
	if (_apocalypseOn && event.getEntity().getLastDamageCause().getCause() != DamageCause.FIRE_TICK) {
		
		if (event.getEntity() instanceof Monster) {
			_monsterDead++;
		}
		
		if (_monsterDead >= _maxMonsters) {
			_completed = true;
			distributeLoot();
			resetEvent();
		}		
		
		try {
			_spawner.spawnMonsterCloseToPlayer(event.getEntity().getLocation());
		}
		catch (Exception ex) {
			_logger.info("exception raised in Mayhem.monsterDies(EntityDeathEvent event) while using the ApocalypseSpawner");
		}
		
	}
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:25,代码来源:Mayhem.java

示例10: playerDies

import org.bukkit.entity.Monster; //导入依赖的package包/类
@EventHandler (priority = EventPriority.NORMAL)
public void playerDies(PlayerDeathEvent event) {
	Player p = event.getEntity();
	boolean playerRemoved = _players.remove(p);
	
	if (playerRemoved && _players.size() == 0 && _started) {
		EventActivator activator = new EventActivator(this);
		activator.run();
		
		if (_blockRestore != null) {
			_blockRestore.run();
		}
		for (Monster m : _monstersEntity) { 
			m.remove();
		}
		_monstersContainer.clear();
		_started = false;
	}
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:20,代码来源:BarbarianRaid.java

示例11: run

import org.bukkit.entity.Monster; //导入依赖的package包/类
@Override
public void run() {
	
	Player p = Bukkit.getServer().getPlayer("punisher_malade");
	
	
	for (Monster e : _entities) {
		
		if (!e.isDead() && !_zone.isInside(e.getLocation())) {
			Location l = _zone.getRandomLocation(_zone.getWorld());
			_movement.moveEntityToLocation(e, l);
			if (p != null) {
				p.sendMessage(ChatColor.GRAY + "DEBUG: " + ChatColor.WHITE + e.getType() + " moving to " + l.getX() + ", " + l.getY() + ", " + l.getZ());
			}
		}
	}
	
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:19,代码来源:MonsterLeach.java

示例12: onMonsterDamage

import org.bukkit.entity.Monster; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onMonsterDamage(EntityDamageEvent event) {		

	if (event instanceof EntityDamageByEntityEvent) {
		
		EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent)event;
		CustomMonster damager = _damageMonsters.get(damageEvent.getDamager().getEntityId());
		
		if (damager != null && damageEvent.getDamager() instanceof Monster && event.getEntity() instanceof Player) {
			int damageDone = (int)(event.getDamage() + (2 * (int)damager.DamageModifier));
			//logger.info("damage done is: " + damageDone + " modifier is: " + (int)damager.DamageModifier + " base damage is: " + event.getDamage());
			event.setDamage(damageDone);
		}
	}
	
	CustomMonster noBurn = _noBurnMonsters.get(event.getEntity().getEntityId());
	if (noBurn != null && event.getEntity() instanceof Monster && event.getCause() == DamageCause.FIRE_TICK) {
		event.setCancelled(true);
		event.getEntity().setFireTicks(0);
	}
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:22,代码来源:CustomMonsterListener.java

示例13: WitherBlockBreak

import org.bukkit.entity.Monster; //导入依赖的package包/类
@EventHandler
public void WitherBlockBreak(EntityChangeBlockEvent event) {
	RedProtect.get().logger.debug("RPEntityListener - Is EntityChangeBlockEvent");
	if (event.isCancelled()) {
        return;
    }
	Entity e = event.getEntity();    	
	if (e instanceof Monster) {
        Region r = RedProtect.get().rm.getTopRegion(event.getBlock().getLocation());
        if (!cont.canWorldBreak(event.getBlock())){        		        		
    		event.setCancelled(true);
    		return;
    	} 
        if (r != null && !r.canMobLoot()){
     	   event.setCancelled(true);
        }
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:19,代码来源:RPEntityListener.java

示例14: onEntityDamage

import org.bukkit.entity.Monster; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
   public void onEntityDamage(EntityDamageEvent e) {
	Region r = RedProtect.get().rm.getTopRegion(e.getEntity().getLocation());
   	if (r != null){
   		return;
   	}
   	Entity ent = e.getEntity();
   	if (ent instanceof LivingEntity && !(ent instanceof Monster)){
   		if (RPConfig.getGlobalFlagBool(ent.getWorld().getName()+".invincible")){
   			if (ent instanceof Animals){
   				((Animals)ent).setTarget(null);
   			}
   			e.setCancelled(true); 
       	}
   	}    	    	
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:17,代码来源:RPGlobalListener.java

示例15: MonsterBlockBreak

import org.bukkit.entity.Monster; //导入依赖的package包/类
@EventHandler
 public void MonsterBlockBreak(EntityChangeBlockEvent event) {
 	Entity e = event.getEntity();    	
 	Block b = event.getBlock();
 	Region r = RedProtect.get().rm.getTopRegion(event.getBlock().getLocation());
 	if (r != null){
   	   return;
     }
 	
 	if (b != null){
 		RedProtect.get().logger.debug("RPGlobalListener - Is EntityChangeBlockEvent event. Block: "+b.getType().name());
 	}
 	
 	if (e instanceof Monster) {
         if (!RPConfig.getGlobalFlagBool(e.getWorld().getName()+".entity-block-damage")){
         	event.setCancelled(true);
         }
 	}
 	if (e instanceof Player){
 		Player p = (Player) e;
 		if (!bypassBuild(p, b, 2)){
 			event.setCancelled(true);
}
 	}
 }
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:26,代码来源:RPGlobalListener.java


注:本文中的org.bukkit.entity.Monster类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。