3
0
Mirror von https://github.com/Moulberry/AxiomPaperPlugin.git synchronisiert 2024-11-08 17:40:04 +01:00

PlotSquared: Don't allow changing time of Plot Worlds

Dieser Commit ist enthalten in:
Moulberry 2023-11-09 17:42:35 +08:00
Ursprung 9382958959
Commit ca7ef8266d
3 geänderte Dateien mit 38 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -2,6 +2,7 @@ package com.moulberry.axiom.integration.plotsquared;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -22,4 +23,11 @@ public class PlotSquaredIntegration {
return PlotSquaredIntegrationImpl.canPlaceBlock(player, loc);
}
public static boolean isPlotWorld(World world) {
if (!Bukkit.getPluginManager().isPluginEnabled("PlotSquared")) {
return true;
}
return PlotSquaredIntegrationImpl.isPlotWorld(world);
}
}

Datei anzeigen

@ -2,6 +2,7 @@ package com.moulberry.axiom.integration.plotsquared;
import com.plotsquared.bukkit.player.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.permissions.Permission;
@ -12,11 +13,12 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.WeakHashMap;
/*
* PlotSquared, a land and world management plugin for Minecraft.
@ -114,4 +116,25 @@ public class PlotSquaredIntegrationImpl {
return pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_ROAD, true);
}
private static final WeakHashMap<World, Boolean> plotWorldCache = new WeakHashMap<>();
static boolean isPlotWorld(World world) {
if (plotWorldCache.containsKey(world)) {
return plotWorldCache.get(world);
}
boolean isPlotWorld = false;
String worldName = world.getName();
for (String plotWorld : PlotSquared.get().getPlotAreaManager().getAllWorlds()) {
if (plotWorld.equals(worldName)) {
isPlotWorld = true;
break;
}
}
plotWorldCache.put(world, isPlotWorld);
return isPlotWorld;
}
}

Datei anzeigen

@ -3,6 +3,7 @@ package com.moulberry.axiom.packet;
import com.moulberry.axiom.AxiomPaper;
import com.moulberry.axiom.event.AxiomModifyWorldEvent;
import com.moulberry.axiom.event.AxiomTimeChangeEvent;
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
import io.netty.buffer.Unpooled;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.FriendlyByteBuf;
@ -44,6 +45,11 @@ public class SetTimePacketListener implements PluginMessageListener {
return;
}
// Don't allow on plot worlds
if (PlotSquaredIntegration.isPlotWorld(player.getWorld())) {
return;
}
// Call time change event
AxiomTimeChangeEvent timeChangeEvent = new AxiomTimeChangeEvent(player, time, freezeTime);
Bukkit.getPluginManager().callEvent(timeChangeEvent);