Skip to content

Commit

Permalink
BukkitBootstrap v1.0.1
Browse files Browse the repository at this point in the history
Updated Mixins.
Reformatted code.
  • Loading branch information
LXGaming committed Mar 30, 2018
1 parent 8fbe899 commit 6f97020
Show file tree
Hide file tree
Showing 12 changed files with 275 additions and 266 deletions.
115 changes: 70 additions & 45 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,64 +1,89 @@
# Windows image file caches
Thumbs.db
ehthumbs.db
# Build
.checkstyle
MANIFEST.MF
dependency-reduced-pom.xml

# Folder config file
Desktop.ini
# Compiled
/target
bin
build
dist
lib
out
run
*.com
*.class
*.dll
*.exe
*.o
*.so

# Recycle Bin used on file shares
$RECYCLE.BIN/
# Databases
*.db
*.sql
*.sqlite

# Windows Installer files
# Logging
/logs
*.log

# Misc
*.bak

# Packages
*.7z
*.cab
*.dmg
*.gz
*.iso
*.msi
*.msm
*.msp
*.rar
*.tar
*.zip

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================
# Project
.classpath
.externalToolBuilders
.gradle
.idea
.nb-gradle
.project
.settings
atlassian-ide-plugin.xml
build.xml
nb-configuration.xml
nbproject
build.bat
*.iml
*.ipr
*.iws
*.launch

# OSX
# =========================
# Repository
.git

.DS_Store
# System - macOS
.AppleDB
.AppleDesktop
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear in the root of a volume
.DS_Store
.DocumentRevisions-V100
.fseventsd
.LSOverride
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
._*
.apdisk
.fseventsd
Network Trash Folder
Temporary Items
.apdisk

# Eclipse project
.settings
.classpath
.project
client.launch
server.launch

# Maven project
target

# Gradle project
.gradle
libs
bin
build
build.bat
# System - Windows
$RECYCLE.BIN/
Desktop.ini
Thumbs.db
ehthumbs.db
*.lnk
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ targetCompatibility = 1.8

group = "io.github.lxgaming"
archivesBaseName = "BukkitBootstrap"
version = "1.0.0"
version = "1.0.1"

configurations {
provided {
compile.extendsFrom(provided)
}

build.dependsOn("signJar")
}

