Skip to content

Commit

Permalink
Merge branch 'mysql-impl'
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
#	src/main/java/cn/lunadeer/dominion/Cache.java
  • Loading branch information
ColdeZhang committed Jun 23, 2024
2 parents a568d87 + 1787043 commit 9089d7a
Show file tree
Hide file tree
Showing 16 changed files with 748 additions and 576 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

## 功能介绍

- 支持 Postgresql 或 sqlite 存储数据;
- 支持 Postgresql、Mysql、Sqlite3 存储数据;
- 支持BlueMap卫星地图渲染;
- 支持为玩家单独设置特权;
- 支持设置领地管理员;
- 支持子领地;
- 采用 TUI 方式进行权限配置交互,简单快捷;
- 支持基础价格系统
- 支持经济系统(需要 Vault 前置)
- 领地区域可视化;
- 管理员可在游戏内使用TUI配置领地系统;

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>cn.lunadeer</groupId>
<artifactId>Dominion</artifactId>
<version>1.32.2-beta</version>
<version>1.33.4-beta</version>
<packaging>jar</packaging>

<name>Dominion</name>
Expand Down Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>cn.lunadeer</groupId>
<artifactId>MinecraftPluginUtils</artifactId>
<version>1.3.2-SNAPSHOT</version>
<version>1.3.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.BlueMap-Minecraft</groupId>
Expand Down
195 changes: 100 additions & 95 deletions src/main/java/cn/lunadeer/dominion/BlueMapConnect.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.lunadeer.dominion;

