mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
Add coreprotect support, start on prism but commented out until they figure out a maven repository for their API
This commit is contained in:
parent
8c5c058292
commit
b35bf63ba4
@ -8,9 +8,13 @@ plugins {
|
||||
id("net.minecrell.plugin-yml.paper") version "0.6.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven(url = uri("https://maven.playpro.com"))
|
||||
// maven(url = uri("https://nexus.darkhelmet.network/repository/maven-snapshots"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
library("org.projectlombok:lombok:1.18.30")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
||||
library("org.json:json:20231013")
|
||||
library("commons-io:commons-io:2.15.1")
|
||||
library("redis.clients:jedis:5.1.0")
|
||||
@ -18,12 +22,18 @@ dependencies {
|
||||
library("com.zaxxer:HikariCP:5.1.0")
|
||||
library("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
||||
library("org.jetbrains:annotations:24.1.0")
|
||||
|
||||
compileOnly("dev.folia:folia-api:1.20.2-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
|
||||
exclude("org.bukkit", "bukkit")
|
||||
}
|
||||
compileOnly("net.coreprotect:coreprotect:22.2")
|
||||
// compileOnly("network.darkhelmet:prism:3.3.1")
|
||||
|
||||
implementation("org.bstats:bstats-base:3.0.2")
|
||||
implementation("org.bstats:bstats-bukkit:3.0.2")
|
||||
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
@ -59,6 +69,10 @@ paper {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
register("CoreProtect") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
register("SlimeWorldManager") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.AFTER
|
||||
|
@ -5,6 +5,8 @@ import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.config.Config;
|
||||
import dev.plex.handlers.CommandHandler;
|
||||
import dev.plex.handlers.ListenerHandler;
|
||||
import dev.plex.hook.CoreProtectHook;
|
||||
//import dev.plex.hook.PrismHook;
|
||||
import dev.plex.module.ModuleManager;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.PunishmentManager;
|
||||
@ -59,6 +61,9 @@ public class Plex extends JavaPlugin
|
||||
private Permission permissions;
|
||||
private Chat chat;
|
||||
|
||||
private CoreProtectHook coreProtectHook;
|
||||
// private PrismHook prismHook;
|
||||
|
||||
public static Plex get()
|
||||
{
|
||||
return plugin;
|
||||
@ -120,12 +125,22 @@ public class Plex extends JavaPlugin
|
||||
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||
{
|
||||
throw new RuntimeException("Vault is required to run on the server if you use permissions alongside a permissions plugin, we recommend LuckPerms!");
|
||||
throw new RuntimeException("Vault is required to run on the server alongside a permissions plugin, we recommend LuckPerms!");
|
||||
}
|
||||
|
||||
permissions = setupPermissions();
|
||||
chat = setupChat();
|
||||
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("CoreProtect")) {
|
||||
PlexLog.log("Hooked into CoreProtect!");
|
||||
coreProtectHook = new CoreProtectHook(this);
|
||||
} else {
|
||||
PlexLog.debug("Not hooking into CoreProtect");
|
||||
}
|
||||
// if (plugin.getServer().getPluginManager().isPluginEnabled("Prism")) {
|
||||
// prismHook = new PrismHook(this);
|
||||
// }
|
||||
|
||||
updateChecker = new UpdateChecker();
|
||||
PlexLog.log("Update checking enabled");
|
||||
|
||||
|
@ -12,6 +12,9 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.*;
|
||||
//import me.botsko.prism.api.PrismParameters;
|
||||
//import me.botsko.prism.api.Result;
|
||||
//import me.botsko.prism.api.actions.PrismProcessType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -20,11 +23,15 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
@CommandParameters(name = "ban", usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||
@CommandParameters(name = "ban", usage = "/<command> <player> [-nrb] [reason] [-nrb]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||
@CommandPermissions(permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||
|
||||
public class BanCMD extends PlexCommand
|
||||
@ -56,10 +63,13 @@ public class BanCMD extends PlexCommand
|
||||
String reason;
|
||||
Punishment punishment = new Punishment(plexPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setType(PunishmentType.BAN);
|
||||
boolean rollBack = true;
|
||||
if (args.length > 1)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
punishment.setReason(reason);
|
||||
String newReason = StringUtils.normalizeSpace(reason.replace("-nrb", ""));
|
||||
punishment.setReason(newReason.trim().isEmpty() ? "No reason provided." : newReason);
|
||||
rollBack = !reason.startsWith("-nrb") && !reason.endsWith("-nrb");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -84,6 +94,41 @@ public class BanCMD extends PlexCommand
|
||||
}
|
||||
});
|
||||
PlexLog.debug("(From /ban command) PunishedPlayer UUID: " + plexPlayer.getUuid());
|
||||
|
||||
if (rollBack)
|
||||
{
|
||||
/*if (plugin.getPrismHook().hasPrism()) {
|
||||
PrismParameters parameters = plugin.getPrismHook().prismApi().createParameters();
|
||||
parameters.addActionType("block-place");
|
||||
parameters.addActionType("block-break");
|
||||
parameters.addActionType("block-burn");
|
||||
parameters.addActionType("entity-spawn");
|
||||
parameters.addActionType("entity-kill");
|
||||
parameters.addActionType("entity-explode");
|
||||
parameters.addPlayerName(plexPlayer.getName());
|
||||
parameters.setBeforeTime(Instant.now().toEpochMilli());
|
||||
parameters.setProcessType(PrismProcessType.ROLLBACK);
|
||||
final Future<Result> result = plugin.getPrismHook().prismApi().performLookup(parameters, sender);
|
||||
Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask -> {
|
||||
try
|
||||
{
|
||||
final Result done = result.get();
|
||||
} catch (InterruptedException | ExecutionException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
else */
|
||||
if (plugin.getCoreProtectHook().hasCoreProtect())
|
||||
{
|
||||
PlexLog.debug("Testing coreprotect");
|
||||
Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask ->
|
||||
{
|
||||
plugin.getCoreProtectHook().coreProtectAPI().performRollback(86400, Collections.singletonList(plexPlayer.getName()), null, null, null, null, 0, null);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
|
63
server/src/main/java/dev/plex/hook/CoreProtectHook.java
Normal file
63
server/src/main/java/dev/plex/hook/CoreProtectHook.java
Normal file
@ -0,0 +1,63 @@
|
||||
package dev.plex.hook;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.CoreProtectAPI;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class CoreProtectHook
|
||||
{
|
||||
private CoreProtectAPI coreProtectAPI;
|
||||
private boolean hasApi;
|
||||
|
||||
public CoreProtectHook(Plex plex)
|
||||
{
|
||||
Plugin plugin = plex.getServer().getPluginManager().getPlugin("CoreProtect");
|
||||
|
||||
// Check that CoreProtect is loaded
|
||||
if (!(plugin instanceof CoreProtect))
|
||||
{
|
||||
PlexLog.debug("Plugin was not CoreProtect.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that the API is enabled
|
||||
CoreProtectAPI coreProtectAPI = ((CoreProtect) plugin).getAPI();
|
||||
this.hasApi = coreProtectAPI.isEnabled();
|
||||
if (!hasApi)
|
||||
{
|
||||
PlexLog.debug("CoreProtect API was disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that a compatible version of the API is loaded
|
||||
if (coreProtectAPI.APIVersion() < 9)
|
||||
{
|
||||
PlexLog.debug("CoreProtect API version is: {0}", coreProtectAPI.APIVersion());
|
||||
return;
|
||||
}
|
||||
this.coreProtectAPI = coreProtectAPI;
|
||||
this.coreProtectAPI.testAPI();
|
||||
}
|
||||
|
||||
public boolean hasCoreProtect() {
|
||||
return hasApi;
|
||||
}
|
||||
|
||||
public CoreProtectAPI coreProtectAPI()
|
||||
{
|
||||
return coreProtectAPI;
|
||||
}
|
||||
}
|
34
server/src/main/java/dev/plex/hook/PrismHook.java
Normal file
34
server/src/main/java/dev/plex/hook/PrismHook.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
package dev.plex.hook;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PrismHook
|
||||
{
|
||||
private PrismApi prismApi;
|
||||
|
||||
public PrismHook(Plex plex)
|
||||
{
|
||||
Plugin plugin = plex.getServer().getPluginManager().getPlugin("Prism");
|
||||
|
||||
// Check that Prism is loaded
|
||||
if (!plugin.isEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that the API is enabled
|
||||
this.prismApi = (PrismApi) plugin;
|
||||
}
|
||||
|
||||
public boolean hasPrism() {
|
||||
return prismApi != null;
|
||||
}
|
||||
|
||||
public PrismApi prismApi()
|
||||
{
|
||||
return prismApi;
|
||||
}
|
||||
}
|
||||
*/
|
Loading…
Reference in New Issue
Block a user