Add versionDependantCall, See #144 BauSystem
Dieser Commit ist enthalten in:
Ursprung
dc92ce6fda
Commit
8468d9a13e
@ -28,6 +28,10 @@ import de.steamwar.sql.SQL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class Core extends JavaPlugin{
|
||||
private static Core instance;
|
||||
@ -82,4 +86,69 @@ public class Core extends JavaPlugin{
|
||||
private static void setInstance(Core instance) {
|
||||
Core.instance = instance;
|
||||
}
|
||||
|
||||
public static void versionDependantCall(Runnable v12, Runnable v15) {
|
||||
switch (getVersion()) {
|
||||
case 12:
|
||||
v12.run();
|
||||
break;
|
||||
case 15:
|
||||
default:
|
||||
v15.run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T versionDependantCall(ExceptionlessCallable<T> v12, ExceptionlessCallable<T> v15) {
|
||||
switch (getVersion()) {
|
||||
case 12:
|
||||
return v12.call();
|
||||
case 15:
|
||||
default:
|
||||
return v15.call();
|
||||
}
|
||||
}
|
||||
|
||||
public static void versionDependantCall(Runnable v8, Runnable v9, Runnable v10, Runnable v12, Runnable v14, Runnable v15) {
|
||||
switch (Core.getVersion()) {
|
||||
case 8:
|
||||
v8.run();
|
||||
break;
|
||||
case 9:
|
||||
v9.run();
|
||||
break;
|
||||
case 10:
|
||||
v10.run();
|
||||
break;
|
||||
case 12:
|
||||
v12.run();
|
||||
break;
|
||||
case 14:
|
||||
v14.run();
|
||||
break;
|
||||
case 15:
|
||||
default:
|
||||
v15.run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T versionDependantCall(ExceptionlessCallable<T> v8, ExceptionlessCallable<T> v9, ExceptionlessCallable<T> v10, ExceptionlessCallable<T> v12, ExceptionlessCallable<T> v14, ExceptionlessCallable<T> v15) {
|
||||
switch (Core.getVersion()) {
|
||||
case 8:
|
||||
return v8.call();
|
||||
case 9:
|
||||
return v9.call();
|
||||
case 10:
|
||||
return v10.call();
|
||||
case 12:
|
||||
return v12.call();
|
||||
case 14:
|
||||
return v14.call();
|
||||
case 15:
|
||||
default:
|
||||
return v15.call();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
6
SpigotCore_Main/src/de/steamwar/core/ExceptionlessCallable.java
Normale Datei
6
SpigotCore_Main/src/de/steamwar/core/ExceptionlessCallable.java
Normale Datei
@ -0,0 +1,6 @@
|
||||
package de.steamwar.core;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ExceptionlessCallable<T> {
|
||||
T call();
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren