Skip to content

Commit

Permalink
initial port to 1.18+
Browse files Browse the repository at this point in the history
  • Loading branch information
Le4nderS committed Aug 31, 2023
1 parent 3d2be35 commit d5cf433
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 24 deletions.
34 changes: 21 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@
</build>

<repositories>
<repository>
<id>papermc-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
Expand All @@ -94,21 +90,35 @@
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<repository>
<id>nachwahl-repo</id>
<url>https://maven.nachwahl.dev/</url>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.intellectualsites.bom</groupId>
<artifactId>bom-1.18.x</artifactId>
<version>1.24</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.socket</groupId>
<artifactId>socket.io-client</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -128,11 +138,9 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>6.1.9</version>
<groupId>com.fastasyncworldedit</groupId>
<artifactId>FastAsyncWorldEdit-Bukkit</artifactId>
<scope>provided</scope>
</dependency>

</dependencies>
</project>
32 changes: 21 additions & 11 deletions src/main/java/dev/nachwahl/btemap/commands/MapCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
import co.aikar.commands.BaseCommand;
import co.aikar.commands.CommandHelp;
import co.aikar.commands.annotation.*;
import co.aikar.util.Counter;
import com.fastasyncworldedit.core.function.mask.AirMask;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.function.block.Counter;

import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.util.Countable;
import dev.nachwahl.btemap.BTEMap;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;


import javax.xml.transform.Result;
import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -101,7 +110,7 @@ public void onCreate(CommandSender sender){
sender.sendMessage("§b§lBTEG §7» §cPlease select a region via WorldEdit first.");
return;
}
List<BlockVector2D> poly = null;
List<BlockVector2> poly = null;
try {
poly = region.polygonize(50);
} catch (IllegalArgumentException e) {
Expand All @@ -113,7 +122,7 @@ public void onCreate(CommandSender sender){


String coords = "[";
for (BlockVector2D vector2D : poly) {
for (BlockVector2 vector2D : poly) {
System.out.println(BTEMap.toGeo(vector2D.getBlockX(), vector2D.getBlockZ())[1] + ", " + BTEMap.toGeo(vector2D.getBlockX(), vector2D.getBlockZ())[0]);
System.out.println(Arrays.toString(BTEMap.toGeo(vector2D.getBlockX(), vector2D.getBlockZ())));
lat = BTEMap.toGeo(vector2D.getBlockX(), vector2D.getBlockZ())[1];
Expand Down Expand Up @@ -156,7 +165,7 @@ public void onCreate(CommandSender sender){
sm.getRegionSelector(WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getSelectionWorld()).clear();

try {
region.contract(new Vector().setY(region.getHeight()-1));
region.contract(Vector3.at(0, region.getHeight()-1, 0).toBlockPoint());
} catch (RegionOperationException e) {
e.printStackTrace();
}
Expand All @@ -166,9 +175,10 @@ public void onCreate(CommandSender sender){
String finalCity = city;
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
UUID uuid = UUID.randomUUID();
Counter counter = new Counter();
RegionVisitor visitor = new RegionVisitor(finalRegion, counter);
Operations.completeBlindly(visitor);

// not sure if this is the right way to do it
int counter = WorldEdit.getInstance().newEditSessionBuilder().build().countBlocks(finalRegion, new AirMask(finalRegion.getWorld()));

try {
PreparedStatement checkUserPs = plugin.getSqlConnector().getConnection().prepareStatement("SELECT * FROM User WHERE minecraftUUID = ?");
checkUserPs.setString(1, player.getUniqueId().toString());
Expand All @@ -182,7 +192,7 @@ public void onCreate(CommandSender sender){
ps.setString(4, player.getUniqueId().toString());
ps.setString(5,finalCoords);
ps.setString(6, finalCity);
ps.setInt(7, counter.getCount());
ps.setInt(7, counter);
ps.setString(8, checkUserRs.getString("id"));
ps.executeUpdate();
} else {
Expand All @@ -193,7 +203,7 @@ public void onCreate(CommandSender sender){
ps.setString(4, player.getUniqueId().toString());
ps.setString(5,finalCoords);
ps.setString(6, finalCity);
ps.setInt(7, counter.getCount());
ps.setInt(7, counter);
ps.executeUpdate();
}

Expand Down

0 comments on commit d5cf433

Please sign in to comment.