Skip to content

Commit

Permalink
Merge branch 'main' into 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerS1066 committed Jun 23, 2024
2 parents 941a397 + 2e3d59c commit c74444e
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: ./gradlew clean shadowJar --parallel

- name: Stage jar
run: mkdir staging && cp Movecraft/build/libs/Movecraft.jar staging && mv staging/Movecraft.jar staging/Movecraft_$GITHUB_SHA.jar
run: mkdir staging && cp Movecraft/build/libs/Movecraft-all.jar staging && mv staging/Movecraft-all.jar staging/Movecraft_$GITHUB_SHA.jar
- name: Upload jar
uses: actions/upload-artifact@v4
with:
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ jobs:
# Build Movecraft
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout Movecraft
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Cache Maven packages
uses: actions/cache@v3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2
restore-keys: ${{ runner.os }}-m2
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"

- name: Build with Maven
run: mvn -T 1C -B package --file pom.xml

- name: Publish package
run: mvn --batch-mode deploy
- name: Build and publish package with Gradle
run: ./gradlew clean shadowJar publish --parallel
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 24 additions & 1 deletion Movecraft/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("buildlogic.java-conventions")
id("io.github.goooler.shadow") version "8.1.7"
`maven-publish`
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
Expand All @@ -15,7 +16,7 @@ dependencies {

tasks.shadowJar {
archiveBaseName.set("Movecraft")
archiveClassifier.set("")
archiveClassifier.set("all")
archiveVersion.set("")

dependencies {
Expand All @@ -35,4 +36,26 @@ tasks.processResources {
}
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "net.countercraft"
artifactId = "movecraft"
version = "${project.version}"

artifact(tasks["shadowJar"])
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/apdevteam/movecraft")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

description = "Movecraft"
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,21 @@

@Deprecated
public class AsyncManager extends BukkitRunnable {
//private static AsyncManager instance = new AsyncManager();
private final HashMap<AsyncTask, Craft> ownershipMap = new HashMap<>();
private final HashMap<Craft, HashMap<Craft, Long>> recentContactTracking = new HashMap<>();
private final Map<AsyncTask, Craft> ownershipMap = new HashMap<>();
private final Map<Craft, Map<Craft, Long>> recentContactTracking = new WeakHashMap<>();
private final BlockingQueue<AsyncTask> finishedAlgorithms = new LinkedBlockingQueue<>();
private final HashSet<Craft> clearanceSet = new HashSet<>();
private final HashMap<HitBox, Long> wrecks = new HashMap<>();
private final HashMap<HitBox, World> wreckWorlds = new HashMap<>();
private final HashMap<HitBox, Map<Location, BlockData>> wreckPhases = new HashMap<>();
private final WeakHashMap<World, Set<MovecraftLocation>> processedFadeLocs = new WeakHashMap<>();
private final Set<Craft> clearanceSet = new HashSet<>();
private final Map<HitBox, Long> wrecks = new WeakHashMap<>();
private final Map<HitBox, World> wreckWorlds = new WeakHashMap<>();
private final Map<HitBox, Map<Location, BlockData>> wreckPhases = new WeakHashMap<>();
private final Map<World, Set<MovecraftLocation>> processedFadeLocs = new WeakHashMap<>();
private final Map<Craft, Integer> cooldownCache = new WeakHashMap<>();

private long lastFadeCheck = 0;
private long lastContactCheck = 0;

public AsyncManager() {}

/* public static AsyncManager getInstance() {
return instance;
}*/

public void submitTask(AsyncTask task, Craft c) {
if (c.isNotProcessing()) {
c.setProcessing(true);
Expand Down Expand Up @@ -445,100 +440,100 @@ private void processFadingBlocks() {

private void processDetection() {
long ticksElapsed = (System.currentTimeMillis() - lastContactCheck) / 50;
if (ticksElapsed > 21) {
for (World w : Bukkit.getWorlds()) {
if (w == null)
continue;
if (ticksElapsed < 20)
return;
lastContactCheck = System.currentTimeMillis();

for (World w : Bukkit.getWorlds()) {
if (w == null)
continue;

for (Craft craft : CraftManager.getInstance().getPlayerCraftsInWorld(w)) {
MovecraftLocation craftCenter;
for (Craft craft : CraftManager.getInstance().getPlayerCraftsInWorld(w)) {
MovecraftLocation craftCenter;
try {
craftCenter = craft.getHitBox().getMidPoint();
}
catch (EmptyHitBoxException e) {
continue;
}
if (!recentContactTracking.containsKey(craft))
recentContactTracking.put(craft, new WeakHashMap<>());
for (Craft target : craft.getContacts()) {
MovecraftLocation targetCenter;
try {
craftCenter = craft.getHitBox().getMidPoint();
targetCenter = target.getHitBox().getMidPoint();
}
catch (EmptyHitBoxException e) {
continue;
}
if (!recentContactTracking.containsKey(craft))
recentContactTracking.put(craft, new HashMap<>());
for (Craft target : craft.getContacts()) {
MovecraftLocation targetCenter;
try {
targetCenter = target.getHitBox().getMidPoint();
}
catch (EmptyHitBoxException e) {
continue;
}
int diffx = craftCenter.getX() - targetCenter.getX();
int diffz = craftCenter.getZ() - targetCenter.getZ();
int distsquared = craftCenter.distanceSquared(targetCenter);
// craft has been detected

// has the craft not been seen in the last
// minute, or is completely new?
if (System.currentTimeMillis()
- recentContactTracking.get(craft).getOrDefault(target, 0L) <= 60000)
continue;


Component notification = I18nSupport.getInternationalisedComponent(
"Contact - New Contact").append(Component.text( ": "));

if (target.getName().length() >= 1)
notification = notification.append(Component.text(target.getName() + " ("));
int diffx = craftCenter.getX() - targetCenter.getX();
int diffz = craftCenter.getZ() - targetCenter.getZ();
int distsquared = craftCenter.distanceSquared(targetCenter);
// craft has been detected

// has the craft not been seen in the last
// minute, or is completely new?
if (System.currentTimeMillis()
- recentContactTracking.get(craft).getOrDefault(target, 0L) <= 60000)
continue;


Component notification = I18nSupport.getInternationalisedComponent(
"Contact - New Contact").append(Component.text( ": "));

if (target.getName().length() >= 1)
notification = notification.append(Component.text(target.getName() + " ("));
notification = notification.append(Component.text(
target.getType().getStringProperty(CraftType.NAME)));
if (target.getName().length() >= 1)
notification = notification.append(Component.text(")"));
notification = notification.append(Component.text(" "))
.append(I18nSupport.getInternationalisedComponent("Contact - Commanded By"))
.append(Component.text(" "));
if (target instanceof PilotedCraft)
notification = notification.append(Component.text(
target.getType().getStringProperty(CraftType.NAME)));
if (target.getName().length() >= 1)
notification = notification.append(Component.text(")"));
notification = notification.append(Component.text(" "))
.append(I18nSupport.getInternationalisedComponent("Contact - Commanded By"))
.append(Component.text(" "));
if (target instanceof PilotedCraft)
notification = notification.append(Component.text(
((PilotedCraft) target).getPilot().getDisplayName()));
else
notification = notification.append(Component.text("NULL"));
notification = notification.append(Component.text(", "))
.append(I18nSupport.getInternationalisedComponent("Contact - Size"))
.append(Component.text( ": "))
.append(Component.text(target.getOrigBlockCount()))
.append(Component.text(", "))
.append(I18nSupport.getInternationalisedComponent("Contact - Range"))
.append(Component.text(": "))
.append(Component.text((int) Math.sqrt(distsquared)))
.append(Component.text(" "))
.append(I18nSupport.getInternationalisedComponent("Contact - To The"))
.append(Component.text(" "));
if (Math.abs(diffx) > Math.abs(diffz)) {
if (diffx < 0)
notification = notification.append(I18nSupport.getInternationalisedComponent(
"Contact/Subcraft Rotate - East"));
else
notification = notification.append(I18nSupport.getInternationalisedComponent(
"Contact/Subcraft Rotate - West"));
}
else if (diffz < 0)
((PilotedCraft) target).getPilot().getDisplayName()));
else
notification = notification.append(Component.text("NULL"));
notification = notification.append(Component.text(", "))
.append(I18nSupport.getInternationalisedComponent("Contact - Size"))
.append(Component.text( ": "))
.append(Component.text(target.getOrigBlockCount()))
.append(Component.text(", "))
.append(I18nSupport.getInternationalisedComponent("Contact - Range"))
.append(Component.text(": "))
.append(Component.text((int) Math.sqrt(distsquared)))
.append(Component.text(" "))
.append(I18nSupport.getInternationalisedComponent("Contact - To The"))
.append(Component.text(" "));
if (Math.abs(diffx) > Math.abs(diffz)) {
if (diffx < 0)
notification = notification.append(I18nSupport.getInternationalisedComponent(
"Contact/Subcraft Rotate - South"));
"Contact/Subcraft Rotate - East"));
else
notification = notification.append(I18nSupport.getInternationalisedComponent(
"Contact/Subcraft Rotate - North"));
"Contact/Subcraft Rotate - West"));
}
else if (diffz < 0)
notification = notification.append(I18nSupport.getInternationalisedComponent(
"Contact/Subcraft Rotate - South"));
else
notification = notification.append(I18nSupport.getInternationalisedComponent(
"Contact/Subcraft Rotate - North"));

notification = notification.append(Component.text("."));
notification = notification.append(Component.text("."));

craft.getAudience().sendMessage(notification);
var object = craft.getType().getObjectProperty(CraftType.COLLISION_SOUND);
if (!(object instanceof Sound))
throw new IllegalStateException("COLLISION_SOUND must be of type Sound");
craft.getAudience().sendMessage(notification);
var object = craft.getType().getObjectProperty(CraftType.COLLISION_SOUND);
if (!(object instanceof Sound))
throw new IllegalStateException("COLLISION_SOUND must be of type Sound");

craft.getAudience().playSound((Sound) object);
craft.getAudience().playSound((Sound) object);

long timestamp = System.currentTimeMillis();
recentContactTracking.get(craft).put(target, timestamp);
}
long timestamp = System.currentTimeMillis();
recentContactTracking.get(craft).put(target, timestamp);
}
}

lastContactCheck = System.currentTimeMillis();
}
}

Expand All @@ -551,9 +546,6 @@ public void run() {
processFadingBlocks();
processDetection();
processAlgorithmQueue();
//processScheduledBlockChanges();
// if(Settings.CompatibilityMode==false)
// FastBlockChanger.getInstance().run();

// now cleanup craft that are bugged and have not moved in the past 60 seconds,
// but have no pilot or are still processing
Expand Down
40 changes: 5 additions & 35 deletions buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,47 +1,17 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
`java-library`
`maven-publish`
}

repositories {
mavenLocal()
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}

maven {
url = uri("https://maven.pkg.github.com/APDevTeam/Movecraft")
}

maven {
url = uri("https://hub.spigotmc.org/nexus/content/groups/public/")
}

maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}

maven {
url = uri("https://repo.dmulloy2.net/nexus/repository/public/")
}

maven {
url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven("https://repo.maven.apache.org/maven2/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://repo.dmulloy2.net/nexus/repository/public/")
maven("https://repo.papermc.io/repository/maven-public/")
}

group = "net.countercraft"
version = "8.0.0_beta-3"

publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
}
}
version = "8.0.0_beta-3_gradle"

tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
Expand Down

0 comments on commit c74444e

Please sign in to comment.