[英]How to use my own .jar as an api/library?
我正在使用intellij IDEA,並且已按照所有指示將項目導出為.jar的說明。 它說我無法將jar用作api並調用方法。 這是我的罐子:
`打包me.JBoss925.com;
import com.sun.org.apache.xerces.internal.xs.StringList;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
/**
* Created by JBoss925 on 4/11/14.
* Made for beginners and people who want to spend less time on code.
* If you can see this please tell me how you were able to decompile this.
*/
public class api extends JavaPlugin{
public static AsyncPlayerChatEvent chat;
public static PlayerJoinEvent join;
public static PlayerInteractEvent pie;
public static void setKilled(Player victim, boolean killed){
if(killed == true){
victim.setHealth(0.0);
}
}
public static void openInventory(Player player, Inventory inventory){
player.openInventory(inventory);
}
public static void closeInventory(Player player, Inventory inventory){
if(player.getOpenInventory().equals(inventory)){
player.closeInventory();
}
}
public static void tellPlayer(Player receiver, String message){
receiver.sendMessage(message);
}
public static void replaceCurseWords(boolean allowed){
if(allowed == true){
return;
}
if(allowed == false){
if(chat.getMessage().contains("crap")){
chat.getMessage().replace("crap", "flip");
}
if(chat.getMessage().contains("good")){
chat.getMessage().replace("good", "poop");
}
if(chat.getMessage().contains("damn")){
chat.getMessage().replace("damn", "darn");
}
if(chat.getMessage().contains("douche")){
chat.getMessage().replace("douche", "friend");
}
}
}
public static void addPotion(PotionEffectType potionEffectType, Player player, Integer time, Integer level){
player.addPotionEffect(new PotionEffect(potionEffectType, level, time));
}
public static void playerAddUUIDList(Player player, List list){
UUID i = player.getUniqueId();
list.add(i);
}
public static void playerAddUUIDList(Player player, ArrayList arrayList){
UUID i = player.getUniqueId();
arrayList.add(i);
}
public static void performCommand(Player player, String command){
player.performCommand(command);
}
public static void playerSetFire(Player victim, Integer ticksIfEnabled, boolean enabled){
if(enabled == true){
victim.setFireTicks(ticksIfEnabled);
}
if(enabled == false){
victim.setFireTicks(0);
}
}
}
`
要將jar文件添加到您的項目類路徑,請按照以下步驟操作
Go to Project-> Libraries and add the folder that has the jars. all in this folder will be added to classpath.
這些jar文件將作為api工作。
使用jdk創建包含所有必需類的jar,然后將其包含在類路徑中。 您應該能夠根據需要導入您的課程。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.