当前位置: 首页>>代码示例>>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;未经允许,请勿转载。