Skip to content
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ processResources {
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
compileOnly 'io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT'
compileOnly 'io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT'
compileOnly 'net.luckperms:api:5.4'
compileOnly 'us.dynmap:DynmapCoreAPI:3.3'
compileOnly 'us.dynmap:dynmap-api:3.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@

import java.time.Duration;
import java.time.Instant;
import java.util.*;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

/**
* Abstract CommandSender representing a player that may not be online.
Expand Down Expand Up @@ -184,6 +187,11 @@ public long getLastSeen() {
return offlinePlayer.getRespawnLocation();
}

@Override
public @Nullable Location getRespawnLocation(boolean b) {
return offlinePlayer.getRespawnLocation(b);
}

@Override
public void incrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException {
offlinePlayer.incrementStatistic(statistic);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.froobworld.nabsuite.modules.mechs.border;

import com.froobworld.nabsuite.modules.mechs.MechsModule;
import io.papermc.paper.entity.TeleportFlag;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -34,7 +33,7 @@ private void knockBack(Player player, WorldBorder worldBorder) {
Entity vehicle = player.getVehicle();
if (vehicle != null) {
player.leaveVehicle();
vehicle.teleport(knockBackLocation, TeleportFlag.EntityState.RETAIN_PASSENGERS);
vehicle.teleport(knockBackLocation);
}
player.teleport(knockBackLocation);
player.sendMessage(KNOCK_BACK_MESSAGE);
Expand All @@ -53,7 +52,7 @@ private void checkPlayers() {
private void onPlayerTeleport(PlayerTeleportEvent event) {
WorldBorder worldBorder = worldBorderManager.getWorldBorder(event.getTo().getWorld());
if (worldBorder != null && !worldBorder.isInBorder(event.getTo())) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL || event.getCause() == PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL || event.getCause() == PlayerTeleportEvent.TeleportCause.CONSUMABLE_EFFECT) {
event.setCancelled(true);
event.getPlayer().sendMessage(KNOCK_BACK_MESSAGE);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void onItemFrameChange(PlayerItemFrameChangeEvent event) {
private void onPlayerInteract(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
if (block != null) {
if (lootLimitManager.isLootChest(block.getLocation()) && lootLimitManager.hasLootedPreviously(event.getPlayer(), block.getLocation())) {
if (lootLimitManager.isInteractableLootBlock(block.getLocation()) && lootLimitManager.hasLootedPreviously(event.getPlayer(), block.getLocation())) {
event.setCancelled(true);
sendFailureMessage(event.getPlayer());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import com.destroystokyo.paper.MaterialTags;
import com.froobworld.nabsuite.modules.mechs.MechsModule;
import com.froobworld.nabsuite.modules.mechs.border.WorldBorderManager;
import io.papermc.paper.event.block.VaultChangeStateEvent;
import io.papermc.paper.event.player.PlayerItemFrameChangeEvent;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.block.data.type.Vault;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -32,6 +34,8 @@ public class LootLimitManager implements Listener {
.add(Material.DIAMOND_ORE, Material.DEEPSLATE_DIAMOND_ORE, Material.ANCIENT_DEBRIS);
private static final MaterialSetTag LOOTABLE_EXPLODABLE_BLOCKS = new MaterialSetTag(NamespacedKey.fromString("loot_tracker_lootable_explodable_blocks"))
.add(Material.DIAMOND_ORE, Material.DEEPSLATE_DIAMOND_ORE);
private static final MaterialSetTag LOOTABLE_INTERACTABLE_BLOCKS = new MaterialSetTag(NamespacedKey.fromString("loot_tracker_lootable_interactable_blocks"))
.add(Material.VAULT);
private final MechsModule mechsModule;
private final PlayerLootTracker playerLootTracker;
private final Map<UUID, Set<Location>> sessionLootCache = new HashMap<>();
Expand Down Expand Up @@ -86,6 +90,13 @@ public boolean isNonExplodableLootBlock(Location location) {
return !location.getChunk().getPersistentDataContainer().has(placedBlockKey(location));
}

public boolean isInteractableLootBlock(Location location) {
if (!worldBorderManager.isBorderRegion(location)) {
return false;
}
return LOOTABLE_INTERACTABLE_BLOCKS.isTagged(location.getBlock()) || isLootChest(location);
}

public boolean isLootChest(Location location) {
if (!worldBorderManager.isBorderRegion(location)) {
return false;
Expand Down Expand Up @@ -216,4 +227,14 @@ private void onLootGenerate(LootGenerateEvent event) {
}
}

@EventHandler
private void onVaultStateChange(VaultChangeStateEvent event) {
if (!worldBorderManager.isBorderRegion(event.getBlock().getLocation())) {
return;
}
if (event.getNewState() == Vault.State.UNLOCKING) {
markAsLooted(event.getPlayer(), event.getBlock().getLocation());
}
}

}