Merge branch 'main' into mc/1.20

# Conflicts:
#	plugins/civduties-paper/build.gradle.kts
#	settings.gradle.kts
This commit is contained in:
okx-code
2024-02-23 22:33:27 +00:00
13 changed files with 35 additions and 75 deletions

View File

@@ -33,6 +33,7 @@ allprojects {
maven("https://repo.aikar.co/content/groups/aikar/")
maven("https://libraries.minecraft.net")
maven("https://repo.codemc.io/repository/maven-public/")
maven("https://repo.kryptonmc.org/releases")
maven("https://jitpack.io")
}

View File

@@ -44,7 +44,6 @@ import vg.civcraft.mc.citadel.ReinforcementLogic;
import vg.civcraft.mc.citadel.events.ReinforcementBypassEvent;
import vg.civcraft.mc.citadel.model.Reinforcement;
import vg.civcraft.mc.civmodcore.inventory.items.ItemUtils;
import vg.civcraft.mc.civmodcore.utilities.MoreClassUtils;
import vg.civcraft.mc.namelayer.GroupManager;
import vg.civcraft.mc.namelayer.NameAPI;
import vg.civcraft.mc.namelayer.NameLayerPlugin;
@@ -265,8 +264,7 @@ public class EntityListener implements Listener {
case EXPLOSION:
return;
case ENTITY: {
Player player = MoreClassUtils.castOrNull(Player.class, event.getRemover());
if (player == null) {
if (!(event.getRemover() instanceof final Player player)) {
break;
}
Hanging entity = event.getEntity();
@@ -313,12 +311,10 @@ public class EntityListener implements Listener {
if (!Citadel.getInstance().getConfigManager().doHangersInheritReinforcements()) {
return;
}
Hanging entity = MoreClassUtils.castOrNull(Hanging.class, event.getEntity());
if (entity == null) {
if (!(event.getEntity() instanceof final Hanging entity)) {
return;
}
Player player = MoreClassUtils.castOrNull(Player.class, event.getDamager());
if (player == null) {
if (!(event.getDamager() instanceof final Player player)) {
event.setCancelled(true);
return;
}
@@ -346,8 +342,7 @@ public class EntityListener implements Listener {
if (!Citadel.getInstance().getConfigManager().doHangersInheritReinforcements()) {
return;
}
Hanging entity = MoreClassUtils.castOrNull(Hanging.class, event.getRightClicked());
if (entity == null) {
if (!(event.getRightClicked() instanceof final Hanging entity)) {
return;
}
Block host = entity.getLocation().getBlock().getRelative(entity.getAttachedFace());

View File

@@ -1,15 +1,15 @@
plugins {
id("io.papermc.paperweight.userdev")
id("io.papermc.paperweight.userdev")
}
version = "1.5.0-SNAPSHOT"
dependencies {
paperweight {
paperDevBundle("1.20.4-R0.1-SNAPSHOT")
}
paperweight {
paperDevBundle("1.20.4-R0.1-SNAPSHOT")
}
compileOnly(project(":plugins:civmodcore-paper"))
compileOnly(project(":plugins:civmodcore-paper"))
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
compileOnly(project(":plugins:combattagplus-paper"))
compileOnly(project(":plugins:combattagplus-paper"))
}

View File

@@ -1,24 +0,0 @@
package vg.civcraft.mc.civmodcore.utilities;
public final class MoreClassUtils {
/**
* Checks whether a value can be cast to a particular type.
*
* @param <T> The type to cast to.
* @param clazz The class of the type.
* @param value The value to attempt to cast.
* @return Returns the value cast to the given type, nor null.
*/
@SuppressWarnings("unchecked")
public static <T> T castOrNull(final Class<T> clazz, final Object value) {
if (clazz == null || value == null) {
return null;
}
if (clazz.isAssignableFrom(value.getClass())) {
return (T) value;
}
return null;
}
}

View File

@@ -10,8 +10,8 @@ dependencies {
}
compileOnly(project(":plugins:civmodcore-paper"))
compileOnly("com.github.NuVotifier.NuVotifier:nuvotifier-bukkit:2.7.2")
compileOnly("com.github.NuVotifier.NuVotifier:nuvotifier-api:2.7.2")
compileOnly("com.github.NuVotifier.NuVotifier:nuvotifier-bukkit:2.7.2")
compileOnly("com.github.NuVotifier.NuVotifier:nuvotifier-api:2.7.2")
compileOnly(project(":plugins:banstick-paper"))
compileOnly(project(":plugins:exilepearl-paper"))
}

View File

@@ -22,7 +22,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import vg.civcraft.mc.civmodcore.inventory.items.ItemUtils;
import vg.civcraft.mc.civmodcore.nbt.wrappers.NBTCompound;
import vg.civcraft.mc.civmodcore.utilities.MoreClassUtils;
@CommandAlias(SetCommand.ALIAS)
@Modifier(slug = "DAMAGE", order = 500)
@@ -61,8 +60,7 @@ public final class DamageableModifier extends ModifierData {
@Override
public boolean conforms(ItemStack item) {
Damageable meta = MoreClassUtils.castOrNull(Damageable.class, item.getItemMeta());
if (meta == null) {
if (!(item.getItemMeta() instanceof final Damageable meta)) {
return false;
}
int itemDamage = meta.getDamage();

View File

@@ -19,7 +19,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import vg.civcraft.mc.civmodcore.inventory.items.EnchantUtils;
import vg.civcraft.mc.civmodcore.nbt.wrappers.NBTCompound;
import vg.civcraft.mc.civmodcore.utilities.MoreClassUtils;
import vg.civcraft.mc.civmodcore.utilities.MoreMapUtils;
@CommandAlias(SetCommand.ALIAS)
@@ -34,8 +33,7 @@ public final class EnchantStorageModifier extends ModifierData {
@Override
public EnchantStorageModifier construct(ItemStack item) {
EnchantmentStorageMeta meta = MoreClassUtils.castOrNull(EnchantmentStorageMeta.class, item.getItemMeta());
if (meta == null) {
if (!(item.getItemMeta() instanceof final EnchantmentStorageMeta meta)) {
return null;
}
EnchantStorageModifier modifier = new EnchantStorageModifier();
@@ -61,8 +59,7 @@ public final class EnchantStorageModifier extends ModifierData {
@Override
public boolean conforms(ItemStack item) {
EnchantmentStorageMeta meta = MoreClassUtils.castOrNull(EnchantmentStorageMeta.class, item.getItemMeta());
if (meta == null) {
if (!(item.getItemMeta() instanceof final EnchantmentStorageMeta meta)) {
return false;
}
if (hasEnchants() != meta.hasStoredEnchants()) {

View File

@@ -22,7 +22,6 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionType;
import vg.civcraft.mc.civmodcore.inventory.items.PotionUtils;
import vg.civcraft.mc.civmodcore.nbt.wrappers.NBTCompound;
import vg.civcraft.mc.civmodcore.utilities.MoreClassUtils;
import vg.civcraft.mc.civmodcore.utilities.NullUtils;
@CommandAlias(SetCommand.ALIAS)
@@ -39,8 +38,7 @@ public final class PotionModifier extends ModifierData {
@Override
public PotionModifier construct(ItemStack item) {
PotionMeta meta = MoreClassUtils.castOrNull(PotionMeta.class, item.getItemMeta());
if (meta == null) {
if (!(item.getItemMeta() instanceof final PotionMeta meta)) {
return null;
}
PotionModifier modifier = new PotionModifier();
@@ -59,8 +57,7 @@ public final class PotionModifier extends ModifierData {
@Override
public boolean conforms(ItemStack item) {
PotionMeta meta = MoreClassUtils.castOrNull(PotionMeta.class, item.getItemMeta());
if (meta == null) {
if (!(item.getItemMeta() instanceof final PotionMeta meta)) {
return false;
}
if (!NullUtils.equalsNotNull(this.base, meta.getBasePotionData())) {

View File

@@ -23,7 +23,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Repairable;
import vg.civcraft.mc.civmodcore.nbt.wrappers.NBTCompound;
import vg.civcraft.mc.civmodcore.utilities.MoreClassUtils;
/**
* <p>This additional represents a repair level condition.</p>
@@ -48,8 +47,7 @@ public final class RepairModifier extends ModifierData {
if (!ItemExchangeConfig.canRepairItem(item.getType())) {
return null;
}
Repairable meta = MoreClassUtils.castOrNull(Repairable.class, item.getItemMeta());
if (meta == null) {
if (!(item.getItemMeta() instanceof final Repairable meta)) {
return null;
}
RepairModifier modifier = new RepairModifier();
@@ -64,8 +62,7 @@ public final class RepairModifier extends ModifierData {
@Override
public boolean conforms(ItemStack item) {
Repairable meta = MoreClassUtils.castOrNull(Repairable.class, item.getItemMeta());
if (meta == null) {
if (!(item.getItemMeta() instanceof final Repairable meta)) {
return false;
}
int itemRepair = meta.getRepairCost();

View File

@@ -5,6 +5,7 @@ import com.untamedears.jukealert.model.Snitch;
import com.untamedears.jukealert.model.actions.ActionCacheState;
import com.untamedears.jukealert.model.actions.LoggedActionPersistence;
import com.untamedears.jukealert.util.JAUtility;
import java.time.format.DateTimeFormatter;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import net.md_5.bungee.api.chat.TextComponent;
@@ -78,7 +79,8 @@ public abstract class LoggablePlayerAction extends PlayerAction implements Logga
if (referenceLoc != snitch.getLocation()) {
comp.addExtra(String.format("%s%s ", ChatColor.YELLOW, referenceLocText));
}
comp.addExtra(new TextComponent(ChatColor.AQUA + getFormattedTime()));
// Example: 2011-12-03T10:15:30
comp.addExtra(new TextComponent(ChatColor.AQUA + getFormattedTime(DateTimeFormatter.ISO_LOCAL_DATE_TIME)));
}
return comp;
}
@@ -89,7 +91,8 @@ public abstract class LoggablePlayerAction extends PlayerAction implements Logga
item = new ItemStack(Material.STONE);
}
ItemUtils.addLore(item, String.format("%sPlayer: %s", ChatColor.GOLD, getPlayerName()),
String.format("%sTime: %s", ChatColor.LIGHT_PURPLE,getFormattedTime()));
// Example: Tue, 3 Jun 2008 11:05:30 GMT
String.format("%sTime: %s", ChatColor.LIGHT_PURPLE, getFormattedTime(DateTimeFormatter.RFC_1123_DATE_TIME)));
ItemUtils.setDisplayName(item, ChatColor.GOLD + getGUIName());
}

View File

@@ -1,16 +1,14 @@
package com.untamedears.jukealert.model.actions.abstr;
import com.untamedears.jukealert.model.Snitch;
import java.time.LocalDateTime;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.UUID;
import org.jetbrains.annotations.NotNull;
import vg.civcraft.mc.namelayer.NameAPI;
public abstract class PlayerAction extends SnitchAction {
private static final DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
protected final UUID player;
public PlayerAction(long time, Snitch snitch, UUID player) {
@@ -30,8 +28,10 @@ public abstract class PlayerAction extends SnitchAction {
return true;
}
protected String getFormattedTime() {
return timeFormatter.format(LocalDateTime.ofEpochSecond(time / 1000, 0, ZoneOffset.UTC));
protected String getFormattedTime(
final @NotNull DateTimeFormatter formatter
) {
return formatter.format(Instant.ofEpochMilli(this.time).atOffset(ZoneOffset.UTC));
}
public String getPlayerName() {

View File

@@ -4,10 +4,6 @@ plugins {
version = "2.0.0-SNAPSHOT"
repositories {
maven("https://repo.kryptonmc.org/releases")
}
dependencies {
paperweight {
paperDevBundle("1.20.4-R0.1-SNAPSHOT")

View File

@@ -23,9 +23,9 @@ include(":plugins:realisticbiomes-paper")
include(":plugins:simpleadminhacks-paper")
include(":plugins:factorymod-paper")
include(":plugins:finale-paper")
include(":plugins:civduties-paper")
include(":plugins:essenceglue-paper")
include(":plugins:hiddenore-paper")
include(":plugins:kirabukkitgateway-paper")
include(":plugins:namecolors-paper")
include(":plugins:railswitch-paper")
include(":plugins:civduties-paper")
include(":plugins:namecolors-paper")
include(":plugins:kirabukkitgateway-paper")
include(":plugins:essenceglue-paper")