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 + "|----------|"); }
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); } } }
@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() )); }
public JavaPlugin getInstance() { if (plugin == null) try { throw new Exception(); } catch (Exception e) { e.printStackTrace(); } return plugin; }
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); }
/** * 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(); }
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)); }
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); }
public AdvancementAPI show(JavaPlugin plugin, Player... players) { add(); grant(players); Bukkit.getScheduler().runTaskLater(plugin, () -> { revoke(players); remove(); }, 20L); return this; }
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())); } }
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.]"); } } }
/** * 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; }
/** * 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"); } }
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."); } }
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(); }
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; }
/** * 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); }
/** * 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); } }
@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; } }
@Override public @Nullable Plugin getImplicitProvidingPlugin(Class<?> cls) { try { return JavaPlugin.getProvidingPlugin(cls); } catch(IllegalArgumentException e) { return null; } }
/** * 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); } }
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); } }
public ScoreboardWrapper(JavaPlugin plugin, ScoreboardProvider provider) { ScoreboardWrapper.instance = this; this.provider = provider; this.plugin = plugin; this.scoreboardManager = new ScoreboardManager(); Bukkit.getPluginManager().registerEvents(scoreboardManager, plugin); }
/** * 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); } }
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; }
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); }
public PreventExplosionListner(JavaPlugin plugin){ this.plugin = plugin; }
public static void registerPlugin(JavaPlugin plugin) { registerPlugin(plugin, null); }
public InternalOnlyRepository(JavaPlugin plugin, String lang) { this.plugin = plugin; this.lang = lang; }
private static Plugin getPlugin() { return JavaPlugin.getPlugin(AstralEditPlugin.class); }
public static void appendCreditCardToUser(JavaPlugin plugin, UUID uuid) { appendCreditCardToUser(plugin.getServer().getPlayer(uuid)); }
public ConfigurationActivator(JavaPlugin plugin) { this.plugin = plugin; }
public GravePlugin(JavaPlugin plugin) { this.plugin = plugin; this.playerListener = new PlayerListener(this); plugin.getServer().getPluginManager().registerEvents(playerListener, plugin); }
public TickTimer(JavaPlugin plugin) { this.plugin = plugin; }
GameEntity(Arena arena) { super(); this.plugin = JavaPlugin.getPlugin(BlockBallPlugin.class); this.arena = arena; }
public void registerCommand(JavaPlugin plugin, String name, CommandExecutor executor) { registerCommand(plugin.getCommand(name), executor); }
public PlayerLifercycleListener(JavaPlugin plugin){ this.plugin = plugin; }