More standard code formatting profile
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
5912ef3b45
commit
4abf3a20c6
@ -246,11 +246,11 @@
|
|||||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
|
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
|
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_if_single_item"/>
|
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
|
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
|
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||||
@ -262,7 +262,7 @@
|
|||||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/>
|
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line"/>
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||||
|
@ -81,10 +81,11 @@ public final class Launcher extends Applet implements AppletStub {
|
|||||||
private final URL documentBase;
|
private final URL documentBase;
|
||||||
private boolean active = false;
|
private boolean active = false;
|
||||||
|
|
||||||
public Launcher(Applet applet) { this(applet, null); }
|
public Launcher(Applet applet) {
|
||||||
|
this(applet, null);
|
||||||
|
}
|
||||||
|
|
||||||
public Launcher(Applet applet, URL documentBase)
|
public Launcher(Applet applet, URL documentBase) {
|
||||||
{
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
this.add(applet, "Center");
|
this.add(applet, "Center");
|
||||||
@ -108,8 +109,7 @@ public final class Launcher extends Applet implements AppletStub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(Applet applet)
|
public void replace(Applet applet) {
|
||||||
{
|
|
||||||
wrappedApplet = applet;
|
wrappedApplet = applet;
|
||||||
|
|
||||||
applet.setStub(this);
|
applet.setStub(this);
|
||||||
@ -128,14 +128,17 @@ public final class Launcher extends Applet implements AppletStub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive() { return active; }
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getDocumentBase() { return documentBase; }
|
public URL getDocumentBase() {
|
||||||
|
return documentBase;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getCodeBase()
|
public URL getCodeBase() {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
// TODO: 2022-10-27 Can this be changed to https?
|
// TODO: 2022-10-27 Can this be changed to https?
|
||||||
return new URL("http://www.minecraft.net/game/");
|
return new URL("http://www.minecraft.net/game/");
|
||||||
@ -145,8 +148,7 @@ public final class Launcher extends Applet implements AppletStub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(String name)
|
public String getParameter(String name) {
|
||||||
{
|
|
||||||
String param = params.get(name);
|
String param = params.get(name);
|
||||||
|
|
||||||
if (param != null)
|
if (param != null)
|
||||||
@ -161,54 +163,62 @@ public final class Launcher extends Applet implements AppletStub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height) { wrappedApplet.resize(width, height); }
|
public void resize(int width, int height) {
|
||||||
|
wrappedApplet.resize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(Dimension size) { wrappedApplet.resize(size); }
|
public void resize(Dimension size) {
|
||||||
|
wrappedApplet.resize(size);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init()
|
public void init() {
|
||||||
{
|
|
||||||
if (wrappedApplet != null)
|
if (wrappedApplet != null)
|
||||||
wrappedApplet.init();
|
wrappedApplet.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start()
|
public void start() {
|
||||||
{
|
|
||||||
wrappedApplet.start();
|
wrappedApplet.start();
|
||||||
|
|
||||||
active = true;
|
active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop()
|
public void stop() {
|
||||||
{
|
|
||||||
wrappedApplet.stop();
|
wrappedApplet.stop();
|
||||||
|
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() { wrappedApplet.destroy(); }
|
public void destroy() {
|
||||||
|
wrappedApplet.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appletResize(int width, int height) { wrappedApplet.resize(width, height); }
|
public void appletResize(int width, int height) {
|
||||||
|
wrappedApplet.resize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean visible)
|
public void setVisible(boolean visible) {
|
||||||
{
|
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
|
|
||||||
wrappedApplet.setVisible(visible);
|
wrappedApplet.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics graphics) {}
|
public void paint(Graphics graphics) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Graphics graphics) {}
|
public void update(Graphics graphics) {
|
||||||
|
}
|
||||||
|
|
||||||
public void setParameter(String name, String value) { params.put(name, value); }
|
public void setParameter(String name, String value) {
|
||||||
|
params.put(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,10 @@ import java.util.logging.Logger;
|
|||||||
public final class EntryPoint {
|
public final class EntryPoint {
|
||||||
private static final Logger LOGGER = Logger.getLogger("EntryPoint");
|
private static final Logger LOGGER = Logger.getLogger("EntryPoint");
|
||||||
|
|
||||||
private EntryPoint() {}
|
private EntryPoint() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args) {
|
||||||
{
|
|
||||||
ExitCode exitCode = listen();
|
ExitCode exitCode = listen();
|
||||||
|
|
||||||
if (exitCode != ExitCode.NORMAL) {
|
if (exitCode != ExitCode.NORMAL) {
|
||||||
@ -85,8 +85,7 @@ public final class EntryPoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PreLaunchAction parseLine(String input, Parameters params) throws ParseException
|
private static PreLaunchAction parseLine(String input, Parameters params) throws ParseException {
|
||||||
{
|
|
||||||
if (input.isEmpty())
|
if (input.isEmpty())
|
||||||
return PreLaunchAction.PROCEED;
|
return PreLaunchAction.PROCEED;
|
||||||
|
|
||||||
@ -109,8 +108,7 @@ public final class EntryPoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ExitCode listen()
|
private static ExitCode listen() {
|
||||||
{
|
|
||||||
Parameters parameters = new Parameters();
|
Parameters parameters = new Parameters();
|
||||||
PreLaunchAction preLaunchAction = PreLaunchAction.PROCEED;
|
PreLaunchAction preLaunchAction = PreLaunchAction.PROCEED;
|
||||||
|
|
||||||
@ -179,7 +177,10 @@ public final class EntryPoint {
|
|||||||
|
|
||||||
private final int numericalCode;
|
private final int numericalCode;
|
||||||
|
|
||||||
ExitCode(int numericalCode) { this.numericalCode = numericalCode; }
|
ExitCode(int numericalCode) {
|
||||||
|
this.numericalCode = numericalCode;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,7 @@ public abstract class AbstractLauncher implements Launcher {
|
|||||||
|
|
||||||
protected final String mainClassName;
|
protected final String mainClassName;
|
||||||
|
|
||||||
protected AbstractLauncher(Parameters params)
|
protected AbstractLauncher(Parameters params) {
|
||||||
{
|
|
||||||
this.mcParams = params.getList("param", new ArrayList<String>());
|
this.mcParams = params.getList("param", new ArrayList<String>());
|
||||||
this.mainClassName = params.getString("mainClass", "net.minecraft.client.Minecraft");
|
this.mainClassName = params.getString("mainClass", "net.minecraft.client.Minecraft");
|
||||||
|
|
||||||
|
@ -62,11 +62,12 @@ import java.lang.invoke.MethodHandle;
|
|||||||
|
|
||||||
public final class StandardLauncher extends AbstractLauncher {
|
public final class StandardLauncher extends AbstractLauncher {
|
||||||
|
|
||||||
public StandardLauncher(Parameters params) { super(params); }
|
public StandardLauncher(Parameters params) {
|
||||||
|
super(params);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launch() throws Throwable
|
public void launch() throws Throwable {
|
||||||
{
|
|
||||||
// window size, title and state
|
// window size, title and state
|
||||||
|
|
||||||
// FIXME: there is no good way to maximize the minecraft window from here.
|
// FIXME: there is no good way to maximize the minecraft window from here.
|
||||||
|
@ -83,8 +83,7 @@ public final class LegacyFrame extends JFrame {
|
|||||||
|
|
||||||
private final Launcher launcher;
|
private final Launcher launcher;
|
||||||
|
|
||||||
public LegacyFrame(String title, Applet applet)
|
public LegacyFrame(String title, Applet applet) {
|
||||||
{
|
|
||||||
super(title);
|
super(title);
|
||||||
|
|
||||||
launcher = new Launcher(applet);
|
launcher = new Launcher(applet);
|
||||||
@ -101,8 +100,7 @@ public final class LegacyFrame extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start(String user, String session, int width, int height, boolean maximize, String serverAddress,
|
public void start(String user, String session, int width, int height, boolean maximize, String serverAddress,
|
||||||
String serverPort, boolean isDemo)
|
String serverPort, boolean isDemo) {
|
||||||
{
|
|
||||||
// Implements support for launching in to multiplayer on classic servers using a
|
// Implements support for launching in to multiplayer on classic servers using a
|
||||||
// mpticket
|
// mpticket
|
||||||
// file generated by an external program and stored in the instance's root
|
// file generated by an external program and stored in the instance's root
|
||||||
@ -166,12 +164,10 @@ public final class LegacyFrame extends JFrame {
|
|||||||
private final class ForceExitHandler extends WindowAdapter {
|
private final class ForceExitHandler extends WindowAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent event)
|
public void windowClosing(WindowEvent event) {
|
||||||
{
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(30000L);
|
Thread.sleep(30000L);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -81,8 +81,7 @@ public final class LegacyLauncher extends AbstractLauncher {
|
|||||||
private final boolean usesApplet;
|
private final boolean usesApplet;
|
||||||
private final String cwd;
|
private final String cwd;
|
||||||
|
|
||||||
public LegacyLauncher(Parameters params)
|
public LegacyLauncher(Parameters params) {
|
||||||
{
|
|
||||||
super(params);
|
super(params);
|
||||||
|
|
||||||
user = params.getString("userName");
|
user = params.getString("userName");
|
||||||
@ -97,8 +96,7 @@ public final class LegacyLauncher extends AbstractLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launch() throws Throwable
|
public void launch() throws Throwable {
|
||||||
{
|
|
||||||
Class<?> main = ClassLoader.getSystemClassLoader().loadClass(this.mainClassName);
|
Class<?> main = ClassLoader.getSystemClassLoader().loadClass(this.mainClassName);
|
||||||
Field gameDirField = ReflectionUtils.getMinecraftGameDirField(main);
|
Field gameDirField = ReflectionUtils.getMinecraftGameDirField(main);
|
||||||
|
|
||||||
|
@ -68,8 +68,7 @@ public final class Parameters {
|
|||||||
|
|
||||||
private final Map<String, List<String>> map = new HashMap<>();
|
private final Map<String, List<String>> map = new HashMap<>();
|
||||||
|
|
||||||
public void add(String key, String value)
|
public void add(String key, String value) {
|
||||||
{
|
|
||||||
List<String> params = map.get(key);
|
List<String> params = map.get(key);
|
||||||
|
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
@ -81,8 +80,7 @@ public final class Parameters {
|
|||||||
params.add(value);
|
params.add(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getList(String key) throws ParameterNotFoundException
|
public List<String> getList(String key) throws ParameterNotFoundException {
|
||||||
{
|
|
||||||
List<String> params = map.get(key);
|
List<String> params = map.get(key);
|
||||||
|
|
||||||
if (params == null)
|
if (params == null)
|
||||||
@ -91,8 +89,7 @@ public final class Parameters {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getList(String key, List<String> def)
|
public List<String> getList(String key, List<String> def) {
|
||||||
{
|
|
||||||
List<String> params = map.get(key);
|
List<String> params = map.get(key);
|
||||||
|
|
||||||
if (params == null || params.isEmpty())
|
if (params == null || params.isEmpty())
|
||||||
@ -101,8 +98,7 @@ public final class Parameters {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(String key) throws ParameterNotFoundException
|
public String getString(String key) throws ParameterNotFoundException {
|
||||||
{
|
|
||||||
List<String> list = getList(key);
|
List<String> list = getList(key);
|
||||||
|
|
||||||
if (list.isEmpty())
|
if (list.isEmpty())
|
||||||
@ -111,8 +107,7 @@ public final class Parameters {
|
|||||||
return list.get(0);
|
return list.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(String key, String def)
|
public String getString(String key, String def) {
|
||||||
{
|
|
||||||
List<String> params = map.get(key);
|
List<String> params = map.get(key);
|
||||||
|
|
||||||
if (params == null || params.isEmpty())
|
if (params == null || params.isEmpty())
|
||||||
|
@ -52,7 +52,8 @@ public final class ReflectionUtils {
|
|||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger("ReflectionUtils");
|
private static final Logger LOGGER = Logger.getLogger("ReflectionUtils");
|
||||||
|
|
||||||
private ReflectionUtils() {}
|
private ReflectionUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate an applet class by name
|
* Instantiate an applet class by name
|
||||||
@ -67,8 +68,7 @@ public final class ReflectionUtils {
|
|||||||
* method handles
|
* method handles
|
||||||
* @throws Throwable any exceptions from the class's constructor
|
* @throws Throwable any exceptions from the class's constructor
|
||||||
*/
|
*/
|
||||||
public static Applet createAppletClass(String appletClassName) throws Throwable
|
public static Applet createAppletClass(String appletClassName) throws Throwable {
|
||||||
{
|
|
||||||
Class<?> appletClass = ClassLoader.getSystemClassLoader().loadClass(appletClassName);
|
Class<?> appletClass = ClassLoader.getSystemClassLoader().loadClass(appletClassName);
|
||||||
|
|
||||||
MethodHandle appletConstructor = MethodHandles.lookup().findConstructor(appletClass,
|
MethodHandle appletConstructor = MethodHandles.lookup().findConstructor(appletClass,
|
||||||
@ -83,8 +83,7 @@ public final class ReflectionUtils {
|
|||||||
*
|
*
|
||||||
* @return The found field.
|
* @return The found field.
|
||||||
*/
|
*/
|
||||||
public static Field getMinecraftGameDirField(Class<?> minecraftMainClass)
|
public static Field getMinecraftGameDirField(Class<?> minecraftMainClass) {
|
||||||
{
|
|
||||||
LOGGER.fine("Resolving minecraft game directory field");
|
LOGGER.fine("Resolving minecraft game directory field");
|
||||||
// Field we're looking for is always
|
// Field we're looking for is always
|
||||||
// private static File obfuscatedName = null;
|
// private static File obfuscatedName = null;
|
||||||
@ -141,8 +140,7 @@ public final class ReflectionUtils {
|
|||||||
* @throws IllegalAccessException If method handles cannot access the entrypoint
|
* @throws IllegalAccessException If method handles cannot access the entrypoint
|
||||||
*/
|
*/
|
||||||
public static MethodHandle findMainEntrypoint(Class<?> entrypointClass)
|
public static MethodHandle findMainEntrypoint(Class<?> entrypointClass)
|
||||||
throws NoSuchMethodException, IllegalAccessException
|
throws NoSuchMethodException, IllegalAccessException {
|
||||||
{
|
|
||||||
return MethodHandles.lookup().findStatic(entrypointClass, "main",
|
return MethodHandles.lookup().findStatic(entrypointClass, "main",
|
||||||
MethodType.methodType(void.class, String[].class));
|
MethodType.methodType(void.class, String[].class));
|
||||||
}
|
}
|
||||||
@ -168,7 +166,8 @@ public final class ReflectionUtils {
|
|||||||
* @throws IllegalAccessException If method handles cannot access the entrypoint
|
* @throws IllegalAccessException If method handles cannot access the entrypoint
|
||||||
*/
|
*/
|
||||||
public static MethodHandle findMainMethod(String entrypointClassName)
|
public static MethodHandle findMainMethod(String entrypointClassName)
|
||||||
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException
|
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException {
|
||||||
{ return findMainEntrypoint(ClassLoader.getSystemClassLoader().loadClass(entrypointClassName)); }
|
return findMainEntrypoint(ClassLoader.getSystemClassLoader().loadClass(entrypointClassName));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ package org.prismlauncher.utils;
|
|||||||
|
|
||||||
public final class StringUtils {
|
public final class StringUtils {
|
||||||
|
|
||||||
private StringUtils() {}
|
private StringUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
public static String[] splitStringPair(char splitChar, String input)
|
public static String[] splitStringPair(char splitChar, String input) {
|
||||||
{
|
|
||||||
int splitPoint = input.indexOf(splitChar);
|
int splitPoint = input.indexOf(splitChar);
|
||||||
if (splitPoint == -1)
|
if (splitPoint == -1)
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user