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:
Ursprung
9382958959
Commit
ca7ef8266d
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren