當前位置: 首頁>>代碼示例>>Java>>正文


Java Minecart類代碼示例

本文整理匯總了Java中org.bukkit.entity.Minecart的典型用法代碼示例。如果您正苦於以下問題:Java Minecart類的具體用法?Java Minecart怎麽用?Java Minecart使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Minecart類屬於org.bukkit.entity包,在下文中一共展示了Minecart類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onMinecartEnter

import org.bukkit.entity.Minecart; //導入依賴的package包/類
@EventHandler
public void onMinecartEnter(PlayerInteractEntityEvent event) {
    if(!(event.getRightClicked() instanceof Minecart)) return;
    event.getRightClicked().setGlowing(false);
    event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1f);
    inMinecarts++;
    if(inMinecarts >= this.getAPI().getGameManager().getPlayersAlive()) {
        new BukkitRunnable() {
            public void run() {
                if(getAPI().getGameManager().getGameState() != GameState.INGAME) return;
                Bukkit.getOnlinePlayers().forEach(player -> {
                    if(getAPI().getGameManager().isAlive(player)) {
                        if(player.getVehicle() == null) getAPI().getGameManager().setAlive(player, false);
                    }
                });
                nextEvent();
            }
        }.runTaskLater(this.getAPI().getPlugin(), 20L);
    }
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:21,代碼來源:MusicalMinecartsGame.java

示例2: run

import org.bukkit.entity.Minecart; //導入依賴的package包/類
/**
 * Clean the cache
 */
