Java Code Examples for com.griefcraft.lwc.LWC#log()

The following examples show how to use com.griefcraft.lwc.LWC#log() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorldGuard.java    From Modern-LWC with MIT License 5 votes vote down vote up
@Override
public void load(LWC lwc) {
    Plugin plugin = lwc.getPlugin().getServer().getPluginManager()
            .getPlugin("WorldGuard");
    if (plugin != null) {
        if (plugin.getDescription().getAPIVersion() != null) {
            worldGuardPlugin = (WorldGuardPlugin) plugin;
        } else if (configuration.getBoolean("worldguard.enabled", false)) {
            lwc.log("An outdated version of WorldGuard has been detected.");
            lwc.log("Please update it if you wish to use WorldGuard with LWC.");
        }
    }
}
 
Example 2
Source File: AdminOwnerAll.java    From Modern-LWC with MIT License 4 votes vote down vote up
@Override
public void onCommand(LWCCommandEvent event) {
    if (event.isCancelled()) {
        return;
    }

    if (!event.hasFlag("a", "admin")) {
        return;
    }

    LWC lwc = event.getLWC();
    CommandSender sender = event.getSender();
    String[] args = event.getArgs();

    if (!args[0].equals("forceownerall")) {
        return;
    }

    if (args.length < 2) {
        lwc.sendSimpleUsage(sender,
                "/lwc admin forceownerall <OldPlayer> <NewPlayer>");
        return;
    }

    UUID oldOwner = UUIDRegistry.getUUID(args[2]);

    if (!(sender instanceof Player)) {
        lwc.sendLocale(sender, "protection.admin.noconsole");
        return;
    }

    String owner;

    if (oldOwner != null) {
        owner = oldOwner.toString();
    } else {
        owner = UUIDRegistry.getName(oldOwner);
    }

    UUID uuid = UUIDRegistry.getUUID(args[1]);
    List<Protection> protection;
    if (uuid != null) {
        protection = lwc.getPhysicalDatabase().loadProtectionsByPlayer(
                uuid.toString());
    } else {
        protection = lwc.getPhysicalDatabase().loadProtectionsByPlayer(
                args[1]);
    }

    LWCPlayer player = lwc.wrapPlayer(sender);
    for (Protection prot : protection) {
        prot.setOwner(owner);
        lwc.getPhysicalDatabase().saveProtection(prot);
        lwc.removeModes(player);
        lwc.log(prot.getOwner() + " Changed");
        lwc.sendLocale(player, "protection.interact.forceowner.finalize",
                "player", prot.getFormattedOwnerPlayerName());
    }
}
 
Example 3
Source File: PhysDB.java    From Modern-LWC with MIT License 4 votes vote down vote up
/**
 * Perform any database updates
 */
public void performDatabaseUpdates() {
    LWC lwc = LWC.getInstance();

    // Indexes
    if (databaseVersion == 0) {
        // Drop old, old indexes
        log("Dropping old indexes (One time, may take a while!)");
        dropIndex("protections", "in1");
        dropIndex("protections", "in6");
        dropIndex("protections", "in7");
        dropIndex("history", "in8");
        dropIndex("history", "in9");
        dropIndex("protections", "in10");
        dropIndex("history", "in12");
        dropIndex("history", "in13");
        dropIndex("history", "in14");

        // Create our updated (good) indexes
        log("Creating new indexes (One time, may take a while!)");
        createIndex("protections", "protections_main", "x, y, z, world");
        createIndex("protections", "protections_utility", "owner");
        createIndex("history", "history_main", "protectionId");
        createIndex("history", "history_utility", "player");
        createIndex("history", "history_utility2", "x, y, z");

        // increment the database version
        incrementDatabaseVersion();
    }

    if (databaseVersion == 1) {
        log("Creating index on internal");
        createIndex("internal", "internal_main", "name");
        incrementDatabaseVersion();
    }

    if (databaseVersion == 2) {
        doUpdate400_2();
        incrementDatabaseVersion();
    }

    if (databaseVersion == 3) {
        createIndex("protections", "protections_type", "type");
        incrementDatabaseVersion();
    }

    if (databaseVersion == 4) {
        List<String> blacklistedBlocks = lwc.getConfiguration().getStringList("optional.blacklistedBlocks",
                new ArrayList<String>());

        if (!blacklistedBlocks.contains("hopper")) {
            blacklistedBlocks.add(Material.HOPPER.name().toLowerCase());
            lwc.getConfiguration().setProperty("optional.blacklistedBlocks", blacklistedBlocks);
            lwc.getConfiguration().save();
            Configuration.reload();

            lwc.log("Added Hoppers to Blacklisted Blocks in core.yml (optional.blacklistedBlocks)");
            lwc.log("This means that Hoppers CANNOT be placed around protections a player does not have access to");
            lwc.log("If you DO NOT want this feature, simply remove '" + Material.HOPPER.name().toLowerCase()
                    + "' from blacklistedBlocks :-)");
        }

        incrementDatabaseVersion();
    }

    if (databaseVersion == 5) {
        boolean foundTrappedChest = false;

        for (String key : lwc.getConfiguration().getNode("protections.blocks").getKeys(null)) {
            if (key.equalsIgnoreCase("trapped_chest")) {
                foundTrappedChest = true;
                break;
            }
        }

        if (!foundTrappedChest) {
            lwc.getConfiguration().setProperty("protections.blocks.trapped_chest.enabled", true);
            lwc.getConfiguration().setProperty("protections.blocks.trapped_chest.autoRegister", "private");
            lwc.getConfiguration().save();
            Configuration.reload();

            lwc.log("Added Trapped Chests to core.yml as default protectable (ENABLED & AUTO REGISTERED)");
            lwc.log("Trapped chests are nearly the same as reg chests but can light up! They can also be double chests.");
            lwc.log("If you DO NOT want this as protected, simply remove it from core.yml! (search/look for trapped_chests under protections -> blocks");
        }

        incrementDatabaseVersion();
    }
}