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