Example usage for com.google.common.base Platform getClass

List of usage examples for com.google.common.base Platform getClass

Introduction

In this page you can find the example usage for com.google.common.base Platform getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.sk89q.worldedit.extension.platform.CommandManager.java

void register(Platform platform) {
    log.log(Level.FINE, "Registering commands with " + platform.getClass().getCanonicalName());

    LocalConfiguration config = platform.getConfiguration();
    boolean logging = config.logCommands;
    String path = config.logFile;

    // Register log
    if (!logging || path.isEmpty()) {
        dynamicHandler.setHandler(null);
        commandLog.setLevel(Level.OFF);
    } else {/*w  w  w . j  av  a2 s  .com*/
        File file = new File(config.getWorkingDirectory(), path);
        commandLog.setLevel(Level.ALL);

        log.log(Level.INFO, "Logging WorldEdit commands to " + file.getAbsolutePath());

        try {
            dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true));
        } catch (IOException e) {
            log.log(Level.WARNING, "Could not use command log file " + path + ": " + e.getMessage());
        }
    }

    platform.registerCommands(dispatcher);
}

From source file:com.sk89q.worldedit.extension.platform.PlatformManager.java

/**
 * Register a platform with WorldEdit./*w  w w.j ava 2s  .  co m*/
 *
 * @param platform the platform
 */
public synchronized void register(Platform platform) {
    checkNotNull(platform);

    logger.log(Level.FINE,
            "Got request to register " + platform.getClass() + " with WorldEdit [" + super.toString() + "]");

    // Just add the platform to the list of platforms: we'll pick favorites
    // once all the platforms have been loaded
    platforms.add(platform);

    // Make sure that versions are in sync
    if (firstSeenVersion != null) {
        if (!firstSeenVersion.equals(platform.getVersion())) {
            logger.log(Level.WARNING,
                    "Multiple ports of WorldEdit are installed but they report different versions ({0} and {1}). "
                            + "If these two versions are truly different, then you may run into unexpected crashes and errors.",
                    new Object[] { firstSeenVersion, platform.getVersion() });
        }
    } else {
        firstSeenVersion = platform.getVersion();
    }
}

From source file:com.sk89q.worldedit.extension.platform.PlatformManager.java

/**
 * Unregister a platform from WorldEdit.
 *
 * <p>If the platform has been chosen for any capabilities, then a new
 * platform will be found.</p>//from  w  ww .j a va2 s . c  o m
 *
 * @param platform the platform
 */
public synchronized boolean unregister(Platform platform) {
    checkNotNull(platform);

    boolean removed = platforms.remove(platform);

    if (removed) {
        logger.log(Level.FINE, "Unregistering " + platform.getClass().getCanonicalName() + " from WorldEdit");

        boolean choosePreferred = false;

        // Check whether this platform was chosen to be the preferred one
        // for any capability and be sure to remove it
        Iterator<Entry<Capability, Platform>> it = preferences.entrySet().iterator();
        while (it.hasNext()) {
            Entry<Capability, Platform> entry = it.next();
            if (entry.getValue().equals(platform)) {
                entry.getKey().unload(this, entry.getValue());
                it.remove();
                choosePreferred = true; // Have to choose new favorites
            }
        }

        if (choosePreferred) {
            choosePreferred();
        }
    }

    return removed;
}