Skip to content

Commit

Permalink
Update for 1.21, drop Spigot and legacy support
Browse files Browse the repository at this point in the history
  • Loading branch information
froobynooby committed Jul 21, 2024
1 parent 186e817 commit addf46f
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 590 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
with:
repository: froobynooby/nab-configuration

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 21
distribution: 'temurin'

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

Expand All @@ -31,7 +37,7 @@ jobs:
uses: gradle/wrapper-validation-action@v1

- name: Build ViewDistanceTweaks
run: ./gradlew build
run: ./gradlew shadowJar

- name: Archive ViewDistanceTweaks
uses: actions/upload-artifact@v2
Expand Down
55 changes: 0 additions & 55 deletions build.gradle

This file was deleted.

41 changes: 41 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
`java-library`
id("io.papermc.paperweight.userdev") version "1.7.1"
id("io.github.goooler.shadow") version "8.1.7"
}

group = "com.froobworld"
version = "1.5.7"

java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
}

repositories {
mavenLocal()
mavenCentral()
maven(url = "https://repo.extendedclip.com/content/repositories/placeholderapi/")
}

dependencies {
paperweight.paperDevBundle("1.21-R0.1-SNAPSHOT")
compileOnly("me.clip", "placeholderapi", "2.11.6")
implementation("org.jooq", "joor-java-8", "0.9.14")
implementation("com.froobworld", "nab-configuration", "1.0.2")
implementation("org.bstats", "bstats-bukkit", "3.0.0")
}

tasks {
compileJava {
options.release = 21
}
javadoc {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
}

shadowJar {
relocate("com.froobworld.nabconfiguration", "com.froobworld.viewdistancetweaks.lib.nabconfiguration")
relocate("org.joor", "com.froobworld.viewdistancetweaks.lib.joor")
relocate("org.bstats", "com.froobworld.viewdistancetweaks.lib.bstats")
}
}
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-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public ChunkCounter getActualNoTickChunkCounter() {
public void init() {
simulationDistanceHook = PreferenceChooser
.bestChoice(PaperSimulationDistanceHook::new, PaperSimulationDistanceHook::isCompatible)
.nextBestChoice(LegacyPaperSimulationDistanceHook::new, LegacyPaperSimulationDistanceHook::isCompatible)
.nextBestChoice(SpigotSimulationDistanceHook::new, SpigotSimulationDistanceHook::isCompatible)
.get();
if (simulationDistanceHook == null) {
throw new IllegalStateException("No simulation distance hook is available. Incompatible version?");
Expand All @@ -65,8 +63,6 @@ public void init() {

viewDistanceHook = PreferenceChooser
.bestChoice(PaperViewDistanceHook::new, PaperViewDistanceHook::isCompatible)
.nextBestChoice(LegacyPaperViewDistanceHook::new, LegacyPaperViewDistanceHook::isCompatible)
.nextBestChoice(() -> new SpigotViewDistanceHook(viewDistanceTweaks.getClientViewDistanceManager()), SpigotViewDistanceHook::isCompatible)
.get();
viewDistanceTweaks.getLogger().info(viewDistanceHook != null ?
"Using " + viewDistanceHook.getClass().getSimpleName() + " for the view distance hook." :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import com.froobworld.viewdistancetweaks.command.VdtCommand;
import com.froobworld.viewdistancetweaks.config.VdtConfig;
import com.froobworld.viewdistancetweaks.hook.viewdistance.SpigotSimulationDistanceHook;
import com.froobworld.viewdistancetweaks.limiter.ClientViewDistanceManager;
import com.froobworld.viewdistancetweaks.metrics.VdtMetrics;
import com.froobworld.viewdistancetweaks.placeholder.VdtExpansion;
import com.froobworld.viewdistancetweaks.util.*;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

Expand Down Expand Up @@ -51,9 +49,6 @@ public void onEnable() {
registerCommands();
initMetrics();

if (hookManager.getSimulationDistanceHook().getClass().equals(SpigotSimulationDistanceHook.class)) {
SpigotViewDistanceSyncer.syncSpigotViewDistances();
}
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
if (new VdtExpansion(this).register()) {
getLogger().info("Registered expansion for PlaceholderAPI.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.froobworld.viewdistancetweaks.hook.tick;

import com.froobworld.viewdistancetweaks.ViewDistanceTweaks;
import com.froobworld.viewdistancetweaks.util.NmsUtils;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftServer;

import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;
Expand All @@ -14,25 +13,7 @@
public class SpigotTickHook implements TickHook {
private static final long[] tickTimes;
static {
Class<?> serverClass = null;
try {
serverClass = Class.forName(NmsUtils.getFullyQualifiedClassName("MinecraftServer", "server"));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
if (serverClass == null) {
tickTimes = null;
} else {
String fieldName = null;
for (Field field : serverClass.getFields()) {
if (field.getType().equals(long[].class)) {
fieldName = field.getName();
}
}
tickTimes = on(Bukkit.getServer())
.call("getServer")
.get(fieldName);
}
tickTimes = ((CraftServer) Bukkit.getServer()).getServer().getTickTimesNanos();
}

private final Set<Consumer<Long>> tickConsumers = new HashSet<>();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@

import static org.joor.Reflect.*;

public class PaperSimulationDistanceHook extends SpigotSimulationDistanceHook {
public class PaperSimulationDistanceHook implements SimulationDistanceHook {

@Override
public int getDistance(World world) {
return world.getSimulationDistance();
}

@Override
public void setDistance(World world, int value) {
value = ViewDistanceUtils.clampViewDistance(value);
if (value != getDistance(world)) {
on(world).call("setSimulationDistance", value);
world.setSimulationDistance(value);
}
}

Expand Down

This file was deleted.

Loading

0 comments on commit addf46f

Please sign in to comment.