Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add advancement support in prevent section. (Updated settings.yml version) #220

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ repositories {

dependencies {
compileOnly("com.velocitypowered:velocity-api:3.1.1")
compileOnly("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
compileOnly("me.clip:placeholderapi:2.11.3")
compileOnly("xyz.jpenilla:squaremap-api:1.1.15")
Expand Down Expand Up @@ -134,10 +134,6 @@ tasks {
serverJar(file("run/paper-1.20.1-48.jar"))
}

jar {
enabled = false
}

val relocate = task<ConfigureShadowRelocation>("relocateShadowJar") {
target = shadowJar.get()
prefix = "ir.syrent.velocityvanish"
Expand All @@ -148,7 +144,6 @@ tasks {

shadowJar {
dependsOn(relocate)
archiveClassifier.set("")
exclude("META-INF/**")
minimize()
}
Expand Down Expand Up @@ -182,10 +177,10 @@ tasks {
ex.awaitTermination(10, TimeUnit.SECONDS)
}

build {
/*build {
dependsOn(extraDeps)
dependsOn(shadowJar)
}
}*/
}

java {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=3.20.0
version=3.21.0
plugin-name=VelocityVanish
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import com.comphenix.protocol.events.ListenerPriority
import com.comphenix.protocol.events.PacketAdapter
import com.comphenix.protocol.events.PacketEvent
import com.comphenix.protocol.wrappers.WrappedGameProfile
import com.cryptomorin.xseries.ReflectionUtils
import com.google.gson.JsonObject
import com.jeff_media.updatechecker.UpdateCheckSource
import com.jeff_media.updatechecker.UpdateChecker
import io.netty.util.internal.ReflectionUtil
import io.papermc.lib.PaperLib
import ir.syrent.velocityvanish.spigot.command.VanishCommand
import ir.syrent.velocityvanish.spigot.bridge.BukkitBridge
Expand All @@ -28,6 +30,7 @@ import ir.syrent.velocityvanish.spigot.utils.Utils
import ir.syrent.velocityvanish.utils.component
import org.bstats.bukkit.Metrics
import org.bukkit.entity.Player
import su.nightexpress.sunlight.api.event.PlayerTeleportRequestEvent


class VelocityVanishSpigot : RUoMPlugin() {
Expand Down Expand Up @@ -166,7 +169,10 @@ class VelocityVanishSpigot : RUoMPlugin() {
PlayerMentionListener(this)
if (!velocitySupport) PrivateMessageListener(this)
}
if (ServerVersion.supports(12)) TabCompleteListener(this)
if (ServerVersion.supports(12)) {
TabCompleteListener(this)
PlayerAdvancementDoneListener(this)
}
if (ServerVersion.supports(19)) BlockReceiveGameListener(this)
if (DependencyManager.essentialsXHook.exists) {
AfkStatusChangeListener(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package ir.syrent.velocityvanish.spigot.command.library

import cloud.commandframework.ArgumentDescription
import cloud.commandframework.CloudCapability
import cloud.commandframework.Command
import cloud.commandframework.arguments.StaticArgument
import cloud.commandframework.bukkit.BukkitCommandManager
import cloud.commandframework.bukkit.BukkitCommandManager.BrigadierFailureException
import cloud.commandframework.execution.CommandExecutionCoordinator
import cloud.commandframework.meta.CommandMeta
import cloud.commandframework.minecraft.extras.MinecraftExceptionHandler
import cloud.commandframework.minecraft.extras.MinecraftHelp
import cloud.commandframework.paper.PaperCommandManager
Expand All @@ -27,9 +23,9 @@ abstract class Command(

var ERROR_PREFIX = "<dark_gray>[</dark_gray><dark_red><bold>✘</bold></dark_red><dark_gray>]</dark_gray><gradient:dark_red:red>"

lateinit var manager: PaperCommandManager<ISender>
lateinit var builder: Command.Builder<ISender>
lateinit var help: MinecraftHelp<ISender>
var manager: PaperCommandManager<ISender>
var builder: Command.Builder<ISender>
var help: MinecraftHelp<ISender>

init {
val senderMapper = { commandSender: CommandSender -> Sender(commandSender) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class VanishManager(
Ruom.runSync({
for (potionEffect in potions) {
try {
val mobEffect = MobEffectInstanceAccessor.getConstructor0().newInstance(
@Suppress("DEPRECATION") val mobEffect = MobEffectInstanceAccessor.getConstructor0().newInstance(
MobEffectAccessor.getMethodById1().invoke(null, potionEffect.type.id),
Int.MAX_VALUE,
potionEffect.amplifier,
Expand All @@ -131,7 +131,7 @@ class VanishManager(
Ruom.runSync({
for (potionEffect in potions) {
try {
NMSUtils.sendPacket(player, ClientboundRemoveMobEffectPacketAccessor.getConstructor0().newInstance(player.entityId, MobEffectAccessor.getMethodById1().invoke(null, potionEffect.type.id)))
@Suppress("DEPRECATION") NMSUtils.sendPacket(player, ClientboundRemoveMobEffectPacketAccessor.getConstructor0().newInstance(player.entityId, MobEffectAccessor.getMethodById1().invoke(null, potionEffect.type.id)))
} catch (e: Exception) {
player.removePotionEffect(potionEffect.type)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ir.syrent.velocityvanish.spigot.listener

import io.papermc.lib.PaperLib
import ir.syrent.velocityvanish.spigot.VelocityVanishSpigot
import ir.syrent.velocityvanish.spigot.ruom.Ruom
import ir.syrent.velocityvanish.spigot.storage.Settings
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerAdvancementDoneEvent

class PlayerAdvancementDoneListener(
private val plugin: VelocityVanishSpigot
) : Listener {

init {
Ruom.registerListener(this)
}

@EventHandler
private fun onPlayerAdvancementDone(event: PlayerAdvancementDoneEvent) {
if (PaperLib.isPaper() && Settings.preventAdvancement) {
val player = event.player
if (!plugin.vanishedNames.contains(player.name)) return
val advancement = event.advancement
event.message(null)
for (criteria in advancement.criteria) {
player.getAdvancementProgress(advancement).revokeCriteria(criteria)
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import java.time.LocalDate

object Settings {

const val latestSettingsConfigVersion = 6
const val latestSettingsConfigVersion = 7

lateinit var settings: YamlConfig
lateinit var language: YamlConfig
Expand All @@ -44,15 +44,16 @@ object Settings {
var remember = false
var seeAsSpectator = true
var invincible = true
var preventPickup = true
var silentOpenContainer = true
var fakeJoinLeaveMessage = true

var forcePreventPrivateMessages = true

var preventPickup = true
var preventBlockBreak = false
var preventBlockPlace = false
var preventInteract = false
var preventAdvancement = false

init {
load()
Expand Down Expand Up @@ -97,13 +98,14 @@ object Settings {
remember = settingsConfig.getBoolean("vanish.remember")
seeAsSpectator = settingsConfig.getBoolean("vanish.see_as_spectator")
invincible = settingsConfig.getBoolean("vanish.invincible")
preventPickup = settingsConfig.getBoolean("vanish.prevent_pickup")
silentOpenContainer = settingsConfig.getBoolean("vanish.silent_open_container")
fakeJoinLeaveMessage = settingsConfig.getBoolean("vanish.fake_join_leave_message")

preventPickup = settingsConfig.getBoolean("vanish.prevent.pickup")
preventBlockBreak = settingsConfig.getBoolean("vanish.prevent.block_break")
preventBlockPlace = settingsConfig.getBoolean("vanish.prevent.block_place")
preventInteract = settingsConfig.getBoolean("vanish.prevent.interact")
preventAdvancement = settingsConfig.getBoolean("vanish.prevent.advancement")

forcePreventPrivateMessages = settingsConfig.getBoolean("hooks.essentials.force_prevent_private_messages")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ object NMSUtils {
}
}


fun getServerPlayer(player: Player?): Any? {
return try {
CRAFT_PLAYER_GET_HANDLE_METHOD!!.invoke(player)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class ServerVersion {

public static int getVersion() {
return ReflectionUtils.PATCH_NUMBER;
return ReflectionUtils.MINOR_NUMBER;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ softdepend:
- 'PlaceholderAPI'
- 'squaremap'
- 'Essentials'
- 'CMI'
- 'CMI'
8 changes: 4 additions & 4 deletions src/main/resources/settings.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Full wiki is available at https://github.com/Syrent/VelocityVanish/wiki
config_version: 6
config_version: 7
default_language: en_US
show_dependency_suggestions: true

Expand Down Expand Up @@ -36,18 +36,18 @@ vanish:
# Should vanished players be protected from all damage sources?
invincible: true

# Prevent vanished players from picking up items
prevent_pickup: true

# You can also achieve this by setting the fake join/leave message to blank in the language file
fake_join_leave_message: true

silent_open_container: true

prevent:
pickup: true
block_break: false
block_place: false
interact: false
# Only works on PaperMC servers (Paper, Purpur, Pufferfish, etc...)
advancement: true

hooks:
essentials:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":"velocityvanish","name":"VelocityVanish","version":"3.20.0","description":"Vanish plugin for velocity servers","url":"syrent.ir","authors":["Syrent"],"dependencies":[],"main":"ir.syrent.velocityvanish.velocity.VelocityVanish"}
{"id":"velocityvanish","name":"VelocityVanish","version":"3.21.0","description":"Vanish plugin for velocity servers","url":"syrent.ir","authors":["Syrent"],"dependencies":[],"main":"ir.syrent.velocityvanish.velocity.VelocityVanish"}