Java Code Examples for org.bukkit.plugin.PluginManager

The following are top voted examples for showing how to use org.bukkit.plugin.PluginManager. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: AntiCheat   File: Orebfuscator.java   View source code 6 votes vote down vote up
@Override
public void enable(Samaritan plugin) {
    // Get plugin manager
    PluginManager pm = plugin.getServer().getPluginManager();

    instance = this;
    nms = createNmsManager();
    this.plugin = plugin;

    // Load configurations
    OrebfuscatorConfig.load();

    // Orebfuscator events
    pm.registerEvents(new OrebfuscatorPlayerListener(), plugin);
    pm.registerEvents(new OrebfuscatorEntityListener(), plugin);
    pm.registerEvents(new OrebfuscatorBlockListener(), plugin);
    pm.registerEvents(new OrebfuscatorChunkListener(), plugin);

    ShadowsAPI.get().registerListener(new ShadowHook());
}
 
Example 2
Project: ProjectAres   File: NicknameCommands.java   View source code 6 votes vote down vote up
@Inject NicknameCommands(NicknameConfiguration config,
                         SyncExecutor syncExecutor,
                         UserService userService,
                         Audiences audiences,
                         IdentityProvider identities,
                         OnlinePlayers onlinePlayers,
                         UserFinder userFinder,
                         PluginManager pluginManager,
                         Plugin plugin) {
    this.config = config;
    this.syncExecutor = syncExecutor;
    this.userService = userService;
    this.audiences = audiences;
    this.identities = identities;
    this.onlinePlayers = onlinePlayers;
    this.userFinder = userFinder;
    this.pluginManager = pluginManager;
    this.plugin = plugin;
}
 
Example 3
Project: FactionsXL   File: ReloadCommand.java   View source code 6 votes vote down vote up
@Override
public void onExecute(String[] args, CommandSender sender) {
    PluginManager plugins = Bukkit.getPluginManager();

    DataReloadEvent event = new DataReloadEvent();
    plugins.callEvent(event);
    if (event.isCancelled()) {
        return;
    }

    plugin.onDisable();
    plugin.loadCore();

    MessageUtil.sendPluginTag(sender, plugin);
    MessageUtil.sendCenteredMessage(sender, FMessage.CMD_RELOAD_DONE.getMessage());
}
 
Example 4
Project: NavyCraft2-Lite   File: PermissionInterface.java   View source code 6 votes vote down vote up
public static void setupPermissions(NavyCraft p) {
	plugin = p;
	PluginManager pm = NavyCraft.instance.getServer().getPluginManager();
	if(pm != null) {
		pm.addPermission(new Permission("navycraft.periscope.use"));
		pm.addPermission(new Permission("navycraft.aa-gun.use"));
		pm.addPermission(new Permission("navycraft.periscope.create"));
		pm.addPermission(new Permission("navycraft.aa-gun.create"));
		
		for (CraftType type : CraftType.craftTypes) 
		{
			pm.addPermission(new Permission("navycraft." + type.name + ".release"));
			pm.addPermission(new Permission("navycraft." + type.name + ".info"));
			pm.addPermission(new Permission("navycraft." + type.name + ".takeover"));
			pm.addPermission(new Permission("navycraft." + type.name + ".start"));
			pm.addPermission(new Permission("navycraft." + type.name + ".create"));
			pm.addPermission(new Permission("navycraft." + type.name + ".sink"));
			pm.addPermission(new Permission("navycraft." + type.name + ".remove"));
		}
	}
}
 
Example 5
Project: Chambers   File: ListenerManager.java   View source code 6 votes vote down vote up
/**
 * Registers all of the Listeners on the server
 */
public void registerListeners() {
	PluginManager pluginManager = Bukkit.getServer().getPluginManager();
	Stream.of(
			new ClaimInteractListener(),
			new ClaimMoveListener(),
			new ClaimProfileListener(),
			new GameDamageListener(),
			new GameInteractListener(),
			new GameProtectionListener(),
			new KothMoveListener(),
			new TeamBlockListener(),
			new TeamDamageListener(),
			new TeamDeathListener(),
			new TeamInteractListener(),
			new ChatListener(),
			new PlayerDeathListener(),
			new PlayerRespawnListener(),
			new ProfileListener(),
			new ProfileStatusListener(),
			new EnderpearlListener()
	).forEach(listener -> pluginManager.registerEvents(listener, Chambers.getInstance()));
}
 