repositories {
Expand All @@ -37,14 +39,15 @@ dependencies {
annotationProcessor("org.apache.logging.log4j:log4j-core:2.8.1")
provided("org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209")
compile("org.slf4j:slf4j-simple:1.7.25")
compile("org.spongepowered:mixin:0.7.3-SNAPSHOT")
compile("org.spongepowered:mixin:0.7.5-SNAPSHOT")
}

jar {
manifest {
attributes(
"Main-Class": "io.github.lxgaming.bukkitbootstrap.Main",
"MixinConfigs": "mixins.bukkitbootstrap.json")
"MixinConfigs": "mixins.bukkitbootstrap.json"
)
}

from {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
18 changes: 0 additions & 18 deletions settings.gradle

This file was deleted.

150 changes: 75 additions & 75 deletions src/main/java/io/github/lxgaming/bukkitbootstrap/Main.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Alex Thomson
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -16,6 +16,9 @@

package io.github.lxgaming.bukkitbootstrap;

import io.github.lxgaming.bukkitbootstrap.util.Reference;
import net.minecraft.launchwrapper.Launch;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
Expand All @@ -32,77 +35,74 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.github.lxgaming.bukkitbootstrap.util.Reference;
import net.minecraft.launchwrapper.Launch;

public class Main {
public static void main(String[] args) {
printInformation(action -> {
System.out.println(action);
});
List<String> arguments = newArrayList(args);
loadServerJar(arguments);
arguments.add("--tweakClass=org.spongepowered.asm.launch.BukkitBootstrap");
System.out.println("Initializing LaunchWrapper...");
Launch.main(arguments.toArray(new String[arguments.size()]));
}
private static void loadServerJar(List<String> arguments) {
try {
Optional<String> serverJarPath = getArgument(arguments, "--serverJar");
if (!serverJarPath.isPresent()) {
throw new IllegalArgumentException("--serverJar argument is not present");
}
File serverJarFile = new File(serverJarPath.get());
if (serverJarFile == null || !serverJarFile.exists()) {
throw new IOException("Failed to find server jar");
}
URLClassLoader classLoader = (URLClassLoader) Main.class.getClassLoader();
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(classLoader, serverJarFile.toURI().toURL());
System.out.println("Loaded Server Jar " + serverJarFile.getAbsolutePath());
} catch (Exception ex) {
System.out.println("Encountered an error processing BukkitBootstrap::loadServerJar");
ex.printStackTrace();
System.exit(1);
}
}
private static Optional<String> getArgument(List<String> arguments, String argument) throws NullPointerException {
Objects.requireNonNull(arguments);
for (Iterator<String> iterator = arguments.iterator(); iterator.hasNext();) {
String string = iterator.next();
if (string != null && string.equals(argument) && iterator.hasNext()) {
iterator.remove();
String value = iterator.next();
iterator.remove();
return Optional.of(value);
}
}
return Optional.empty();
}
public static void printInformation(Consumer<? super String> consumer) {
List<String> information = new ArrayList<String>();
information.add(Reference.APP_NAME + " v" + Reference.APP_VERSION);
information.add("Authors: " + Reference.AUTHORS);
information.add("Source: " + Reference.SOURCE);
information.add("Website: " + Reference.WEBSITE);
int length = Collections.max(information, Comparator.comparingInt(String::length)).length();
information.add(0, String.join("", Collections.nCopies(length, "-")));
information.add(String.join("", Collections.nCopies(length, "-")));
information.forEach(consumer);
}
@SafeVarargs
public static <E> ArrayList<E> newArrayList(E... elements) throws NullPointerException {
Objects.requireNonNull(elements);
return Stream.of(elements).collect(Collectors.toCollection(ArrayList::new));
}
public static void main(String[] args) {
printInformation(action -> {
System.out.println(action);
});
List<String> arguments = newArrayList(args);
loadServerJar(arguments);
arguments.add("--tweakClass=org.spongepowered.asm.launch.BukkitBootstrap");
System.out.println("Initializing LaunchWrapper...");
Launch.main(arguments.toArray(new String[arguments.size()]));
}
private static void loadServerJar(List<String> arguments) {
try {
Optional<String> serverJarPath = getArgument(arguments, "--serverJar");
if (!serverJarPath.isPresent()) {
throw new IllegalArgumentException("--serverJar argument is not present");
}
File serverJarFile = new File(serverJarPath.get());
if (serverJarFile == null || !serverJarFile.exists()) {
throw new IOException("Failed to find server jar");
}
URLClassLoader classLoader = (URLClassLoader) Main.class.getClassLoader();
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(classLoader, serverJarFile.toURI().toURL());
System.out.println("Loaded Server Jar " + serverJarFile.getAbsolutePath());
} catch (Exception ex) {
System.out.println("Encountered an error processing BukkitBootstrap::loadServerJar");
ex.printStackTrace();
System.exit(1);
}
}
private static Optional<String> getArgument(List<String> arguments, String argument) throws NullPointerException {
Objects.requireNonNull(arguments);
for (Iterator<String> iterator = arguments.iterator(); iterator.hasNext(); ) {
String string = iterator.next();
if (string != null && string.equals(argument) && iterator.hasNext()) {
iterator.remove();
String value = iterator.next();
iterator.remove();
return Optional.of(value);
}
}
return Optional.empty();
}
public static void printInformation(Consumer<? super String> consumer) {
List<String> information = new ArrayList<String>();
information.add(Reference.APP_NAME + " v" + Reference.APP_VERSION);
information.add("Authors: " + Reference.AUTHORS);
information.add("Source: " + Reference.SOURCE);
information.add("Website: " + Reference.WEBSITE);
int length = Collections.max(information, Comparator.comparingInt(String::length)).length();
information.add(0, String.join("", Collections.nCopies(length, "-")));
information.add(String.join("", Collections.nCopies(length, "-")));
information.forEach(consumer);
}
@SafeVarargs
public static <E> ArrayList<E> newArrayList(E... elements) throws NullPointerException {
Objects.requireNonNull(elements);
return Stream.of(elements).collect(Collectors.toCollection(ArrayList::new));
}
}
Loading

0 comments on commit 6f97020

Please sign in to comment.