Java 类org.bukkit.plugin.java.JavaPlugin 实例源码

项目:MT_Communication    文件:MortuusTerraChat.java   
public void onEnable() {
    // Console sender
    getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "|----------|");
    getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "Starting Mortuus Terra chat.");

    core = JavaPlugin.getPlugin(MortuusTerraCore.class);

    frequencyManager = new FrequencyManager();
    fileManager = new FileManager();
    playerManager = new PlayerManager();
    textMessageManager = new TextMessageManager();
    messageScrambler = new MessageScrambler();

    getFileManager().loadFiles();

    registerCommands();
    registerListeners();

    // Console sender
    getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "Mortuus Terra chat ready.");
    getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "|----------|");
}
项目:MT_Communication    文件:MortuusTerraChat.java   
public void onEnable() {
    // Console sender
    getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "|----------|");
    getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "Starting Mortuus Terra chat.");

    core = JavaPlugin.getPlugin(MortuusTerraCore.class);

    frequencyManager = new FrequencyManager();
    fileManager = new FileManager();
    playerManager = new PlayerManager();
    textMessageManager = new TextMessageManager();
    messageScrambler = new MessageScrambler();

    getFileManager().loadFiles();

    registerCommands();
    registerListeners();

    // Console sender
    getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "Mortuus Terra chat ready.");
    getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "|----------|");
}
项目:MinecraftMarket-Plugin    文件:SignsConfig.java   
public SignsConfig(JavaPlugin plugin) {
    super(plugin, "signs");

    for (String key : config.getKeys(false)) {
        if (Utils.isInt(key)) {
            Set<DonorSign> signs = new HashSet<>();
            for (Location loc : stringsToLocArray(config.getStringList(key))) {
                if (loc != null) {
                    Block block = loc.getWorld().getBlockAt(loc);
                    if (block.getState() instanceof Sign) {
                        signs.add(new DonorSign(Utils.getInt(key), block));
                    }
                }
            }
            donorSigns.put(Utils.getInt(key), signs);
        }
    }
}
项目:libmanager    文件:BukkitLibraryManager.java   
@Override
public LibraryResolver getLibraryResolver(Object realm) {
    if (!(realm instanceof JavaPlugin))
        throw new IllegalArgumentException("Only realms of type " + JavaPlugin.class.getName() + " are supported");
    JavaPlugin plugin = (JavaPlugin) realm;
    ClassLoader classLoader = plugin.getClass().getClassLoader();
    if (!(classLoader instanceof URLClassLoader))
        throw new UnsupportedOperationException("Plugin " + plugin.getName() + " was not loaded by a URLClassLoader");
    return libraryResolvers.computeIfAbsent(plugin.getName(), name -> new ClassLoaderLibraryResolver(
            repositorySystem,
            createSession(),
            remoteRepositorySupplier,
            (URLClassLoader) classLoader,
            plugin.getLogger()
    ));
}
项目:RankVouchers    文件:UserManager.java   
public JavaPlugin getInstance() {
    if (plugin == null)
        try {
            throw new Exception();
        } catch (Exception e) {
            e.printStackTrace();
        }
    return plugin;
}
项目:mczone    文件:ConfigAPI.java   
public ConfigAPI(File file, JavaPlugin plugin) {
    if (!file.exists()) {
try {
    file.getParentFile().mkdirs();
    file.createNewFile();
} catch (IOException e) {
    e.printStackTrace();
}
    }
     this.config = YamlConfiguration.loadConfiguration(file);
 }
项目:UltimateTs    文件:Config.java   
/**
 * Creates new PluginFile, with defaults
 * @param plugin - Your plugin
 * @param fileName - Name of the file
 * @param defaultsName - Name of the defaults
 */