Example 6
Project: behave   File: MainPart.java   View source code 6 votes vote down vote up
private boolean execBeh(String beh){
	String[] arr = beh.split(" ");
	String cmd = arr[0];
	String[] args = Arrays.copyOfRange(arr, 1, arr.length);
	String argsas = "";
	for(String a : args){
		argsas = argsas + a + " ";
	}
	switch(cmd){
		case "print":
			getLogger().info(argsas);
			return true;
		case "addperm":
			PluginManager pm = Bukkit.getServer().getPluginManager();
			pm.addPermission(new Permission(argsas));
			return true;
		case "//":
			return true;
		default:
			return false;
	}
}
 
Example 7
Project: SignEdit   File: SignEditTest.java   View source code 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    Configuration config = new Configuration(File.createTempFile("SignEdit-", "-config.yml"));
    spyConfig = spy(config);
    listener = new Interact();
    doReturn(false).when(spyConfig).writeFullConfig(new YamlConfiguration());

    uiSignSubcommand = mock(UiSignSubcommand.class);
    whenNew(UiSignSubcommand.class).withAnyArguments().thenReturn(uiSignSubcommand);

    signCommand = new SignCommand(spyConfig, listener);

    player = mock(Player.class);
    command = mock(Command.class);
    sign = mock(Sign.class);
    block = mock(Block.class);
    when(player.hasPermission("SignEdit.use")).thenReturn(true);
    when(block.getState()).thenReturn(sign);

    server = mock(Server.class);
    pluginManager = mock(PluginManager.class);
    mockStatic(Bukkit.class);
    when(Bukkit.getServer()).thenReturn(server);
    when(server.getPluginManager()).thenReturn(pluginManager);
}
 
Example 8
Project: ConditionalPerms   File: HookManager.java   View source code 6 votes vote down vote up
public void init() {
    PluginManager pm = plugin.getServer().getPluginManager();

    for (Hook hook : Hook.values()) {
        try {
            if (pm.isPluginEnabled(hook.getPluginName())) {
                AbstractHook ah = make(hook.getClazz(), plugin);
                if (ah != null) {
                    plugin.bindComposite(ah);
                    hooks.put(hook.getClazz(), ah);
                }

                plugin.getLogger().info("Hooked with " + hook.getPluginName() + "...");
            }
        } catch (Exception e) {
            plugin.getLogger().severe("Exception thrown whilst hooking with " + hook.getPluginName() + "...");
            e.printStackTrace();
        }
    }
}
 
Example 9
Project: KillerMoney   File: MessageHandler.java   View source code 6 votes vote down vote up
public static void process(Player player, String message) {
    KMPlayer kmp = KMPlayerManager.getKMPlayer(player);
    PluginManager pm = Bukkit.getPluginManager();

    if (!kmp.isEnableMessages()) {
        return;
    }

    switch (DefaultConfig.getMessageMethod()) {
        case DISABLED:              return;

        case ACTION_BAR:            pm.callEvent(new KMSendActionBarMessageEvent(player, message, 3));
                                    break;

        case CHAT:                  pm.callEvent(new KMSendMessageEvent(player, message));
                                    break;
    }
}
 
Example 10
Project: PhantomAdmin   File: PhantomAdmin.java   View source code 6 votes vote down vote up
public void onEnable()
{ 		
	instance = this;
	
	this.loadConfig();
	
	@SuppressWarnings("unchecked")
       Collection<Player> players = (Collection<Player>)(Bukkit.getServer().getOnlinePlayers());
	for(Player player : players)
	{
	    this.handlePlayerLogin(player);
	}
	
	//register for events
	PluginManager pluginManager = this.getServer().getPluginManager();
	PAEventHandler eventHandler = new PAEventHandler();
	pluginManager.registerEvents(eventHandler, this);
	
	AddLogEntry("PhantomAdmin enabled.");
}
 
Example 11
Project: LuckPerms   File: SubscriptionMapInjector.java   View source code 6 votes vote down vote up
private void inject() throws Exception {
    PluginManager pluginManager = this.plugin.getServer().getPluginManager();

    if (!(pluginManager instanceof SimplePluginManager)) {
        this.plugin.getLog().severe("PluginManager instance is not a 'SimplePluginManager', instead: " + pluginManager.getClass());
        this.plugin.getLog().severe("Unable to inject LuckPerms Permission Subscription map.");
        return;
    }

    Object map = PERM_SUBS_FIELD.get(pluginManager);
    if (map instanceof LPSubscriptionMap) {
        return; // already injected
    }

    //noinspection unchecked
    Map<String, Map<Permissible, Boolean>> castedMap = (Map<String, Map<Permissible, Boolean>>) map;

    // make a new subscription map
    LPSubscriptionMap newMap = new LPSubscriptionMap(this.plugin, castedMap);

    // inject it
    PERM_SUBS_FIELD.set(pluginManager, newMap);
}
 
