Skip to content

Commit ca4dc4b

Browse files
Merge pull request #25 from TechnicallyCoded/dev
Merge Dev For 0.4.3
2 parents c720ba1 + 9e602d3 commit ca4dc4b

16 files changed

Lines changed: 939 additions & 143 deletions

File tree

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,4 @@ bin/
4343

4444
# Custom
4545
/.idea/
46-
/gradle/
47-
gradlew
48-
gradlew.bat
4946
/target/

build.gradle

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
buildscript {
2-
ext {
3-
revision = '0.2.4'
4-
}
1+
plugins {
2+
id 'maven-publish'
53
}
64

5+
group 'com.tcoded'
6+
77
allprojects {
88
apply plugin: 'java'
99

10-
version = '0.3.4'
10+
version = '0.4.3'
1111

1212
repositories {
1313

@@ -47,16 +47,15 @@ allprojects {
4747
}
4848
}
4949

50-
group 'com.tcoded'
51-
52-
def baseName
50+
tasks.assemble {
51+
dependsOn clean
52+
}
5353

54-
subprojects.each { subproject -> evaluationDependsOn(subproject.path)}
54+
subprojects.each { subproject -> evaluationDependsOn(subproject.path) }
5555
tasks.register('allJar', Jar) {
5656
dependsOn 'compileJava'
5757
dependsOn 'jar'
5858
dependsOn subprojects.tasks['build']
59-
baseName = 'allJar'
6059
subprojects.each { subproject ->
6160
from subproject.configurations.archives.allArtifacts.files.collect {
6261
zipTree(it)
@@ -66,4 +65,16 @@ tasks.register('allJar', Jar) {
6665

6766
artifacts {
6867
archives allJar
68+
}
69+
70+
publishing {
71+
publications {
72+
mavenJava(MavenPublication) {
73+
from components.java
74+
}
75+
}
76+
}
77+
78+
generateMetadataFileForMavenJavaPublication {
79+
dependsOn allJar
6980
}

common/src/main/java/com/tcoded/folialib/FoliaLib.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.tcoded.folialib;
22

33
import com.tcoded.folialib.enums.ImplementationType;
4-
import com.tcoded.folialib.impl.ServerImplementation;
4+
import com.tcoded.folialib.impl.PlatformScheduler;
55
import com.tcoded.folialib.util.InvalidTickDelayNotifier;
66
import org.bukkit.plugin.java.JavaPlugin;
77

@@ -13,7 +13,7 @@ public class FoliaLib {
1313
private final JavaPlugin plugin;
1414

1515
private final ImplementationType implementationType;
16-
private final ServerImplementation implementation;
16+
private final PlatformScheduler scheduler;
1717

1818
public FoliaLib(JavaPlugin plugin) {
1919
this.plugin = plugin;
@@ -31,10 +31,10 @@ public FoliaLib(JavaPlugin plugin) {
3131

3232
// Apply the implementation based on the type
3333
this.implementationType = foundType;
34-
this.implementation = this.createServerImpl(this.implementationType.getImplementationClassName());
34+
this.scheduler = this.createServerImpl(this.implementationType.getImplementationClassName());
3535

3636
// Check for valid implementation
37-
if (this.implementation == null) {
37+
if (this.scheduler == null) {
3838
throw new IllegalStateException(
3939
"Failed to create server implementation. Please report this to the FoliaLib GitHub issues page. " +
4040
"Forks of server software may not all be supported. If you are using an unofficial fork, " +
@@ -62,9 +62,17 @@ public ImplementationType getImplType() {
6262
return implementationType;
6363
}
6464

65+
/**
66+
* @deprecated Use {@link #getImplType()} instead. (forRemoval = true, since = "0.3.5")
67+
*/
68+
@Deprecated
6569
@SuppressWarnings("unused")
66-
public ServerImplementation getImpl() {
67-
return implementation;
70+
public PlatformScheduler getImpl() {
71+
return getScheduler();
72+
}
73+
74+
public PlatformScheduler getScheduler() {
75+
return scheduler;
6876
}
6977

7078
@SuppressWarnings("unused")
@@ -105,11 +113,11 @@ public void enableInvalidTickValueDebug() {
105113

106114
// Internal Utils
107115

108-
private ServerImplementation createServerImpl(String implName) {
116+
private PlatformScheduler createServerImpl(String implName) {
109117
String basePackage = this.getClass().getPackage().getName() + ".impl.";
110118

111119
try {
112-
return (ServerImplementation) Class.forName(basePackage + implName)
120+
return (PlatformScheduler) Class.forName(basePackage + implName)
113121
.getConstructor(this.getClass())
114122
.newInstance(this);
115123
} catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException |

common/src/main/java/com/tcoded/folialib/enums/ImplementationType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.tcoded.folialib.enums;
22

3-
import com.tcoded.folialib.impl.ServerImplementation;
3+
import com.tcoded.folialib.impl.PlatformScheduler;
44
import com.tcoded.folialib.util.ImplementationTestsUtil;
55

66
import java.util.function.Consumer;
@@ -13,7 +13,7 @@
1313
* <p>
1414
* A server is considered 'legacy' if it does not support task consumers. This feature was added in 1.13.2.
1515
* This means that even 1.13.1 servers are considered legacy servers as they do not support highly important
16-
* features that developers may want to use. Refer to {@link ServerImplementation#runLater(Consumer, long)}
16+
* features that developers may want to use. Refer to {@link PlatformScheduler#runLater(Consumer, long)}
1717
* for more information on the behavior of task consumer-enabled methods on servers which do not support this feature.
1818
*/
1919
@SuppressWarnings("SpellCheckingInspection")

common/src/main/java/com/tcoded/folialib/util/ImplementationTestsUtil.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.tcoded.folialib.util;
22

3+
import org.bukkit.Location;
4+
import org.bukkit.entity.Entity;
5+
import org.bukkit.event.player.PlayerTeleportEvent;
36
import org.bukkit.plugin.Plugin;
47
import org.bukkit.scheduler.BukkitScheduler;
58
import org.bukkit.scheduler.BukkitTask;
@@ -10,6 +13,7 @@ public class ImplementationTestsUtil {
1013

1114
private static final boolean IS_CANCELLED_SUPPORTED;
1215
private static final boolean IS_TASK_CONSUMERS_SUPPORTED;
16+
private static final boolean IS_ASYNC_TELEPORT_SUPPORTED;
1317

1418

1519
static {
@@ -36,6 +40,19 @@ public class ImplementationTestsUtil {
3640
}
3741
// Set class-wide
3842
IS_TASK_CONSUMERS_SUPPORTED = taskConsumersSupported;
43+
44+
45+
boolean isAsyncTeleportSupported = false;
46+
try {
47+
Class<Entity> entityClass = Entity.class;
48+
// noinspection JavaReflectionMemberAccess
49+
entityClass.getDeclaredMethod("teleportAsync", Location.class, PlayerTeleportEvent.TeleportCause.class);
50+
isAsyncTeleportSupported = true;
51+
} catch (NoSuchMethodException e) {
52+
// ignore
53+
}
54+
// Set class-wide
55+
IS_ASYNC_TELEPORT_SUPPORTED = isAsyncTeleportSupported;
3956
}
4057

4158
public static boolean isCancelledSupported() {
@@ -46,4 +63,8 @@ public static boolean isTaskConsumersSupported() {
4663
return IS_TASK_CONSUMERS_SUPPORTED;
4764
}
4865

66+
public static boolean isAsyncTeleportSupported() {
67+
return IS_ASYNC_TELEPORT_SUPPORTED;
68+
}
69+
4970
}

gradle/wrapper/gradle-wrapper.jar

60.2 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)