當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。