Skip to content

Commit

Permalink
Revert "Update to Java 21, MC 1.20.6"
Browse files Browse the repository at this point in the history
  • Loading branch information
nouish committed Aug 4, 2024
1 parent 0d83f59 commit 414765e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Worldguard dependency -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionEffectTypeCategory;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
Expand All @@ -60,13 +59,34 @@ public class EntityDamageHandler implements Listener

private static final Set<PotionEffectType> GRIEF_EFFECTS = Set.of(
// Damaging effects
PotionEffectType.INSTANT_DAMAGE,
PotionEffectType.HARM,
PotionEffectType.POISON,
PotionEffectType.WITHER,
// Effects that could remove entities from normally-secure pens
PotionEffectType.JUMP_BOOST,
PotionEffectType.JUMP,
PotionEffectType.LEVITATION
);
private static final Set<PotionEffectType> POSITIVE_EFFECTS = Set.of(
PotionEffectType.ABSORPTION,
PotionEffectType.CONDUIT_POWER,
PotionEffectType.DAMAGE_RESISTANCE,
PotionEffectType.DOLPHINS_GRACE,
PotionEffectType.FAST_DIGGING,
PotionEffectType.FIRE_RESISTANCE,
PotionEffectType.HEAL,
PotionEffectType.HEALTH_BOOST,
PotionEffectType.HERO_OF_THE_VILLAGE,
PotionEffectType.INCREASE_DAMAGE,
PotionEffectType.INVISIBILITY,
PotionEffectType.JUMP,
PotionEffectType.LUCK,
PotionEffectType.NIGHT_VISION,
PotionEffectType.REGENERATION,
PotionEffectType.SATURATION,
PotionEffectType.SLOW_FALLING,
PotionEffectType.SPEED,
PotionEffectType.WATER_BREATHING
);
private static final Set<EntityType> TEMPTABLE_SEMI_HOSTILES = Set.of(
EntityType.HOGLIN,
EntityType.POLAR_BEAR,
Expand Down Expand Up @@ -126,7 +146,7 @@ private void handleEntityDamageEvent(@NotNull EntityCombustByEntityEvent event,
if (event.getEntity() instanceof Mule && !instance.config_claims_protectDonkeys) return;
if (event.getEntity() instanceof Llama && !instance.config_claims_protectLlamas) return;
//protected death loot can't be destroyed, only picked up or despawned due to expiration
if (event.getEntityType() == EntityType.ITEM)
if (event.getEntityType() == EntityType.DROPPED_ITEM)
{
if (event.getEntity().hasMetadata("GP_ITEMOWNER"))
{
Expand Down Expand Up @@ -194,7 +214,7 @@ private void handleEntityDamageEvent(@NotNull EntityDamageEvent event, boolean s
if (event.getEntity() instanceof Mule && !instance.config_claims_protectDonkeys) return;
if (event.getEntity() instanceof Llama && !instance.config_claims_protectLlamas) return;
//protected death loot can't be destroyed, only picked up or despawned due to expiration
if (event.getEntityType() == EntityType.ITEM)
if (event.getEntityType() == EntityType.DROPPED_ITEM)
{
if (event.getEntity().hasMetadata("GP_ITEMOWNER"))
{
Expand Down Expand Up @@ -682,7 +702,7 @@ private boolean handleClaimedBuildTrustDamageByEntity(
&& entityType != EntityType.GLOW_ITEM_FRAME
&& entityType != EntityType.ARMOR_STAND
&& entityType != EntityType.VILLAGER
&& entityType != EntityType.END_CRYSTAL)
&& entityType != EntityType.ENDER_CRYSTAL)
{
return false;
}
Expand Down Expand Up @@ -740,7 +760,7 @@ private boolean handleClaimedBuildTrustDamageByEntity(
&& entityType != EntityType.GLOW_ITEM_FRAME
&& entityType != EntityType.ARMOR_STAND
&& entityType != EntityType.VILLAGER
&& entityType != EntityType.END_CRYSTAL)
&& entityType != EntityType.ENDER_CRYSTAL)
{
return false;
}
Expand Down Expand Up @@ -818,7 +838,7 @@ private boolean handleCreatureDamageByEntity(
if (attacker == null
&& damageSourceType != EntityType.CREEPER
&& damageSourceType != EntityType.WITHER
&& damageSourceType != EntityType.END_CRYSTAL
&& damageSourceType != EntityType.ENDER_CRYSTAL
&& damageSourceType != EntityType.AREA_EFFECT_CLOUD
&& damageSourceType != EntityType.WITCH
&& !(damageSource instanceof Projectile)
Expand Down Expand Up @@ -854,7 +874,7 @@ private boolean handleCreatureDamageByEntity(
playerData.lastClaim = claim;

// Do not message players about fireworks to prevent spam due to multi-hits.
sendMessages &= damageSourceType != EntityType.FIREWORK_ROCKET;
sendMessages &= damageSourceType != EntityType.FIREWORK;

Supplier<String> override = null;
if (sendMessages)
Expand Down Expand Up @@ -900,7 +920,7 @@ private boolean handleCreatureDamageByEntity(
if (attacker == null
&& damageSourceType != EntityType.CREEPER
&& damageSourceType != EntityType.WITHER
&& damageSourceType != EntityType.END_CRYSTAL
&& damageSourceType != EntityType.ENDER_CRYSTAL
&& damageSourceType != EntityType.AREA_EFFECT_CLOUD
&& damageSourceType != EntityType.WITCH
&& !(damageSource instanceof Projectile)
Expand Down Expand Up @@ -936,7 +956,7 @@ private boolean handleCreatureDamageByEntity(
playerData.lastClaim = claim;

// Do not message players about fireworks to prevent spam due to multi-hits.
sendMessages &= damageSourceType != EntityType.FIREWORK_ROCKET;
sendMessages &= damageSourceType != EntityType.FIREWORK;

Supplier<String> override = null;
if (sendMessages)
Expand Down Expand Up @@ -1117,7 +1137,7 @@ else if (damageSource instanceof Projectile projectile)
}

//if not a player and not an explosion, always allow
if (attacker == null && damageSourceType != EntityType.CREEPER && damageSourceType != EntityType.WITHER && damageSourceType != EntityType.TNT)
if (attacker == null && damageSourceType != EntityType.CREEPER && damageSourceType != EntityType.WITHER && damageSourceType != EntityType.PRIMED_TNT)
{
return;
}
Expand Down Expand Up @@ -1236,7 +1256,7 @@ public void onPotionSplash(@NotNull PotionSplashEvent event)
if (thrower == null) return;

//otherwise, no restrictions for positive effects
if (effectType.getCategory() == PotionEffectTypeCategory.BENEFICIAL) continue;
if (POSITIVE_EFFECTS.contains(effectType)) continue;

for (LivingEntity affected : event.getAffectedEntities())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3636,25 +3636,7 @@ public String allowBuild(Player player, Location location, Material material)
playerData.lastClaim = claim;
Block block = location.getBlock();

ItemStack itemStack;
if (material.isItem())
{
itemStack = new ItemStack(material);
}
else
{
var blockType = material.asBlockType();
if (blockType != null && blockType.hasItemType())
{
itemStack = blockType.getItemType().createItemStack();
}
else
{
itemStack = new ItemStack(Material.DIRT);
}
}

Supplier<String> supplier = claim.checkPermission(player, ClaimPermission.Build, new BlockPlaceEvent(block, block.getState(), block, itemStack, player, true, EquipmentSlot.HAND));
Supplier<String> supplier = claim.checkPermission(player, ClaimPermission.Build, new BlockPlaceEvent(block, block.getState(), block, new ItemStack(material), player, true, EquipmentSlot.HAND));

if (supplier == null) return null;

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 @@ -3,7 +3,7 @@ main: me.ryanhamshire.GriefPrevention.GriefPrevention
softdepend: [Vault, Multiverse-Core, My_Worlds, MystCraft, Transporter, WorldGuard, WorldEdit, RoyalCommands, MultiWorld, Denizen, CommandHelper]
dev-url: https://dev.bukkit.org/projects/grief-prevention
version: '${git.commit.id.describe}'
api-version: '1.20.6'
api-version: '1.20'
commands:
abandonclaim:
description: Deletes a claim.
Expand Down

0 comments on commit 414765e

Please sign in to comment.