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   Source Code and License 8 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: SurvivalCG   File: SCG.java   Source Code and License 7 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 3
Project: PerWorldInventory   File: PerWorldInventory.java   Source Code and License 7 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 4
Project: ProjectAres   File: NicknameCommands.java   Source Code and License 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 5
Project: FactionsXL   File: ReloadCommand.java   Source Code and License 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 6
Project: NavyCraft2-Lite   File: PermissionInterface.java   Source Code and License 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 7
Project: Chambers   File: ListenerManager.java   Source Code and License 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 8
Project: behave   File: MainPart.java   Source Code and License 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 9
Project: SignEdit   File: SignEditTest.java   Source Code and License 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 10
Project: ConditionalPerms   File: HookManager.java   Source Code and License 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 11
Project: KillerMoney   File: MessageHandler.java   Source Code and License 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 12
Project: PhantomAdmin   File: PhantomAdmin.java   Source Code and License 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 13
Project: LuckPerms   File: SubscriptionMapInjector.java   Source Code and License 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 14
Project: LuckPerms   File: SubscriptionMapInjector.java   Source Code and License 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 15
Project: Thermos-Bukkit   File: Permission.java   Source Code and License 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 16
Project: LastManStanding   File: LMS.java   Source Code and License 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 17
Project: DiamondGuarantee   File: DiamondGuarantee.java   Source Code and License 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 18
Project: LagMonitor   File: SystemCommand.java   Source Code and License 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 19
Project: GoldDigger   File: GoldDigger.java   Source Code and License 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 20
Project: CauldronGit   File: Permission.java   Source Code and License 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 21
Project: ExtremeSurvival   File: Main.java   Source Code and License 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 22
Project: AdvancedAchievements   File: AdvancedAchievements.java   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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;
	}
}
 
Example 41
Project: PlotMe-Core   File: PlotMe_CorePlugin.java   Source Code and License 6 votes vote down vote up
@Override
public void onEnable() {
    INSTANCE = this;
    getLogger().info("Enabling PlotMe...Waiting for generator data.");
    serverObjectBuilder = new BukkitServerBridge(this, getLogger());
    plotme.registerServerBridge(serverObjectBuilder);
    getAPI().enable();
    doMetric();

    //Register Bukkit Events
    PluginManager pm = getServer().getPluginManager();
    BukkitPlotListener listener = new BukkitPlotListener(this);
    pm.registerEvents(listener, this);
    pm.registerEvents(new BukkitPlotDenyListener(this), this);
    plotme.getEventBus().register(listener);
    //Register Command
    this.getCommand("plotme").setExecutor(new BukkitCommand(this));
}
 
Example 42
Project: VoidSpawn   File: VoidSpawn.java   Source Code and License 6 votes vote down vote up
private void loadDependencies(){
    PluginManager pm = Bukkit.getPluginManager();
    if(pm.isPluginEnabled("IslandWorld")){
        log("&eIslandWorld found, initializing support.");
        IslandWorld = true;
        log("&eIslandWorld support initialized.");
    }

    if(pm.isPluginEnabled("ASkyBlock")){
        log("&eASkyBlock found, initializing support.");
        ASkyBlock = true;
        log("&eASkyBlock support initialized.");
    }

    if(pm.isPluginEnabled("uSkyBlock")){
        log("&eUSkyBlock found, initializing support.");
        USkyBlock = true;
        log("&eUSkyBlock support initialized.");
    }

    if(!IslandWorld && !ASkyBlock && !USkyBlock){
        log("&eNo SkyBlock plugins found, disabling island mode support.");
    }
}
 
Example 43
Project: TreeLogging   File: TreeLoggingPlugin.java   Source Code and License 6 votes vote down vote up
/**
 * Called on mPlugin enable.
 */
public void onEnable() {
    if (!getDataFolder().exists())
        getDataFolder().mkdir();

    saveDefaultConfig();
    final List<String> ignoredBlocks = getConfig().getStringList("ignoredBlocks");
    loadIgnoredBlocks(ignoredBlocks);

    mDatabase = new Database(this);
    mStateManager = new StateManager(this);

    final PluginManager pluginManager = getServer().getPluginManager();
    pluginManager.registerEvents(new BlockListener(this), this);
    pluginManager.registerEvents(new PlayerListener(this), this);
    getCommand("tl").setExecutor(new TLCommandExecutor(this));
    getLogger().info("Enabled.");
}
 
