3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00

Add Ban Methods to Player Objects

Allows a more logical API for banning players.

player.banPlayer("Breaking the rules");
Dieser Commit ist enthalten in:
Aikar 2018-04-28 11:31:26 -04:00
Ursprung 2120696fcf
Commit 33a6de0f13
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 401ADFC9891FAAFE
9 geänderte Dateien mit 252 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,232 @@
From 49542a3fdb8594cc0e398a21dee2664f87d0993f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 28 Apr 2018 10:28:50 -0400
Subject: [PATCH] Add Ban Methods to Player Objects
Allows a more logical API for banning players.
player.banPlayer("Breaking the rules");
diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java
index 3ab2e4c7..8daf2ddc 100644
--- a/src/main/java/org/bukkit/OfflinePlayer.java
+++ b/src/main/java/org/bukkit/OfflinePlayer.java
@@ -40,6 +40,56 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
* @return true if banned, otherwise false
*/
public boolean isBanned();
+ // Paper start
+
+ /**
+ * Permanently Bans this player from the server
+ *
+ * @param reason Reason for Ban
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayer(String reason) {
+ return banPlayer(reason, null, null);
+ }
+
+ /**
+ * Permanently Bans this player from the server
+ * @param reason Reason for Ban
+ * @param source Source of the ban, or null for default
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayer(String reason, String source) {
+ return banPlayer(reason, null, source);
+ }
+
+ /**
+ * Bans this player from the server
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayer(String reason, Date expires) {
+ return banPlayer(reason, expires, null);
+ }
+
+ /**
+ * Bans this player from the server
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @param source Source of the ban or null for default
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayer(String reason, Date expires, String source) {
+ return banPlayer(reason, expires, source, true);
+ }
+ public default BanEntry banPlayer(String reason, Date expires, String source, boolean kickIfOnline) {
+ BanEntry banEntry = Bukkit.getServer().getBanList(BanList.Type.NAME).addBan(getName(), reason, expires, source);
+ if (kickIfOnline && isOnline()) {
+ getPlayer().kickPlayer(reason);
+ }
+ return banEntry;
+ }
+ // Paper end
/**
* Checks if this player is whitelisted or not
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 87a9b750..d874d166 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -1,10 +1,14 @@
package org.bukkit.entity;
import java.net.InetSocketAddress;
+import java.util.Date;
import com.destroystokyo.paper.Title;
import com.destroystokyo.paper.profile.PlayerProfile;
import org.bukkit.Achievement;
+import org.bukkit.BanEntry;
+import org.bukkit.BanList;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
@@ -397,6 +401,139 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
public void sendMap(MapView map);
// Paper start
+ /**
+ * Permanently Bans the Profile and IP address currently used by the player.
+ *
+ * @param reason Reason for ban
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerFull(String reason) {
+ return banPlayerFull(reason, null, null);
+ }
+
+ /**
+ * Permanently Bans the Profile and IP address currently used by the player.
+ *
+ * @param reason Reason for ban
+ * @param source Source of ban, or null for default
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerFull(String reason, String source) {
+ return banPlayerFull(reason, null, source);
+ }
+
+ /**
+ * Bans the Profile and IP address currently used by the player.
+ *
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerFull(String reason, Date expires) {
+ return banPlayerFull(reason, expires, null);
+ }
+
+ /**
+ * Bans the Profile and IP address currently used by the player.
+ *
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @param source Source of the ban, or null for default
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerFull(String reason, Date expires, String source) {
+ banPlayer(reason, expires, source);
+ return banPlayerIP(reason, expires, source, true);
+ }
+
+ /**
+ * Permanently Bans the IP address currently used by the player.
+ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)}
+ *
+ * @param reason Reason for ban
+ * @param kickPlayer Whether or not to kick the player afterwards
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerIP(String reason, boolean kickPlayer) {
+ return banPlayerIP(reason, null, null, kickPlayer);
+ }
+
+ /**
+ * Permanently Bans the IP address currently used by the player.
+ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)}
+ * @param reason Reason for ban
+ * @param source Source of ban, or null for default
+ * @param kickPlayer Whether or not to kick the player afterwards
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerIP(String reason, String source, boolean kickPlayer) {
+ return banPlayerIP(reason, null, source, kickPlayer);
+ }
+
+ /**
+ * Bans the IP address currently used by the player.
+ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)}
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @param kickPlayer Whether or not to kick the player afterwards
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerIP(String reason, Date expires, boolean kickPlayer) {
+ return banPlayerIP(reason, expires, null, kickPlayer);
+ }
+
+ /**
+ * Permanently Bans the IP address currently used by the player.
+ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)}
+ *
+ * @param reason Reason for ban
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerIP(String reason) {
+ return banPlayerIP(reason, null, null);
+ }
+
+ /**
+ * Permanently Bans the IP address currently used by the player.
+ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)}
+ * @param reason Reason for ban
+ * @param source Source of ban, or null for default
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerIP(String reason, String source) {
+ return banPlayerIP(reason, null, source);
+ }
+
+ /**
+ * Bans the IP address currently used by the player.
+ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)}
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerIP(String reason, Date expires) {
+ return banPlayerIP(reason, expires, null);
+ }
+
+ /**
+ * Bans the IP address currently used by the player.
+ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)}
+ * @param reason Reason for Ban
+ * @param expires When to expire the ban
+ * @param source Source of the banm or null for default
+ * @return Ban Entry
+ */
+ public default BanEntry banPlayerIP(String reason, Date expires, String source) {
+ return banPlayerIP(reason, expires, source, true);
+ }
+ public default BanEntry banPlayerIP(String reason, Date expires, String source, boolean kickPlayer) {
+ BanEntry banEntry = Bukkit.getServer().getBanList(BanList.Type.IP).addBan(getAddress().getAddress().getHostAddress(), reason, expires, source);
+ if (kickPlayer && isOnline()) {
+ getPlayer().kickPlayer(reason);
+ }
+
+ return banEntry;
+ }
/**
* Sends an Action Bar message to the client.
--
2.17.0

Datei anzeigen

@ -1,11 +1,11 @@
From d0691988443de01bda2253f429d0d19fe988a125 Mon Sep 17 00:00:00 2001
From 546315b2c4410127330c66a51e4dc275640dde34 Mon Sep 17 00:00:00 2001
From: Iceee <andrew@opticgaming.tv>
Date: Wed, 2 Mar 2016 01:39:52 -0600
Subject: [PATCH] Fix lag from explosions processing dead entities
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
index 98c2bdcf..a1ebcf85 100644
index 98c2bdcf7..a1ebcf858 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
@@ -104,7 +104,14 @@ public class Explosion {
@ -25,5 +25,5 @@ index 98c2bdcf..a1ebcf85 100644
for (int l1 = 0; l1 < list.size(); ++l1) {
--
2.14.3
2.17.0

Datei anzeigen

@ -1,4 +1,4 @@
From 1041665a9111bf437a33aef1bc08d7842c5ae211 Mon Sep 17 00:00:00 2001
From 44be4254d3e0b4553144b3e11ef864c9eaf57d13 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 02:17:54 -0600
Subject: [PATCH] Generator Settings
@ -308,5 +308,5 @@ index 66a80a776..34fd7edfe 100644
ObjectIterator objectiterator = this.c.values().iterator();
--
2.14.3
2.17.0

Datei anzeigen

@ -1,4 +1,4 @@
From 345e60055a56d14763a2e9902b54079ca1ce7f72 Mon Sep 17 00:00:00 2001
From 4a3ce0b9f53b9cb651783d272853855f45ac78dd Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 11:59:48 -0600
Subject: [PATCH] Optimize explosions
@ -156,5 +156,5 @@ index 77ed2d249..fc7315f7d 100644
public CraftWorld getWorld() {
return this.world;
--
2.14.3
2.17.0

Datei anzeigen

@ -1,11 +1,11 @@
From d03ae937e89c84d1069229eb94714aa1f2b2e009 Mon Sep 17 00:00:00 2001
From 491235cd2a7ab7a9eaff4d02718c37d657b78167 Mon Sep 17 00:00:00 2001
From: Iceee <andrew@opticgaming.tv>
Date: Wed, 2 Mar 2016 12:03:23 -0600
Subject: [PATCH] Stop updating flowing block if material has changed
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
index 62234a7c..3b47253a 100644
index 62234a7c9..3b47253a4 100644
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
@@ -90,6 +90,7 @@ public class BlockFlowing extends BlockFluids {
@ -17,5 +17,5 @@ index 62234a7c..3b47253a 100644
IBlockData iblockdata2 = world.getType(blockposition.down());
--
2.14.3
2.17.0

Datei anzeigen

@ -1,4 +1,4 @@
From dfbf1e7d43cafde4cfcd6a4c03e53d61bc454f06 Mon Sep 17 00:00:00 2001
From ebb2e432e50bb6758f584920396ae4ed8ef98b0e Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 12:20:52 -0600
Subject: [PATCH] Fast draining
@ -109,5 +109,5 @@ index 3b47253a4..3aaa19b2f 100644
+ // Paper end
}
--
2.14.3
2.17.0

Datei anzeigen

@ -1,4 +1,4 @@
From 39fb008250a9039f1547408fbd9769db26333787 Mon Sep 17 00:00:00 2001
From f764c07be09e378b2e3561779358108f37bb82f0 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 12:27:07 -0600
Subject: [PATCH] Configurable lava flow speed
@ -47,5 +47,5 @@ index f3eb2a797..d0265f960 100644
return this.e;
}
--
2.14.3
2.17.0

Datei anzeigen

@ -1,11 +1,11 @@
From 3a5c6b152a7a804921e9ff7f2057eb5c6f79a9e4 Mon Sep 17 00:00:00 2001
From b37938d4ce59d4ae17feb44e60dd1f8124c1a4d8 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 14:35:27 -0600
Subject: [PATCH] Add player view distance API
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 9829cdd89..5b0675718 100644
index dfaab774d..3058dfef0 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -66,6 +66,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@ -224,5 +224,5 @@ index 44d0db180..b2b707305 100644
private final Player.Spigot spigot = new Player.Spigot()
{
--
2.16.1
2.17.0

Datei anzeigen

@ -1,4 +1,4 @@
From f16a164dfccddfb47a36c363b71dd7788bcd2134 Mon Sep 17 00:00:00 2001
From 3205346921413de13db17a2fa51e33847237783c Mon Sep 17 00:00:00 2001
From: Sudzzy <originmc@outlook.com>
Date: Wed, 2 Mar 2016 14:48:03 -0600
Subject: [PATCH] Disable explosion knockback
@ -19,7 +19,7 @@ index b0b3033e7..afc13e851 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 756590ac0..05d1fc10d 100644
index d15cfdd76..2aaeac324 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -906,6 +906,7 @@ public abstract class EntityLiving extends Entity {
@ -70,5 +70,5 @@ index e7f0e84d4..e148901e5 100644
}
}
--
2.14.3
2.17.0