Example 12
Project: LuckPerms   File: SubscriptionMapInjector.java   View source code 6 votes vote down vote up
public static void uninject() {
    try {
        PluginManager pluginManager = Bukkit.getServer().getPluginManager();
        if (!(pluginManager instanceof SimplePluginManager)) {
            return;
        }

        Object map = PERM_SUBS_FIELD.get(pluginManager);
        if (map instanceof LPSubscriptionMap) {
            LPSubscriptionMap lpMap = (LPSubscriptionMap) map;
            PERM_SUBS_FIELD.set(pluginManager, lpMap.detach());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 13
Project: Thermos-Bukkit   File: Permission.java   View source code 6 votes vote down vote up
/**
 * Adds this permission to the specified parent permission.
 * <p>
 * If the parent permission does not exist, it will be created and
 * registered.
 *
 * @param name Name of the parent permission
 * @param value The value to set this permission to
 * @return Parent permission it created or loaded
 */
public Permission addParent(String name, boolean value) {
    PluginManager pm = Bukkit.getServer().getPluginManager();
    String lname = name.toLowerCase();

    Permission perm = pm.getPermission(lname);

    if (perm == null) {
        perm = new Permission(lname);
        pm.addPermission(perm);
    }

    addParent(perm, value);

    return perm;
}
 
Example 14
Project: LastManStanding   File: LMS.java   View source code 6 votes vote down vote up
@Override
public void onEnable() {
    instance = this;
    saveDefaultConfig();

    this.playerManager = new PlayerManager();
    this.gameManager = new GameManager();
    this.gameManager.loadGames();

    PluginManager pm = Bukkit.getPluginManager();
    pm.registerEvents(new PlayerListener(), this);
    pm.registerEvents(new GameListener(), this);

    getCommand("lms").setExecutor(new CommandHandler());

}
 
Example 15
Project: DiamondGuarantee   File: DiamondGuarantee.java   View source code 6 votes vote down vote up
public void onEnable()
{ 		
	AddLogEntry("DiamondGuarantee enabled.");		
	
	instance = this;
	
	this.dataStore = new DataStore();
	
	this.loadConfig();
	
	//register for events
	PluginManager pluginManager = this.getServer().getPluginManager();
	
	DGEventHandler dGEventHandler = new DGEventHandler();
	pluginManager.registerEvents(dGEventHandler, this);
	
	@SuppressWarnings("unchecked")
       Collection<Player> players = (Collection<Player>)this.getServer().getOnlinePlayers();
	for(Player player : players)
	{
	    PlayerData.Preload(player);
	}
}
 
Example 16
Project: LagMonitor   File: SystemCommand.java   View source code 6 votes vote down vote up
private void displayMinecraftInfo(CommandSender sender) {
    //minecraft specific
    sender.sendMessage(PRIMARY_COLOR + "TPS: " + SECONDARY_COLOR + plugin.getTpsHistoryTask().getLastSample());

    TrafficReader trafficReader = plugin.getTrafficReader();
    if (trafficReader != null) {
        String formattedIncoming = readableByteCount(trafficReader.getIncomingBytes().get());
        String formattedOutgoing = readableByteCount(trafficReader.getOutgoingBytes().get());
        sender.sendMessage(PRIMARY_COLOR + "Incoming Traffic: " + SECONDARY_COLOR + formattedIncoming);
        sender.sendMessage(PRIMARY_COLOR + "Outgoing Traffic: " + SECONDARY_COLOR + formattedOutgoing);
    }

    PluginManager pluginManager = Bukkit.getPluginManager();
    Plugin[] plugins = pluginManager.getPlugins();
    sender.sendMessage(PRIMARY_COLOR + "Loaded Plugins: "
            + SECONDARY_COLOR + getEnabledPlugins(plugins) + '/' + plugins.length);

    int onlinePlayers = Bukkit.getOnlinePlayers().size();
    int maxPlayers = Bukkit.getMaxPlayers();
    sender.sendMessage(PRIMARY_COLOR + "Players: " + SECONDARY_COLOR + onlinePlayers + '/' + maxPlayers);

    displayWorldInfo(sender);
    sender.sendMessage(PRIMARY_COLOR + "Server version: " + SECONDARY_COLOR + Bukkit.getVersion());
}
 
Example 17
Project: GoldDigger   File: GoldDigger.java   View source code 6 votes vote down vote up
@Override
   public void onEnable() {
// Enable the plugin

// Load the config.yml file - not needed

// Register commands
getCommand("digdig").setExecutor(new digCommand());

// Register event listeners
// Get the manager that handles plugins
PluginManager manager = getServer().getPluginManager();

// Register the listener to blocks being broken by players
manager.registerEvents(new BlockBreakListener(), this);
   }
 
Example 18
Project: CauldronGit   File: Permission.java   View source code 6 votes vote down vote up
/**
 * Adds this permission to the specified parent permission.
 * <p>
 * If the parent permission does not exist, it will be created and
 * registered.
 *
 * @param name Name of the parent permission
 * @param value The value to set this permission to
 * @return Parent permission it created or loaded
 */
public Permission addParent(String name, boolean value) {
    PluginManager pm = Bukkit.getServer().getPluginManager();
    String lname = name.toLowerCase();

    Permission perm = pm.getPermission(lname);

    if (perm == null) {
        perm = new Permission(lname);
        pm.addPermission(perm);
    }

    addParent(perm, value);

    return perm;
}
 
Example 19
Project: ExtremeSurvival   File: Main.java   View source code 6 votes vote down vote up
@Override
public void onEnable() {
    this.saveDefaultConfig();
    int size = this.getConfig().getInt("size");
    int decreaseSize = this.getConfig().getInt("decreasedSize");
    int triggerTime = this.getConfig().getInt("triggerMinuteTime");
    Location loc = Main.parseLocationString(this.getConfig().getString("loc"));
    this.border = new BorderManagement(size, decreaseSize, loc, triggerTime);
    System.out.print(this.getName()+" zostal wlaczony");
    Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){

        @Override
        public void run() {
            Main.getES().getBorder().startBorder();
        }
    }, 20l, triggerTime*60*20l);
    Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new InfoScoreboardRunnable(), 20l, 20l);
    PluginManager pm = Bukkit.getServer().getPluginManager();
    pm.registerEvents(new PingListListener(), this);
    pm.registerEvents(new PlayerLoginListener(), this);
    pm.registerEvents(new PlayerQuitListener(), this);
    pm.registerEvents(new PlayerDeathListener(), this);
    pm.registerEvents(new PlayerJoinListener(), this);
}
 