@Override
public void run()
{
    long currentTime = System.currentTimeMillis();

    List<Map.Entry<Chunk, Long>> temp = new ArrayList<>();
    temp.addAll(this.lastChunkCleanUp.entrySet());

    for (Map.Entry<Chunk, Long> entry : temp)
    {
        Chunk chunk = entry.getKey();

        if (!chunk.isLoaded() || (currentTime - entry.getValue() <= 60000))
            continue;

        for (Entity entity : chunk.getEntities())
            if (!(entity instanceof Item || entity instanceof HumanEntity || entity instanceof Minecart))
                entity.remove();

        this.lastChunkCleanUp.remove(chunk);
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:26,代碼來源:ChunkListener.java

示例3: init

import org.bukkit.entity.Minecart; //導入依賴的package包/類
@SuppressWarnings("null")
@Override
protected boolean init(final @Nullable Class<? extends Minecart> c, final @Nullable Minecart e) {
	final MinecartType[] ts = MinecartType.values();
	for (int i = ts.length - 1; i >= 0; i--) {
		final Class<?> mc = ts[i].c;
		if (mc == null)
			continue;
		if (e == null ? mc.isAssignableFrom(c) : mc.isInstance(e)) {
			type = ts[i];
			return true;
		}
	}
	assert false;
	return false;
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:17,代碼來源:MinecartData.java

示例4: run

import org.bukkit.entity.Minecart; //導入依賴的package包/類
@Override
public void run() {
    if (!player.isOnline()) return;
    boolean kick = false;
    if (player.getVehicle() instanceof Minecart) {
        if (playerData.wasInMinecartLastRound) kick = true;
        playerData.wasInMinecartLastRound = true;
    } else {
        playerData.wasInMinecartLastRound = false;
    }
    try {
        if (playerData.lastObservedLocation != null && (playerData.lastObservedLocation.distance(player.getLocation()) < 3))
            kick = true;
    } catch (IllegalArgumentException ignored) {}

    int playersOnline = PopulationDensity.inst.getServer().getOnlinePlayers().length;
    if (!Lib.perm(player, "populationdensity.idle") && kick && ConfigData.minimumPlayersOnlineForIdleBoot <= playersOnline) {
        Log.log("Kicked " + player.getName() + " for idling.");
        player.kickPlayer("Kicked for idling, to make room for active players.");
        return;
    }
    playerData.lastObservedLocation = player.getLocation();
    playerData.afkCheckTaskID = PopulationDensity.inst.getServer().getScheduler().scheduleSyncDelayedTask(PopulationDensity.inst, this, 20L * 60 * ConfigData.maxIdleMinutes);
}
 
開發者ID:RoyalDev,項目名稱:PopulationDensity,代碼行數:25,代碼來源:AfkCheckTask.java

示例5: onInventoryOpening

import org.bukkit.entity.Minecart; //導入依賴的package包/類
/**
 * Controls chest ownership for carts.
 *
 * @param e The {@link InventoryMoveItemEvent} associated with the chest.
 */
@EventHandler
public void onInventoryOpening(InventoryOpenEvent e) {
    Inventory inv = e.getInventory();
    if (e.getPlayer() instanceof Player) {
        Player p = (Player) e.getPlayer();
        if (inv.getHolder() instanceof Minecart) {
            Minecart cart = (Minecart) inv.getHolder();
            MinecartMember<?> toCheck = MinecartMemberStore.getAt(cart.getLocation());
            if (toCheck != null && !toCheck.isDerailed()) {
                CartProperties cp = toCheck.getProperties();
                if (!cp.getOwners().contains(p.getName().toLowerCase())) {
                    p.sendMessage(ChatColor.RED + "You do not own this chest!");
                    e.setCancelled(true);
                }
            }
        }
    }
}
 
開發者ID:GoldRushMC,項目名稱:GoldRushPlugin,代碼行數:24,代碼來源:TrainStationLis.java

示例6: onInventoryOpening

import org.bukkit.entity.Minecart; //導入依賴的package包/類
/**
 * This will facilitate the need to update the {@link TrainFactory#ownerStorage} list, because if the inventory changes, the instance changes.
 * 
 * @param e The {@link InventoryMoveItemEvent} associated with the chest.
 */
@EventHandler
public void onInventoryOpening(InventoryOpenEvent e) {
	Inventory inv = e.getInventory();
	if(e.getPlayer() instanceof Player) {
		Player p = (Player) e.getPlayer();
		if(inv.getHolder() instanceof Minecart) {
			Minecart cart = (Minecart) inv.getHolder();
			MinecartMember<?> toCheck = MinecartMemberStore.getAt(cart.getLocation());
			if(toCheck != null) {
				CartProperties cp = toCheck.getProperties();
				if(!cp.getOwners().contains(p.getName().toLowerCase())) {
					p.sendMessage(ChatColor.RED + "You do not own this chest!");
					e.setCancelled(true);
				}
			}
		}
	}
}
 
開發者ID:lexwebb,項目名稱:GoldRushMC,代碼行數:24,代碼來源:TrainStationLis.java

示例7: execute

import org.bukkit.entity.Minecart; //導入依賴的package包/類
@Override
public void execute(Minecart minecart, Object parameter) {

    String data = String.valueOf(parameter);

    if (String.valueOf(parameter).startsWith("+")) {
        TagUtils.addTag(minecart, data.replaceAll("\\+", "").trim());
    } else if (String.valueOf(parameter).startsWith("-")) {
        if (data.replaceAll("-", "").trim().isEmpty()) {
            TagUtils.clearTags(minecart);
        } else {
            TagUtils.removeTag(minecart, data.replaceAll("-", "").trim());
        }
    } else {
        TagUtils.addTag(minecart, data.trim());
    }
}
 
開發者ID:QuarterCode,項目名稱:MinecartRevolutionTags,代碼行數:18,代碼來源:TagCommand.java

示例8: killMinecarts

import org.bukkit.entity.Minecart; //導入依賴的package包/類
private void killMinecarts() {
    this.getAPI().getMapRegistry().getCurrentWorld().getEntities().forEach(entity -> {
        if(entity instanceof Minecart) {
            entity.setMetadata("allow-exit", new FixedMetadataValue(this.getAPI().getPlugin(), true));
            if(!entity.getPassengers().isEmpty()) entity.eject();
            entity.remove();
        }
    });
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:10,代碼來源:MusicalMinecartsGame.java

示例9: spawnMinecarts

import org.bukkit.entity.Minecart; //導入依賴的package包/類
private void spawnMinecarts() {
    int minecarts = this.getAPI().getGameManager().getPlayersAlive();
    if(!enoughMinecarts) minecarts--;
    for(int i=0; i<minecarts; i++) {
        Location location = spawnLocations.get(new Random().nextInt(spawnLocations.size()));
        Minecart minecart = location.getWorld().spawn(location, Minecart.class);
        minecart.getWorld().playSound(minecart.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1f, 1f);
        minecart.setGlowing(true);
    }
    if(enoughMinecarts) enoughMinecarts = false;
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:12,代碼來源:MusicalMinecartsGame.java

示例10: onChunkUnload

import org.bukkit.entity.Minecart; //導入依賴的package包/類
/**
 * Save unloaded chunk
 *
 * @param event Event
 */
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event)
{
    for (Entity entity : event.getChunk().getEntities())
        if (!(entity instanceof Item || entity instanceof HumanEntity || entity instanceof Minecart))
            entity.remove();

    //event.setCancelled(true);
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:15,代碼來源:ChunkListener.java

示例11: onEntityPortal

import org.bukkit.entity.Minecart; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityPortal(EntityPortalEvent e) {
	if (!cm.isAntiMinecartPortal) {
		return;
	}
	if (e.getEntity() instanceof Minecart) {
		e.setCancelled(true);
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:10,代碼來源:AntiMinecartPortal.java

示例12: onCommand

import org.bukkit.entity.Minecart; //導入依賴的package包/類
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
 if (cmd.getName().equalsIgnoreCase("cartcamera")) {
  sender.sendMessage("ja hoor");
  Player p = (Player) sender;
  Minecart minecart = (Minecart) p.getLocation().getWorld().spawn(p.getLocation(), Minecart.class);
  degree = 0;
  direction = false;
  rotating = false;
  uploopcounter = 0;
  playerpublic = (Player) sender;
  Bukkit.getScheduler().scheduleSyncRepeatingTask(main.getPL(), new Runnable() {
   @Override
   public void run() {
    if (rotating == true) {
     degree++;
     degree++; degree++;
     degree++; degree++;
     degree++;degree++;
     degree++; degree++;
     degree++; degree++;
     degree++;
    }
    if (degree == 360 || degree > 360) {
     degree = 0;
    }
    moveEntity(minecart, degree + 1 * 90);
   }
  }, 0, 1);
 }
 return false;
}
 
開發者ID:Mindgamesnl,項目名稱:UselessCode,代碼行數:32,代碼來源:transportation.java

示例13: onPlayerInteract

import org.bukkit.entity.Minecart; //導入依賴的package包/類
@EventHandler
   public void onPlayerInteract(PlayerInteractEntityEvent e) {
   	if (e.isCancelled()) {
           return;
       }

   	Player p = e.getPlayer();
       Entity ent = e.getRightClicked();
       Location l = ent.getLocation();
       Region r = RedProtect.get().rm.getTopRegion(l);
       if (r != null){
		return;
	}
       
       if (ent instanceof ItemFrame || ent instanceof Painting) {
           if (!bypassBuild(p, null, 0)) {
               e.setCancelled(true);
               return;
           }
       } 
       
       if (ent instanceof Minecart || ent instanceof Boat){
       	if (!RPConfig.getGlobalFlagBool(l.getWorld().getName()+".use-minecart") && !p.hasPermission("redprotect.bypass.world")) {
               e.setCancelled(true);
               return;
           }
       } 
       
       if (!RPConfig.getGlobalFlagBool(l.getWorld().getName()+".interact") && !p.hasPermission("redprotect.bypass.world") && (!(ent instanceof Player))) {
   		if (RPConfig.getGlobalFlagList(p.getWorld().getName() + ".if-interact-false.allow-entities").contains(ent.getType().name())){
   			return;
   		} 
           e.setCancelled(true);
	}
}
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:36,代碼來源:RPGlobalListener.java

示例14: wtfOperation

import org.bukkit.entity.Minecart; //導入依賴的package包/類
public static Parameter wtfOperation(Parameter dummy, Context ctx, LocationParameter where) {
	org.bukkit.World w = where.asLocation(ctx).getWorld();
	Location l = where.asLocation(ctx);
	l.setPitch(100.0f);
	l.setYaw(45.0f);
	Minecart e = (Minecart)w.spawnEntity(l, EntityType.MINECART);
	e.setPassenger(w.spawnEntity(where.asLocation(ctx), EntityType.SLIME));
	return Parameter.EmptyString;
	
}
 
開發者ID:basicer,項目名稱:parchment,代碼行數:11,代碼來源:ET.java

示例15: getPlayerFromMinecart

import org.bukkit.entity.Minecart; //導入依賴的package包/類
public RoutePlayer getPlayerFromMinecart(Minecart minecart) {
	for (RoutePlayer player : this.getRoutePlayers()) {
		if (player.getMinecart() == minecart) {
			return player;
		}
	}
	return null;
}
 
開發者ID:Howaner,項目名稱:DeinCart,代碼行數:9,代碼來源:CartManager.java


注:本文中的org.bukkit.entity.Minecart類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。