Java Code Examples for org.bukkit.Bukkit.getPluginManager()

The following are Jave code examples for showing how to use getPluginManager() of the org.bukkit.Bukkit class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: FactionsXL   File: ReloadCommand.java   View Source Code Vote up 6 votes
@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 2
Project: EchoPet   File: CommandManager.java   View Source Code Vote up 6 votes
public CommandMap getCommandMap() {
    if (!(Bukkit.getPluginManager() instanceof SimplePluginManager)) {
        this.plugin.getLogger().warning("Seems like your server is using a custom PluginManager? Well let's try injecting our custom commands anyways...");
    }

    CommandMap map = null;

    try {
        map = SERVER_COMMAND_MAP.get(Bukkit.getPluginManager());

        if (map == null) {
            if (fallback != null) {
                return fallback;
            } else {
                fallback = map = new SimpleCommandMap(EchoPet.getPlugin().getServer());
                Bukkit.getPluginManager().registerEvents(new FallbackCommandRegistrationListener(fallback), this.plugin);
            }
        }
    } catch (Exception pie) {
        this.plugin.getLogger().warning("Failed to dynamically register the commands! Let's give it a last shot...");
        // Hmmm.... Pie...
        fallback = map = new SimpleCommandMap(EchoPet.getPlugin().getServer());
        Bukkit.getPluginManager().registerEvents(new FallbackCommandRegistrationListener(fallback), this.plugin);
    }
    return map;
}
 
Example 3
Project: Crescent   File: Crescent.java   View Source Code Vote up 5 votes
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 4
Project: Bssentials-Reloaded   File: Bssentials.java   View Source Code Vote up 5 votes
private void registerEvents() {
	PluginManager manager = Bukkit.getPluginManager();
	
	manager.registerEvents(new Logcat(),			this);
	manager.registerEvents(new Operator(),			this);
	manager.registerEvents(new AverageJoe(this),	this);
}
 
Example 5
Project: WC   File: WCCommands.java   View Source Code Vote up 5 votes
private static CommandMap getCommandMap() {
    CommandMap commandMap = null;
    try {
        if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
            Field f = SimplePluginManager.class.getDeclaredField("commandMap");
            f.setAccessible(true);
            commandMap = (CommandMap) f.get(Bukkit.getPluginManager());
        }
    } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {
        e.printStackTrace();
    }
    return commandMap;
}
 
Example 6
Project: SmartInvs   File: InventoryManager.java   View Source Code Vote up 5 votes
public InventoryManager(SmartInvsPlugin plugin) {
    this.plugin = plugin;
    this.pluginManager = Bukkit.getPluginManager();

    this.inventories = new HashMap<>();
    this.contents = new HashMap<>();

    this.defaultOpeners = Arrays.asList(
            new ChestInventoryOpener(),
            new SpecialInventoryOpener()
    );

    this.openers = new ArrayList<>();
}
 
Example 7
Project: Sunscreen   File: CombustionListener.java   View Source Code Vote up 5 votes
/**
 * 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 8
Project: UltimateSpawn   File: Manager.java   View Source Code Vote up 5 votes
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 9
Project: PA   File: PACommands.java   View Source Code Vote up 5 votes
private static CommandMap getCommandMap() {
    CommandMap commandMap = null;
    try {
        if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
            Field f = SimplePluginManager.class.getDeclaredField("commandMap");
            f.setAccessible(true);
            commandMap = (CommandMap) f.get(Bukkit.getPluginManager());
        }
    } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {
        e.printStackTrace();
    }
    return commandMap;
}
 
Example 10
Project: MCLibrary   File: CommandManager.java   View Source Code Vote up 5 votes
public CommandManager() {
    PluginManager manager = Bukkit.getPluginManager();
    try {
        Field mapField = SimplePluginManager.class.getDeclaredField("commandMap");
        mapField.setAccessible(true);
        commandMap = (CommandMap) mapField.get(manager);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        throw new IllegalStateException(e);
    }
}
 
Example 11
Project: Bukkit-Utilities   File: CommandManager.java   View Source Code Vote up 5 votes
private static CommandMap getCommandMap() {
  if (!(Bukkit.getPluginManager() instanceof SimplePluginManager)) throw new IllegalStateException("PluginManager instance is not SimplePluginManager");
  try {
    Field field = SimplePluginManager.class.getDeclaredField("commandMap");
    field.setAccessible(true);
    return (SimpleCommandMap) field.get(Bukkit.getPluginManager());
  } catch (IllegalAccessException | NoSuchFieldException excepted) {
    excepted.printStackTrace();
  }
  return null;
}
 
Example 12
Project: MCPluginDebuggerforMC   File: Util.java   View Source Code Vote up 4 votes
public static void loadPlugin(File pluginFile) throws InvalidDescriptionException, InvalidPluginException {
	PluginManager pluginManager = Bukkit.getPluginManager();
	Plugin plugin = pluginManager.loadPlugin(pluginFile);
	plugin.onLoad();
	pluginManager.enablePlugin(plugin);
}
 
Example 13
Project: McPlayUHC   File: McPlayUHC.java   View Source Code Vote up 4 votes
public void registerListeners() {
	PluginManager pm = Bukkit.getPluginManager();
	pm.registerEvents(new PlayerJoinListener(), this);
	pm.registerEvents(new EntityRegainHealthListener(), this);
	
}
 
Example 14
Project: Peach   File: Peach.java   View Source Code Vote up 3 votes
@Override
public void onEnable() {
    instance = this;
    PeachAPIProvider.setPeachInstance(this);

    ConsoleLog.setLogger(new PluginLogger(this));
    ConsoleLog.info("Peach enabling.. (version: " + this.getDescription().getVersion() + ") by ImABradley.");


    // Load API fields //
    scheduler = new Scheduler(this);
    claimManager = new ClaimManager(this);
    resourceHandler = new PeachResourceHandler(this);


    // Load resources //
    Arrays.stream(ResourceType.values())
            .forEach(type -> resourceHandler.loadResource(type.getFileName()));


    // Register listeners //
    PluginManager pluginManager = Bukkit.getPluginManager();
    pluginManager.registerEvents(new PlayerMoveListener(claimManager), this);


    ConsoleLog.info("Peach enabled (version: " + this.getDescription().getVersion() + ") by ImABradley.");
}