Spigot GriefPrevention 16.17.1

PREVENTS all forms of grief - build/break, theft, spam, spawn camping, and more without a database.

  1. I've noticed that you can trample farm blocks inside claims. But pretty sure the config says you shouldn't be able to do that.
     
  2. If you're having problems, highly recommend you open an issue.
     
  3. Hello!

    Is it possible to display a message when you enter a claim?
    I've seen that there's a plugin called GriefPrevention Flags, but it has been abandoned.

    Is it possible to do it without any external plugin?

    Thanks!
     
    • Useful Useful x 1
  4. I'm not sure if it can be done without an external plugin, however, such a plugin wouldn't be complicated.

    Here's a Basic implementation for reference.
    Code (Java):
    public class ClaimMessage extends JavaPlugin implements Listener {

        private final Map<Player, Long> lastClaim = new HashMap<>();

        public void onEnable() {
            PluginManager pm = getServer().getPluginManager();
            if (pm.isPluginEnabled("GriefPrevention")) {
                pm.disablePlugin(this);
                getLogger().info("[!] GriefPrevention not Loaded, ClaimMsg will now shutdown.");
            } else pm.registerEvents(this, this);
        }

        @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
        public void onPlayerMove(PlayerMoveEvent evt) {
            checkPlayer(evt.getPlayer(), evt.getTo());
        }

        @EventHandler
        public void onPlayerQuit(PlayerQuitEvent evt) {
            lastClaim.remove(evt.getPlayer());
        }

        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent evt) {
            checkPlayer(evt.getPlayer(), null);
        }

        private void checkPlayer(final Player player, Location to) {
            if (to == null) to = player.getLocation();
            Claim claim = GriefPrevention.instance.dataStore.getClaimAt(to, true, null);
            if (claim != null) {
                final long id = claim.getID(), previous = lastClaim.getOrDefault(player, -1L);
                if (previous != id) {
                    lastClaim.put(player, id);
                    player.sendMessage("MESSAGE GOES HERE");
                }
            } else lastClaim.remove(player);
        }
    }

    Better version below
     
    #7064 TheMrJezza, Oct 2, 2021
    Last edited: Oct 2, 2021
  5. No, you need an addon to do that. GPFlags is still out there, you just have to look. Currently looks like drbot7's fork receives the most support, but there are plenty of alternatives.
    I know that this is a sample implementation, but I highly recommend you just piggyback GP's PlayerData.lastClaim field (and use it in DataStore#getClaimAt!) in combination with ignoring all moves that are not to a new block.
     
    • Agree Agree x 1
    • Friendly Friendly x 1
  6. You are absolutely correct.
    Code (Java):
    public class ClaimListener implements Listener {
        private static final DataStore DATA_STORE = GriefPrevention.instance.dataStore;

        ClaimListener(final JavaPlugin plugin) {
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
        }

        private static boolean compare(final Location one, final Location two) {
            return one.getBlockX() == two.getBlockX() &&
                   one.getBlockZ() == two.getBlockZ() &&
                   Objects.equals(one.getWorld(), two.getWorld());
        }

        // Enable "forceParent" to ignore Sub Claims
        private static Claim claimAt(Location loc, Claim cached, boolean forceParent) {
            Claim found = DATA_STORE.getClaimAt(loc, true, cached);
            if (found != null && found.parent != null) found = found.parent;
            return found;
        }

        @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
        public void onPlayerTeleport(final PlayerTeleportEvent evt) { onPlayerMove(evt); }

        @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
        public void onPlayerMove(final PlayerMoveEvent evt) {
            final Location to = evt.getTo(), from = evt.getFrom();

            // Filter out Jumping, falling, head rotations etc.
            if (to == null || compare(from, to)) return;

            final Player player = evt.getPlayer();
            final PlayerData pd = DATA_STORE.getPlayerData(player.getUniqueId());

            // Relying on only the "lastClaim" field alone isn't always accurate.
            // i.e. If a player interacts with a claim before walking into it.
            final Claim cached = pd.lastClaim,
                    fromClaim = claimAt(from, cached, true),
                    nextClaim = claimAt(to, cached, true);

            if (nextClaim != null && nextClaim != fromClaim) {
                player.sendMessage("You Entered a Claim!");

                // Optional: Play a sound when you send the message.
                player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 10f, 10f);
                pd.lastClaim = nextClaim;
            }
        }
    }
     
    #7066 TheMrJezza, Oct 2, 2021
    Last edited: Oct 2, 2021
    • Useful Useful x 1
  7. Just bumping this. Don't know why it still happens.
     
  8. If you're having problems, highly recommend you open an issue.
     
  9. Is this a dead plugin? No more updates?
     
    • Agree Agree x 1
  10. Latest change on GitHub: 10 days ago...
    Doesn't sound like dead to me...
     
    • Agree Agree x 1
  11. Then where is the update for 1.17?
     
  12. How do I transfer player regions from WorldGuard to this plugin?
     
  13. Is there a way to create an admin claim with a command, providing the coordinates as parameters?
     
  14. It's so crazy to me that we're in November and the 1.17.1 version hasn't been released in the last 5 months.
     
  15. What doesn't work?
     
  16. How when player claim purge send chat info
     
  17. Mojang added in 1.14 the possibility to dye signs. Is it possible with GriefPrevention to prevent not trusted players to dye signs in protected areas?
     
  18. I know right
     
    • Friendly Friendly x 1