Skip to content

Commit

Permalink
Merge pull request #8 from r3back/feature/nms-remapped-versions-unifi…
Browse files Browse the repository at this point in the history
…cation

Added particle lib for 1.21
  • Loading branch information
r3back authored Oct 20, 2024
2 parents 5c4fbe7 + 7e4b196 commit a8eb5a3
Show file tree
Hide file tree
Showing 22 changed files with 1,397 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ build
*/*/*/build
*/*/*/*/build
/all-generated
/test-suite/mc-config/plugins/*
/test-suite/mc-config/plugins/*
.runJitpackPublication/*
.run/*/*
7 changes: 5 additions & 2 deletions addons/mmo-items/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ repositories{
maven("https://mvn.lumine.io/repository/maven-public/") {
name = "Lumine"
}
maven("https://nexus.phoenixdevt.fr/repository/maven-public/") {
name = "MMO Items"
}
}

dependencies {
Expand All @@ -10,6 +13,6 @@ dependencies {
compileOnly(project(":api"))
compileOnly(project(":addons:addons-commons"))

compileOnly("net.Indyuce:MMOItems:6.7.1-SNAPSHOT")
compileOnly("io.lumine:MythicLib-dist:1.4")
compileOnly("net.Indyuce:MMOItems-API:6.9.5-SNAPSHOT")
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
}
5 changes: 1 addition & 4 deletions addons/placeholders/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
repositories {
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") {
name = "PlaceholderAPI"
}
maven("https://nexus.lucko.me/repository/all/") {
name = "Lucko"
}
Expand All @@ -17,5 +14,5 @@ dependencies {
compileOnly("be.maximvdw:MVdWPlaceholderAPI:3.0.1-SNAPSHOT") {
exclude(group = "org.spigotmc")
}
compileOnly("me.clip:placeholderapi:2.11.3")
compileOnly("me.clip:placeholderapi:2.11.6")
}
2 changes: 1 addition & 1 deletion addons/regions/ultra-regions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repositories {

dependencies {
compileOnly("org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT")
compileOnly("me.TechsCode:UltraPermissionsAPI:5.5.2")
compileOnly("me.TechsCode:GradleBasePlugin:4.5.0-BETA")

compileOnly(project(":addons:regions:regions-commons"))
compileOnly(project(":addons:addons-commons"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public TabHandler(final TabAdapter adapter, final JavaPlugin plugin, final long
this.adapter = adapter;
this.ticks = ticks;

new TabRunnable(this).runTaskTimer(plugin, 20L, ticks);
new TabRunnable(this).runTaskTimerAsynchronously(plugin, 20L, ticks);
}

/**
Expand Down Expand Up @@ -64,9 +64,9 @@ public TabHandler(final TabElementHandler handler, final JavaPlugin plugin, fina
private TabAdapter createAdapter() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
final String serverPackage = Bukkit.getServer().getClass().getPackage().getName();
final String nmsVersion = serverPackage.replace(".", ",").split(",")[3].substring(1);
final String disguisePackage = "io.github.nosequel.tab.v" + nmsVersion.toLowerCase() + ".v" + nmsVersion;
final String disguisePackage = "com.qualityplus.assistant.base.nms.v" + nmsVersion;

return (TabAdapter) Class.forName(disguisePackage + "TabAdapter").newInstance();
return (TabAdapter) Class.forName(disguisePackage + "_Tab").newInstance();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.qualityplus.assistant.api.util;

import lombok.experimental.UtilityClass;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;

/**
* Reflection utility class
*/
@UtilityClass
public final class ReflectionUtil {
private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();

/**
* Get Setter
*
* @param clazz clazz type
* @param name name
* @return {@link MethodHandle}
*/
public static MethodHandle getSetter(final Class<?> clazz, final String name) {
try {
return LOOKUP.unreflectSetter(getField(clazz, name));
} catch (final IllegalAccessException e) {
e.printStackTrace();
}
return null;
}

/**
* Get field
*
* @param clazz clazz type
* @param fieldName field name
* @return {@link Field}
*/
public static Field getField(final Class<?> clazz, final String fieldName) {
if (clazz == null) {
return null;
}
try {
final Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return field;
} catch (final NoSuchFieldException | SecurityException e) {
e.printStackTrace();
return null;
}
}
}
12 changes: 9 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
group = "com.github.r3back"
version = "3.2.12"

ext.set("mojangUnmappedVersions", setOf("v1_20_R2", "v1_20_R1", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_18_R1", "v1_18_R2", "v1_17_R1"))
ext.set("mojangUnmappedVersions", setOf("v1_20_R3","v1_20_R2", "v1_20_R1", "v1_19_R1", "v1_19_R2", "v1_18_R1", "v1_18_R2", "v1_17_R1"))

subprojects {
group = rootProject.group
Expand Down Expand Up @@ -55,6 +55,12 @@ subprojects {
maven("https://repo.rapture.pw/repository/maven-releases/") {
name = "Rapture"
}
maven("https://nexus.lucko.me/repository/all/") {
name = "Lucko"
}
maven("https://repo.georgev22.com/releases") {
name = "georgev22RepoReleases"
}
}

dependencies {
Expand All @@ -67,8 +73,8 @@ subprojects {


tasks.withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
sourceCompatibility = "8"
targetCompatibility = "8"
}

val projectSourceSets = sourceSets
Expand Down
1 change: 1 addition & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<suppressions>
<suppress files="[\\/]test[\\/]" checks="JavadocPackage"/>
<suppress files="CustomErrorDecoder.java" checks="IllegalCatch"/>
<suppress files="EmptyConnection.java" checks="IllegalCatch"/>
<suppress files="SkinType.java" checks="LineLength"/>
<suppress files="SkinType.java" checks="Indentation"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.qualityplus.assistant.api.util.FakeInventoryFactory;
import eu.okaeri.injector.annotation.Inject;
import lombok.Getter;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.core.BlockPos;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.PacketFlow;
Expand Down Expand Up @@ -259,4 +261,9 @@ public void sendParticles(final World world, final String type, final float x,
player.spawnParticle(particle, x, y, z, amount, offsetX, offsetY, offsetZ, data);
}
}

@Override
public void sendActionBar(final Player player, final String message) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.qualityplus.assistant.api.util.FakeInventoryFactory;
import eu.okaeri.injector.annotation.Inject;
import lombok.Getter;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.core.BlockPos;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.PacketFlow;
Expand Down Expand Up @@ -259,4 +261,10 @@ public void sendParticles(final World world, final String type, final float x,
player.spawnParticle(particle, x, y, z, amount, offsetX, offsetY, offsetZ, data);
}
}


@Override
public void sendActionBar(final Player player, final String message) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public TabAdapter showRealPlayers(final Player player) {

networkField.setAccessible(true);

final Connection manager = (Connection) unsafe.getObject(connection, unsafe.objectFieldOffset(networkField));
final Connection manager = (Connection) networkField.get(connection);

final ChannelPipeline pipeline = manager.channel.pipeline();

Expand All @@ -318,7 +318,7 @@ public TabAdapter showRealPlayers(final Player player) {

pipeline.addBefore("packet_handler", player.getName(), this.createShowListener(player));
} catch (NoSuchFieldException | NoSuchElementException | IllegalArgumentException | NullPointerException
| SecurityException e) {
| SecurityException | IllegalAccessException e) {
e.printStackTrace();
}

Expand Down
22 changes: 22 additions & 0 deletions nms/v1_20_R3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
tasks {
remap {
version.set("1.20.4")
}
}

dependencies {
//Required for GameProfile
compileOnly("com.mojang:authlib:1.5.25")
compileOnly("com.mojang:brigadier:1.0.18")
compileOnly("io.netty:netty-all:4.1.90.Final")
compileOnly("com.mojang:datafixerupper:1.0.20")

compileOnly("org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:remapped-mojang@jar") {
isTransitive = false
}
compileOnly("org.spigotmc:spigot-api:1.20.4-experimental-SNAPSHOT") {
isTransitive = false
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package com.qualityplus.assistant.base.nms;

import io.netty.channel.AbstractChannel;
import io.netty.channel.Channel;
import io.netty.channel.ChannelConfig;
import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelOutboundBuffer;
import io.netty.channel.DefaultChannelConfig;
import io.netty.channel.EventLoop;

import java.net.SocketAddress;

/**
* Empty channel class
*/
public final class EmptyChannel extends AbstractChannel {
private final ChannelConfig config = new DefaultChannelConfig(this);

/**
*
* @param parent {@link Channel}
*/
public EmptyChannel(final Channel parent) {
super(parent);
}

/**
*
* @return {@link ChannelConfig}
*/
@Override
public ChannelConfig config() {
this.config.setAutoRead(true);
return this.config;
}

/**
*
* @throws Exception thrown exception
*/
@Override
protected void doBeginRead() throws Exception {
}

/**
*
* @param arg0 {@link SocketAddress}
* @throws Exception thrown exception
*/
@Override
protected void doBind(final SocketAddress arg0) throws Exception {
}

/**
*
* @throws Exception thrown exception
*/
@Override
protected void doClose() throws Exception {
}

/**
*
* @throws Exception thrown exception
*/
@Override
protected void doDisconnect() throws Exception {
}

/**
*
* @param arg0 {@link ChannelOutboundBuffer}
* @throws Exception thrown exception
*/
@Override
protected void doWrite(final ChannelOutboundBuffer arg0) throws Exception {
}

/**
*
* @return if it's active
*/
@Override
public boolean isActive() {
return false;
}

/**
*
* @param arg0 {@link EventLoop}
* @return t
*/
@Override
protected boolean isCompatible(final EventLoop arg0) {
return false;
}

/**
*
* @return if it's open
*/
@Override
public boolean isOpen() {
return false;
}

/**
*
* @return {@link SocketAddress}
*/
@Override
protected SocketAddress localAddress0() {
return null;
}

/**
*
* @return {@link ChannelMetadata}
*/
@Override
public ChannelMetadata metadata() {
return new ChannelMetadata(true);
}

/**
*
* @return {@link AbstractUnsafe}
*/
@Override
protected AbstractUnsafe newUnsafe() {
return null;
}

/**
*
* @return {@link SocketAddress}
*/
@Override
protected SocketAddress remoteAddress0() {
return null;
}
}
Loading

0 comments on commit a8eb5a3

Please sign in to comment.