Skip to content

Commit

Permalink
Add support for VelociTab and fix an NSME error for potions on 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Syrent committed Nov 17, 2023
1 parent 5cb1b8e commit 9f1394e
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 11 deletions.
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ repositories {

// Cloud SNAPSHOT (Dev repository)
maven("https://repo.masmc05.dev/repository/maven-snapshots/")

// Velocitab
maven("https://repo.william278.net/releases")
}

dependencies {
Expand All @@ -100,6 +103,7 @@ dependencies {
compileOnly("com.discordsrv:discordsrv:1.26.2")
compileOnly("com.mojang:authlib:1.11")
compileOnly("io.netty:netty-all:4.1.99.Final")
compileOnly("net.william278:velocitab:1.5.1")

// SayanChat 2.8.1
// ProCosmetics
Expand Down
22 changes: 22 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id 'maven-publish'
}

version = '1.0.0'
group = 'ir.syrent'

repositories {
}

dependencies {
}

def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
it.options.release = 17
}
Empty file added common/gradle.properties
Empty file.
Empty file added common/settings.gradle
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.comphenix.protocol.wrappers.PlayerInfoData
import com.comphenix.protocol.wrappers.WrappedChatComponent
import com.comphenix.protocol.wrappers.WrappedGameProfile
import com.mojang.authlib.GameProfile
import io.papermc.paper.threadedregions.scheduler.EntityScheduler
import ir.syrent.nms.accessors.*
import ir.syrent.velocityvanish.spigot.VelocityVanishSpigot
import ir.syrent.velocityvanish.spigot.event.PostUnVanishEvent
Expand Down Expand Up @@ -136,7 +135,9 @@ class VanishManager(
fun removePotionEffects(player: Player) {
Ruom.runSync({
for (potionEffect in potions) {
if (player.getPotionEffect(potionEffect.type)?.amplifier != potionEffect.amplifier) continue
if (ServerVersion.supports(10)) {
if (player.getPotionEffect(potionEffect.type)?.amplifier != potionEffect.amplifier) continue
}
try {
@Suppress("DEPRECATION") NMSUtils.sendPacket(player, ClientboundRemoveMobEffectPacketAccessor.getConstructor0().newInstance(player.entityId, MobEffectAccessor.getMethodById1().invoke(null, potionEffect.type.id)))
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,13 @@ class PlayerJoinListener(
@EventHandler(priority = EventPriority.LOWEST)
private fun onPlayerJoin(event: PlayerJoinEvent) {
handleVanishOnJoin(event)
Ruom.runSync({
/*Ruom.runSync({
handleVanishOnJoin(event)
}, 15)
}, 15)*/
}

fun handleVanishOnJoin(event: PlayerJoinEvent) {
val oldPlayer = event.player
/*
* Velocity plugin message problem on 1.20.2 (1.20.2 is not yet supported offically)
* https://github.com/PaperMC/Velocity/pull/1088#issuecomment-1744385241
* */
val player = Bukkit.getPlayer(oldPlayer.uniqueId) ?: return
val player = event.player

// Note: DiscordSRV support
player.setMetadata("vanished", FixedMetadataValue(plugin, true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ir.syrent.velocityvanish.velocity.event.VelocityUnVanishEvent
import ir.syrent.velocityvanish.velocity.event.VelocityVanishEvent
import ir.syrent.velocityvanish.velocity.vruom.VRuom
import ir.syrent.velocityvanish.velocity.vruom.utils.GsonUtils
import net.william278.velocitab.api.VelocitabAPI

@Suppress("UnstableApiUsage")
class VelocityBridgeManager(
Expand Down Expand Up @@ -61,9 +62,17 @@ class VelocityBridgeManager(

if (vanished) {
plugin.vanishedPlayers.add(name)
VRuom.getServer().eventManager.fire(VelocityVanishEvent(VRuom.getPlayer(name).orElse(null), name))
val player = VRuom.getPlayer(name).orElse(null)
if (player != null) {
VelocitabAPI.getInstance().vanishPlayer(player)
}
VRuom.getServer().eventManager.fire(VelocityVanishEvent(player, name))
} else {
plugin.vanishedPlayers.remove(name)
val player = VRuom.getPlayer(name).orElse(null)
if (player != null) {
VelocitabAPI.getInstance().unVanishPlayer(player)
}
VRuom.getServer().eventManager.fire(VelocityUnVanishEvent(VRuom.getPlayer(name).orElse(null), name))
}
}
Expand Down

0 comments on commit 9f1394e

Please sign in to comment.