public Config(JavaPlugin plugin, String fileName, String defaultsName) {
    this.plugin = plugin;
    this.defaults = defaultsName;
    this.file = new File(plugin.getDataFolder(), fileName);
    reload();
}
项目:EscapeLag    文件:AzureAPI.java   
public static void fatal(final String prefix, final String context, final JavaPlugin plugin) {
    Bukkit.getScheduler().runTaskTimer(plugin, new Runnable(){
        @Override
        public void run(){
            Bukkit.getLogger().severe(prefix + context);
        }
    }, 0L, TimeUnit.SECONDS.toMillis(30));
}
项目:AlphaLibary    文件:FakeRegister.java   
void initAll(JavaPlugin plugin) {
    armorstandLocationsFile = new ArmorstandLocationsFile(plugin);
    endercrystalLocationsFile = new EndercrystalLocationsFile(plugin);
    playerLocationsFile = new PlayerLocationsFile(plugin);
    itemLocationsFile = new ItemLocationsFile(plugin);
    mobLocationsFile = new MobLocationsFile(plugin);
    bigItemLocationsFile = new BigItemLocationsFile(plugin);
    xpOrbLocationsFile = new XPOrbLocationsFile(plugin);
}
项目:Arcadia-Spigot    文件:AdvancementAPI.java   
public AdvancementAPI show(JavaPlugin plugin, Player... players) {
    add();
    grant(players);
    Bukkit.getScheduler().runTaskLater(plugin, () -> {
        revoke(players);
        remove();
    }, 20L);
    return this;
}
项目:PetBlocks    文件:PetBlockHelper.java   
public static void playParticleEffectForPipeline(Location location, ParticleEffectMeta particleEffectMeta, PetBlock petBlock) {
    if (ConfigPet.getInstance().areParticlesForOtherPlayersVisible()) {
        for (final Player player : location.getWorld().getPlayers()) {
            Bukkit.getServer().getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PetBlocksPlugin.class), () -> ((ParticleEffectData) particleEffectMeta).applyTo(location, player));
        }
    } else {
        Bukkit.getServer().getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PetBlocksPlugin.class), () -> ((ParticleEffectData) particleEffectMeta).applyTo(location, (Player) petBlock.getPlayer()));
    }
}
项目:PetBlocks    文件:NMSRegistry.java   
public static void registerAll() {
    RegisterHelper.PREFIX = PetBlocksPlugin.PREFIX_CONSOLE;
    RegisterHelper.register("WorldGuard", "com.sk89q.worldguard.protection.ApplicableRegionSet", '5');
    RegisterHelper.register("WorldGuard", "com.sk89q.worldguard.protection.ApplicableRegionSet", '6');
    if (RegisterHelper.register("ClearLag")) {
        try {
            new ClearLagListener((JavaPlugin) Bukkit.getPluginManager().getPlugin("PetBlocks"));
        } catch (final Exception ex) {
            Bukkit.getServer().getConsoleSender().sendMessage(PetBlocksPlugin.PREFIX_CONSOLE + ChatColor.DARK_RED + "Manual hook failed. No interacting with [ClearLag.]");
        }
    }
}
项目:AstralEdit    文件:SelectionManager.java   
/**
 * Undos an operation
 *
 * @param player player
 */
boolean undoOperation(Player player) {
    if (!this.hasSelection(player))
        return false;
    if (!this.operations.containsKey(player))
        this.operations.put(player, new Operation[this.maxUndoAmount]);
    final Operation operation = this.operations.get(player)[0];
    if (operation != null) {
        if (operation.getType() == OperationType.MIRROR) {
            this.getSelection(player).mirror();
        } else if (operation.getType() == OperationType.FLIP) {
            this.getSelection(player).flip();
        } else if (operation.getType() == OperationType.UPSIDEDOWN) {
            this.getSelection(player).upSideDown();
        } else if (operation.getType() == OperationType.UNCOMBINE) {
            this.getSelection(player).join();
        } else if (operation.getType() == OperationType.COMBINE) {
            this.getSelection(player).tearApart();
        } else if (operation.getType() == OperationType.ROTATE) {
            this.selections.get(player).unSecureRotate((Double) operation.getOperationData());
        } else if (operation.getType() == OperationType.ANGLES) {
            this.getSelection(player).setBlockAngle((EulerAngle) operation.getOperationData());
        } else if (operation.getType() == OperationType.PLACE || operation.getType() == OperationType.CONVERTOBLOCKS) {
            final List<Container> containers = (List<Container>) operation.getOperationData();
            Bukkit.getServer().getScheduler().runTask(JavaPlugin.getPlugin(AstralEditPlugin.class), () -> this.placeUndoCalc(0, containers.get(0), containers, 0));
        } else if (operation.getType() == OperationType.MOVE) {
            this.selections.get(player).teleport((Location) operation.getOperationData());
        }
        this.removeOperation(player);
        return true;
    }
    return false;
}
项目:MockBukkit    文件:MockBukkit.java   
/**
 * Loads and enables a plugin for mocking.
 * 
 * @param class1 The plugin to load for mocking.
 */
