geforkt von Mirrors/AxiomPaperPlugin
Implement whitelist-world-regex and blacklist-world-regex config options
Dieser Commit ist enthalten in:
Ursprung
a76aaba3d0
Commit
eb1a1cd9cd
@ -2,6 +2,7 @@ package com.moulberry.axiom;
|
|||||||
|
|
||||||
import com.moulberry.axiom.buffer.CompressedBlockEntity;
|
import com.moulberry.axiom.buffer.CompressedBlockEntity;
|
||||||
import com.moulberry.axiom.event.AxiomCreateWorldPropertiesEvent;
|
import com.moulberry.axiom.event.AxiomCreateWorldPropertiesEvent;
|
||||||
|
import com.moulberry.axiom.event.AxiomModifyWorldEvent;
|
||||||
import com.moulberry.axiom.packet.*;
|
import com.moulberry.axiom.packet.*;
|
||||||
import com.moulberry.axiom.world_properties.server.ServerWorldPropertiesRegistry;
|
import com.moulberry.axiom.world_properties.server.ServerWorldPropertiesRegistry;
|
||||||
import com.moulberry.axiom.world_properties.server.ServerWorldProperty;
|
import com.moulberry.axiom.world_properties.server.ServerWorldProperty;
|
||||||
@ -175,6 +176,22 @@ public class AxiomPaper extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canModifyWorld(Player player, World world) {
|
||||||
|
String whitelist = this.configuration.getString("whitelist-world-regex");
|
||||||
|
if (whitelist != null && !world.getName().matches(whitelist)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String blacklist = this.configuration.getString("blacklist-world-regex");
|
||||||
|
if (blacklist != null && world.getName().matches(blacklist)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AxiomModifyWorldEvent modifyWorldEvent = new AxiomModifyWorldEvent(player, world);
|
||||||
|
Bukkit.getPluginManager().callEvent(modifyWorldEvent);
|
||||||
|
return !modifyWorldEvent.isCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFailMove(PlayerFailMoveEvent event) {
|
public void onFailMove(PlayerFailMoveEvent event) {
|
||||||
if (event.getPlayer().hasPermission("axiom.*")) {
|
if (event.getPlayer().hasPermission("axiom.*")) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.moulberry.axiom.event;
|
package com.moulberry.axiom.event;
|
||||||
|
|
||||||
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
|
@ -51,10 +51,7 @@ public class RequestChunkDataPacketListener implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call AxiomModifyWorldEvent event
|
if (!this.plugin.canModifyWorld(bukkitPlayer, bukkitPlayer.getWorld())) {
|
||||||
AxiomModifyWorldEvent modifyWorldEvent = new AxiomModifyWorldEvent(bukkitPlayer, bukkitPlayer.getWorld());
|
|
||||||
Bukkit.getPluginManager().callEvent(modifyWorldEvent);
|
|
||||||
if (modifyWorldEvent.isCancelled()) {
|
|
||||||
sendEmptyResponse(player, id);
|
sendEmptyResponse(player, id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -96,10 +96,9 @@ public class SetBlockBufferPacketListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call AxiomModifyWorldEvent event
|
if (!this.plugin.canModifyWorld(player.getBukkitEntity(), world.getWorld())) {
|
||||||
AxiomModifyWorldEvent modifyWorldEvent = new AxiomModifyWorldEvent(player.getBukkitEntity(), world.getWorld());
|
return;
|
||||||
Bukkit.getPluginManager().callEvent(modifyWorldEvent);
|
}
|
||||||
if (modifyWorldEvent.isCancelled()) return;
|
|
||||||
|
|
||||||
// Allowed, apply buffer
|
// Allowed, apply buffer
|
||||||
BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos();
|
BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos();
|
||||||
@ -257,10 +256,9 @@ public class SetBlockBufferPacketListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call AxiomModifyWorldEvent event
|
if (!this.plugin.canModifyWorld(player.getBukkitEntity(), world.getWorld())) {
|
||||||
AxiomModifyWorldEvent modifyWorldEvent = new AxiomModifyWorldEvent(player.getBukkitEntity(), world.getWorld());
|
return;
|
||||||
Bukkit.getPluginManager().callEvent(modifyWorldEvent);
|
}
|
||||||
if (modifyWorldEvent.isCancelled()) return;
|
|
||||||
|
|
||||||
Set<LevelChunk> changedChunks = new HashSet<>();
|
Set<LevelChunk> changedChunks = new HashSet<>();
|
||||||
|
|
||||||
|
@ -65,10 +65,9 @@ public class SetBlockPacketListener implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if player is allowed to modify this world
|
if (!this.plugin.canModifyWorld(bukkitPlayer, bukkitPlayer.getWorld())) {
|
||||||
AxiomModifyWorldEvent modifyWorldEvent = new AxiomModifyWorldEvent(bukkitPlayer, bukkitPlayer.getWorld());
|
return;
|
||||||
Bukkit.getPluginManager().callEvent(modifyWorldEvent);
|
}
|
||||||
if (modifyWorldEvent.isCancelled()) return;
|
|
||||||
|
|
||||||
// Read packet
|
// Read packet
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
|
||||||
|
@ -40,9 +40,9 @@ public class SetTimePacketListener implements PluginMessageListener {
|
|||||||
if (!level.dimension().equals(key)) return;
|
if (!level.dimension().equals(key)) return;
|
||||||
|
|
||||||
// Call modify world
|
// Call modify world
|
||||||
AxiomModifyWorldEvent modifyWorldEvent = new AxiomModifyWorldEvent(player, player.getWorld());
|
if (!this.plugin.canModifyWorld(player, player.getWorld())) {
|
||||||
Bukkit.getPluginManager().callEvent(modifyWorldEvent);
|
return;
|
||||||
if (modifyWorldEvent.isCancelled()) return;
|
}
|
||||||
|
|
||||||
// Call time change event
|
// Call time change event
|
||||||
AxiomTimeChangeEvent timeChangeEvent = new AxiomTimeChangeEvent(player, time, freezeTime);
|
AxiomTimeChangeEvent timeChangeEvent = new AxiomTimeChangeEvent(player, time, freezeTime);
|
||||||
|
@ -20,6 +20,14 @@ unsupported-axiom-version: "kick"
|
|||||||
# Maximum packet size. Must not be less than 32767
|
# Maximum packet size. Must not be less than 32767
|
||||||
max-block-buffer-packet-size: 0x100000
|
max-block-buffer-packet-size: 0x100000
|
||||||
|
|
||||||
|
# Regex for whitelisting worlds
|
||||||
|
# The world can only be modified if the regex matches the world's name
|
||||||
|
whitelist-world-regex: null
|
||||||
|
|
||||||
|
# Regex for blacklisting worlds
|
||||||
|
# If the regex matches the world's name, the world can't be modified
|
||||||
|
blacklist-world-regex: null
|
||||||
|
|
||||||
# Toggles for individual packet handlers. May break certain features
|
# Toggles for individual packet handlers. May break certain features
|
||||||
packet-handlers:
|
packet-handlers:
|
||||||
hello: true
|
hello: true
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren