本文整理匯總了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();
}
}
}
}