Search in sources :

Example 1 with PluginPlatform

use of org.spongepowered.common.applaunch.plugin.PluginPlatform in project SpongeCommon by SpongePowered.

the class MainMixin_Forge method forge$initLaunch.

@Inject(method = "<clinit>", at = @At("RETURN"))
private static void forge$initLaunch(final CallbackInfo ci) {
    final PluginPlatform pluginPlatform = AppLaunch.pluginPlatform();
    final ForgeLaunch launch = new ForgeLaunch(pluginPlatform);
    Launch.setInstance(launch);
}
Also used : ForgeLaunch(org.spongepowered.forge.launch.ForgeLaunch) PluginPlatform(org.spongepowered.common.applaunch.plugin.PluginPlatform) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with PluginPlatform

use of org.spongepowered.common.applaunch.plugin.PluginPlatform in project SpongeCommon by SpongePowered.

the class TokenHoldingString method parsePlaceholders.

/**
 * Parse an environment variable-style placeholder syntax.
 *
 * <p>Variable names are case-insensitive, and detected with the
 * {@link #TOKEN_MATCH} expression.</p>
 *
 * @param input input string
 * @return string with placeholders replaced
 */
private static String parsePlaceholders(final String input) {
    final Matcher matcher = TokenHoldingString.TOKEN_MATCH.matcher(input);
    if (!matcher.find()) {
        return input;
    }
    final StringBuffer result = new StringBuffer();
    do {
        final String token = matcher.group(1);
        final Function<PluginPlatform, String> replacer = TokenHoldingString.TOKENS.get(token.toLowerCase());
        final String replaced = replacer == null ? "" : replacer.apply(AppLaunch.pluginPlatform());
        matcher.appendReplacement(result, replaced == null ? "" : TokenHoldingString.sanitizePath(replaced));
    } while (matcher.find());
    matcher.appendTail(result);
    return result.toString();
}
Also used : Matcher(java.util.regex.Matcher) PluginPlatform(org.spongepowered.common.applaunch.plugin.PluginPlatform)

Example 3 with PluginPlatform

use of org.spongepowered.common.applaunch.plugin.PluginPlatform in project SpongeCommon by SpongePowered.

the class MainMixin_Forge method forge$initLaunch.

@Inject(method = "<clinit>", at = @At("RETURN"))
private static void forge$initLaunch(final CallbackInfo ci) {
    if (Launch.instance() != null) {
        return;
    }
    final PluginPlatform pluginPlatform = AppLaunch.pluginPlatform();
    final ForgeLaunch launch = new ForgeLaunch(pluginPlatform);
    Launch.setInstance(launch);
}
Also used : ForgeLaunch(org.spongepowered.forge.launch.ForgeLaunch) PluginPlatform(org.spongepowered.common.applaunch.plugin.PluginPlatform) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

PluginPlatform (org.spongepowered.common.applaunch.plugin.PluginPlatform)3 Inject (org.spongepowered.asm.mixin.injection.Inject)2 ForgeLaunch (org.spongepowered.forge.launch.ForgeLaunch)2 Matcher (java.util.regex.Matcher)1