Example 20
Project: SurvivalCG   File: SCG.java   View source code 6 votes vote down vote up
public void registerListeners() {
    PluginManager pm = Bukkit.getPluginManager();
    pm.registerEvents(new PlayerChatListener(this), this);
    pm.registerEvents(new PlayerDamagePlayerListener(this), this);
    pm.registerEvents(new PlayerDeathListener(this), this);
    pm.registerEvents(new PlayerJoinListener(this), this);
    pm.registerEvents(new PlayerQuitListener(this), this);
    pm.registerEvents(new PlayerTeleportListener(this), this);
    pm.registerEvents(new PlayerPlaceListener(this), this);
    pm.registerEvents(new PlayerBlockBreakListener(this), this);
    pm.registerEvents(new PlayerRespawnListener(this), this);
    pm.registerEvents(new PlayerLoginListener(this), this);
    pm.registerEvents(new PlayerKickListener(this), this);
    pm.registerEvents(new PlayerBucketListeners(this), this);
    pm.registerEvents(new PlayerInteractListener(this), this);
    pm.registerEvents(new SignListener(this), this);
}
 
Example 21
Project: PerWorldInventory   File: PerWorldInventory.java   View source code 6 votes vote down vote up
protected void registerEventListeners(Injector injector) {
    getLogger().info("Registering listeners...");

    PluginManager pluginManager = getServer().getPluginManager();

    pluginManager.registerEvents(injector.getSingleton(PluginListener.class), this);

    pluginManager.registerEvents(injector.getSingleton(PlayerTeleportListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(PlayerChangedWorldListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(PlayerDeathListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(PlayerGameModeChangeListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(PlayerQuitListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(EntityPortalEventListener.class), this);
    pluginManager.registerEvents(injector.getSingleton(InventoryLoadingListener.class), this);

    // The PlayerSpawnLocationEvent is only fired in Spigot
    // As of version 1.9.2
    if (Bukkit.getVersion().contains("Spigot") && Utils.checkServerVersion(Bukkit.getVersion(), 1, 9, 2)) {
        pluginManager.registerEvents(injector.getSingleton(PlayerSpawnLocationListener.class), this);
    }
    getLogger().info("Listeners registered!");
}
 
Example 22
Project: AdvancedAchievements   File: AdvancedAchievements.java   View source code 6 votes vote down vote up
/**
 * Registers permissions that depend on the user's configuration file (for MultipleAchievements; for instance for
 * stone breaks, achievement.count.breaks.stone will be registered).
 */
private void registerPermissions() {
	getLogger().info("Registering permissions...");

	PluginManager pluginManager = getServer().getPluginManager();
	for (MultipleAchievements category : MultipleAchievements.values()) {
		for (String section : config.getConfigurationSection(category.toString()).getKeys(false)) {
			int startOfMetadata = section.indexOf(':');
			if (startOfMetadata > -1) {
				// Permission ignores metadata (eg. sand:1) for Breaks, Places and Crafts categories.
				section = section.substring(0, startOfMetadata);
			}
			if (category == MultipleAchievements.PLAYERCOMMANDS) {
				// Permissions don't take spaces into account for this category.
				section = StringUtils.replace(section, " ", "");
			}

			// Bukkit only allows permissions to be set once, check to ensure they were not previously set when
			// performing /aach reload.
			if (pluginManager.getPermission(category.toPermName() + "." + section) == null) {
				pluginManager.addPermission(
						new Permission(category.toPermName() + "." + section, PermissionDefault.TRUE));
			}
		}
	}
}
 
Example 23
Project: autojailer   File: main.java   View source code 6 votes vote down vote up
@Override
public void onEnable() {
	PluginDescriptionFile pdfFile = this.getDescription();
	this.logger.info("[" + pdfFile.getName() + "] v."
			+ pdfFile.getVersion() + " has been Enabled");
	PluginManager pm = getServer().getPluginManager();
	pm.registerEvents(new autojailerListener(this), this);
	this.folderVerify();

	getCommand("setJailMessage").setExecutor(this);
	getCommand("setfreedomMessage").setExecutor(this);
	getCommand("setFreedomLocation").setExecutor(this);
	getCommand("setvouchThreshold").setExecutor(this);
	getCommand("vouch").setExecutor(this);
	getCommand("free").setExecutor(this);
	getCommand("jailertoggle").setExecutor(this);
}
 
Example 24
Project: PvpToggle   File: PvpToggle.java   View source code 6 votes vote down vote up
public static boolean checkDepends()
{
	PluginManager pluginManager = Bukkit.getPluginManager();
	List<Plugin> depends = new ArrayList<Plugin>();
	
	depends.add(pluginManager.getPlugin("WorldEdit"));
	depends.add(pluginManager.getPlugin("WorldGuard"));
	
	for(Plugin p : depends)
	{
		if(p == null)
		{
			return false;
		}
	}
	
	return true;
}
 
Example 25
Project: PvpToggle   File: PvpToggle.java   View source code 6 votes vote down vote up
@Override
public void onLoad()
{
	pvptoggle = this;
	utils = new PvpUtils();
	pvpmanager = new PvpManager();
	boolean dep = checkDepends();
	if(!dep)
	{
		PluginManager pluginManager = Bukkit.getPluginManager();
		getLogger().warning("Please install WorldEdit and WorldGuard to use PvpToggle plugin.");
		pluginManager.disablePlugin((Plugin) pvptoggle);
	}
	else
	{
		pvptoggle.getLogger().info("Loaded dependencies.");
	}
	return;
	
}
 
Example 26
Project: EventoZero   File: CommandManagerImpl.java   View source code 6 votes vote down vote up
private SimpleCommandMap getCommandMap()
{
	final PluginManager pluginManager = getOwner().getServer().getPluginManager();

	FieldAccessor<SimpleCommandMap> cmdMapField = FieldAccessor.access(
			pluginManager, "commandMap" );

	Optional<SimpleCommandMap> optCmdMap = cmdMapField.getValue();

	if ( optCmdMap.isPresent() )
		return optCmdMap.get();

	final String message = String.format( "Cound not get commandMap, CraftBukkit Version: %s, PluginManager: %s",
			MCReflectUtil.getCBVersion(),
			pluginManager );

	throw new IllegalStateException( message );
}
 
Example 27
Project: hooks   File: IRCChannels.java   View source code 6 votes vote down vote up
@Override
public void init() {
    this.loadConfig();
    if (!this.setUpLanguage()) return;
    this.setUpAPI();
    this.registerModes();
    this.registerStages();
    this.registerCommands();
    final PluginManager pm = this.getChatterbox().getServer().getPluginManager();
    pm.registerEvents(new ChannelListener(this), this.getChatterbox());
    final BukkitScheduler bs = this.getChatterbox().getServer().getScheduler();
    bs.scheduleSyncRepeatingTask(this.getChatterbox(), new SaveChannelsTask(this), 36000L, 36000L);
    // Turn ConfigChannels into IRCConfigChannels
    this.transformConfigChannels();
    // Create saved channels and set modes on config channels
    this.loadFromIRCChannelsConfig();
    // Make sure all players join their previous channels that have just been made
    this.getChatterbox().getServer().getOnlinePlayers().stream()
        .map(player -> this.getChatterboxAPI().getPlayerAPI().getCPlayer(player))
        .forEach(CPlayer::joinPreviousChannels);
    this.getLogger().info("Loaded.");
}
 
Example 28
Project: plot2dynmap   File: Main.java   View source code 6 votes vote down vote up
@Override
public void onEnable() {
    final PluginManager pm = getServer().getPluginManager();
    this.dynmap = pm.getPlugin("dynmap");
    if (this.dynmap == null) {
        severe("Dynmap not found, disabling Plot2Dynmap");
        return;
    }
    this.dynAPI = (DynmapAPI) this.dynmap;
    this.plot2 = pm.getPlugin("PlotSquared");
    getServer().getPluginManager().registerEvents(this, this);
    
    if (this.dynmap.isEnabled() && this.plot2.isEnabled()) {
        initialize();
    }
}
 
Example 29
Project: LagMonitor   File: SystemCommand.java   View source code 6 votes vote down vote up
private void displayMinecraftInfo(CommandSender sender) {
    //minecraft specific
    sender.sendMessage(PRIMARY_COLOR + "TPS: " + SECONDARY_COLOR + plugin.getTpsHistoryTask().getLastSample());

    TrafficReader trafficReader = plugin.getTrafficReader();
    if (trafficReader != null) {
        String formattedIncoming = readableByteCount(trafficReader.getIncomingBytes().get());
        String formattedOutgoing = readableByteCount(trafficReader.getOutgoingBytes().get());
        sender.sendMessage(PRIMARY_COLOR + "Incoming Traffic: " + SECONDARY_COLOR + formattedIncoming);
        sender.sendMessage(PRIMARY_COLOR + "Outgoing Traffic: " + SECONDARY_COLOR + formattedOutgoing);
    }

    PluginManager pluginManager = Bukkit.getPluginManager();
    Plugin[] plugins = pluginManager.getPlugins();
    sender.sendMessage(PRIMARY_COLOR + "Loaded Plugins: "
            + SECONDARY_COLOR + getEnabledPlugins(plugins) + '/' + plugins.length);

    int onlinePlayers = Bukkit.getOnlinePlayers().size();
    int maxPlayers = Bukkit.getMaxPlayers();
    sender.sendMessage(PRIMARY_COLOR + "Players: " + SECONDARY_COLOR + onlinePlayers + '/' + maxPlayers);

    displayWorldInfo(sender);
    sender.sendMessage(PRIMARY_COLOR + "Server version: " + SECONDARY_COLOR + Bukkit.getVersion());
}
 
Example 30
Project: askygrid   File: ASkyGrid.java   View source code 6 votes vote down vote up
/**
    * Registers events
    */
   public void registerEvents() {
final PluginManager manager = getServer().getPluginManager();
// Nether portal events
manager.registerEvents(new NetherPortals(this), this);
// Player events
manager.registerEvents(new PlayerEvents(this), this);
// Events for when a player joins or leaves the server
manager.registerEvents(new JoinLeaveEvents(this), this);
// Enables warp signs in ASkyGrid
warpSignsListener = new WarpSigns(this);
manager.registerEvents(warpSignsListener, this);
// EnderDragon removal
if (Settings.createEnd) {
    manager.registerEvents(new BlockEndDragon(this), this);
}
   }
 
Example 31
Project: pploader   File: ReflectionHelper.java   View source code 6 votes vote down vote up
/**
 * Retrieve loaders field from JavaPluginLoader instance
 * @param pm plugin manager to search for JavaPluginLoader in (if necessary)
 * @return loaders field retrieved
 */
@SuppressWarnings("unchecked")
public static Map<String, ?> getJavaLoaders(PluginManager pm) {
    if (javaLoaders != null)
        return javaLoaders;

    getJavaPluginLoader(pm);
    if (javapluginloader == null)
        return null;

    try {
        Field fieldLoaders = JavaPluginLoader.class.getDeclaredField("loaders");
        fieldLoaders.setAccessible(true);

        javaLoaders = (Map<String, ?>) fieldLoaders.get(javapluginloader);
        return javaLoaders;
    } catch (Throwable t) {
        t.printStackTrace();
        return null;
    }
}
 
Example 32
Project: ticket-master   File: TicketMaster.java   View source code 6 votes vote down vote up
@Override
public void onEnable() {
	instance = this;

	// Load lang.yml
	LangConfig.reloadConfig();

	// Open database
	DatabaseManager.open();
	DatabaseManager.createTablesIfNotExists();
	DatabaseManager.updateDatabase();
	
	// Commands
	CommandHandler cmdHandler = new CommandHandler();
	getCommand("ticket").setExecutor(cmdHandler);
	getCommand("tickets").setExecutor(cmdHandler);
	
	// Listeners
	PluginManager pm = getServer().getPluginManager();
	pm.registerEvents(new PlayerJoinListener(), this);
	
	// Tasks
	new PendingTicketNotifier().register(this);
	new CooldownCleanup().register(this);
}
 
Example 33
Project: SortingHopper   File: SortingHopper.java   View source code 6 votes vote down vote up
@Override
public void onEnable() {
           
               PluginManager pm = getServer().getPluginManager();
               this.saveDefaultConfig();               
                
               pm.registerEvents(hopperListener, this);
               
               if(getConfig().getBoolean("replacedrops")){
                   final BreakListener breakListener = new BreakListener(this);
                   pm.registerEvents(breakListener, this);                    
               }
               if(getConfig().getBoolean("preventitempickup")){
                   final PickupListener pickupListener = new PickupListener(this);
                   pm.registerEvents(pickupListener, this);                    
               }                
               if (getConfig().getBoolean("crafting.enabled")){
                   addRecipe(getItem());
       	}               
	mclog.info("[SortingHopper] started!");
               
}
 
Example 34
Project: AlmightyNotch   File: CreeperExplodeEvent.java   View source code 6 votes vote down vote up
@Override
public void trigger(AlmightyNotchPlugin plugin, World world) {
    PluginManager pluginManager = Bukkit.getPluginManager();
    for (LivingEntity entity : world.getLivingEntities()) {
        if (entity.getType() == EntityType.CREEPER) {
            Creeper creeper = (Creeper) entity;

            float power = creeper.isPowered() ? 6.0F : 3.0F;
            ExplosionPrimeEvent event = new ExplosionPrimeEvent(creeper, power, false);
            pluginManager.callEvent(event);
            if (!event.isCancelled()) {
                creeper.damage(creeper.getHealth());
                world.createExplosion(creeper.getLocation(), power);
            }
        }
    }
    plugin.getMessenger().sendMessage(Bukkit.getServer(), getOccurMessage());
}
 
Example 35
Project: LapisPortals   File: EnderPortals.java   View source code 6 votes vote down vote up
public void onEnable() {
	loadConfig();
	VaultHook.enable(this);
	EnderPortal.initialize(this);
	Messenger.init(this);

	setFileHandler(new FileHandler(this));
	PluginDescriptionFile pdfFile = getDescription();
	PluginManager pm = getServer().getPluginManager();
	pm.registerEvents(this.playerListener, this);
	getServer().getScheduler().scheduleSyncRepeatingTask(this,
			new Runnable() {
				public void run() {
					EnderPortals.getFileHandler().save();
				}
			}, 600L, 600L);
	Messenger.info(pdfFile.getName() + " " + pdfFile.getVersion()
			+ " is now enabled.");
}
 
Example 36
Project: sensibletoolbox   File: SensibleToolboxPlugin.java   View source code 6 votes vote down vote up
private void registerEventListeners() {
    PluginManager pm = this.getServer().getPluginManager();
    pm.registerEvents(new GeneralListener(this), this);
    pm.registerEvents(new FurnaceListener(this), this);
    pm.registerEvents(new MobListener(this), this);
    pm.registerEvents(new WorldListener(this), this);
    pm.registerEvents(new TrashCanListener(this), this);
    pm.registerEvents(new ElevatorListener(this), this);
    pm.registerEvents(new AnvilListener(this), this);
    uuidTracker = new PlayerUUIDTracker(this);
    pm.registerEvents(uuidTracker, this);
    if (isProtocolLibEnabled()) {
        soundMufflerListener = new SoundMufflerListener(this);
        soundMufflerListener.start();
    }
    floodlightListener = new FloodlightListener(this);
    pm.registerEvents(floodlightListener, this);
    enderStorageManager = new EnderStorageManager(this);
    pm.registerEvents(enderStorageManager, this);
}
 
Example 37
Project: MobSweeper   File: Region.java   View source code 6 votes vote down vote up
public void init(Plugin plugin)
{
    BukkitScheduler bs;
    PluginManager   pm;
    String          wn;

    if (radius < 1) {
        for (World w : Bukkit.getWorlds()) {
            wn = w.getName();

            if (worlds.contains(wn))
                subregions.add(new SubRegion(this, wn, 0, 0, true));
        }
    }

    if (event > 0) {
        pm = plugin.getServer().getPluginManager();
        pm.registerEvents(this, plugin);
    }

    if (sweep > 0) {
        bs     = plugin.getServer().getScheduler();
        taskid = bs.scheduleSyncRepeatingTask(plugin, this, sweep, sweep);
    }
}
 
Example 38
Project: CraftControl   File: CraftControl.java   View source code 6 votes vote down vote up
@Override
public void onEnable() {
    PluginManager pm = getServer().getPluginManager();
    
    // Save Default Configuration
    saveDefaultConfig();
    
    // Helper classes
    PermissionChecker permissionChecker = new PermissionChecker();
    MessageHelper messageHelper = new MessageHelper(this);
    
    // Load Custom Recipes
    recipeLoader = new RecipeLoader(this);
    recipeLoader.loadFromConfig();
    
    getServer().getConsoleSender().sendMessage("[CraftControl] " + ChatColor.GREEN + "Loaded " + recipeLoader.getRecipes().size() + " custom recipe(s)");
    
    // Register Events
    pm.registerEvents(new CraftingListener(this, permissionChecker, messageHelper), this);
    pm.registerEvents(new FurnaceListener(this, permissionChecker, messageHelper), this);
    
    // Start Worker
    WorkerTask.start(this);
}
 
Example 39
Project: Tweakkit-Server   File: NBTMetadataStore.java   View source code 6 votes vote down vote up
/**
 * Retrieve all stored metadata for all plugins.
 *
 * @param metadataKey The metadata to look up
 * @return A List of values found, or an empty List.
 */
public List<MetadataValue> getPluginMetadata(String metadataKey) {
    NBTTagCompound metadataRoot = getPluginMetadataRoot(false);
    PluginManager pm = Bukkit.getPluginManager();
    List<MetadataValue> metadata = new ArrayList<MetadataValue>();

    Set<String> pluginKeys = getAllKeys(metadataRoot);
    for (String pluginKey : pluginKeys) {
        NBTTagCompound pluginData = metadataRoot.getCompound(pluginKey);
        if (pluginData.hasKey(metadataKey)) {
            MetadataValue value = convertToMetadata(pm.getPlugin(pluginKey), pluginData.get(metadataKey));
            if (value != null) {
                metadata.add(value);
            }
        }
    }
    return Collections.unmodifiableList(metadata);
}
 
Example 40
Project: Songlantern   File: SonglanternCommand.java   View source code 6 votes vote down vote up
public boolean reload(CommandSender sender, String[] args)
{
	try
	{
		if(PermissionsUtil.checkPermission(sender, "songlantern.reload", false))
		{
			ConfigUtil.loadYaml(plugin.getConfig(), plugin.getConfigFile());
			ConfigUtil.loadYaml(plugin.getMaterials(), plugin.getMaterialFile());
			ConfigUtil.loadYaml(plugin.getItems(), plugin.getItemFile());
			PluginManager pluginManager = Bukkit.getPluginManager();
			pluginManager.disablePlugin(plugin);
			pluginManager.enablePlugin(plugin);
			MessageUtil.sendMessage(plugin, sender, "Reloaded.");
		}
		return true;
	}
	catch(Throwable t)
	{
		MessageUtil.sendError(plugin, sender, "Failed to reload.");
		return false;
	}
}