Author SHA1 Message Date
besiece 0d36b3039c Add documentation for Paper Anti-Xray configuration in README 2026-11-08 13:54:46 +01:00
4 changed files with 29 additions and 91 deletions

No files matched your search

+29
View File
@@ -1,3 +1,32 @@
# Chatcoloring
Der Spieler benötigt das Recht "chatcolor" damit dessen Namen blau im Chat angezeigt wird.
# Server Configuration
## Paper Anti-Xray
Enable Paper's built-in Anti-Xray protection in the Nether to prevent players from locating Ancient Debris through lava using transparent lava resource packs.
**File:** `world/dimensions/minecraft/the_nether/paper-world.yml`
Under `anticheat.anti-xray`, configure:
```yaml
anticheat:
anti-xray:
enabled: true
engine-mode: 1
hidden-blocks:
- ancient_debris
- nether_gold_ore
- nether_quartz_ore
lava-obscures: true
max-block-height: 128
update-radius: 2
use-permission: false
```
Restart the server to apply the changes.
**Tested:** Ancient Debris hidden behind lava is no longer visible when using a transparent lava resource pack.
@@ -1,32 +0,0 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.wanderingTrader;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
import java.util.Objects;
import java.util.function.Supplier;
record TraderOffer(Supplier<ItemStack> resultFactory, int emeraldPrice, int maxUses, double chance) {
TraderOffer {
Objects.requireNonNull(resultFactory, "resultFactory");
if(emeraldPrice < 1 || emeraldPrice > 64)
throw new IllegalArgumentException("emeraldPrice must be between 1 and 64");
if(maxUses < 1)
throw new IllegalArgumentException("maxUses must be positive");
if(!Double.isFinite(chance) || chance < 0 || chance > 1)
throw new IllegalArgumentException("chance must be finite and between 0 and 1");
}
static TraderOffer offer(Material material, int emeraldPrice, int maxUses, double chance) {
Objects.requireNonNull(material, "material");
return new TraderOffer(() -> new ItemStack(material), emeraldPrice, maxUses, chance);
}
MerchantRecipe createRecipe() {
ItemStack result = Objects.requireNonNull(this.resultFactory.get(), "resultFactory result").clone();
MerchantRecipe recipe = new MerchantRecipe(result, 0, this.maxUses, false, 0, 0f);
recipe.addIngredient(new ItemStack(Material.EMERALD, this.emeraldPrice));
return recipe;
}
}
@@ -1,19 +0,0 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.wanderingTrader;
import eu.mhsl.craftattack.spawn.core.Main;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import org.bukkit.Bukkit;
import org.bukkit.entity.WanderingTrader;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.CreatureSpawnEvent;
class WanderingTraderSpawnListener extends ApplianceListener<WanderingTraderTrades> {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSpawn(CreatureSpawnEvent event) {
if(!(event.getEntity() instanceof WanderingTrader trader)) return;
// Add custom trades on the next tick, after the spawn has finished.
Bukkit.getScheduler().runTask(Main.instance(), () -> this.getAppliance().addTrades(trader));
}
}
@@ -1,40 +0,0 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.wanderingTrader;
import eu.mhsl.craftattack.spawn.core.Main;
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.WanderingTrader;
import org.bukkit.event.Listener;
import org.bukkit.inventory.MerchantRecipe;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
public class WanderingTraderTrades extends Appliance {
private final NamespacedKey appliedKey = new NamespacedKey(Main.instance(), "wandering_trader_trades_applied");
private final List<TraderOffer> additionalTrades = List.of(
TraderOffer.offer(Material.HEART_OF_THE_SEA, 32, 1, 0.5)
);
void addTrades(WanderingTrader trader) {
if(!trader.isValid() || trader.isDead()) return;
if(trader.getPersistentDataContainer().has(this.appliedKey, PersistentDataType.BYTE)) return;
List<MerchantRecipe> recipes = new ArrayList<>(trader.getRecipes());
this.additionalTrades.forEach(offer -> {
if(ThreadLocalRandom.current().nextDouble() < offer.chance()) recipes.add(offer.createRecipe());
});
trader.setRecipes(recipes);
// Mark this trader as having had custom trades applied.
trader.getPersistentDataContainer().set(this.appliedKey, PersistentDataType.BYTE, (byte) 1);
}
@Override
protected @NotNull List<Listener> listeners() {
return List.of(new WanderingTraderSpawnListener());
}
}