import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.minecraftpluginutils.Scheduler;
import cn.lunadeer.minecraftpluginutils.XLogger;
import com.flowpowered.math.vector.Vector2d;
import de.bluecolored.bluemap.api.BlueMapAPI;
Expand All @@ -17,112 +18,116 @@ public static void render() {
if (!Dominion.config.getBlueMap()) {
return;
}
try {
BlueMapAPI.getInstance().ifPresent(api -> {
Map<String, List<DominionDTO>> world_dominions = new HashMap<>();
for (DominionDTO dominion : Cache.instance.getDominions()) {
if (!world_dominions.containsKey(dominion.getWorld())) {
world_dominions.put(dominion.getWorld(), new ArrayList<>());
Scheduler.runTaskAsync(() -> {
try {
BlueMapAPI.getInstance().ifPresent(api -> {
Map<String, List<DominionDTO>> world_dominions = new HashMap<>();
for (DominionDTO dominion : Cache.instance.getDominions()) {
if (!world_dominions.containsKey(dominion.getWorld())) {
world_dominions.put(dominion.getWorld(), new ArrayList<>());
}
world_dominions.get(dominion.getWorld()).add(dominion);
}
world_dominions.get(dominion.getWorld()).add(dominion);
}
for (Map.Entry<String, List<DominionDTO>> d : world_dominions.entrySet()) {
api.getWorld(d.getKey()).ifPresent(world -> {
MarkerSet markerSet = MarkerSet.builder()
.label("Dominion")
.build();
for (Map.Entry<String, List<DominionDTO>> d : world_dominions.entrySet()) {
api.getWorld(d.getKey()).ifPresent(world -> {
MarkerSet markerSet = MarkerSet.builder()
.label("Dominion")
.build();

for (DominionDTO dominion : d.getValue()) {
Collection<Vector2d> vectors = new ArrayList<>();
vectors.add(new Vector2d(dominion.getX1() + 0.001, dominion.getZ1() + 0.001));
vectors.add(new Vector2d(dominion.getX2() - 0.001, dominion.getZ1() + 0.001));
vectors.add(new Vector2d(dominion.getX2() - 0.001, dominion.getZ2() - 0.001));
vectors.add(new Vector2d(dominion.getX1() + 0.001, dominion.getZ2() - 0.001));
Shape shape = new Shape(vectors);
double x = vectors.iterator().next().getX();
double z = vectors.iterator().next().getY();
double y = dominion.getY1();
for (DominionDTO dominion : d.getValue()) {
Collection<Vector2d> vectors = new ArrayList<>();
vectors.add(new Vector2d(dominion.getX1() + 0.001, dominion.getZ1() + 0.001));
vectors.add(new Vector2d(dominion.getX2() - 0.001, dominion.getZ1() + 0.001));
vectors.add(new Vector2d(dominion.getX2() - 0.001, dominion.getZ2() - 0.001));
vectors.add(new Vector2d(dominion.getX1() + 0.001, dominion.getZ2() - 0.001));
Shape shape = new Shape(vectors);
double x = vectors.iterator().next().getX();
double z = vectors.iterator().next().getY();
double y = dominion.getY1();

int r = dominion.getColorR();
int g = dominion.getColorG();
int b = dominion.getColorB();
int r = dominion.getColorR();
int g = dominion.getColorG();
int b = dominion.getColorB();

Color line = new Color(r, g, b, 0.8F);
Color fill = new Color(r, g, b, 0.2F);
ExtrudeMarker marker = ExtrudeMarker.builder()
.label(dominion.getName())
.position(x, y, z)
.shape(shape, dominion.getY1() + 0.001f, dominion.getY2() - 0.001f)
.lineColor(line)
.fillColor(fill)
.build();
markerSet.getMarkers()
.put(dominion.getName(), marker);
}
Color line = new Color(r, g, b, 0.8F);
Color fill = new Color(r, g, b, 0.2F);
ExtrudeMarker marker = ExtrudeMarker.builder()
.label(dominion.getName())
.position(x, y, z)
.shape(shape, dominion.getY1() + 0.001f, dominion.getY2() - 0.001f)
.lineColor(line)
.fillColor(fill)
.build();
markerSet.getMarkers()
.put(dominion.getName(), marker);
}

for (BlueMapMap map : world.getMaps()) {
map.getMarkerSets().put(d.getKey() + "-" + markerSet.getLabel(), markerSet);
}
});
}
});
} catch (NoClassDefFoundError e) {
XLogger.warn("无法连接 BlueMap 插件,如果你不打算使用卫星地图渲染建议前往配置文件关闭此功能以避免下方的报错。");
XLogger.err(e.getMessage());
}
for (BlueMapMap map : world.getMaps()) {
map.getMarkerSets().put(d.getKey() + "-" + markerSet.getLabel(), markerSet);
}
});
}
});
} catch (NoClassDefFoundError e) {
XLogger.warn("无法连接 BlueMap 插件,如果你不打算使用卫星地图渲染建议前往配置文件关闭此功能以避免下方的报错。");
XLogger.err(e.getMessage());
}
});
}

public static void renderMCA(Map<String, List<String>> mca_files) {
if (!Dominion.config.getBlueMap()) {
return;
}
try {
BlueMapAPI.getInstance().ifPresent(api -> {
for (String world : mca_files.keySet()) {
api.getWorld(world).ifPresent(bmWorld -> {
MarkerSet markerSet = MarkerSet.builder()
.label("MCA")
.defaultHidden(true)
.build();
for (String file : mca_files.get(world)) {
// r.-1.-1.mca
int mca_x = Integer.parseInt(file.split("\\.")[1]);
int mca_z = Integer.parseInt(file.split("\\.")[2]);
int world_x1 = mca_x * 512;
int world_x2 = (mca_x + 1) * 512;
int world_z1 = mca_z * 512;
int world_z2 = (mca_z + 1) * 512;
Collection<Vector2d> vectors = new ArrayList<>();
vectors.add(new Vector2d(world_x1 + 0.001, world_z1 + 0.001));
vectors.add(new Vector2d(world_x2 - 0.001, world_z1 + 0.001));
vectors.add(new Vector2d(world_x2 - 0.001, world_z2 - 0.001));
vectors.add(new Vector2d(world_x1 + 0.001, world_z2 - 0.001));
Shape shape = new Shape(vectors);
double x = vectors.iterator().next().getX();
double z = vectors.iterator().next().getY();
double y = -64;

Color line = new Color(0, 204, 0, 0.8F);
Color fill = new Color(0, 204, 0, 0.2F);
ExtrudeMarker marker = ExtrudeMarker.builder()
.label(file)
.position(x, y, z)
.shape(shape, -64, 320)
.lineColor(line)
.fillColor(fill)
Scheduler.runTaskAsync(() -> {
try {
BlueMapAPI.getInstance().ifPresent(api -> {
for (String world : mca_files.keySet()) {
api.getWorld(world).ifPresent(bmWorld -> {
MarkerSet markerSet = MarkerSet.builder()
.label("MCA")
.defaultHidden(true)
.build();
markerSet.getMarkers()
.put(file, marker);
}
for (BlueMapMap map : bmWorld.getMaps()) {
map.getMarkerSets().put(world + "-" + markerSet.getLabel(), markerSet);
}
});
}
});
} catch (NoClassDefFoundError e) {
XLogger.warn("无法连接 BlueMap 插件,如果你不打算使用卫星地图渲染建议前往配置文件关闭此功能以避免下方的报错。");
XLogger.err(e.getMessage());
}
for (String file : mca_files.get(world)) {
// r.-1.-1.mca
int mca_x = Integer.parseInt(file.split("\\.")[1]);
int mca_z = Integer.parseInt(file.split("\\.")[2]);
int world_x1 = mca_x * 512;
int world_x2 = (mca_x + 1) * 512;
int world_z1 = mca_z * 512;
int world_z2 = (mca_z + 1) * 512;
Collection<Vector2d> vectors = new ArrayList<>();
vectors.add(new Vector2d(world_x1 + 0.001, world_z1 + 0.001));
vectors.add(new Vector2d(world_x2 - 0.001, world_z1 + 0.001));
vectors.add(new Vector2d(world_x2 - 0.001, world_z2 - 0.001));
vectors.add(new Vector2d(world_x1 + 0.001, world_z2 - 0.001));
Shape shape = new Shape(vectors);
double x = vectors.iterator().next().getX();
double z = vectors.iterator().next().getY();
double y = -64;

Color line = new Color(0, 204, 0, 0.8F);
Color fill = new Color(0, 204, 0, 0.2F);
ExtrudeMarker marker = ExtrudeMarker.builder()
.label(file)
.position(x, y, z)
.shape(shape, -64, 320)
.lineColor(line)
.fillColor(fill)
.build();
markerSet.getMarkers()
.put(file, marker);
}
for (BlueMapMap map : bmWorld.getMaps()) {
map.getMarkerSets().put(world + "-" + markerSet.getLabel(), markerSet);
}
});
}
});
} catch (NoClassDefFoundError e) {
XLogger.warn("无法连接 BlueMap 插件,如果你不打算使用卫星地图渲染建议前往配置文件关闭此功能以避免下方的报错。");
XLogger.err(e.getMessage());
}
});
}
}
Loading

0 comments on commit 9089d7a

Please sign in to comment.