Merge remote-tracking branch 'origin/1.19' into 1.19
# Conflicts: # common/build.gradle # common/src/main/java/io/github/flemmli97/flan/claim/Claim.java # common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java
This commit is contained in:
commit
01f12e3efa
common
fabric/src/main/java/io/github/flemmli97/flan/fabric
forge/src/main/java/io/github/flemmli97/flan/forge
@ -7,6 +7,7 @@ configurations {
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven {
|
||||
name = "FTB"
|
||||
url = "https://maven.saps.dev/minecraft"
|
||||
@ -27,6 +28,7 @@ dependencies {
|
||||
modImplementation dynmap_fabric
|
||||
|
||||
modImplementation "dev.ftb.mods:ftb-chunks:${rootProject.ftb_chunks}"
|
||||
implementation 'com.github.BlueMap-Minecraft:BlueMapAPI:v2.2.1'
|
||||
}
|
||||
|
||||
architectury {
|
||||
|
@ -15,7 +15,6 @@ import io.github.flemmli97.flan.config.ConfigHandler;
|
||||
import io.github.flemmli97.flan.platform.ClaimPermissionCheck;
|
||||
import io.github.flemmli97.flan.platform.CrossPlatformStuff;
|
||||
import io.github.flemmli97.flan.platform.integration.dynmap.DynmapCalls;
|
||||
import io.github.flemmli97.flan.player.DisplayBox;
|
||||
import io.github.flemmli97.flan.player.LogoutTracker;
|
||||
import io.github.flemmli97.flan.player.PlayerClaimData;
|
||||
import net.minecraft.ChatFormatting;
|
||||
@ -167,7 +166,7 @@ public class Claim implements IPermissionContainer {
|
||||
public void setClaimName(String name) {
|
||||
this.claimName = name;
|
||||
this.setDirty(true);
|
||||
DynmapCalls.changeClaimName(this);
|
||||
WebmapCalls.changeClaimName(this);
|
||||
}
|
||||
|
||||
public UUID getOwner() {
|
||||
@ -581,20 +580,29 @@ public class Claim implements IPermissionContainer {
|
||||
this.setDirty(true);
|
||||
}
|
||||
|
||||
public void displayEnterTitle(ServerPlayer player) {
|
||||
if (this.enterTitle != null) {
|
||||
player.connection.send(new ClientboundSetTitleTextPacket(this.enterTitle));
|
||||
if (this.enterSubtitle != null)
|
||||
player.connection.send(new ClientboundSetSubtitleTextPacket(this.enterSubtitle));
|
||||
private void displayTitleMessage(ServerPlayer player, @Nullable Component title, @Nullable Component subtitle) {
|
||||
if (title == null) return;
|
||||
if (ConfigHandler.config.claimDisplayActionBar) {
|
||||
if (subtitle != null) {
|
||||
MutableComponent message = title.copy().append(Component.literal(" | ").setStyle(Style.EMPTY.withColor(ChatFormatting.WHITE))).append(subtitle);
|
||||
player.sendSystemMessage(message, ChatType.GAME_INFO);
|
||||
return;
|
||||
}
|
||||
player.sendSystemMessage(title, ChatType.GAME_INFO);
|
||||
return;
|
||||
}
|
||||
player.connection.send(new ClientboundSetTitleTextPacket(title));
|
||||
if (subtitle != null) {
|
||||
player.connection.send(new ClientboundSetSubtitleTextPacket(subtitle));
|
||||
}
|
||||
}
|
||||
|
||||
public void displayEnterTitle(ServerPlayer player) {
|
||||
displayTitleMessage(player, this.enterTitle, this.enterSubtitle);
|
||||
}
|
||||
|
||||
public void displayLeaveTitle(ServerPlayer player) {
|
||||
if (this.leaveTitle != null) {
|
||||
player.connection.send(new ClientboundSetTitleTextPacket(this.leaveTitle));
|
||||
if (this.leaveSubtitle != null)
|
||||
player.connection.send(new ClientboundSetSubtitleTextPacket(this.leaveSubtitle));
|
||||
}
|
||||
displayTitleMessage(player, this.leaveTitle, this.leaveSubtitle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,10 +14,8 @@ import io.github.flemmli97.flan.api.data.IPlayerData;
|
||||
import io.github.flemmli97.flan.api.permission.ClaimPermission;
|
||||
import io.github.flemmli97.flan.api.permission.PermissionRegistry;
|
||||
import io.github.flemmli97.flan.config.ConfigHandler;
|
||||
import io.github.flemmli97.flan.platform.integration.claiming.OtherClaimingModCheck;
|
||||
import io.github.flemmli97.flan.platform.integration.dynmap.DynmapCalls;
|
||||
import io.github.flemmli97.flan.platform.integration.permissions.PermissionNodeHandler;
|
||||
import io.github.flemmli97.flan.player.DisplayBox;
|
||||
import io.github.flemmli97.flan.player.EnumDisplayType;
|
||||
import io.github.flemmli97.flan.player.EnumEditMode;
|
||||
import io.github.flemmli97.flan.player.OfflinePlayerData;
|
||||
@ -159,7 +157,7 @@ public class ClaimStorage implements IPermissionStorage {
|
||||
claim.remove();
|
||||
claim.getOwnerPlayer().ifPresent(o -> PlayerClaimData.get(o).updateScoreboard());
|
||||
}
|
||||
DynmapCalls.removeMarker(claim);
|
||||
WebmapCalls.removeMarker(claim);
|
||||
return this.claimUUIDMap.remove(claim.getClaimID()) != null;
|
||||
}
|
||||
|
||||
@ -281,7 +279,7 @@ public class ClaimStorage implements IPermissionStorage {
|
||||
old.add(claim);
|
||||
return old;
|
||||
});
|
||||
DynmapCalls.addClaimMarker(claim);
|
||||
WebmapCalls.addClaimMarker(claim);
|
||||
}
|
||||
|
||||
public boolean transferOwner(Claim claim, ServerPlayer player, UUID newOwner) {
|
||||
@ -299,7 +297,7 @@ public class ClaimStorage implements IPermissionStorage {
|
||||
return old;
|
||||
});
|
||||
this.dirty.add(claim.getOwner());
|
||||
DynmapCalls.changeClaimOwner(claim);
|
||||
WebmapCalls.changeClaimOwner(claim);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -311,6 +309,10 @@ public class ClaimStorage implements IPermissionStorage {
|
||||
return ImmutableSet.copyOf(this.playerClaimMap.get(null));
|
||||
}
|
||||
|
||||
public Map<UUID, Set<Claim>> getClaims() {
|
||||
return this.playerClaimMap;
|
||||
}
|
||||
|
||||
public static int[] getChunkPos(Claim claim) {
|
||||
int[] dim = claim.getDimensions();
|
||||
int[] pos = new int[4];
|
||||
|
@ -45,6 +45,7 @@ public class Config {
|
||||
public Item inspectionItem = Items.STICK;
|
||||
|
||||
public int claimDisplayTime = 1000;
|
||||
public boolean claimDisplayActionBar = false;
|
||||
public int permissionLevel = 2;
|
||||
|
||||
public BuySellHandler buySellHandler = new BuySellHandler();
|
||||
@ -173,6 +174,7 @@ public class Config {
|
||||
if (obj.has("inspectionItem"))
|
||||
this.inspectionItem = CrossPlatformStuff.INSTANCE.registryItems().getFromId(new ResourceLocation((obj.get("inspectionItem").getAsString())));
|
||||
this.claimDisplayTime = ConfigHandler.fromJson(obj, "claimDisplayTime", this.claimDisplayTime);
|
||||
this.claimDisplayActionBar = ConfigHandler.fromJson(obj, "claimDisplayActionBar", this.claimDisplayActionBar);
|
||||
this.permissionLevel = ConfigHandler.fromJson(obj, "permissionLevel", this.permissionLevel);
|
||||
|
||||
this.ftbChunksCheck = ConfigHandler.fromJson(obj, "ftbChunksCheck", this.ftbChunksCheck);
|
||||
@ -273,6 +275,7 @@ public class Config {
|
||||
obj.addProperty("claimingItem", CrossPlatformStuff.INSTANCE.registryItems().getIDFrom(this.claimingItem).toString());
|
||||
obj.addProperty("inspectionItem", CrossPlatformStuff.INSTANCE.registryItems().getIDFrom(this.inspectionItem).toString());
|
||||
obj.addProperty("claimDisplayTime", this.claimDisplayTime);
|
||||
obj.addProperty("claimDisplayActionBar", this.claimDisplayActionBar);
|
||||
obj.addProperty("permissionLevel", this.permissionLevel);
|
||||
|
||||
obj.addProperty("ftbChunksCheck", this.ftbChunksCheck);
|
||||
|
@ -0,0 +1,118 @@
|
||||
package io.github.flemmli97.flan.platform.integration.webmap;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.api.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.markers.Marker;
|
||||
import de.bluecolored.bluemap.api.markers.MarkerSet;
|
||||
import de.bluecolored.bluemap.api.markers.ShapeMarker;
|
||||
import de.bluecolored.bluemap.api.math.Color;
|
||||
import de.bluecolored.bluemap.api.math.Shape;
|
||||
import io.github.flemmli97.flan.claim.Claim;
|
||||
import io.github.flemmli97.flan.claim.ClaimStorage;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BluemapIntegration {
|
||||
private static final String markerID = "flan.claims", markerLabel = "Claims";
|
||||
|
||||
public static void reg(MinecraftServer server) {
|
||||
BlueMapAPI.onEnable(api -> {
|
||||
for (ServerLevel level : server.getAllLevels()) {
|
||||
api.getWorld(level).ifPresent(world -> {
|
||||
world.getMaps().forEach(map -> {
|
||||
MarkerSet markerSet = MarkerSet.builder().label(markerLabel).build();
|
||||
map.getMarkerSets().put(markerID, markerSet);
|
||||
});
|
||||
});
|
||||
processClaims(level);
|
||||
}
|
||||
WebmapCalls.bluemapLoaded = true;
|
||||
});
|
||||
}
|
||||
|
||||
public static void processClaims(ServerLevel level) {
|
||||
ClaimStorage claimStorage = ClaimStorage.get(level);
|
||||
Map<UUID, Set<Claim>> claimMap = claimStorage.getClaims();
|
||||
claimMap.forEach((uuid, claims) -> {
|
||||
claims.forEach(BluemapIntegration::addClaimMarker);
|
||||
});
|
||||
}
|
||||
|
||||
public static void addClaimMarker(Claim claim) {
|
||||
BlueMapAPI.getInstance().flatMap(api -> api.getWorld(claim.getWorld())).ifPresent(world -> {
|
||||
for (BlueMapMap map : world.getMaps()) {
|
||||
MarkerSet markerSet = map.getMarkerSets().get(markerID);
|
||||
int[] dim = claim.getDimensions();
|
||||
ShapeMarker marker = ShapeMarker.builder()
|
||||
.label(claimLabel(claim))
|
||||
.depthTestEnabled(false)
|
||||
.shape(Shape.createRect(dim[0], dim[2], dim[1], dim[3]), claim.getWorld().getSeaLevel())
|
||||
.lineColor(new Color(lineColor(claim.isAdminClaim()), 0.8F))
|
||||
.lineWidth(3)
|
||||
.fillColor(new Color(fillColor(claim.isAdminClaim()), 0.2F))
|
||||
.build();
|
||||
markerSet.put(claim.getClaimID().toString(), marker);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void removeMarker(Claim claim) {
|
||||
BlueMapAPI.getInstance().flatMap(api -> api.getWorld(claim.getWorld())).ifPresent(world -> {
|
||||
for (BlueMapMap map : world.getMaps()) {
|
||||
MarkerSet markerSet = map.getMarkerSets().get(markerID);
|
||||
markerSet.remove(claim.getClaimID().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void changeClaimName(Claim claim) {
|
||||
BlueMapAPI.getInstance().flatMap(api -> api.getWorld(claim.getWorld())).ifPresent(world -> {
|
||||
for (BlueMapMap map : world.getMaps()) {
|
||||
MarkerSet markerSet = map.getMarkerSets().get(markerID);
|
||||
Marker marker = markerSet.get(claim.getClaimID().toString());
|
||||
marker.setLabel(claimLabel(claim));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void changeClaimOwner(Claim claim) {
|
||||
BlueMapAPI.getInstance().flatMap(api -> api.getWorld(claim.getWorld())).ifPresent(world -> {
|
||||
for (BlueMapMap map : world.getMaps()) {
|
||||
MarkerSet markerSet = map.getMarkerSets().get(markerID);
|
||||
Marker marker = markerSet.get(claim.getClaimID().toString());
|
||||
marker.setLabel(claimLabel(claim));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static int lineColor(boolean admin) {
|
||||
return admin ? 0xb50909 : 0xffa200;
|
||||
}
|
||||
|
||||
private static int fillColor(boolean admin) {
|
||||
return admin ? 0xff0000 : 0xe0e01d;
|
||||
}
|
||||
|
||||
private static String claimLabel(Claim claim) {
|
||||
String name = claim.getClaimName();
|
||||
if (claim.isAdminClaim()) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
return "Admin Claim";
|
||||
} else {
|
||||
return name + " - " + "Admin Claim";
|
||||
}
|
||||
}
|
||||
Optional<GameProfile> prof = claim.getWorld().getServer().getProfileCache().get(claim.getOwner());
|
||||
if (name == null || name.isEmpty()) {
|
||||
return prof.map(GameProfile::getName).orElse("UNKNOWN") + "'s Claim";
|
||||
} else {
|
||||
return name + " - " + prof.map(GameProfile::getName).orElse("UNKNOWN") + "'s Claim";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package io.github.flemmli97.flan.platform.integration.dynmap;
|
||||
package io.github.flemmli97.flan.platform.integration.webmap;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.github.flemmli97.flan.claim.Claim;
|
||||
@ -23,7 +23,7 @@ public class DynmapIntegration {
|
||||
public void apiEnabled(DynmapCommonAPI dynmapCommonAPI) {
|
||||
MarkerAPI markerAPI = dynmapCommonAPI.getMarkerAPI();
|
||||
markerSet = markerAPI.createMarkerSet(markerID, markerLabel, dynmapCommonAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||
DynmapCalls.dynmapLoaded = true;
|
||||
WebmapCalls.dynmapLoaded = true;
|
||||
}
|
||||
});
|
||||
}
|
@ -1,28 +1,37 @@
|
||||
package io.github.flemmli97.flan.platform.integration.dynmap;
|
||||
package io.github.flemmli97.flan.platform.integration.webmap;
|
||||
|
||||
import io.github.flemmli97.flan.claim.Claim;
|
||||
|
||||
public class DynmapCalls {
|
||||
public class WebmapCalls {
|
||||
|
||||
public static boolean dynmapLoaded;
|
||||
public static boolean bluemapLoaded;
|
||||
|
||||
public static void addClaimMarker(Claim claim) {
|
||||
if (dynmapLoaded)
|
||||
DynmapIntegration.addClaimMarker(claim);
|
||||
if (bluemapLoaded)
|
||||
BluemapIntegration.addClaimMarker(claim);
|
||||
}
|
||||
|
||||
public static void removeMarker(Claim claim) {
|
||||
if (dynmapLoaded)
|
||||
DynmapIntegration.removeMarker(claim);
|
||||
if (bluemapLoaded)
|
||||
BluemapIntegration.removeMarker(claim);
|
||||
}
|
||||
|
||||
public static void changeClaimName(Claim claim) {
|
||||
if (dynmapLoaded)
|
||||
DynmapIntegration.changeClaimName(claim);
|
||||
if (bluemapLoaded)
|
||||
BluemapIntegration.changeClaimName(claim);
|
||||
}
|
||||
|
||||
public static void changeClaimOwner(Claim claim) {
|
||||
if (dynmapLoaded)
|
||||
DynmapIntegration.changeClaimOwner(claim);
|
||||
if (bluemapLoaded)
|
||||
BluemapIntegration.changeClaimOwner(claim);
|
||||
}
|
||||
}
|
@ -9,7 +9,8 @@ import io.github.flemmli97.flan.event.ItemInteractEvents;
|
||||
import io.github.flemmli97.flan.event.PlayerEvents;
|
||||
import io.github.flemmli97.flan.event.WorldEvents;
|
||||
import io.github.flemmli97.flan.fabric.platform.integration.playerability.PlayerAbilityEvents;
|
||||
import io.github.flemmli97.flan.platform.integration.dynmap.DynmapIntegration;
|
||||
import io.github.flemmli97.flan.platform.integration.webmap.BluemapIntegration;
|
||||
import io.github.flemmli97.flan.platform.integration.webmap.DynmapIntegration;
|
||||
import io.github.flemmli97.flan.player.PlayerDataHandler;
|
||||
import io.github.flemmli97.flan.scoreboard.ClaimCriterias;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
@ -76,6 +77,8 @@ public class FlanFabric implements ModInitializer {
|
||||
public static void serverLoad(MinecraftServer server) {
|
||||
Flan.lockRegistry(server);
|
||||
ConfigHandler.serverLoad(server);
|
||||
if (FabricLoader.getInstance().isModLoaded("bluemap"))
|
||||
BluemapIntegration.reg(server);
|
||||
}
|
||||
|
||||
public static void serverFinishLoad(MinecraftServer server) {
|
||||
|
@ -6,7 +6,7 @@ import io.github.flemmli97.flan.forge.forgeevent.EntityInteractEventsForge;
|
||||
import io.github.flemmli97.flan.forge.forgeevent.ItemInteractEventsForge;
|
||||
import io.github.flemmli97.flan.forge.forgeevent.ServerEvents;
|
||||
import io.github.flemmli97.flan.forge.forgeevent.WorldEventsForge;
|
||||
import io.github.flemmli97.flan.platform.integration.dynmap.DynmapIntegration;
|
||||
import io.github.flemmli97.flan.platform.integration.webmap.DynmapIntegration;
|
||||
import io.github.flemmli97.flan.scoreboard.ClaimCriterias;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
|
@ -4,6 +4,7 @@ import io.github.flemmli97.flan.Flan;
|
||||
import io.github.flemmli97.flan.commands.CommandClaim;
|
||||
import io.github.flemmli97.flan.config.ConfigHandler;
|
||||
import io.github.flemmli97.flan.event.PlayerEvents;
|
||||
import io.github.flemmli97.flan.platform.integration.webmap.BluemapIntegration;
|
||||
import io.github.flemmli97.flan.player.LogoutTracker;
|
||||
import io.github.flemmli97.flan.player.PlayerDataHandler;
|
||||
import net.minecraft.world.level.Level;
|
||||
@ -12,12 +13,16 @@ import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.server.ServerAboutToStartEvent;
|
||||
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
public class ServerEvents {
|
||||
|
||||
public static void serverStart(ServerAboutToStartEvent event) {
|
||||
Flan.lockRegistry(event.getServer());
|
||||
ConfigHandler.serverLoad(event.getServer());
|
||||
|
||||
if (ModList.get().isLoaded("bluemap"))
|
||||
BluemapIntegration.reg(event.getServer());
|
||||
}
|
||||
|
||||
public static void serverFinishLoad(ServerStartedEvent event) {
|
||||
|
Loading…
Reference in New Issue
Block a user