@SuppressWarnings("unchecked")
public static <T extends JavaPlugin> T load(Class<T> plugin)
{
    if (mock != null)
    {
        JavaPlugin instance = mock.getPluginManager().loadPlugin(plugin);
        mock.getPluginManager().enablePlugin(instance);
        return (T) instance;
    }
    else
    {
        throw new IllegalStateException("Not mocking");
    }
}
项目:BlockBall    文件:NMSRegistry.java   
public static void registerAll() {
    try {
        LightRegistry.RABBIT.register("com.github.shynixn.blockball.business.bukkit.nms.VERSION.CustomRabbit");
        RegisterHelper.PREFIX = BlockBallPlugin.PREFIX_CONSOLE;
        RegisterHelper.register("WorldGuard", "com.sk89q.worldguard.protection.ApplicableRegionSet", '5');
        RegisterHelper.register("WorldGuard", "com.sk89q.worldguard.protection.ApplicableRegionSet", '6');
        RegisterHelper.register("BossBarAPI");
        RegisterHelper.register("Vault");
        if (RegisterHelper.register("PlaceholderAPI")) {
            PlaceHolderApiConnection.init((JavaPlugin) Bukkit.getPluginManager().getPlugin("BlockBall"));
        }
    } catch (final Error ex) {
        Bukkit.getConsoleSender().sendMessage(BlockBallPlugin.PREFIX_CONSOLE + ChatColor.DARK_RED + "Failed to register the last dependency.");
    }
}
项目:BlockBall    文件:GameController.java   
public GameController() {
    super(JavaPlugin.getPlugin(BlockBallPlugin.class));
    this.arenaManager = ArenaController.createArenaController(this);
    new EventCommandExecutor(this);
    if (Config.getInstance().getGlobalJoinCommand().isEnabled())
        new GlobalJoinCommandExecutor(this);
    if (Config.getInstance().getGlobalLeaveCommand().isEnabled())
        new GlobalLeaveCommandExecutor(this);
    new GameListener(this);
    this.run();
}
项目:SamaGamesAPI    文件:PowerupManager.java   
public PowerupManager(JavaPlugin plugin)
{
    this.plugin = plugin;
    this.random = new Random();

    this.powerups = new ArrayList<>();
    this.locations = new ArrayList<>();

    this.inverseFrequency = 750;
    this.despawnTime = 20;
}
项目:SamaGamesAPI    文件:AdvertisingObjectiveSign.java   
/**
 * Constructor
 *
 * @param plugin      Plugin
 * @param name        Objective's name
 * @param displayName Objective's display name
 */
public AdvertisingObjectiveSign(JavaPlugin plugin, String name, String displayName)
{
    super(name, displayName);

    this.originalDisplayName = displayName;
    this.advertisingText = "      Vous jouez sur mc.samagames.net !                  "; // 6 spaces before and 18 spaces after

    this.finalText = this.advertisingText;
    this.ticks = 0;
    this.advertisingCursor = 0;
    this.advertisingState = false;

    plugin.getServer().getScheduler().runTaskTimer(plugin, this, 5L, 5L);
}
项目:SpigotPaginatedGUI    文件:PaginatedGUI.java   
/**
 * Simply an alias to register the Inventory listeners for a certain plugin.
 * Intended to improve code readability.
 *
 * @param plugin The Spigot plugin instance that you wish to register the listeners for.
 */
public static void prepare(JavaPlugin plugin){
    if(inventoryListenerGUI == null){
        inventoryListenerGUI = new InventoryListenerGUI();
        plugin.getServer().getPluginManager().registerEvents(inventoryListenerGUI, plugin);
    }
}
项目:ProjectAres    文件:BukkitPluginResolver.java   
@Override
public @Nullable <T extends Plugin> T getPlugin(Class<T> cls) {
    try {
        return (T) JavaPlugin.getPlugin(cls.asSubclass(JavaPlugin.class));
    } catch(IllegalArgumentException e) {
        return null;
    }
}
项目:ProjectAres    文件:BukkitPluginResolver.java   
@Override
public @Nullable Plugin getImplicitProvidingPlugin(Class<?> cls) {
    try {
        return JavaPlugin.getProvidingPlugin(cls);
    } catch(IllegalArgumentException e) {
        return null;
    }
}
项目:AstralEdit    文件:SelectionManager.java   
/**
 * Places an undos
 * @param counter counter
 * @param container container
 * @param containers containers
 * @param nextContainer nextContainer
 */
private void placeUndo(final int counter, final Container container, final List<Container> containers, final int nextContainer) {
    if (counter > 100) {
        Bukkit.getServer().getScheduler().runTaskLater(JavaPlugin.getPlugin(AstralEditPlugin.class), () -> this.placeUndoCalc(0, container, containers, nextContainer), 1L);
    } else {
        this.placeUndoCalc(counter, container, containers, nextContainer);
    }
}
项目:DogTags    文件:UserManager.java   
public JavaPlugin getInstance() {
    if (plugin == null)
        try {
            throw new Exception();
        } catch (Exception e) {
            e.printStackTrace();
        }
    return plugin;
}
项目:UltimateTs    文件:Config.java   
/**
 * Creates new PluginFile, with defaults
 * @param plugin - Your plugin
 * @param fileName - Name of the file
 * @param defaultsName - Name of the defaults
 */
