Java 类org.bukkit.Bukkit 实例源码
项目:skLib
文件:SbManager.java
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
}
项目:WC
文件:PlayerEvent.java
@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);
}
}
}
项目:KingdomFactions
文件:ChatChannel.java
/**
* 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.");
}
}
项目:SamaGamesCore
文件:InvisiblePlayerFixListener.java
@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);
}
项目:ProScoreboard
文件:ProScoreboard.java
@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);
}
项目:bskyblock
文件:Metrics.java
/**
* 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 :)
}
项目:Warzone
文件:KOTHControlPointService.java
@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);
}
}
}
}
项目:VanillaPlus
文件:MenuManager.java
@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);
}
}
});
}
项目:AstralEdit
文件:UpdateUtils.java
/**
* 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 + "================================================");
}
}
}
项目:ProjectAres
文件:KDMListener.java
@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();
}
}
项目:ZorahPractice
文件:PingCommand.java
@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;
}
}
项目:UltimateSpawn
文件:Metrics.java
/**
* 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 :)
}
项目:helper
文件:HelperScriptBindings.java
@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);
}
项目:HCFCore
文件:PlayerFaction.java
public boolean addMember(CommandSender sender, @Nullable Player player, UUID playerUUID, FactionMember factionMember) {
if (members.containsKey(playerUUID)) {
return false;
}
PlayerJoinFactionEvent eventPre = new PlayerJoinFactionEvent(sender, player, playerUUID, this);
Bukkit.getPluginManager().callEvent(eventPre);
if (eventPre.isCancelled()) {
return false;
}
// Set the player as a member before calling the
// event so we can change the scoreboard.
lastDtrUpdateTimestamp = System.currentTimeMillis();
invitedPlayerNames.remove(factionMember.getName());
members.put(playerUUID, factionMember);
Bukkit.getPluginManager().callEvent(new PlayerJoinedFactionEvent(sender, player, playerUUID, this));
return true;
}
项目:SayNoToMcLeaks
文件:Metrics.java
@SuppressWarnings("unchecked")
protected JSONObject getRequestJsonObject() {
JSONObject chart = new JSONObject();
chart.put("chartId", chartId);
try {
JSONObject data = getChartData();
if (data == null) {
// If the data is null we don't send the chart.
return null;
}
chart.put("data", data);
} catch (Throwable t) {
if (logFailedRequests) {
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
}
return null;
}
return chart;
}
项目:behave
文件:MainPart.java
private boolean execBeh(String beh){
String[] arr = beh.split(" ");
String cmd = arr[0];
String[] args = Arrays.copyOfRange(arr, 1, arr.length);
String argsas = "";
for(String a : args){
argsas = argsas + a + " ";
}
switch(cmd){
case "print":
getLogger().info(argsas);
return true;
case "addperm":
PluginManager pm = Bukkit.getServer().getPluginManager();
pm.addPermission(new Permission(argsas));
return true;
case "//":
return true;
default:
return false;
}
}
项目:ProjectAres
文件:Lobby.java
private void setupScoreboard() {
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
for(Team team : scoreboard.getTeams()) {
team.unregister();
}
for(Objective objective : scoreboard.getObjectives()) {
objective.unregister();
}
}
项目:AlphaLibary
文件:SimpleMovingInventory.java
/**
* Creates a new {@link Inventory} with multiple Sites
*
* @param p the {@link Player} to open the {@link Inventory} for
* @param size the site of the {@link Inventory}
* @param items a {@link ArrayList} of {@link ItemStack}s which should be inside the {@link Inventory}
* @param name the name of the {@link Inventory}
* @param nextPage the name for the {@link ItemStack} for the next page
* @param prevPage the name for the {@link ItemStack} for the previous page
*/
public SimpleMovingInventory(Player p, int size, ArrayList<ItemStack> items, String name, ItemStack nextPage, ItemStack prevPage) {
Bukkit.getPluginManager().registerEvents(this, AlphaLibary.getInstance());
this.title = name;
this.items = items;
this.size = size;
this.nextPage = nextPage;
this.previousPage = prevPage;
Inventory page = getBlankPage(name, size);
for (ItemStack item : items) {
if (page.firstEmpty() == -1) {
PAGES.add(page);
page = getBlankPage(name, size);
page.addItem(item);
} else {
page.addItem(item);
}
}
PAGES.add(page);
p.openInventory(PAGES.get(currpage));
USERS.put(p.getUniqueId(), this);
}
项目:SamaGamesCore
文件:APIPlugin.java
@EventHandler
public void onLogin(PlayerLoginEvent event)
{
if (!allowJoin)
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.RED + denyJoinReason);
event.setResult(PlayerLoginEvent.Result.KICK_WHITELIST);
event.setKickMessage(ChatColor.RED + denyJoinReason);
return;
}
if (joinPermission != null && !api.getPermissionsManager().hasPermission(event.getPlayer(), joinPermission))
{
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "Vous n'avez pas la permission de rejoindre ce serveur.");
}
if (!ipWhiteList.contains(event.getRealAddress().getHostAddress()))
{
event.setResult(PlayerLoginEvent.Result.KICK_WHITELIST);
event.setKickMessage(ChatColor.RED + "Erreur de connexion vers le serveur... Merci de bien vouloir ré-essayer plus tard.");
Bukkit.getLogger().log(Level.WARNING, "An user tried to connect from IP " + event.getRealAddress().getHostAddress());
}
}
项目:HCFCore
文件:ClassLoad.java
public ClassLoad(HCF plugin) {
super("Class Warmup", TimeUnit.SECONDS.toMillis(0L), false);
this.plugin = plugin;
// Re-equip the applicable class for every player during reloads.
new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
attemptEquip(player);
}
}
}.runTaskLater(plugin, 10L);
}
项目:PetBlocks
文件:CustomGroundArmorstand.java
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);
}
}
项目:AlphaLibary
文件:SimpleScoreboard.java
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);
}
项目:SuperiorCraft
文件:AddMin.java
public AddMin() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.isOp()) {
noreload.put(player.getName(), true);
}
}
}
项目:HCFCore
文件:EnderChestRemovalListener.java
/**
* Removes the ender-chest crafting recipe from the server meaning it can only be obtained from creative mode.
*/
private void removeRecipe() {
for (Iterator<Recipe> iterator = Bukkit.recipeIterator(); iterator.hasNext();) {
if (iterator.next().getResult().getType() == Material.ENDER_CHEST) {
iterator.remove();
}
}
}
项目:UltimateSpawn
文件:WorldUtils.java
public static void setWGetWorldResetExperience() {
if (ConfigGXP.getConfig().getBoolean("XP.Options.Exp.Enable")) {
if (!ConfigGXP.getConfig().getBoolean("XP.Options.Exp.World.All_World")) {
for (String world : ConfigGXP.getConfig().getStringList("XP.Options.Exp.World.Worlds")) {
if (Bukkit.getWorld(world) == null) {
System.out.println("| Invalid world in Experience-OnJoin-config.yml, XP.Options.Exp.World: "+world);
} else {
worlds_XP_Exp.add(world);
}
}
}
}
}
项目:HCFCore
文件:RawcastCommand.java
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length < 1)
{
sender.sendMessage(ChatColor.RED + "Usage: " + "/rawcast");
return true;
}
String arg;
String requiredNode;
int position = 0;
if ((args.length > 2) && ((arg = args[0]).startsWith("-p")))
{
int position1 = 1;
requiredNode = arg.substring(2, arg.length());
}
else
{
position = 0;
requiredNode = null;
}
String message = StringUtils.join(args, ' ', position, args.length);
if (message.length() < 3)
{
sender.sendMessage(ChatColor.RED + "Broadcasts must be at least 3 characters.");
return true;
}
message = ChatColor.translateAlternateColorCodes('&', message);
if (requiredNode != null) {
Bukkit.broadcast(message, requiredNode);
} else {
Bukkit.broadcastMessage(message);
}
return true;
}
项目:Kineticraft
文件:CommandSeen.java
@Override
protected void onCommand(CommandSender sender, String[] args) {
QueryTools.getData(args[0], p -> {
long now = System.currentTimeMillis();
long seenTime = now - (p.isOnline() ?
(p.isVanished() ? MetadataManager.getValue(p.getPlayer(), "vanishTime", System.currentTimeMillis()) : now)
: Bukkit.getOfflinePlayer(p.getUuid()).getLastPlayed());
sender.sendMessage(ChatColor.GRAY + "Showing report of " + ChatColor.GRAY + p.getUsername() + ChatColor.GRAY + ":");
sendValue(sender, "Last Seen", Utils.formatTime(seenTime));
// Show extra data to helpers.
if (Utils.isStaff(sender) && !(sender instanceof DiscordSender))
sendValue(sender, "IP Address", p.getLastIP());
// Show punishments.
sendValue(sender, "Muted", p.isMuted());
if (!p.getPunishments().isEmpty()) {
sendValue(sender, "Banned", p.isBanned());
sender.sendMessage(ChatColor.GRAY + "Punishments:");
p.getPunishments().stream().map(Punishments.Punishment::toString).map(s -> " - " + s).forEach(sender::sendMessage);
}
}, () -> sender.sendMessage(ChatColor.RED + "Player not found."));
}
项目:PetBlocks
文件:CustomGroundArmorstand.java
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 World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, SpawnReason.CUSTOM);
final NBTTagCompound compound = new 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.getEngineEntity()).setRemoveWhenFarAway(false);
this.health = ConfigPet.getInstance().getCombat_health();
if (this.petMeta == null)
return;
PetBlockHelper.setItemConsideringAge(this);
}
}
项目:OpenUHC
文件:QueueModule.java
/**
* Calls a {@link PlayerInitEvent} for all online players at the start of the game.
*
* @param event The event
*/
@EventHandler
public void onGameStart(GameStartEvent event) {
for (Player player : Bukkit.getOnlinePlayers()) {
//TODO: Only run if the player is playing in the game (not spectating)
Bukkit.getPluginManager().callEvent(new PlayerInitEvent(player, false));
initialized.add(player.getUniqueId());
}
}
项目:HCFCore
文件:ItemRemoverListener.java
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
Bukkit.getScheduler().scheduleSyncDelayedTask(hcf, new Runnable() {
public void run() {
for(int i = 0 ; i < e.getDrops().size() ; i++) {
e.getDrops().remove(i);
}
}
}, 20L * 60L * 3L);
}
项目:FactionsXL
文件:PopulationMenu.java
public PopulationMenu(Faction faction) {
this.faction = faction;
demandResources = new DemandMenu(faction);
military = new MilitaryMenu(faction);
setupGUI();
Bukkit.getPluginManager().registerEvents(this, plugin);
}
项目:AsgardAscension
文件:MainInventory.java
public static void setupGodFoodInventory(Player player) {
Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BOLD + "Food of the Gods");
inv.setItem(2, ItemStackGenerator.createItem(Material.SLIME_BALL, 0, 0,
ChatColor.RED + "" + ChatColor.BOLD + "Add Food of the Gods", null));
inv.setItem(4, ItemStackGenerator.createItem(Material.PAPER, 0, 0,
ChatColor.RED + "" + ChatColor.BOLD + "Statistics",
Arrays.asList(ChatColor.GRAY + "Amount of God Foods: " + ChatColor.RED + GodFoodFile.getEffectAmount())));
inv.setItem(6, ItemStackGenerator.createItem(Material.BOOK_AND_QUILL, 0, 0,
ChatColor.RED + "" + ChatColor.BOLD + "Edit Food of the Gods", null));
player.openInventory(inv);
}
项目:MCLibrary
文件:PageGUI.java
@Override
protected Inventory createInventory() {
GUIData data = getData();
Inventory inv = Bukkit.createInventory(null, data.size(), data.title());
setLayout(inv);
setContents(inv);
return inv;
}
项目:RankVouchers
文件:MessagePart.java
public void writeJson(JsonWriter json) {
try {
json.beginObject();
text.writeJson(json);
json.name("color").value(color.name().toLowerCase());
for (final ChatColor style : styles) {
json.name(stylesToNames.get(style)).value(true);
}
if (clickActionName != null && clickActionData != null) {
json.name("clickEvent")
.beginObject()
.name("action").value(clickActionName)
.name("value").value(clickActionData)
.endObject();
}
if (hoverActionName != null && hoverActionData != null) {
json.name("hoverEvent")
.beginObject()
.name("action").value(hoverActionName)
.name("value");
hoverActionData.writeJson(json);
json.endObject();
}
if (insertionData != null) {
json.name("insertion").value(insertionData);
}
if (translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)) {
json.name("with").beginArray();
for (JsonRepresentedObject obj : translationReplacements) {
obj.writeJson(json);
}
json.endArray();
}
json.endObject();
} catch (IOException e) {
Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e);
}
}
项目:BlockBall
文件:PlayerDataRepository.java
/**
* Inserts the item into the database and sets the id
*
* @param item item
*/
@Override
public void insert(PlayerMeta item) {
try (Connection connection = this.dbContext.getConnection()) {
if(item.getUUID() == null)
throw new IllegalArgumentException("UUId cannot be null!");
final long id = this.dbContext.executeStoredInsert("player/insert", connection,
item.getName(), item.getUUID().toString());
((PlayerData)item).setId(id);
} catch (final SQLException e) {
Bukkit.getLogger().log(Level.WARNING, "Database error occurred.", e);
}
}
项目:PetBlocks
文件:PetBlockHelper.java
public static boolean setDieing(final PetBlock petBlock) {
if (!petBlock.isDieing()) {
petBlock.jump();
if (petBlock.getArmorStand() != null && !getArmorstand(petBlock).isDead())
getArmorstand(petBlock).setHeadPose(new EulerAngle(0, 1, 0));
Bukkit.getPluginManager().getPlugin("PetBlocks").getServer().getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugin("PetBlocks"), () -> {
petBlock.getEffectPipeline().playParticleEffect(petBlock.getLocation(), cloud);
petBlock.remove();
}, 20 * 2);
return true;
}
return petBlock.isDieing();
}
项目:KingdomFactions
文件:SayCommand.java
@Override
public void execute() {
String message = "";
for (String part : getArgs()) {
if (message != "")
message += " ";
message += part;
}
Bukkit.broadcastMessage(ChatColor.GRAY + "[" + ChatColor.GREEN +"Broadcast" + ChatColor.GRAY + "] " + ChatColor.WHITE + getPlayerName() +": " + ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', message));
}
项目:KingdomFactions
文件:BuildMenu.java
public void openBuildMenu(KingdomFactionsPlayer p) {
if(p.getCurrentNexus() == null) {
p.sendMessage(Messages.getInstance().getPrefix() + "Je staat momenteel niet in een stad!");
}
if(p.getCurrentNexus() instanceof CapitalNexus) {
p.sendMessage(Messages.getInstance().getPrefix() + "Je staat momenteel in de hoofdstad!");
return;
}
Inventory in = Bukkit.createInventory(null, InventoryType.HOPPER, ChatColor.BLUE + "Gebouwen");
Nexus nexus = (Nexus) p.getCurrentNexus();
for (BuildingType b : BuildingType.values()) {
ArrayList<String> lore = new ArrayList<String>();
if(b == BuildingType.NEXUS) {
if(BuildLevel.getLevel(nexus.getLevel()) == BuildLevel.LEVEL_8) {
lore.add(ChatColor.RED + "Maximaal geupgrade!");
} else {
lore.add(ChatColor.RED + "Level: " + BuildLevel.getLevel(nexus.getLevel()).getRoman());
lore.add(ChatColor.RED + "Upgrade kosten: " + BuildingType.NEXUS.getPrice(p.getKingdomTerritory(),
BuildLevel.getLevel(nexus.getLevel()).next()));
}
} else if (nexus.getBuilding(b) != null) {
if(nexus.getBuilding(b).getLevel() == BuildLevel.LEVEL_8) {
lore.add(ChatColor.RED + "Maximaal geupgrade!");
} else {
Building bu = nexus.getBuilding(b);
lore.add(ChatColor.RED + "Level: " + bu.getLevel().getRoman());
lore.add(ChatColor.RED + "Upgrade kosten: " + bu.getType().getPrice(p.getKingdomTerritory(), bu.getLevel().next()));
}
} else {
lore.add(ChatColor.RED + "Nog niet gebouwd!");
lore.add(ChatColor.RED + "Bouw kosten: " + b.getPrice(p.getKingdomTerritory(), BuildLevel.LEVEL_1));
lore.add(ChatColor.RED + "Benodigde Nexus Level: " + b.getLevel());
}
in.addItem(Item.getInstance().getItem(b.getMaterial(), ChatColor.RED + b.toString(), 1, lore));
}
p.openInventory(in);
}
项目:Kineticraft
文件:ActionEntityPathfind.java
@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);
}
项目:AlphaLibary
文件:SQLDatabaseHandler.java
public void insert(String... values) {
Bukkit.getScheduler().runTaskAsynchronously(AlphaLibary.getInstance(), () -> {
StringBuilder builder = new StringBuilder();
for (String str : values)
builder.append(",").append("\'").append(str).append("\'");
StringBuilder builder2 = new StringBuilder();
String info;
for (int c = 1; c <= getColumnAmount(); c++) {
builder2.append(",").append(getColumnName(c));
}
info = builder2.toString().replaceFirst(",", "");
if (connector != null) {
if (connector.handler().isConnected()) {
try {
String qry = "INSERT INTO " + table + " (" + info + ") VALUES (" + builder.toString().replaceFirst(",", "") + ");";
connector.connect().prepareStatement(qry).executeUpdate();
} catch (SQLException ignored) {
}
}
}
});
}