Added plugin.yml (removed spigot plugin annotations), Updates to FFAListener, FFAReKitEvent & Main.java, Added OtakuCommand, Added build.properties & DateUtils (to get the build timestamp) and updated pom.xml

This commit is contained in:
Matheus 2024-03-11 10:34:54 -04:00
parent 7fadf0e6d7
commit eefe4a7584
9 changed files with 88 additions and 12 deletions

18
pom.xml
View File

@ -60,6 +60,12 @@
</repository> </repository>
</repositories> </repositories>
<scm>
<connection>scm:git:https://github.com/lugamii/OtakuFFA.git</connection>
<developerConnection>scm:git:https://github.com/lugamii/OtakuFFA.git</developerConnection>
<url>https://github.com/lugamii/OtakuFFA</url>
</scm>
<build> <build>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>
<finalName>Otaku</finalName> <finalName>Otaku</finalName>
@ -71,6 +77,18 @@
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>

View File

@ -28,13 +28,8 @@ import lombok.Setter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.annotation.plugin.Plugin;
import org.bukkit.plugin.java.annotation.plugin.author.Author;
import java.util.Arrays; import java.util.Arrays;
@Plugin(name = "Otaku", version = "${project.version}")
@Author("Lugami")
public class Main extends JavaPlugin { public class Main extends JavaPlugin {
@Getter @Setter private static Main instance; @Getter @Setter private static Main instance;
@ -74,7 +69,7 @@ public class Main extends JavaPlugin {
Hotbar.init(); Hotbar.init();
Profile.init(); Profile.init();
Arrays.asList(new FFAListener(), new GeneralListeners(), new ProfileListener(), new MenuListener()).forEach(listener -> Bukkit.getPluginManager().registerEvents(listener, this)); Arrays.asList(new FFAListener(), new GeneralListeners(), new ProfileListener(), new MenuListener()).forEach(listener -> Bukkit.getPluginManager().registerEvents(listener, this));
Arrays.asList(new FFACommand(), new FFASetSpawnCommand(), new KitSetIconCommand(), new KitCreateCommand(), new KitDeleteCommand(), new KitGetLoadoutCommand(), new KitSetLoadoutCommand(), new KitsCommand(), new KitSetLocationCommand(), new MainMenuCommand(), new FFAJoinCommand(), new FFAQuitCommand(), new KitCommand(), new ReKitCommand()).forEach(command -> honcho.registerCommand(command)); Arrays.asList(new OtakuCommand(), new FFACommand(), new FFASetSpawnCommand(), new KitSetIconCommand(), new KitCreateCommand(), new KitDeleteCommand(), new KitGetLoadoutCommand(), new KitSetLoadoutCommand(), new KitsCommand(), new KitSetLocationCommand(), new MainMenuCommand(), new FFAJoinCommand(), new FFAQuitCommand(), new KitCommand(), new ReKitCommand()).forEach(command -> honcho.registerCommand(command));
getServer().getWorlds().forEach(essentials::clearEntities); getServer().getWorlds().forEach(essentials::clearEntities);
} }

View File

@ -0,0 +1,27 @@
package dev.lugami.otaku.commands;
import com.qrakn.honcho.command.CommandMeta;
import dev.lugami.otaku.Main;
import dev.lugami.otaku.utils.CC;
import dev.lugami.otaku.utils.DateUtils;
import org.bukkit.command.CommandSender;
import org.spigotmc.SpigotConfig;
@CommandMeta(label = "otaku")
public class OtakuCommand {
public void execute(CommandSender sender) {
if (Main.getInstance().getMainConfig().getBoolean("OPTIONS.BLOCK_OTAKU_CMD") && (sender.hasPermission("otaku.admin") || sender.isOp())) {
sender.sendMessage(CC.CHAT_BAR);
sender.sendMessage(CC.translate(CC.AQUA + CC.BOLD + "Otaku &7- &fAn FFA core."));
sender.sendMessage("");
sender.sendMessage(CC.translate(CC.AQUA + "Version&f: &7" + Main.getInstance().getDescription().getVersion()));
sender.sendMessage(CC.translate(CC.AQUA + "Author&f: &7" + Main.getInstance().getDescription().getAuthors()));
sender.sendMessage(CC.translate(CC.AQUA + "Build Date&f: " + DateUtils.getBuildDate()));
sender.sendMessage(CC.CHAT_BAR);
} else if (Main.getInstance().getMainConfig().getBoolean("OPTIONS.BLOCK_OTAKU_CMD") && !(sender.hasPermission("otaku.admin") || sender.isOp())) {
sender.sendMessage(SpigotConfig.unknownCommandMessage);
}
}
}

View File

@ -11,7 +11,7 @@ public class FFAReKitEvent extends PlayerEvent implements Cancellable {
private final Kit kit; private final Kit kit;
private boolean cancelled; private boolean cancelled;
private boolean bypassCooldown; private final boolean bypassCooldown;
public FFAReKitEvent(Player player, Kit k, boolean bypass) { public FFAReKitEvent(Player player, Kit k, boolean bypass) {
super(player); super(player);

View File

@ -180,9 +180,8 @@ public class FFAListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
ItemStack itemStack = event.getItem(); ItemStack itemStack = event.getItem();
if (itemStack != null && (event.getAction() == Action.RIGHT_CLICK_AIR || if (itemStack != null && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
event.getAction() == Action.RIGHT_CLICK_BLOCK)) { if (itemStack.getType() == Material.ENDER_PEARL) {
if (itemStack.getType() == Material.ENDER_PEARL && event.getClickedBlock() == null) {
if (Profile.getOrCreate(player).getFFA().getKitRules().isEnderpearlCooldown()) { if (Profile.getOrCreate(player).getFFA().getKitRules().isEnderpearlCooldown()) {
if (Main.getInstance().getEnderpearlManager().isPearlCooldown(player)) { if (Main.getInstance().getEnderpearlManager().isPearlCooldown(player)) {
event.getPlayer().sendMessage(CC.RED + "You're still in cooldown!" + CC.GRAY + " (Remaining: " + Main.getInstance().getEnderpearlManager().getPearlCooldown(event.getPlayer()) + "s)"); event.getPlayer().sendMessage(CC.RED + "You're still in cooldown!" + CC.GRAY + " (Remaining: " + Main.getInstance().getEnderpearlManager().getPearlCooldown(event.getPlayer()) + "s)");
@ -200,8 +199,9 @@ public class FFAListener implements Listener {
if (event.getEntity() instanceof Player) { if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
if (event.getCause() == EntityDamageEvent.DamageCause.FALL) { if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
if (Profile.getOrCreate(player).getState() == ProfileState.PLAYING) { Profile profile = Profile.getOrCreate(player);
event.setCancelled(Profile.getOrCreate(player).getFFA().getKitRules().isNoFall()); if (profile.getState() == ProfileState.PLAYING) {
event.setCancelled(profile.getFFA().getKitRules().isNoFall());
} }
} }
} else { } else {

View File

@ -0,0 +1,28 @@
package dev.lugami.otaku.utils;
import dev.lugami.otaku.Main;
import java.io.IOException;
import java.io.InputStream;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Properties;
public class DateUtils {
public static String getBuildDate() {
Properties properties = new Properties();
try (InputStream input = Main.class.getClassLoader().getResourceAsStream("build.properties")) {
properties.load(input);
Instant instant = Instant.parse(properties.getProperty("build.timestamp"));
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, java.time.ZoneId.systemDefault());
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd 'at' HH:mm:ss");
return zonedDateTime.format(formatter);
} catch (IOException e) {
e.printStackTrace();
return "Unknown";
}
}
}

View File

@ -0,0 +1 @@
build.timestamp=${maven.build.timestamp}

View File

@ -10,6 +10,9 @@ MONGO:
# Possible values: MONGO, FLATFILE # Possible values: MONGO, FLATFILE
SAVE_METHOD: "MONGO" SAVE_METHOD: "MONGO"
OPTIONS:
BLOCK_OTAKU_CMD: true
HOTBAR_ITEMS: HOTBAR_ITEMS:
MAIN_MENU: MAIN_MENU:
MATERIAL: "NETHER_STAR" MATERIAL: "NETHER_STAR"

View File

@ -0,0 +1,4 @@
main: dev.lugami.otaku.Main
name: Otaku
version: ${project.version}
author: Lugami