本文整理汇总了Java中org.bukkit.entity.Entity.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.remove方法的具体用法?Java Entity.remove怎么用?Java Entity.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Entity
的用法示例。
在下文中一共展示了Entity.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onHit
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onHit(EntityDamageEvent event)
{
if(event.isCancelled()) return;
Entity hitTarget = event.getEntity();
if(hitTarget != null && hitTarget instanceof ArmorStand && hitTarget.getCustomName() == "Chair")
// Chair entity is immune to damage.
event.setCancelled(true);
else if(hitTarget != null && hitTarget instanceof Player && hitTarget.getVehicle() != null)
{
// Let players stand up if receiving damage.
Entity vehicle = hitTarget.getVehicle();
if(vehicle != null && vehicle instanceof ArmorStand && vehicle.getCustomName() == "Chair")
vehicle.remove();
}
}
示例2: onMobDeath
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void onMobDeath(EntityDeathEvent event) {
if(event.getEntity() instanceof Entity){
Entity e = (Entity) event.getEntity();
if(e.hasMetadata("challenge")){
event.getDrops().clear();
String[] meta = e.getMetadata("challenge").get(0).asString().split(", ");
final String player = meta[1];
plugin.getChallenges().addKill(Bukkit.getPlayer(player));
Bukkit.getPlayer(player).setLevel(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)));
if(e.getType().equals(EntityType.MAGMA_CUBE) || e.getType().equals(EntityType.SLIME)) {
e.remove();
}
if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0){
plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false);
}
}
}
}
示例3: removeBlock
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void removeBlock(BlockBreakEvent e) {
for (Entity en : e.getBlock().getWorld().getEntities()) {
if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().add(-0.5, 0, -0.5).equals(e.getBlock().getLocation())) {
en.remove();
en.getWorld().getBlockAt(en.getLocation().add(-0.5, 0, -0.5)).setType(Material.AIR);
ItemStack block = new ItemStack(Material.MONSTER_EGG, 1);
ItemMeta bmeta = block.getItemMeta();
bmeta.setDisplayName(name);
block.setItemMeta(bmeta);
if (e.getPlayer() != null && e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
e.getPlayer().getInventory().addItem(block);
} else {
e.getBlock().getWorld().dropItemNaturally(en.getLocation().add(-0.5, 0, -0.5), block);
}
}
}
//}
}
示例4: CheckCrowd
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void CheckCrowd(ChunkLoadEvent evt) {
if (ConfigOptimize.NoCrowdedEntityenable) {
Chunk chunk = evt.getChunk();
Entity[] entities = chunk.getEntities();
for (Entity e : entities) {
EntityType type = e.getType();
int count = 0;
if (ConfigOptimize.NoCrowdedEntityTypeList.contains("*")
|| ConfigOptimize.NoCrowdedEntityTypeList.contains(type.name())) {
count++;
if (count > ConfigOptimize.NoCrowdedEntityPerChunkLimit && e.getType() != EntityType.PLAYER) {
e.remove();
}
}
}
}
}
示例5: onSpawn
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
if (ConfigOptimize.NoCrowdedEntityenable) {
Chunk chunk = event.getEntity().getLocation().getChunk();
Entity[] entities = chunk.getEntities();
for (Entity e : entities) {
EntityType type = e.getType();
int count = 0;
if (ConfigOptimize.NoCrowdedEntityTypeList.contains("*")
|| ConfigOptimize.NoCrowdedEntityTypeList.contains(type.name())) {
count++;
if (count > ConfigOptimize.NoCrowdedEntityPerChunkLimit && e.getType() != EntityType.PLAYER) {
e.remove();
}
}
}
}
}
示例6: onPlace
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlace(BlockPlaceEvent e) {
if (!cm.isAntiPlaceDoorDupe) {
return;
}
// 判断手里的物品是否为门
if (e.getItemInHand().getType() == Material.WOOD_DOOR || e.getItemInHand().getType() == Material.IRON_DOOR) {
// 清理所在区块的甘蔗掉落物
for (Entity entity : e.getPlayer().getLocation().getChunk().getEntities()) {
if (entity instanceof Item) {
Material itemType = ((Item) entity).getItemStack().getType();
if (itemType == Material.SUGAR_CANE || itemType == Material.CACTUS) {
entity.remove();
}
}
}
}
}
示例7: start
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public void start() {
worldName = getPhase().getFeature(MapFeature.class).getWorld().getName();
if (removeExisting) {
for (Entity entity : getPhase().getFeature(MapFeature.class).getWorld().getEntities()) {
if (blacklist.length != 0) {
if (Arrays.stream(blacklist).anyMatch(m -> m.equals(entity.getType()))) {
entity.remove();
}
} else if (whitelist.length != 0) {
if (Arrays.stream(whitelist).noneMatch(m -> m.equals(entity.getType()))) {
entity.remove();
}
} else {
entity.remove();
}
}
}
}
示例8: onCommand
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("hbike")) {
Player player = (Player) sender;
if (args[0].equals("create")) {
create(player.getLocation()).setPassenger(player);
}
else if (args[0].equals("destroy")) {
for (Entity ent : player.getNearbyEntities(0.2, 0.2, 0.2)) {
if (ent.getCustomName() != null && ent.getCustomName().equals("HoverBike")) {
ent.remove();
return true;
}
}
}
return true;
}
return false;
}
示例9: removeLabel
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public static void removeLabel(Item item) {
if (itemLabels.containsKey(item.getUniqueId())) {
Entity e = itemLabels.remove(item.getUniqueId());
if (e != null)
e.remove();
e = null;
}
}
示例10: loadMap
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void loadMap() {
Chat.log(Prefix.LOG_WORLDS + "Generating world: " + worldName + "...");
WorldCreator wc = new WorldCreator(worldName);
wc.createWorld();
getWorld().setAutoSave(false);
getWorld().setKeepSpawnInMemory(false);
getWorld().setFullTime(6000);
for (Entity e : getWorld().getEntities())
if (e instanceof Player == false)
e.remove();
}
示例11: onSpec
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void onSpec(PlayerAliveStatusEvent e) {
if (e.isAlive()) {
return;
}
Entity entity = e.getPlayer().getVehicle();
if (entity != null) {
entity.eject();
entity.remove();
}
}
示例12: killNextCommand
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
private void killNextCommand(Player sender) {
double distance = 100;
Entity nearest = null;
for (final Entity entity : sender.getLocation().getChunk().getEntities()) {
if (!(entity instanceof Player) && sender.getLocation().distance(entity.getLocation()) < distance) {
distance = sender.getLocation().distance(entity.getLocation());
nearest = entity;
}
}
if (nearest != null) {
nearest.remove();
sender.sendMessage(Config.getInstance().getPrefix() + "" + ChatColor.GREEN + "You removed entity " + nearest.getType() + '.');
}
}
示例13: endGame
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void endGame() {
gameState = GameState.ENDING;
if (SkyWarsReloaded.getCfg().bungeeEnabled()&& !shutdown) {
BungeeUtil.sendSignUpdateRequest(this);
}
if (SkyWarsReloaded.getCfg().signJoinMode() && !shutdown) {
SkyWarsReloaded.getGC().updateSign(gameNumber);
}
for (GamePlayer gplayer: getPlayers()) {
deletePlayer(gplayer, false, false);
}
if (SkyWarsReloaded.getCfg().spectatingEnabled()) {
for (GamePlayer gPlayer: getSpectators()) {
removeSpectator(gPlayer);
}
}
for (Player player: mapWorld.getPlayers()) {
if (player != null) {
player.teleport(SkyWarsReloaded.getCfg().getSpawn(), TeleportCause.PLUGIN);
}
}
for (Entity entity: mapWorld.getEntities()) {
if (entity != null) {
entity.remove();
}
}
if (!SkyWarsReloaded.getCfg().spectatingEnabled() && !shutdown) {
SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(), new Runnable() {
@Override
public void run() {
deleteGame();
}
}, 20 * SkyWarsReloaded.getCfg().getTimeAfterGame());
} else {
deleteGame();
}
}
示例14: chunkUnloadClearBullets
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
/**
* This eliminates pending bullets on chunk unload
*
* @param event
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void chunkUnloadClearBullets(ChunkUnloadEvent event) {
if (event.getChunk() == null) return;
Entity[] entities = event.getChunk().getEntities();
for (Entity e : entities) {
if (inFlightBullets.containsKey(e.getUniqueId())) {
inFlightBullets.remove(e.getUniqueId());
travelPaths.remove(e.getUniqueId());
e.remove();
}
}
}
示例15: run
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public void run() {
for (final World world : Bukkit.getWorlds()) {
for (final Entity entity : world.getEntities()) {
if (BallListener.this.isDeadBall(entity)) {
entity.remove();
}
}
}
}