Skip to content

Commit

Permalink
Feature/paper plugin 1 21 (#23)
Browse files Browse the repository at this point in the history
* T+- java 21 test, using custom java 21 t-- dependency and paper-plugin.yml.

* Java 21 in compiler/

---------

Co-authored-by: ELgamer <[email protected]>
  • Loading branch information
Le4nderS and LM-Wolfert authored Aug 7, 2024
1 parent 308d273 commit 58f9514
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 155 deletions.
59 changes: 29 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.btegermany</groupId>
<artifactId>terraplusminus</artifactId>
<version>1.3.3</version>
<version>1.4.0</version>
<packaging>jar</packaging>

<name>Terraplusminus</name>
Expand All @@ -25,8 +25,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>14</source>
<target>14</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -55,13 +55,9 @@
</build>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
Expand All @@ -87,25 +83,40 @@

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.7</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>com.github.SmylerMC</groupId>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>com.github.BTEUK</groupId>
<artifactId>terraminusminus</artifactId>
<version>feature~bukkit-5907790da3-1</version>
<version>22449a34bf</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
<version>33.2.1-jre</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -117,16 +128,10 @@
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>4.1.72.Final</version>
<version>4.1.111.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -140,12 +145,6 @@
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.daporkchop.lib</groupId>
<artifactId>common</artifactId>
Expand Down
29 changes: 22 additions & 7 deletions src/main/java/de/btegermany/terraplusminus/Terraplusminus.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.btegermany.terraplusminus;


import com.mojang.brigadier.Command;
import de.btegermany.terraplusminus.commands.OffsetCommand;
import de.btegermany.terraplusminus.commands.TpllCommand;
import de.btegermany.terraplusminus.commands.WhereCommand;
Expand All @@ -12,18 +13,26 @@
import de.btegermany.terraplusminus.utils.FileBuilder;
import de.btegermany.terraplusminus.utils.LinkedWorld;
import de.btegermany.terraplusminus.utils.PlayerHashMapManagement;
import io.papermc.paper.command.brigadier.Commands;
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import net.buildtheearth.terraminusminus.TerraConfig;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;

import java.io.*;
import java.util.List;
import java.util.logging.Level;

public final class Terraplusminus extends JavaPlugin implements Listener {
Expand All @@ -36,15 +45,16 @@ public void onEnable() {
PluginDescriptionFile pdf = this.getDescription();
String pluginVersion = pdf.getVersion();

Bukkit.getLogger().log(Level.INFO, "\n╭━━━━╮\n" +
getLogger().log(Level.INFO, "\n╭━━━━╮\n" +
"┃╭╮╭╮┃\n" +
"╰╯┃┃┣┻━┳━┳━┳━━╮╭╮\n" +
"╱╱┃┃┃┃━┫╭┫╭┫╭╮┣╯╰┳━━╮\n" +
"╱╱┃┃┃┃━┫┃┃┃┃╭╮┣╮╭┻━━╯\n" +
"╱╱╰╯╰━━┻╯╰╯╰╯╰╯╰╯\n" +
"Version: " + pluginVersion);

// Config ------------------
// Config ------------------]
ConfigurationSerialization.registerClass(ConfigurationSerializable.class);
this.saveDefaultConfig();
config = getConfig();
this.updateConfig();
Expand Down Expand Up @@ -81,11 +91,7 @@ public void onEnable() {

TerraConfig.reducedConsoleMessages = Terraplusminus.config.getBoolean("reduced_console_messages"); // Disables console log of fetching data

// Registering commands
getCommand("tpll").setExecutor(new TpllCommand());
getCommand("where").setExecutor(new WhereCommand());
getCommand("offset").setExecutor(new OffsetCommand());
// --------------------------
registerCommands();

Bukkit.getLogger().log(Level.INFO, "[T+-] Terraplusminus successfully enabled");
}
Expand Down Expand Up @@ -245,4 +251,13 @@ private void updateConfig() {
}
}

private void registerCommands() {
LifecycleEventManager<Plugin> manager = this.getLifecycleManager();
manager.registerEventHandler(LifecycleEvents.COMMANDS, event -> {
final Commands commands = event.registrar();
commands.register("tpll", "Teleports you to longitude and latitude", List.of("tpc"), new TpllCommand());
commands.register("where", "Gives you the longitude and latitude of your minecraft coordinates", new WhereCommand());
commands.register("offset", "Displays the x,y and z offset of your world", new OffsetCommand());
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@

import de.btegermany.terraplusminus.Terraplusminus;
import de.btegermany.terraplusminus.utils.ConfigurationHelper;
import io.papermc.paper.command.brigadier.BasicCommand;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class OffsetCommand implements CommandExecutor {
public class OffsetCommand implements BasicCommand {
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
if (!command.getName().equalsIgnoreCase("offset")) {
return true;
}
Player player = (Player) commandSender;
if (!player.hasPermission("t+-.offset")) {
player.sendMessage(Terraplusminus.config.getString("prefix") + "§7No permission for /offset");
return true;
}
player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Offsets:");
player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | X: §8" + Terraplusminus.config.getInt("terrain_offset.x"));

if (!Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE") || !Terraplusminus.config.getBoolean("linked_worlds.enabled")) {
player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | Y: §8" + Terraplusminus.config.getInt("terrain_offset.y"));
} else {
if (Terraplusminus.config.getBoolean("linked_worlds.enabled") && Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) {
ConfigurationHelper.getWorlds().forEach(world -> player.sendMessage(Terraplusminus.config.getString("prefix") + "§9 " + world.getWorldName() + "§7 | Y: §8" + world.getOffset()));
public void execute(@NotNull CommandSourceStack stack, @NotNull String[] args) {
if (stack.getSender() instanceof Player player) {
if (!player.hasPermission("t+-.offset")) {
player.sendMessage(Terraplusminus.config.getString("prefix") + "§7No permission for /offset");
return;
}
}
player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Offsets:");
player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | X: §8" + Terraplusminus.config.getInt("terrain_offset.x"));

player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | Z: §8" + Terraplusminus.config.getInt("terrain_offset.z"));
if (!Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE") || !Terraplusminus.config.getBoolean("linked_worlds.enabled")) {
player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | Y: §8" + Terraplusminus.config.getInt("terrain_offset.y"));
} else {
if (Terraplusminus.config.getBoolean("linked_worlds.enabled") && Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) {
ConfigurationHelper.getWorlds().forEach(world -> player.sendMessage(Terraplusminus.config.getString("prefix") + "§9 " + world.getWorldName() + "§7 | Y: §8" + world.getOffset()));
}
}

return true;
player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | Z: §8" + Terraplusminus.config.getInt("terrain_offset.z"));
}
}
}
Loading

0 comments on commit 58f9514

Please sign in to comment.