当前位置: 首页>>代码示例>>Java>>正文


Java Bukkit类代码示例

本文整理汇总了Java中org.bukkit.Bukkit的典型用法代码示例。如果您正苦于以下问题:Java Bukkit类的具体用法?Java Bukkit怎么用?Java Bukkit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Bukkit类属于org.bukkit包,在下文中一共展示了Bukkit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLeave

import org.bukkit.Bukkit; //导入依赖的package包/类
@EventHandler
public void onLeave(PlayerQuitEvent event){
	Player p = event.getPlayer();

	if(Files.user.contains("Users." + p.getName())){

		try{
			Files.user.save(Files.users);
			Files.user.load(Files.users);
		}catch(IOException | InvalidConfigurationException e){
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		if(manager.isInPvP(p)){
			p.setHealth(0D);
			Bukkit.broadcastMessage(Message.prefix + ChatColor.GRAY + " ¡" + ChatColor.GOLD + p.getName() + Message.leave_in_pvp);
		}
	}
}
 
开发者ID:cadox8,项目名称:WC,代码行数:21,代码来源:PlayerEvent.java

示例2: mute

import org.bukkit.Bukkit; //导入依赖的package包/类
/**
 * mutes a KingdomFactionsPlayer
 *
 * @param muted
 *            the KingdomFactionsPlayer who gets muted
 * @param byWho
 *            the muter
 */
public void mute(KingdomFactionsPlayer muted, KingdomFactionsPlayer byWho) {
	ChannelMuteEvent event = new ChannelMuteEvent(this, muted, byWho);
	Bukkit.getPluginManager().callEvent(event);

	if (!event.isCancelled()) {
		try {
			event.getChannel().setRankFor(event.getMuted(), new ListenerChannelRank());
		} catch (ChannelRankException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		event.getChannel().whisperTo(event.getMuted(),
				Messages.getInstance().getPrefix() + "Je kunt niet langer praten in dit chatkanaal.");
		event.getChannel().whisperTo(event.getByWho(),
				Messages.getInstance().getPrefix() + event.getMuted().getName() + " kan niet langer praten.");
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:26,代码来源:ChatChannel.java

示例3: createscrollsb

import org.bukkit.Bukkit; //导入依赖的package包/类
public static void createscrollsb(Player p, String title) {
	Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
	playerScoreboard = scoreboard.registerNewObjective("sklib", "dummy"); //The name of the scoreboard is the name of the player, not that it really needs to be
	playerScoreboard.setDisplayName("Placeholder"); //Will not show to the user, we just need to set this to make bukkit happy
	playerScoreboard.setDisplaySlot(DisplaySlot.SIDEBAR);
	p.setScoreboard(scoreboard);
	new BukkitRunnable()
   	{
   		Scroller scroller = new Scroller(p, title, 16, 4, '&');
   	
   		public void run()
   		{
   			playerScoreboard.setDisplayName(scroller.next(p));
   		}
   		
   	}.runTaskTimer(Main.getInstance(), 0L, 3L); // runs every 3 ticks
	
}
 
开发者ID:WheezyGold7931,项目名称:skLib,代码行数:19,代码来源:SbManager.java

示例4: spawn

import org.bukkit.Bukkit; //导入依赖的package包/类
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final net.minecraft.server.v1_8_R1.World mcWorld = ((org.bukkit.craftbukkit.v1_8_R1.CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final net.minecraft.server.v1_8_R1.NBTTagCompound compound = new net.minecraft.server.v1_8_R1.NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.rabbit.getEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:31,代码来源:CustomGroundArmorstand.java

示例5: SimpleScoreboard

import org.bukkit.Bukkit; //导入依赖的package包/类
public SimpleScoreboard(String id, Player holder) {
    this.holder = holder;
    // Initiate the Bukkit scoreboard
    scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
    scoreboard.registerNewObjective(id, "dummy").setDisplaySlot(DisplaySlot.SIDEBAR);
    objective = scoreboard.getObjective(DisplaySlot.SIDEBAR);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:8,代码来源:SimpleScoreboard.java

示例6: onPlayerLogin

import org.bukkit.Bukkit; //导入依赖的package包/类
@EventHandler
public void onPlayerLogin(PlayerLoginEvent event)
{
    //Don't force if player is hided moderator
    Bukkit.getScheduler().runTaskLater(pluginAPI, () -> {
        if(!pluginAPI.getAPI().getJoinManager().getModeratorsExpected().contains(event.getPlayer().getUniqueId()))
        {
            try{
                sendPlayerToAll(event.getPlayer());
                sendAllToPlayer(event.getPlayer());
            }catch (Exception e)
            {
                e.printStackTrace();
            }
        }
    }, 5L);
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:18,代码来源:InvisiblePlayerFixListener.java

示例7: onEnable

import org.bukkit.Bukkit; //导入依赖的package包/类
@Override
public void onEnable() {
	// Copy config.yml file
	saveDefaultConfig();
	// Load Objects
	loadObjects();
	// Load online players
	createAll();
	// Register command and events
	Bukkit.getPluginCommand("proscoreboard").setExecutor(this);
	Bukkit.getPluginManager().registerEvents(this, this);
	// Create task for update the scoreboards
	long ticks = getConfig().getLong("Options.update-ticks");
	new BukkitRunnable() {

		@Override
		public void run() {
			updateAll();
		}

	}.runTaskTimer(this, ticks, ticks);
}
 
开发者ID:crisdev333,项目名称:ProScoreboard,代码行数:23,代码来源:ProScoreboard.java

示例8: sendData

import org.bukkit.Bukkit; //导入依赖的package包/类
/**
 * Sends the data to the bStats server.
 *
 * @param data The data to send.
 * @throws Exception If the request failed.
 */
private static void sendData(JSONObject data) throws Exception {
    if (data == null) {
        throw new IllegalArgumentException("Data cannot be null!");
    }
    if (Bukkit.isPrimaryThread()) {
        throw new IllegalAccessException("This method must not be called from the main thread!");
    }
    HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();

    // Compress the data to save bandwidth
    byte[] compressedData = compress(data.toString());

    // Add headers
    connection.setRequestMethod("POST");
    connection.addRequestProperty("Accept", "application/json");
    connection.addRequestProperty("Connection", "close");
    connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
    connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
    connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
    connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);

    // Send data
    connection.setDoOutput(true);
    DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
    outputStream.write(compressedData);
    outputStream.flush();
    outputStream.close();

    connection.getInputStream().close(); // We don't care about the response - Just send our data :)
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:37,代码来源:Metrics.java

示例9: captured

import org.bukkit.Bukkit; //导入依赖的package包/类
@Override
public void captured(MatchTeam matchTeam) {
    Bukkit.broadcastMessage(matchTeam.getColor() + ChatColor.BOLD.toString() + matchTeam.getAlias() + ChatColor.WHITE
            + " took control of " + ChatColor.AQUA + ChatColor.BOLD.toString() + definition.getName());


    kothModule.incrementPoints(matchTeam, definition.getPointsPerTick());
    kothModule.updateScoreboardControlPointLine(definition);


    for (MatchTeam team : match.getModule(TeamManagerModule.class).getTeams()) {
        for (PlayerContext playerContext : team.getMembers()) {
            if (team == matchTeam || team.isSpectator()) {
                playerContext.getPlayer().playSound(playerContext.getPlayer().getLocation(), Sound.BLOCK_PORTAL_TRAVEL, 0.7f, 2f);
            } else {
                playerContext.getPlayer().playSound(playerContext.getPlayer().getLocation(), Sound.ENTITY_BLAZE_DEATH, 0.8f, 0.8f);
            }
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:21,代码来源:KOTHControlPointService.java

示例10: onClose

import org.bukkit.Bukkit; //导入依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onClose(InventoryCloseEvent event) {
	if (!(event.getInventory().getHolder() instanceof MenuLink))
		return;
	final VPPlayer player = VanillaPlusCore.getPlayerManager().getPlayer((Player) event.getPlayer());
	final MenuLink menu = ((MenuLink) event.getInventory().getHolder());
	Bukkit.getScheduler().scheduleSyncDelayedTask(VanillaPlus.getInstance(), new Runnable() {
		@Override
		public void run() {
			if(player.getPlayer().getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING){
				menu.getIconMenu().closed(player, menu);
			}else{
				menu.getIconMenu().changed(player, menu);
			}
		}
	});
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:18,代码来源:MenuManager.java

示例11: checkPluginUpToDateAndPrintMessage

import org.bukkit.Bukkit; //导入依赖的package包/类
/**
 * Checks if the given plugin version and spigot resource Id is the same by doing and webRequest and printing the result into the console
 *
 * @param resourceId spigot resourceId
 * @param prefix     prefix
 * @param pluginName pluginName
 * @param plugin     plugin
 * @throws IOException exception
 */
public static void checkPluginUpToDateAndPrintMessage(long resourceId, String prefix, String pluginName, Plugin plugin) throws IOException {
    if (!isPluginUpToDate(resourceId, plugin)) {
        if (plugin.getDescription().getVersion().endsWith("SNAPSHOT")) {
            Bukkit.getServer().getConsoleSender().sendMessage(prefix + ChatColor.YELLOW + "================================================");
            Bukkit.getServer().getConsoleSender().sendMessage(prefix + ChatColor.YELLOW + "You are using a snapshot of " + pluginName);
            Bukkit.getServer().getConsoleSender().sendMessage(prefix + ChatColor.YELLOW + "Please check regularly if there is a new version");
            Bukkit.getServer().getConsoleSender().sendMessage(prefix + ChatColor.YELLOW + "================================================");
        } else {
            Bukkit.getServer().getConsoleSender().sendMessage(prefix + ChatColor.YELLOW + "================================================");
            Bukkit.getServer().getConsoleSender().sendMessage(prefix + ChatColor.YELLOW + pluginName + " is outdated");
            Bukkit.getServer().getConsoleSender().sendMessage(prefix + ChatColor.YELLOW + "Please download the latest version from spigotmc.org");
            Bukkit.getServer().getConsoleSender().sendMessage(prefix + ChatColor.YELLOW + "================================================");
        }
    }
}
 
开发者ID:Shynixn,项目名称:AstralEdit,代码行数:25,代码来源:UpdateUtils.java

示例12: onMatchEnd

import org.bukkit.Bukkit; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onMatchEnd(MatchEndEvent event) {
    Match match = event.getMatch();
    Tourney plugin = Tourney.get();
    this.session.appendMatch(match, plugin.getMatchManager().getTeamManager().teamToEntrant(Iterables.getOnlyElement(event.getMatch().needMatchModule(VictoryMatchModule.class).winners(), null)));

    Entrant winningParticipation = this.session.calculateWinner();
    int matchesPlayed = this.session.getMatchesPlayed();
    if (winningParticipation != null) {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "A winner has been determined!");
        Bukkit.broadcastMessage(ChatColor.AQUA + WordUtils.capitalize(winningParticipation.team().name()) + ChatColor.RESET + ChatColor.YELLOW + " wins! Congratulations!");
        plugin.clearKDMSession();
    } else if (matchesPlayed < 3) {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "A winner has not yet been determined! Beginning match #" + (matchesPlayed + 1) + "...");
        match.needMatchModule(CycleMatchModule.class).startCountdown(Duration.ofSeconds(15), session.getMap());
    } else {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "There is a tie! Congratulations to both teams!");
        Tourney.get().clearKDMSession();
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:21,代码来源:KDMListener.java

示例13: onTabComplete

import org.bukkit.Bukkit; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, String[] args) {
    if (args.length == 0 || args[0].equals("")) {
        return Bukkit.getOnlinePlayers().stream().map(player -> player.getName()).collect(Collectors.toList());
    } else {
        ArrayList<String> returnList = new ArrayList<>();

        for (Player p : Bukkit.getOnlinePlayers()) {
            if (p.getName().toLowerCase().startsWith(args[0].toLowerCase())) {
                returnList.add(p.getName());
            }
        }

        return returnList;
    }
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:17,代码来源:PingCommand.java

示例14: execute

import org.bukkit.Bukkit; //导入依赖的package包/类
@Override
public void execute() {
    if (this.target == null)
        return;

    Entity e = getEntity();
    Location goal = this.target.clone();
    goal.setWorld(e.getWorld());
    BukkitTask[] task = new BukkitTask[1];
    final double walkSpeed = e.getLocation().distance(goal) / (double) getEvent().getTickDelay();

    task[0] = Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> stepLocation(e, goal, walkSpeed), 0L, 1L); // Move the entity closer every tick.
    Bukkit.getScheduler().runTaskLater(Core.getInstance(), task[0]::cancel, getEvent().getTickDelay() - 1);
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:15,代码来源:ActionEntityPathfind.java

示例15: appendTo

import org.bukkit.Bukkit; //导入依赖的package包/类
@Override
public void appendTo(@Nonnull Bindings bindings) {

    // provide exports to access the exports registry & core server classes
    bindings.put("exports", exports);
    bindings.put("server", Bukkit.getServer());
    bindings.put("plugin", plugin);
    bindings.put("services", Bukkit.getServicesManager());

    // some util functions
    bindings.put("colorize", (Function<Object, String>) HelperScriptBindings::colorize);
    bindings.put("newMetadataKey", (Function<Object, MetadataKey>) HelperScriptBindings::newMetadataKey);
    bindings.put("newEmptyScheme", (Supplier<MenuScheme>) HelperScriptBindings::newScheme);
    bindings.put("newScheme", (Function<SchemeMapping, MenuScheme>) HelperScriptBindings::newScheme);

    // some general functions for working with java collections in js
    GeneralScriptBindings.appendTo(bindings);

    // provide hook into the resolvePackageWildcard method below, used by the importWildcardPackage function
    bindings.put("resolvePackageWildcard", (Function<String, List<String>>) HelperScriptBindings::resolvePackageWildcard);
}
 
开发者ID:lucko,项目名称:helper,代码行数:22,代码来源:HelperScriptBindings.java


注:本文中的org.bukkit.Bukkit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。