public Config(JavaPlugin plugin, String fileName, String defaultsName) {
    this.plugin = plugin;
    this.defaults = defaultsName;
    this.file = new File(plugin.getDataFolder(), fileName);
    reload();
}
项目:NyaaCore    文件:LanguageRepository.java   
private static void loadLocalMap(JavaPlugin plugin, String codeName,
                                    Map<String, String> targetMap, boolean ignoreInternal, boolean ignoreNormal) {
    if (plugin == null || codeName == null || targetMap == null) throw new IllegalArgumentException();
    if (Boolean.parseBoolean(System.getProperty("nyaautils.i18n.refreshLangFiles", "false"))) return;
    File langFile = new File(plugin.getDataFolder(), codeName + ".yml");
    if (langFile.exists() && langFile.isFile()) {
        YamlConfiguration section = YamlConfiguration.loadConfiguration(langFile);
        loadLanguageSection(targetMap, section, "", ignoreInternal, ignoreNormal);
    }
}
项目:Chambers    文件:ScoreboardWrapper.java   
public ScoreboardWrapper(JavaPlugin plugin, ScoreboardProvider provider) {
    ScoreboardWrapper.instance = this;
    this.provider = provider;
    this.plugin = plugin;
    this.scoreboardManager = new ScoreboardManager();
    Bukkit.getPluginManager().registerEvents(scoreboardManager, plugin);
}
项目:MockBukkit    文件:PluginManagerMock.java   
/**
 * Load a plugin from a class. It will use the system resource
 * {@code plugin.yml} as the resource file.
 * 
 * @param class1 The plugin to load.
 * @return The loaded plugin.
 */
public JavaPlugin loadPlugin(Class<? extends JavaPlugin> class1)
{
    try
    {
        return loadPlugin(class1, new PluginDescriptionFile(ClassLoader.getSystemResourceAsStream("plugin.yml")));
    }
    catch (InvalidDescriptionException e)
    {
        throw new RuntimeException(e);
    }
}
项目:AlphaLibary    文件:PluginWatcher.java   
public PluginWatcher(JavaPlugin plugin, long time) {
    this.task = new BukkitRunnable() {
        @Override
        public void run() {
            if (check())
                Bukkit.reload();
        }
    };

    this.lastModified = new File("plugins/", plugin.getName() + ".jar").lastModified();
    this.time = time;
    this.plugin = plugin;
}
项目:BlockBall    文件:SCommandExecutor.java   
public SCommandExecutor() {
    super();
    this.plugin = JavaPlugin.getPlugin(BlockBallPlugin.class);
    if (this.plugin == null)
        throw new IllegalArgumentException("Pluginloader failed to load " + this.getClass().getSimpleName() + '.');
    this.plugin.getCommand(this.getCommand()).setExecutor(this);
}
项目:BasicSurvivalPlus    文件:PreventExplosionListner.java   
public PreventExplosionListner(JavaPlugin plugin){
    this.plugin = plugin;
}
项目:CentauriCloud    文件:SpigotConnectorPlugin.java   
public static void registerPlugin(JavaPlugin plugin) {
    registerPlugin(plugin, null);
}
项目:NyaaCore    文件:LanguageRepository.java   
public InternalOnlyRepository(JavaPlugin plugin, String lang) {
    this.plugin = plugin;
    this.lang = lang;
}
项目:AstralEdit    文件:SelectionHolder.java   
private static Plugin getPlugin() {
    return JavaPlugin.getPlugin(AstralEditPlugin.class);
}
项目:bankomat    文件:BankomatCommand.java   
public static void appendCreditCardToUser(JavaPlugin plugin, UUID uuid) {
    appendCreditCardToUser(plugin.getServer().getPlayer(uuid));
}
项目:bankomat    文件:ConfigurationActivator.java   
public ConfigurationActivator(JavaPlugin plugin) {
    this.plugin = plugin;
}
项目:Warzone    文件:GravePlugin.java   
public GravePlugin(JavaPlugin plugin) {
    this.plugin = plugin;
    this.playerListener = new PlayerListener(this);
    plugin.getServer().getPluginManager().registerEvents(playerListener, plugin);
}
项目:Warzone    文件:TickTimer.java   
public TickTimer(JavaPlugin plugin) {
    this.plugin = plugin;
}
项目:BlockBall    文件:GameEntity.java   
GameEntity(Arena arena) {
    super();
    this.plugin = JavaPlugin.getPlugin(BlockBallPlugin.class);
    this.arena = arena;
}
项目:mczone    文件:Hive.java   
public void registerCommand(JavaPlugin plugin, String name, CommandExecutor executor) {
    registerCommand(plugin.getCommand(name), executor);
}
项目:BasicSurvivalPlus    文件:PlayerLifercycleListener.java   
public PlayerLifercycleListener(JavaPlugin plugin){
    this.plugin = plugin;
}