Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
e38eceb42a
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Spigot Changes: a19903d2 SPIGOT-520: Add option to disable player data saving
128 Zeilen
5.5 KiB
Diff
128 Zeilen
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: kickash32 <kickash32@gmail.com>
|
|
Date: Mon, 3 Jun 2019 02:02:39 -0400
|
|
Subject: [PATCH] Implement alternative item-despawn-rate
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
index a24bace235f72e15af84f6d64a1c7fa4334a57c0..53ededbb615ec608e91ee87f46301a3c2964a7a3 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -1,10 +1,15 @@
|
|
package com.destroystokyo.paper;
|
|
|
|
import java.util.Arrays;
|
|
+import java.util.EnumMap;
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
+import java.util.Map;
|
|
|
|
import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
|
|
import org.bukkit.Bukkit;
|
|
+import org.bukkit.Material;
|
|
+import org.bukkit.configuration.ConfigurationSection;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
import org.spigotmc.SpigotWorldConfig;
|
|
|
|
@@ -500,4 +505,52 @@ public class PaperWorldConfig {
|
|
private void disableRelativeProjectileVelocity() {
|
|
disableRelativeProjectileVelocity = getBoolean("game-mechanics.disable-relative-projectile-velocity", false);
|
|
}
|
|
+
|
|
+ public boolean altItemDespawnRateEnabled;
|
|
+ public Map<Material, Integer> altItemDespawnRateMap;
|
|
+ private void altItemDespawnRate() {
|
|
+ String path = "alt-item-despawn-rate";
|
|
+
|
|
+ altItemDespawnRateEnabled = getBoolean(path + ".enabled", false);
|
|
+
|
|
+ Map<Material, Integer> altItemDespawnRateMapDefault = new EnumMap<>(Material.class);
|
|
+ altItemDespawnRateMapDefault.put(Material.COBBLESTONE, 300);
|
|
+ for (Material key : altItemDespawnRateMapDefault.keySet()) {
|
|
+ config.addDefault("world-settings.default." + path + ".items." + key, altItemDespawnRateMapDefault.get(key));
|
|
+ }
|
|
+
|
|
+ Map<String, Integer> rawMap = new HashMap<>();
|
|
+ try {
|
|
+ ConfigurationSection mapSection = config.getConfigurationSection("world-settings." + worldName + "." + path + ".items");
|
|
+ if (mapSection == null) {
|
|
+ mapSection = config.getConfigurationSection("world-settings.default." + path + ".items");
|
|
+ }
|
|
+ for (String key : mapSection.getKeys(false)) {
|
|
+ int val = mapSection.getInt(key);
|
|
+ rawMap.put(key, val);
|
|
+ }
|
|
+ }
|
|
+ catch (Exception e) {
|
|
+ logError("alt-item-despawn-rate was malformatted");
|
|
+ altItemDespawnRateEnabled = false;
|
|
+ }
|
|
+
|
|
+ altItemDespawnRateMap = new EnumMap<>(Material.class);
|
|
+ if (!altItemDespawnRateEnabled) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ for(String key : rawMap.keySet()) {
|
|
+ try {
|
|
+ altItemDespawnRateMap.put(Material.valueOf(key), rawMap.get(key));
|
|
+ } catch (Exception e) {
|
|
+ logError("Could not add item " + key + " to altItemDespawnRateMap: " + e.getMessage());
|
|
+ }
|
|
+ }
|
|
+ if(altItemDespawnRateEnabled) {
|
|
+ for(Material key : altItemDespawnRateMap.keySet()) {
|
|
+ log("Alternative item despawn rate of " + key + ": " + altItemDespawnRateMap.get(key));
|
|
+ }
|
|
+ }
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
|
|
index 765eb57ae017acf6cc800f86d0160ca5e3b7b230..b832c8df8ee08d7e00c5d7763baa51ff37259880 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityItem.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityItem.java
|
|
@@ -6,6 +6,7 @@ import java.util.Objects;
|
|
import java.util.UUID;
|
|
import javax.annotation.Nullable;
|
|
// CraftBukkit start
|
|
+import org.bukkit.Material; // Paper
|
|
import org.bukkit.event.entity.EntityPickupItemEvent;
|
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
|
// CraftBukkit end
|
|
@@ -134,7 +135,7 @@ public class EntityItem extends Entity {
|
|
}
|
|
}
|
|
|
|
- if (!this.world.isClientSide && this.age >= world.spigotConfig.itemDespawnRate) { // Spigot
|
|
+ if (!this.world.isClientSide && this.age >= this.getDespawnRate()) { // Spigot // Paper
|
|
// CraftBukkit start - fire ItemDespawnEvent
|
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
|
this.age = 0;
|
|
@@ -158,7 +159,7 @@ public class EntityItem extends Entity {
|
|
this.lastTick = MinecraftServer.currentTick;
|
|
// CraftBukkit end
|
|
|
|
- if (!this.world.isClientSide && this.age >= world.spigotConfig.itemDespawnRate) { // Spigot
|
|
+ if (!this.world.isClientSide && this.age >= this.getDespawnRate()) { // Spigot // Paper
|
|
// CraftBukkit start - fire ItemDespawnEvent
|
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
|
this.age = 0;
|
|
@@ -508,9 +509,16 @@ public class EntityItem extends Entity {
|
|
|
|
public void s() {
|
|
this.o();
|
|
- this.age = world.spigotConfig.itemDespawnRate - 1; // Spigot
|
|
+ this.age = this.getDespawnRate() - 1; // Spigot // Paper
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public int getDespawnRate(){
|
|
+ Material material = this.getItemStack().getBukkitStack().getType();
|
|
+ return world.paperConfig.altItemDespawnRateMap.getOrDefault(material, world.spigotConfig.itemDespawnRate);
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public Packet<?> P() {
|
|
return new PacketPlayOutSpawnEntity(this);
|