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


Java Plugin類代碼示例

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


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

示例1: getEventTimingsByPlugin

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
public static Map<String, MonitorRecord> getEventTimingsByPlugin(Plugin plg) {
	Map<String, MonitorRecord> record = new HashMap<>();
	if (plg == null) {
		return record;
	}
	for (RegisteredListener listener : HandlerList.getRegisteredListeners(plg)) {
		try {
			FieldAccessor<EventExecutor> field = Reflection.getField(RegisteredListener.class, "executor", EventExecutor.class);
			EventExecutor executor = field.get(listener);
			if (executor instanceof EventExecutorInjector) {
				EventExecutorInjector eventExecutorInjector = (EventExecutorInjector) executor;
				String eventName = eventExecutorInjector.getEventName();
				if (eventName != null) {
					MonitorRecord monitorRecord = getMonitorRecord(eventName, eventExecutorInjector.getTotalTime(), eventExecutorInjector.getTotalCount(),
						eventExecutorInjector.getMaxExecuteTime());
					if (record.containsKey(eventName)) {
						MonitorRecord otherMonitorRecord = record.get(eventName);
						record.put(eventName, otherMonitorRecord.merge(monitorRecord));
					} else {
						record.put(eventName, monitorRecord);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return record;
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:30,代碼來源:MonitorUtils.java

示例2: postSpawn

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
@Override
public void postSpawn(HCF plugin) {
    if (this.world.addEntity((Entity)this)) {
        Bukkit.getConsoleSender().sendMessage(String.format((Object)ChatColor.GOLD + "Combat logger of " + this.getName() + " has spawned at %.2f, %.2f, %.2f", this.locX, this.locY, this.locZ));
        MinecraftServer.getServer().getPlayerList().playerFileData.load((EntityHuman)this);
    } else {
        Bukkit.getConsoleSender().sendMessage(String.format((Object)ChatColor.RED + "Combat logger of " + this.getName() + " failed to spawned at %.2f, %.2f, %.2f", this.locX, this.locY, this.locZ));
    }
    this.removalTask = new BukkitRunnable(){

        public void run() {
            MinecraftServer.getServer().getPlayerList().sendAll((Packet)PacketPlayOutPlayerInfo.removePlayer((EntityPlayer)LoggerEntityHuman.this.getBukkitEntity().getHandle()));
            LoggerEntityHuman.this.destroy();
        }
    }.runTaskLater((Plugin)plugin, SettingsYML.COMBAT_LOG_DESPAWN_TICKS);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:17,代碼來源:LoggerEntityHuman.java

示例3: setTemporarySidebar

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
public void setTemporarySidebar(final SidebarProvider provider, final long expiration) {
    if (this.removed.get()) {
        throw new IllegalStateException("Cannot update whilst board is removed");
    }
    this.temporaryProvider = provider;
    this.updateObjective();
    new BukkitRunnable() {
        public void run() {
            if (PlayerBoard.this.removed.get()) {
                this.cancel();
                return;
            }
            if (PlayerBoard.this.temporaryProvider == provider) {
                PlayerBoard.access$4(PlayerBoard.this, null);
                PlayerBoard.this.updateObjective();
            }
        }
    }.runTaskLaterAsynchronously((Plugin)this.plugin, expiration);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:20,代碼來源:PlayerBoard.java

示例4: onEnable

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
@Override
public void onEnable() {
    instance=this;
    new ConfigManager();
    new Database();
    new Cacher();
    new Commands();
    Plugin papi= Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
    if(papi==null){
        Bukkit.getConsoleSender().sendMessage("§6§lGlobalPrefix §7>>> §c無法找到PlaceholderAPI插件,請檢查是否安裝");
    } else{
      if(!new PrefixPlaceholder().hook()){
          Bukkit.getConsoleSender().sendMessage("§6§lGlobalPrefix §7>>> §c注冊PlaceholderAPI變量失敗!");
      }
    }
    new Metrics(instance);
    Bukkit.getConsoleSender().sendMessage("§6§lGlobalPrefix §7>>> §a插件加載完成!");
}
 
開發者ID:Soldier233,項目名稱:GlobalPrefix,代碼行數:19,代碼來源:GlobalPrefix.java

示例5: mockPlugin

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    final Server server = mock(Server.class);
    when(server.getLogger()).thenReturn(Logger.getGlobal());
    if(Bukkit.getServer() == null)
        Bukkit.setServer(server);
    new File("BlockBall/BlockBall.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("BlockBall"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:23,代碼來源:PlayerMetaMySQLControllerTest.java

示例6: setDefaultSidebar

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
public void setDefaultSidebar(final SidebarProvider provider, final long updateInterval) {
    if (provider != this.defaultProvider) {
        this.defaultProvider = provider;
        if (this.runnable != null) {
            this.runnable.cancel();
        }
        if (provider == null) {
            this.scoreboard.clearSlot(DisplaySlot.SIDEBAR);
            return;
        }
        (this.runnable = new BukkitRunnable() {
            public void run() {
                if (PlayerBoard.this.removed.get()) {
                    this.cancel();
                    return;
                }
                if (provider == PlayerBoard.this.defaultProvider) {
                    PlayerBoard.this.updateObjective();
                }
            }
        }).runTaskTimerAsynchronously((Plugin)this.plugin, updateInterval, updateInterval);
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:24,代碼來源:PlayerBoard.java

示例7: mockPlugin

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    new File("PetBlocks.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("PetBlocks"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:19,代碼來源:ParticleEffectMetaMySQLControllerIT.java

示例8: mockPlugin

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    if (Bukkit.getServer() == null) {
        final Server server = mock(Server.class);
        when(server.getLogger()).thenReturn(Logger.getGlobal());
        Bukkit.setServer(server);
    }
    new File("PetBlocks.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("PetBlocks"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:24,代碼來源:PlayerMetaMySQLControllerIT.java

示例9: uninject

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
public static void uninject(Plugin plg) {
	if (plg != null) {
		for (BukkitTask pendingTask : Bukkit.getScheduler().getPendingTasks()) {
			if (pendingTask.isSync() && pendingTask.getOwner().equals(plg)) {
				try {
					FieldAccessor<Runnable> field = Reflection.getField(pendingTask.getClass(), "task", Runnable.class);
					Runnable runnable = field.get(pendingTask);
					if (runnable instanceof SchedulerTaskInjector) {
						field.set(pendingTask, ((SchedulerTaskInjector) runnable).getRunnable());
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:18,代碼來源:SchedulerTaskInjector.java

示例10: call

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
public Object call() throws Exception {
    StringWriter value = new StringWriter();
    try {
        value.append("\n   Running: ").append(Bukkit.getName()).append(" version ").append(Bukkit.getVersion()).append(" (Implementing API version ").append(Bukkit.getBukkitVersion()).append(") ").append(String.valueOf(net.minecraft.server.MinecraftServer.getServer().isServerInOnlineMode()));
        value.append("\n   Plugins: {");
        for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
            PluginDescriptionFile description = plugin.getDescription();
            value.append(' ').append(description.getFullName()).append(' ').append(description.getMain()).append(' ').append(Arrays.toString(description.getAuthors().toArray())).append(',');
        }
        value.append("}\n   Warnings: ").append(Bukkit.getWarningState().name());
        value.append("\n   Threads: {");
        for (Map.Entry<Thread, ? extends Object[]> entry : Thread.getAllStackTraces().entrySet()) {
            value.append(' ').append(entry.getKey().getState().name()).append(' ').append(entry.getKey().getName()).append(": ").append(Arrays.toString(entry.getValue())).append(',');
        }
        value.append("}\n   ").append(Bukkit.getScheduler().toString());
    } catch (Throwable t) {
        value.append("\n   Failed to handle CraftCrashReport:\n");
        PrintWriter writer = new PrintWriter(value);
        t.printStackTrace(writer);
        writer.flush();
    }
    return value.toString();
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:24,代碼來源:CraftCrashReport.java

示例11: loadConfig

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
public static void loadConfig(Plugin plugin) {
    pl = plugin;

    file = new File(pl.getDataFolder(), "Config/Global/OnJoin/Gamemode-OnJoin.yml");
    Config = YamlConfiguration.loadConfiguration(file);

    if (!pl.getDataFolder().exists()) {
        pl.getDataFolder().mkdir();
    }

    create();

    int gamemode = Config.getInt("On-Join.Spawn.Gamemode.Gamemode");

    if ((gamemode != 0) && (gamemode != 1) && (gamemode != 2) && (gamemode != 3)) {
        Config.set("Gamemode.Value", Integer.valueOf(0));
    }
}
 
開發者ID:DianoxDragon,項目名稱:UltimateSpawn,代碼行數:19,代碼來源:ConfigGGM.java

示例12: doubleValue

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
static Parser<Double> doubleValue() {
    return new Parser<Double>() {
        @Override
        public Double load(Plugin plugin, Object object) {
            if (object instanceof Number)
                return ((Number) object).doubleValue();
            else if (object instanceof String)
                return Double.parseDouble((String) object);
            else
                throw new IllegalArgumentException("Cannot parse " + object + " as short");
        }

        @Override
        public Object save(Double s) {
            return s;
        }
    };
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:19,代碼來源:Parser.java

示例13: NavyCraft_Timer

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
public NavyCraft_Timer(Plugin plug, int seconds, Craft vehicle, Player p, String state, boolean forward) {
	//toolkit = Toolkit.getDefaultToolkit();
	plugin = plug;
	this.craft = vehicle;
	this.player = p;
	timer = new Timer();
	if(state.equals("engineCheck"))
		timer.scheduleAtFixedRate(new EngineTask(), 1000, 1000);
	else if(state.equals("engineCheck"))
		timer.schedule(new AutoMoveTask(forward), 1000);
	else if(state.equals("abandonCheck"))
		timer.scheduleAtFixedRate(new ReleaseTask(), seconds * 1000, 60000);
	else if(state.equals("takeoverCheck"))
		timer.scheduleAtFixedRate(new TakeoverTask(), seconds * 1000, 60000);
	else if(state.equals("takeoverCaptainCheck"))
		timer.scheduleAtFixedRate(new TakeoverCaptainTask(), seconds * 1000, 60000);
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:18,代碼來源:NavyCraft_Timer.java

示例14: actionsValue

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
@SuppressWarnings("unchecked")
static Parser<List<Action>> actionsValue() {
    return new Parser<List<Action>>() {
        @Override
        public List<Action> load(Plugin plugin, Object object) {
            if (object instanceof Collection)
                return ActionType.deserialize(plugin, (Collection<Map<String, Object>>) object);
            else
                throw new IllegalArgumentException("Cannot parse " + object + " as short");
        }

        @Override
        public Object save(List<Action> s) {
            return ActionType.serialize(s);
        }
    };
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:18,代碼來源:Parser.java

示例15: addAttachment

import org.bukkit.plugin.Plugin; //導入依賴的package包/類
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks)
{
    if (oldpermissible == null)
    {
        return super.addAttachment(plugin, name, value, ticks);
    }
    return oldpermissible.addAttachment(plugin, name, value, ticks);
}
 
開發者ID:SamaGames,項目名稱:SamaGamesCore,代碼行數:10,代碼來源:Permissible.java


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