diff --git a/pom.xml b/pom.xml index 311e33b..b42103a 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,12 @@ + + scm:git:https://github.com/lugamii/OtakuFFA.git + scm:git:https://github.com/lugamii/OtakuFFA.git + https://github.com/lugamii/OtakuFFA + + clean install Otaku @@ -71,6 +77,18 @@ + + org.codehaus.mojo + buildnumber-maven-plugin + 1.4 + + + + create + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/src/main/java/dev/lugami/otaku/Main.java b/src/main/java/dev/lugami/otaku/Main.java index d7f144d..156e803 100644 --- a/src/main/java/dev/lugami/otaku/Main.java +++ b/src/main/java/dev/lugami/otaku/Main.java @@ -28,13 +28,8 @@ import lombok.Setter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; 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; - -@Plugin(name = "Otaku", version = "${project.version}") -@Author("Lugami") public class Main extends JavaPlugin { @Getter @Setter private static Main instance; @@ -74,7 +69,7 @@ public class Main extends JavaPlugin { Hotbar.init(); Profile.init(); 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); } diff --git a/src/main/java/dev/lugami/otaku/commands/OtakuCommand.java b/src/main/java/dev/lugami/otaku/commands/OtakuCommand.java new file mode 100644 index 0000000..e2c7106 --- /dev/null +++ b/src/main/java/dev/lugami/otaku/commands/OtakuCommand.java @@ -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); + } + } + +} diff --git a/src/main/java/dev/lugami/otaku/events/FFAReKitEvent.java b/src/main/java/dev/lugami/otaku/events/FFAReKitEvent.java index 72ba8da..5dffd79 100644 --- a/src/main/java/dev/lugami/otaku/events/FFAReKitEvent.java +++ b/src/main/java/dev/lugami/otaku/events/FFAReKitEvent.java @@ -11,7 +11,7 @@ public class FFAReKitEvent extends PlayerEvent implements Cancellable { private final Kit kit; private boolean cancelled; - private boolean bypassCooldown; + private final boolean bypassCooldown; public FFAReKitEvent(Player player, Kit k, boolean bypass) { super(player); diff --git a/src/main/java/dev/lugami/otaku/listener/FFAListener.java b/src/main/java/dev/lugami/otaku/listener/FFAListener.java index b3a3474..11f6cff 100644 --- a/src/main/java/dev/lugami/otaku/listener/FFAListener.java +++ b/src/main/java/dev/lugami/otaku/listener/FFAListener.java @@ -180,9 +180,8 @@ public class FFAListener implements Listener { Player player = event.getPlayer(); ItemStack itemStack = event.getItem(); - if (itemStack != null && (event.getAction() == Action.RIGHT_CLICK_AIR || - event.getAction() == Action.RIGHT_CLICK_BLOCK)) { - if (itemStack.getType() == Material.ENDER_PEARL && event.getClickedBlock() == null) { + if (itemStack != null && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) { + if (itemStack.getType() == Material.ENDER_PEARL) { if (Profile.getOrCreate(player).getFFA().getKitRules().isEnderpearlCooldown()) { 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)"); @@ -200,8 +199,9 @@ public class FFAListener implements Listener { if (event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); if (event.getCause() == EntityDamageEvent.DamageCause.FALL) { - if (Profile.getOrCreate(player).getState() == ProfileState.PLAYING) { - event.setCancelled(Profile.getOrCreate(player).getFFA().getKitRules().isNoFall()); + Profile profile = Profile.getOrCreate(player); + if (profile.getState() == ProfileState.PLAYING) { + event.setCancelled(profile.getFFA().getKitRules().isNoFall()); } } } else { diff --git a/src/main/java/dev/lugami/otaku/utils/DateUtils.java b/src/main/java/dev/lugami/otaku/utils/DateUtils.java new file mode 100644 index 0000000..2698d7c --- /dev/null +++ b/src/main/java/dev/lugami/otaku/utils/DateUtils.java @@ -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"; + } + } + +} diff --git a/src/main/resources/build.properties b/src/main/resources/build.properties new file mode 100644 index 0000000..de3b1d2 --- /dev/null +++ b/src/main/resources/build.properties @@ -0,0 +1 @@ +build.timestamp=${maven.build.timestamp} \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ed57692..4a3f704 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -10,6 +10,9 @@ MONGO: # Possible values: MONGO, FLATFILE SAVE_METHOD: "MONGO" +OPTIONS: + BLOCK_OTAKU_CMD: true + HOTBAR_ITEMS: MAIN_MENU: MATERIAL: "NETHER_STAR" diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..23707ce --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,4 @@ +main: dev.lugami.otaku.Main +name: Otaku +version: ${project.version} +author: Lugami