本文整理了Java中org.bukkit.plugin.Plugin.getServer()
方法的一些代码示例,展示了Plugin.getServer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Plugin.getServer()
方法的具体详情如下:
包路径:org.bukkit.plugin.Plugin
类名称:Plugin
方法名:getServer
[英]Returns the Server instance currently running this plugin
[中]返回当前运行此插件的服务器实例
代码示例来源:origin: Bukkit/Bukkit
@Override
protected boolean isInputValid(ConversationContext context, String input) {
return plugin.getServer().getPlayer(input) != null;
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Stops the active inactivity timer.
*/
private void stopTimer() {
if (taskId != -1) {
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
}
}
代码示例来源:origin: Bukkit/Bukkit
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
return acceptValidatedInput(context, plugin.getServer().getPlayer(input));
}
代码示例来源:origin: EngineHub/WorldEdit
void register(Plugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Starts an inactivity timer.
*/
private void startTimer() {
taskId = plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
if (conversation.getState() == Conversation.ConversationState.UNSTARTED) {
startTimer();
} else if (conversation.getState() == Conversation.ConversationState.STARTED) {
cancelling(conversation);
conversation.abandon(new ConversationAbandonedEvent(conversation, InactivityConversationCanceller.this));
}
}
}, timeoutSeconds * 20);
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Creates a new PluginLogger that extracts the name from a plugin.
*
* @param context A reference to the plugin
*/
public PluginLogger(Plugin context) {
super(context.getClass().getCanonicalName(), null);
String prefix = context.getDescription().getPrefix();
pluginName = prefix != null ? new StringBuilder().append("[").append(prefix).append("] ").toString() : "[" + context.getDescription().getName() + "] ";
setParent(context.getServer().getLogger());
setLevel(Level.ALL);
}
代码示例来源:origin: EngineHub/WorldEdit
protected PermissionsResolverManager(Plugin plugin) {
this.server = plugin.getServer();
(new ServerListener()).register(plugin); // Register the events
loadConfig(new File("wepif.yml"));
findResolver();
}
代码示例来源:origin: EngineHub/WorldEdit
public CommandMap getCommandMap() {
CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
if (commandMap == null) {
if (fallbackCommands != null) {
commandMap = fallbackCommands;
} else {
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() +
": Could not retrieve server CommandMap, using fallback instead!");
fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer());
Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin);
}
}
return commandMap;
}
代码示例来源:origin: mcMMO-Dev/mcMMO
@Override
protected void sendMessage() {
plugin.getServer().broadcast(message, "mcmmo.chat.adminchat");
}
}
代码示例来源:origin: MilkBowl/Vault
@Override
public double getBalance(String playerName) {
List<World> worlds = plugin.getServer().getWorlds();
return getBalance(playerName, worlds.get(0).getName());
}
代码示例来源:origin: MilkBowl/Vault
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
List<World> worlds = plugin.getServer().getWorlds();
return depositPlayer(playerName, worlds.get(0).getName(), amount);
}
代码示例来源:origin: MilkBowl/Vault
@Override
public String getPlayerPrefix(String world, String player) {
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
}
if (!p.getWorld().getName().equals(world)) {
return null;
}
return iChat.getPrefix(p);
}
代码示例来源:origin: MilkBowl/Vault
@Override
public String getPlayerSuffix(String world, String player) {
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
}
if (!p.getWorld().getName().equals(world)) {
return null;
}
return iChat.getSuffix(p);
}
代码示例来源:origin: MilkBowl/Vault
public void unload_api() {
SDFEconomy pluginSDF = (SDFEconomy) plugin.getServer().getPluginManager().getPlugin("SDFEconomy");
if(isEnabled() && pluginSDF != null) {
api = null;
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), name));
}
}
代码示例来源:origin: MilkBowl/Vault
@Override
public boolean groupAdd(String world, String group, String permission) {
if (world != null) {
permission = world + ":" + permission;
}
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions group setperm " + group + " " + permission + " true");
}
代码示例来源:origin: MilkBowl/Vault
public Economy_Craftconomy3(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin ec = plugin.getServer().getPluginManager().getPlugin("Craftconomy3");
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.greatmancode.craftconomy3.BukkitLoader")) {
economy = (BukkitLoader) ec;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
代码示例来源:origin: MilkBowl/Vault
public Economy_SDFEconomy(Plugin _plugin) {
plugin = _plugin;
// Register a listener to wait for plugin being loaded
plugin.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Try and Load API in case plugin was loaded before Vault
load_api();
}
代码示例来源:origin: MilkBowl/Vault
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (chat.overPerms == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("OverPermissions");
if (chat != null) {
this.chat.overPerms = (OverPermissions) chat;
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", new Object[] {plugin.getDescription().getName(), getName()}));
}
}
}
代码示例来源:origin: MilkBowl/Vault
public Economy_CommandsEX(Plugin plugin){
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
if (economy == null) {
Plugin commandsex = plugin.getServer().getPluginManager().getPlugin("CommandsEX");
if (commandsex != null && commandsex.isEnabled()) {
economy = (CommandsEX) commandsex;
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
代码示例来源:origin: MilkBowl/Vault
public Economy_McMoney(Plugin plugin) {
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (economy == null) {
Plugin econ = plugin.getServer().getPluginManager().getPlugin("McMoney");
if (econ != null && econ.isEnabled()) {
economy = McMoneyAPI.getInstance();
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!