Example 44
Project: AlmuraForgeBridge   File: BridgePlugin.java   Source Code and License 6 votes vote down vote up
@Override
public void onEnable() {
    instance = this;
    BridgeConfiguration.reloadConfig();
    Bukkit.getMessenger().registerOutgoingPluginChannel(this, PacketUtil.CHANNEL);
    Bukkit.getMessenger().registerIncomingPluginChannel(this, PacketUtil.CHANNEL, this);
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new PlayerListener(), this);
    pm.registerEvents(new EntityListener(), this);
    pm.registerEvents(new EconListener(), this);
    pm.registerEvents(new WorldListener(), this);
    // These packets have to be unique to the environment they are not coded per side.
    // DISCRIMINATOR_DISPLAY_NAME = 0;  
    // DISCRIMINATOR_CURRENCY = 1;
    // DISCRIMINATOR_ADDITIONAL_WORLD_INFORMATION = 2;
    // DISCRIMINATOR_RESIDENCE_INFO = 3;
    // [PlayerAccessory] = 4;
    // DISCRIMINATOR_GUI_CONTROLLER = 5;
    MessageRegistar.registerMessage(B00PlayerDeathConfirmation.class, B00PlayerDeathConfirmation.class, 6);
    MessageRegistar.registerMessage(B01ResTokenConfirmation.class, B01ResTokenConfirmation.class, 7);
    MessageRegistar.registerMessage(B02ClientDetailsResponse.class, B02ClientDetailsResponse.class, 9);
    MessageRegistar.registerMessage(B03ChunkRegenWand.class, B03ChunkRegenWand.class, 10);
}
 
Example 45
Project: Cauldron   File: Permission.java   Source Code and License 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 46
Project: rftd   File: RftdPlugin.java   Source Code and License 6 votes vote down vote up
@Override
public void onEnable() {
	RftdController controller = new RftdController(this);

	controller.onEnable();

	getCommand("egg").setExecutor(new EggExecutor(controller));
	getCommand("start").setExecutor(new StartExecutor(controller));
	getCommand("team").setExecutor(new TeamExecutor());

	PluginManager pm = getServer().getPluginManager();
	pm.registerEvents(new BlockListener(controller), this);
	pm.registerEvents(new EntityListener(controller), this);
	pm.registerEvents(new InventoryListener(controller), this);
	pm.registerEvents(new PlayerListener(controller), this);
	pm.registerEvents(new WeatherListener(), this);
}
 
Example 47
Project: Almura-API   File: Permission.java   Source Code and License 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 48
Project: Crescent   File: Crescent.java   Source Code and License 5 votes vote down vote up
private void registerListeners() {
	final PluginManager pm = Bukkit.getPluginManager();

	final BehaviourListeners behaviourListeners = new BehaviourListeners();
	behaviourListeners.registerPacketListeners();

	pm.registerEvents(behaviourListeners, this);
	pm.registerEvents(new DetectionListener(), this);
}
 
Example 49
Project: MT_Communication   File: MortuusTerraChat.java   Source Code and License 5 votes vote down vote up
public void registerListeners() {
	PluginManager pm = getServer().getPluginManager();

	pm.registerEvents(new CellularPhoneListener(this), this);
	pm.registerEvents(new PlayerListener(this), this);
	pm.registerEvents(new PlayerChatListener(), this);
	pm.registerEvents(new WalkieTalkieListener(this), this);
}
 
Example 50
Project: MT_Communication   File: MortuusTerraChat.java   Source Code and License 5 votes vote down vote up
public void registerListeners() {
	PluginManager pm = getServer().getPluginManager();

	pm.registerEvents(new CellularPhoneListener(this), this);
	pm.registerEvents(new PlayerListener(this), this);
	pm.registerEvents(new PlayerChatListener(), this);
	pm.registerEvents(new WalkieTalkieListener(this), this);
}
 
Example 51
Project: CraftyProfessions   File: CraftyProfessions.java   Source Code and License 5 votes vote down vote up
/**
 * This method registers all of the needed listeners for the Plugin
 */
private void registerListeners ()
{
    PluginManager pluginManager = this.getServer ().getPluginManager ();
    mCommandController = new CommandController (this);
    mCoreListener = new CoreListener (this);

    // Register the CraftyProfession Command Entry Point
    getCommand ("prof").setExecutor (mCommandController);

    // Register the Core Listener of CraftyProfessions
    pluginManager.registerEvents (mCoreListener, this);
}
 
Example 52
Project: uppercore   File: NodeCommand.java   Source Code and License 5 votes vote down vote up
@Override
public void registerPermissions(PluginManager manager) {
    super.registerPermissions(manager);
    if (anyPerm != null)
        manager.addPermission(anyPerm);
    for (Command command : commands)
        command.registerPermissions(manager);
}
 
