mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 01:17:42 +01:00
Add a raid cooldown setting to stop cheaty farms
This commit is contained in:
72
patches/server/0133-Raid-cooldown-setting.patch
Normal file
72
patches/server/0133-Raid-cooldown-setting.patch
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jmp <jasonpenilla2@me.com>
|
||||||
|
Date: Sun, 23 Aug 2020 17:26:39 -0700
|
||||||
|
Subject: [PATCH] Raid cooldown setting
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/PersistentRaid.java b/src/main/java/net/minecraft/server/PersistentRaid.java
|
||||||
|
index b46b20ca..89be52ca 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/PersistentRaid.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/PersistentRaid.java
|
||||||
|
@@ -9,6 +9,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class PersistentRaid extends PersistentBase {
|
||||||
|
|
||||||
|
+ public final Map<java.util.UUID, Integer> playerCooldowns = new java.util.HashMap<>(); // Purpur
|
||||||
|
public final Map<Integer, Raid> raids = Maps.newHashMap();
|
||||||
|
private final WorldServer b;
|
||||||
|
private int c;
|
||||||
|
@@ -27,6 +28,17 @@ public class PersistentRaid extends PersistentBase {
|
||||||
|
|
||||||
|
public void a() {
|
||||||
|
++this.d;
|
||||||
|
+ // Purpur start
|
||||||
|
+ if (b.purpurConfig.raidCooldownSeconds != 0 && this.d % 20 == 0) {
|
||||||
|
+ com.google.common.collect.ImmutableMap.copyOf(playerCooldowns).forEach((id, i) -> {
|
||||||
|
+ if (i < 1) {
|
||||||
|
+ playerCooldowns.remove(id);
|
||||||
|
+ } else {
|
||||||
|
+ playerCooldowns.put(id, i - 1);
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
+ // Purpur end
|
||||||
|
Iterator iterator = this.raids.values().iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
@@ -67,6 +79,15 @@ public class PersistentRaid extends PersistentBase {
|
||||||
|
if (!dimensionmanager.hasRaids()) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
+ // Purpur start
|
||||||
|
+ if (b.purpurConfig.raidCooldownSeconds != 0) {
|
||||||
|
+ if (!playerCooldowns.containsKey(entityplayer.getUniqueID())) {
|
||||||
|
+ playerCooldowns.put(entityplayer.getUniqueID(), b.purpurConfig.raidCooldownSeconds);
|
||||||
|
+ } else {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Purpur end
|
||||||
|
BlockPosition blockposition = entityplayer.getChunkCoordinates();
|
||||||
|
List<VillagePlaceRecord> list = (List) this.b.y().c(VillagePlaceType.b, blockposition, 64, VillagePlace.Occupancy.IS_OCCUPIED).collect(Collectors.toList());
|
||||||
|
int i = 0;
|
||||||
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||||
|
index fcfc684f..8d5d841c 100644
|
||||||
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||||
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||||
|
@@ -155,6 +155,7 @@ public class PurpurWorldConfig {
|
||||||
|
public boolean saveProjectilesToDisk = true;
|
||||||
|
public double tridentLoyaltyVoidReturnHeight = 0.0D;
|
||||||
|
public double voidDamageHeight = -64.0D;
|
||||||
|
+ public int raidCooldownSeconds = 0;
|
||||||
|
private void miscGameplayMechanicsSettings() {
|
||||||
|
useBetterMending = getBoolean("gameplay-mechanics.use-better-mending", useBetterMending);
|
||||||
|
boatEjectPlayersOnLand = getBoolean("gameplay-mechanics.boat.eject-players-on-land", boatEjectPlayersOnLand);
|
||||||
|
@@ -166,6 +167,7 @@ public class PurpurWorldConfig {
|
||||||
|
saveProjectilesToDisk = getBoolean("gameplay-mechanics.save-projectiles-to-disk", saveProjectilesToDisk);
|
||||||
|
tridentLoyaltyVoidReturnHeight = getDouble("gameplay-mechanics.trident-loyalty-void-return-height", tridentLoyaltyVoidReturnHeight);
|
||||||
|
voidDamageHeight = getDouble("gameplay-mechanics.void-damage-height", voidDamageHeight);
|
||||||
|
+ raidCooldownSeconds = getInt("gameplay-mechanics.raid-cooldown-seconds", raidCooldownSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean catSpawning;
|
||||||
Reference in New Issue
Block a user