Search in sources :

Example 1 with MyDependingPluginsGraph

use of com.bergerkiller.bukkit.common.metrics.MyDependingPluginsGraph in project BKCommonLib by bergerhealer.

the class CommonPlugin method enable.

@Override
public void enable() {
    // Validate version
    if (Common.IS_COMPATIBLE) {
        log(Level.INFO, "BKCommonLib is running on " + Common.SERVER_DESCRIPTION);
    } else {
        String verText = StringUtil.combineNames(Common.TEMPLATE_RESOLVER.getSupportedVersions());
        log(Level.SEVERE, "This version of BKCommonLib is not compatible with: " + Common.SERVER_DESCRIPTION);
        log(Level.SEVERE, "It could be that BKCommonLib has to be updated, as the current version is built for MC " + verText);
        log(Level.SEVERE, "Please look for a new updated BKCommonLib version that is compatible:");
        log(Level.SEVERE, "https://www.spigotmc.org/resources/bkcommonlib.39590/");
        log(Level.SEVERE, "Unstable development builds for MC " + Common.MC_VERSION + " may be found on our continuous integration server:");
        log(Level.SEVERE, "https://ci.mg-dev.eu/job/BKCommonLib/");
        this.onCriticalFailure();
        return;
    }
    // Set the packet handler to use before enabling further - it could fail!
    if (!this.updatePacketHandler()) {
        this.onCriticalFailure();
        return;
    }
    // Welcome message
    final List<String> welcomeMessages = Arrays.asList("This library is written with stability in mind.", "No Bukkit moderators were harmed while compiling this piece of art.", "Have a problem Bukkit can't fix? Write a library!", "Bringing home the bacon since 2011!", "Completely virus-free and scanned by various Bukkit-dev-staff watching eyes.", "Hosts all the features that are impossible to include in a single Class", "CraftBukkit: redone, reworked, translated and interfaced.", "Having an error? *gasp* Don't forget to file a ticket on dev.bukkit.org!", "Package versioning is what brought BKCommonLib and CraftBukkit closer together!", "For all the haters out there: BKCommonLib at least tries!", "Want fries with that? We have hidden fries in the FoodUtil class.", "Not enough wrappers. Needs more wrappers. Moooreee...", "Reflection can open the way to everyone's heart, including CraftBukkit.", "Our love is not permitted by the overlords. We must flee...", "Now a plugin, a new server implementation tomorrow???", "Providing support for supporting the unsupportable.", "Every feature break in Bukkit makes my feature list longer.", "I...I forgot an exclamation mark...*rages internally*", "I am still winning the game. Are you?", "We did what our big brother couldn't", "If you need syntax help visit javadocs.a.b.v1_2_3.net", "v1_1_R1 1+1+1 = 3, Half life 3 confirmed?", "BKCommonLib > Minecraft.a.b().q.f * Achievement.OBFUSCATED.value", "BKCommonLib isn't a plugin, its a language based on english.", "Updating is like reinventing the wheel for BKCommonLib.", "Say thanks to our wonderful devs: Friwi, KamikazePlatypus and mg_1999");
    setEnableMessage(welcomeMessages.get(new Random().nextInt(welcomeMessages.size())));
    setDisableMessage(null);
    // Initialize MapColorPalette (static initializer)
    MapColorPalette.getColor(Color.RED);
    // Initialize NBTBase createHandle() - workaround for a reported error
    // The error this potentially fixes is related to a linkageerror when generating the class
    NBTBaseHandle.T.createHandle(null, true);
    // Initialize permissions
    permissionHandler = new PermissionHandler();
    // Initialize event factory
    eventFactory = new CommonEventFactory();
    // Initialize entity map (needs to be here because of CommonPlugin instance needed)
    playerVisibleChunks = new EntityMap<Player, CommonPlayerMeta>();
    // Initialize Entity Blacklist
    entityBlacklist = new CommonEntityBlacklist();
    // Register events and tasks, initialize
    register(listener = new CommonListener());
    // NO LONGER USED!!!
    // register(new CommonPacketMonitor(), CommonPacketMonitor.TYPES);
    tabController = new CommonTabController();
    register(tabController);
    PacketUtil.addPacketListener(this, tabController, PacketType.OUT_PLAYER_INFO);
    register(mapController = new CommonMapController());
    PacketUtil.addPacketListener(this, mapController, CommonMapController.PACKET_TYPES);
    mapController.onEnable(this, startedTasks);
    startedTasks.add(new NextTickHandler(this).start(1, 1));
    startedTasks.add(new MoveEventHandler(this).start(1, 1));
    startedTasks.add(new EntityRemovalHandler(this).start(1, 1));
    startedTasks.add(new TabUpdater(this).start(1, 1));
    // For those servers, we handle them using our own system
    if (!EntityPlayerHandle.T.removeQueue.isAvailable()) {
        startedTasks.add(new EntityRemoveQueueSyncTask(this).start(1, 1));
    }
    // Operations to execute the next tick (when the server has started)
    CommonUtil.nextTick(new Runnable() {

        public void run() {
            // Set server started state
            isServerStarted = true;
            // Tell the tabs to initialize the initial dimensions
            getTabController().setDefaultSize();
        }
    });
    // Register listeners and hooks
    for (World world : WorldUtil.getWorlds()) {
        ChunkProviderServerHook.hook(world);
        notifyWorldAdded(world);
    }
    // BKCommonLib Metrics
    if (hasMetrics()) {
        // Soft dependencies
        getMetrics().addGraph(new SoftDependenciesGraph());
        // Depending
        getMetrics().addGraph(new MyDependingPluginsGraph());
    }
    // Server-specific enabling occurs
    Common.SERVER.enable(this);
    // Parse BKCommonLib version to int
    int version = this.getVersionNumber();
    if (version != Common.VERSION) {
        log(Level.SEVERE, "Common.VERSION needs to be updated to contain '" + version + "'!");
    }
}
Also used : Player(org.bukkit.entity.Player) World(org.bukkit.World) SoftDependenciesGraph(com.bergerkiller.bukkit.common.metrics.SoftDependenciesGraph) MyDependingPluginsGraph(com.bergerkiller.bukkit.common.metrics.MyDependingPluginsGraph) CommonEventFactory(com.bergerkiller.bukkit.common.events.CommonEventFactory)

Aggregations

CommonEventFactory (com.bergerkiller.bukkit.common.events.CommonEventFactory)1 MyDependingPluginsGraph (com.bergerkiller.bukkit.common.metrics.MyDependingPluginsGraph)1 SoftDependenciesGraph (com.bergerkiller.bukkit.common.metrics.SoftDependenciesGraph)1 World (org.bukkit.World)1 Player (org.bukkit.entity.Player)1