Example 53
Project: Warzone   File: EntityDamageEventListener.java   Source Code and License 5 votes vote down vote up
public void register(@Nonnull Plugin plugin) {
    Preconditions.checkNotNull(plugin, "plugin");

    PluginManager pm = plugin.getServer().getPluginManager();

    for(EventPriority priority : EventPriority.values()) {
        pm.registerEvent(org.bukkit.event.entity.EntityDamageEvent.class, this, priority, new EntityDamageEventRunner(this, priority), plugin, false);
    }
}
 
Example 54
Project: Bssentials-Reloaded   File: Bssentials.java   Source Code and License 5 votes vote down vote up
private void registerEvents() {
	PluginManager manager = Bukkit.getPluginManager();
	
	manager.registerEvents(new Logcat(),			this);
	manager.registerEvents(new Operator(),			this);
	manager.registerEvents(new AverageJoe(this),	this);
}
 
Example 55
Project: bskyblock   File: BSkyBlock.java   Source Code and License 5 votes vote down vote up
protected void registerListeners() {
    PluginManager manager = getServer().getPluginManager();
    // Player join events
    manager.registerEvents(new JoinLeaveListener(this), this);
    manager.registerEvents(new NetherEvents(this), this);
    manager.registerEvents(new NetherPortals(this), this);
    manager.registerEvents(new IslandGuard(this), this);
    manager.registerEvents(new IslandGuard1_8(this), this);
    manager.registerEvents(new IslandGuard1_9(this), this);
    manager.registerEvents(new PanelListener(this), this);
}
 
Example 56
Project: WC   File: WCTWD.java   Source Code and License 5 votes vote down vote up
private void registerEvents(){
    PluginManager pm = getServer().getPluginManager();

    pm.registerEvents(new Thirst(instance), instance);
    pm.registerEvents(new Weapons(instance), instance);
    pm.registerEvents(new WeaponShop(instance), instance);
    pm.registerEvents(new GaussShop(instance), instance);
    pm.registerEvents(new WorldInteract(instance), instance);
}
 
Example 57
Project: chaoticWeapons   File: Core.java   Source Code and License 5 votes vote down vote up
@Override
public void onEnable() {
	getLogger().info("/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*");
	getLogger().info("The epic swords and stuff are now available");
	getLogger().info("/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*");
	PluginManager pm = getServer().getPluginManager();
	pm.addPermission(creator);
	Bukkit.getServer().getPluginManager().registerEvents(this, this);
}
 
Example 58
Project: Sunscreen   File: CombustionListener.java   Source Code and License 5 votes vote down vote up
/**
 * Constructor
 * 
 * @author HomieDion
 * @since 1.1.0
 */
public CombustionListener() {
	//Variables
	Sunscreen plugin = Sunscreen.getInstance();
	PluginManager pm = Bukkit.getPluginManager();
	
	settings = plugin.getSettings();
	pm.registerEvents(this, plugin);
}
 
Example 59
Project: UltimateSpawn   File: Manager.java   Source Code and License 5 votes vote down vote up
public void registerEvents() {
	PluginManager pm = Bukkit.getPluginManager();
	pm.registerEvents(new BasicFeatures(), pl);
	pm.registerEvents(new OnJoin(), pl);
	pm.registerEvents(new OnQuit(), pl);
	pm.registerEvents(new OnChat(), pl);
	pm.registerEvents(new FunFeatures(), pl);
	pm.registerEvents(new LittlesEvent(), pl);
	pm.registerEvents(new ChangeWorldEvent(), pl);
	pm.registerEvents(new OnCommand(), pl);
	pm.registerEvents(new CustomJoinItem(), pl);
}
 
Example 60
Project: WebSandboxMC   File: WebSandboxPlugin.java   Source Code and License 5 votes vote down vote up
@Override
public void onEnable() {
    final Settings settings = new SettingsBukkit(this);

    checkUnbind(settings);

    final Plugin plugin = this;

    // Run in a delayed task to ensure all worlds are loaded on startup (not only load: POSTWORLD).
    Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
        @Override
        public void run() {

            webSocketServerThread = new WebSocketServerThread(settings);

            webSocketServerThread.blockBridge = new BlockBridge(webSocketServerThread, settings);
            webSocketServerThread.playersBridge = new PlayersBridge(webSocketServerThread, settings);
            webSocketServerThread.webPlayerBridge = new WebPlayerBridge(webSocketServerThread, settings);

            // Register our events
            PluginManager pm = getServer().getPluginManager();

            pm.registerEvents(new BlockListener(webSocketServerThread.blockBridge), plugin);
            pm.registerEvents(new PlayersListener(webSocketServerThread.playersBridge), plugin);
            pm.registerEvents(new EntityListener(webSocketServerThread.webPlayerBridge), plugin);

            // Register our commands
            getCommand("websandbox").setExecutor(new WsCommand(webSocketServerThread, settings.usePermissions));

            // Run the websocket server
            webSocketServerThread.start();
        }
    });
}