diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 1e5427c..5fa805e 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 0469cab..9920ebf 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -11,6 +11,11 @@
+
+
+
+
+
@@ -21,6 +26,11 @@
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 1a10df0..fdc35ea 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..223ff14
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Bouncyballs.iml b/Bouncyballs.iml
new file mode 100644
index 0000000..a589521
--- /dev/null
+++ b/Bouncyballs.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ SPIGOT
+
+ 1
+
+
+
+
\ No newline at end of file
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index 5162451..ddf2f11 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.huskydreaming
Bouncyballs
- 6.4-RELEASE
+ 6.5-RELEASE
@@ -41,6 +41,11 @@
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ github
+ https://maven.pkg.github.com/huskydreaming/huskycore
+
diff --git a/pom.xml b/pom.xml
index 1bff5ea..7e75d8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.huskydreaming
Bouncyballs
- 6.4-RELEASE
+ 7.0-RELEASE
1.20.4-R0.1-SNAPSHOT
@@ -55,6 +55,13 @@
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+ github
+ https://maven.pkg.github.com/huskydreaming/huskycore
+
+ true
+
+
@@ -65,21 +72,10 @@
${minecraft.version}
provided
-
- org.jetbrains
- annotations
- 23.0.0
- compile
-
com.huskydreaming
- HuskyCore
- 1.1-SNAPSHOT
-
-
- fr.minuskube.inv
- smart-invs
- 1.2.7
+ huskycore
+ 1.7-SNAPSHOT
\ No newline at end of file
diff --git a/src/main/java/com/huskydreaming/bouncyball/BouncyBallPlugin.java b/src/main/java/com/huskydreaming/bouncyball/BouncyBallPlugin.java
index 426d25f..f23b031 100644
--- a/src/main/java/com/huskydreaming/bouncyball/BouncyBallPlugin.java
+++ b/src/main/java/com/huskydreaming/bouncyball/BouncyBallPlugin.java
@@ -4,43 +4,46 @@
import com.huskydreaming.bouncyball.commands.subcommands.CreateCommand;
import com.huskydreaming.bouncyball.commands.subcommands.GiveCommand;
import com.huskydreaming.bouncyball.commands.subcommands.ReloadCommand;
+import com.huskydreaming.bouncyball.handlers.implementations.InventoryHandlerImpl;
+import com.huskydreaming.bouncyball.handlers.implementations.LocalizationHandlerImpl;
+import com.huskydreaming.bouncyball.handlers.implementations.ParticleHandlerImpl;
+import com.huskydreaming.bouncyball.handlers.implementations.ProjectileHandlerImpl;
+import com.huskydreaming.bouncyball.handlers.interfaces.InventoryHandler;
+import com.huskydreaming.bouncyball.handlers.interfaces.LocalizationHandler;
+import com.huskydreaming.bouncyball.handlers.interfaces.ParticleHandler;
+import com.huskydreaming.bouncyball.handlers.interfaces.ProjectileHandler;
import com.huskydreaming.bouncyball.listeners.ProjectileListener;
-import com.huskydreaming.bouncyball.services.implementations.InventoryServiceImpl;
-import com.huskydreaming.bouncyball.services.implementations.LocaleServiceImpl;
-import com.huskydreaming.bouncyball.services.implementations.ParticleServiceImpl;
-import com.huskydreaming.bouncyball.services.implementations.ProjectileServiceImpl;
-import com.huskydreaming.bouncyball.services.interfaces.InventoryService;
-import com.huskydreaming.bouncyball.services.interfaces.LocaleService;
-import com.huskydreaming.bouncyball.services.interfaces.ParticleService;
-import com.huskydreaming.bouncyball.services.interfaces.ProjectileService;
+import com.huskydreaming.bouncyball.repositories.implementations.ParticleRepositoryImpl;
+import com.huskydreaming.bouncyball.repositories.implementations.ProjectileRepositoryImpl;
+import com.huskydreaming.bouncyball.repositories.interfaces.ParticleRepository;
+import com.huskydreaming.bouncyball.repositories.interfaces.ProjectileRepository;
import com.huskydreaming.huskycore.HuskyPlugin;
+import com.huskydreaming.huskycore.handlers.implementations.DefaultConfigHandlerImpl;
+import com.huskydreaming.huskycore.handlers.interfaces.CommandHandler;
+import com.huskydreaming.huskycore.handlers.interfaces.DefaultConfigHandler;
public class BouncyBallPlugin extends HuskyPlugin {
@Override
- public void onEnable() {
- super.onEnable();
+ public void onInitialize() {
+ handlerRegistry.register(DefaultConfigHandler.class, new DefaultConfigHandlerImpl());
+ handlerRegistry.register(LocalizationHandler.class, new LocalizationHandlerImpl());
+ handlerRegistry.register(InventoryHandler.class, new InventoryHandlerImpl());
+ handlerRegistry.register(ParticleHandler.class, new ParticleHandlerImpl());
+ handlerRegistry.register(ProjectileHandler.class, new ProjectileHandlerImpl());
- // Register Services
- serviceRegistry.register(LocaleService.class, new LocaleServiceImpl());
- serviceRegistry.register(InventoryService.class, new InventoryServiceImpl());
- serviceRegistry.register(ProjectileService.class, new ProjectileServiceImpl());
- serviceRegistry.register(ParticleService.class, new ParticleServiceImpl(this));
- serviceRegistry.deserialize(this);
- serviceRegistry.provide(ParticleService.class).run(this);
-
- // Register Commands
- commandRegistry.setCommandExecutor(new BaseCommand(this));
- commandRegistry.add(new CreateCommand(this));
- commandRegistry.add(new GiveCommand(this));
- commandRegistry.add(new ReloadCommand(this));
- commandRegistry.deserialize(this);
-
- registerListeners(new ProjectileListener(this));
+ repositoryRegistry.register(ParticleRepository.class, new ParticleRepositoryImpl());
+ repositoryRegistry.register(ProjectileRepository.class, new ProjectileRepositoryImpl());
}
@Override
- public void onDisable() {
- serviceRegistry.serialize(this);
+ public void onPostInitialize() {
+ CommandHandler commandHandler = handlerRegistry.provide(CommandHandler.class);
+ commandHandler.setCommandExecutor(new BaseCommand(this));
+ commandHandler.add(new CreateCommand(this));
+ commandHandler.add(new GiveCommand(this));
+ commandHandler.add(new ReloadCommand(this));
+
+ registerListeners(new ProjectileListener(this));
}
}
\ No newline at end of file
diff --git a/src/main/java/com/huskydreaming/bouncyball/commands/BaseCommand.java b/src/main/java/com/huskydreaming/bouncyball/commands/BaseCommand.java
index e6325e4..fcd5369 100644
--- a/src/main/java/com/huskydreaming/bouncyball/commands/BaseCommand.java
+++ b/src/main/java/com/huskydreaming/bouncyball/commands/BaseCommand.java
@@ -1,38 +1,49 @@
package com.huskydreaming.bouncyball.commands;
-import com.huskydreaming.bouncyball.services.interfaces.InventoryService;
-import com.huskydreaming.bouncyball.services.interfaces.ProjectileService;
-import com.huskydreaming.bouncyball.pareseables.Locale;
+import com.huskydreaming.bouncyball.handlers.interfaces.InventoryHandler;
+import com.huskydreaming.bouncyball.enumerations.Locale;
+import com.huskydreaming.bouncyball.repositories.interfaces.ProjectileRepository;
import com.huskydreaming.huskycore.HuskyPlugin;
-import com.huskydreaming.huskycore.commands.AbstractCommand;
-import com.huskydreaming.huskycore.interfaces.Parseable;
+import com.huskydreaming.huskycore.commands.abstraction.AbstractCommand;
+import com.huskydreaming.huskycore.commands.annotations.CommandAnnotation;
+import com.huskydreaming.huskycore.utilities.general.Parseable;
+import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+@CommandAnnotation(label = "bouncyballs")
public class BaseCommand extends AbstractCommand {
private final HuskyPlugin plugin;
- private final InventoryService inventoryService;
- private final ProjectileService projectileService;
+ private final InventoryHandler inventoryHandler;
+ private final ProjectileRepository projectileRepository;
public BaseCommand(HuskyPlugin plugin) {
- super("bouncyballs", plugin);
-
+ super(plugin);
this.plugin = plugin;
- this.inventoryService = plugin.provide(InventoryService.class);
- this.projectileService = plugin.provide(ProjectileService.class);
+ this.inventoryHandler = plugin.provide(InventoryHandler.class);
+ this.projectileRepository = plugin.provide(ProjectileRepository.class);
}
@Override
- public void run(Player player, String[] strings) {
- if (projectileService.getProjectileDataMap().isEmpty()) {
- player.sendMessage(Locale.NO_BOUNCY_BALLS.prefix());
+ public void onCommand(CommandSender commandSender, String[] strings) {
+ if(commandSender instanceof Player player) {
+ if (projectileRepository.getProjectileDataMap().isEmpty()) {
+ player.sendMessage(Locale.NO_BOUNCY_BALLS.prefix());
+ } else {
+ inventoryHandler.getBouncyBallsInventory(plugin).open(player);
+ }
} else {
- inventoryService.getBouncyBallsInventory(plugin).open(player);
+ commandSender.sendMessage("You must be a player to run this command");
}
}
@Override
- public Parseable getPermissionsLocale() {
+ public Parseable getUsage() {
+ return Locale.USAGE;
+ }
+
+ @Override
+ public Parseable getPermission() {
return Locale.NO_PERMISSIONS;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/CreateCommand.java b/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/CreateCommand.java
index e4a7dd4..98b66bd 100644
--- a/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/CreateCommand.java
+++ b/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/CreateCommand.java
@@ -1,57 +1,39 @@
package com.huskydreaming.bouncyball.commands.subcommands;
import com.huskydreaming.bouncyball.data.projectiles.ProjectileDefault;
-import com.huskydreaming.bouncyball.services.interfaces.ParticleService;
-import com.huskydreaming.bouncyball.services.interfaces.ProjectileService;
-import com.huskydreaming.bouncyball.pareseables.Locale;
+import com.huskydreaming.bouncyball.enumerations.Locale;
+import com.huskydreaming.bouncyball.repositories.interfaces.ParticleRepository;
+import com.huskydreaming.bouncyball.repositories.interfaces.ProjectileRepository;
import com.huskydreaming.huskycore.HuskyPlugin;
-import com.huskydreaming.huskycore.commands.Command;
-import com.huskydreaming.huskycore.commands.SubCommand;
-import org.bukkit.command.ConsoleCommandSender;
+import com.huskydreaming.huskycore.commands.annotations.CommandAnnotation;
+import com.huskydreaming.huskycore.commands.providers.PlayerCommandProvider;
import org.bukkit.entity.Player;
-@Command(label = "create")
-public class CreateCommand implements SubCommand {
+@CommandAnnotation(label = "create")
+public class CreateCommand implements PlayerCommandProvider {
- private final ParticleService particleService;
- private final ProjectileService projectileService;
+ private final ParticleRepository particleRepository;
+ private final ProjectileRepository projectileRepository;
public CreateCommand(HuskyPlugin plugin) {
- this.particleService = plugin.provide(ParticleService.class);
- this.projectileService = plugin.provide(ProjectileService.class);
+ this.particleRepository = plugin.provide(ParticleRepository.class);
+ this.projectileRepository = plugin.provide(ProjectileRepository.class);
}
@Override
- public void run(Player player, String[] strings) {
+ public void onCommand(Player player, String[] strings) {
if (strings.length == 2) {
- String string = strings[1].toLowerCase();
- if (projectileService.containKey(string.toLowerCase())) {
- player.sendMessage(Locale.BOUNCY_BALL_EXISTS.prefix(string));
+ String projectileName = strings[1].toLowerCase();
+ if (projectileRepository.hasProjectileData(projectileName)) {
+ player.sendMessage(Locale.BOUNCY_BALL_EXISTS.prefix(projectileName));
return;
}
ProjectileDefault projectileDefault = ProjectileDefault.DEFAULT;
- particleService.addParticle(string, projectileDefault.getParticleData());
- projectileService.addProjectile(string, projectileDefault.getProjectileData());
+ particleRepository.addParticleData(projectileName, projectileDefault.getParticleData());
+ projectileRepository.addProjectileData(projectileName, projectileDefault.getProjectileData());
- player.sendMessage(Locale.BOUNCY_BALL_CREATE.prefix(string));
- }
- }
-
- @Override
- public void run(ConsoleCommandSender sender, String[] strings) {
- if (strings.length == 2) {
- String string = strings[1].toLowerCase();
- if (projectileService.containKey(string.toLowerCase())) {
- sender.sendMessage(Locale.BOUNCY_BALL_EXISTS.prefix(string));
- return;
- }
-
- ProjectileDefault projectileDefault = ProjectileDefault.DEFAULT;
- particleService.addParticle(string, projectileDefault.getParticleData());
- projectileService.addProjectile(string, projectileDefault.getProjectileData());
-
- sender.sendMessage(Locale.BOUNCY_BALL_CREATE.prefix(string));
+ player.sendMessage(Locale.BOUNCY_BALL_CREATE.prefix(projectileName));
}
}
}
\ No newline at end of file
diff --git a/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/GiveCommand.java b/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/GiveCommand.java
index 644e2b3..29154cb 100644
--- a/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/GiveCommand.java
+++ b/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/GiveCommand.java
@@ -1,10 +1,11 @@
package com.huskydreaming.bouncyball.commands.subcommands;
-import com.huskydreaming.bouncyball.services.interfaces.ProjectileService;
-import com.huskydreaming.bouncyball.pareseables.Locale;
+import com.huskydreaming.bouncyball.handlers.interfaces.ProjectileHandler;
+import com.huskydreaming.bouncyball.enumerations.Locale;
+import com.huskydreaming.bouncyball.repositories.interfaces.ProjectileRepository;
import com.huskydreaming.huskycore.HuskyPlugin;
-import com.huskydreaming.huskycore.commands.Command;
-import com.huskydreaming.huskycore.commands.SubCommand;
+import com.huskydreaming.huskycore.commands.annotations.CommandAnnotation;
+import com.huskydreaming.huskycore.commands.providers.PlayerCommandProvider;
import com.huskydreaming.huskycore.utilities.Util;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -13,18 +14,19 @@
import java.util.List;
import java.util.stream.Collectors;
-@Command(label = "give")
-public class GiveCommand implements SubCommand {
+@CommandAnnotation(label = "give")
+public class GiveCommand implements PlayerCommandProvider {
- private final ProjectileService projectileService;
+ private final ProjectileHandler projectileHandler;
+ private final ProjectileRepository projectileRepository;
public GiveCommand(HuskyPlugin plugin) {
- this.projectileService = plugin.provide(ProjectileService.class);
+ this.projectileHandler = plugin.provide(ProjectileHandler.class);
+ this.projectileRepository = plugin.provide(ProjectileRepository.class);
}
-
@Override
- public void run(Player player, String[] strings) {
+ public void onCommand(Player player, String[] strings) {
if (strings.length == 3) {
Player target = Bukkit.getPlayer(strings[1]);
if (target == null) {
@@ -32,12 +34,13 @@ public void run(Player player, String[] strings) {
return;
}
- if (projectileService.containKey(strings[2])) {
- ItemStack itemStack = projectileService.getItemStackFromKey(strings[2]);
+ String projectileName = strings[2];
+ if (projectileRepository.hasProjectileData(projectileName)) {
+ ItemStack itemStack = projectileHandler.getItemStackFromKey(projectileName);
player.getInventory().addItem(itemStack);
- player.sendMessage(Locale.BOUNCY_BALL_GIVE.prefix(strings[2].toLowerCase()));
+ player.sendMessage(Locale.BOUNCY_BALL_GIVE.prefix(projectileName.toLowerCase()));
} else {
- player.sendMessage(Locale.BOUNCY_BALL_NULL.prefix(strings[2]));
+ player.sendMessage(Locale.BOUNCY_BALL_NULL.prefix(projectileName));
}
}
@@ -53,21 +56,23 @@ public void run(Player player, String[] strings) {
return;
}
- if (projectileService.containKey(strings[2])) {
- ItemStack itemStack = projectileService.getItemStackFromKey(strings[2]);
+ String projectileName = strings[2];
+ if (projectileRepository.hasProjectileData(projectileName)) {
+ ItemStack itemStack = projectileHandler.getItemStackFromKey(projectileName);
itemStack.setAmount(Integer.parseInt(strings[3]));
player.getInventory().addItem(itemStack);
- player.sendMessage(Locale.BOUNCY_BALL_GIVE.prefix(strings[2].toLowerCase()));
+ player.sendMessage(Locale.BOUNCY_BALL_GIVE.prefix(projectileName.toLowerCase()));
} else {
- player.sendMessage(Locale.BOUNCY_BALL_NULL.prefix(strings[1]));
+ player.sendMessage(Locale.BOUNCY_BALL_NULL.prefix(projectileName));
}
}
}
@Override
public List onTabComplete(Player player, String[] strings) {
- if (strings.length == 2) return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
- if (strings.length == 3) return projectileService.getProjectileDataMap().keySet().stream().toList();
+ if (strings.length == 2)
+ return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
+ if (strings.length == 3) return projectileRepository.getProjectileDataMap().keySet().stream().toList();
return List.of();
}
}
\ No newline at end of file
diff --git a/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/ReloadCommand.java b/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/ReloadCommand.java
index 26e0576..8221ee2 100644
--- a/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/ReloadCommand.java
+++ b/src/main/java/com/huskydreaming/bouncyball/commands/subcommands/ReloadCommand.java
@@ -1,50 +1,38 @@
package com.huskydreaming.bouncyball.commands.subcommands;
-import com.huskydreaming.bouncyball.services.interfaces.LocaleService;
-import com.huskydreaming.bouncyball.services.interfaces.ParticleService;
-import com.huskydreaming.bouncyball.services.interfaces.ProjectileService;
-import com.huskydreaming.bouncyball.pareseables.Locale;
+import com.huskydreaming.bouncyball.handlers.interfaces.LocalizationHandler;
+import com.huskydreaming.bouncyball.enumerations.Locale;
+import com.huskydreaming.bouncyball.repositories.interfaces.ParticleRepository;
+import com.huskydreaming.bouncyball.repositories.interfaces.ProjectileRepository;
import com.huskydreaming.huskycore.HuskyPlugin;
-import com.huskydreaming.huskycore.commands.Command;
-import com.huskydreaming.huskycore.commands.SubCommand;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.entity.Player;
+import com.huskydreaming.huskycore.commands.annotations.CommandAnnotation;
+import com.huskydreaming.huskycore.commands.providers.CommandProvider;
+import org.bukkit.command.CommandSender;
-@Command(label = "reload")
-public class ReloadCommand implements SubCommand {
+@CommandAnnotation(label = "reload")
+public class ReloadCommand implements CommandProvider {
private final HuskyPlugin plugin;
- private final LocaleService localeService;
- private final ParticleService particleService;
- private final ProjectileService projectileService;
+ private final LocalizationHandler localizationHandler;
+ private final ParticleRepository particleRepository;
+ private final ProjectileRepository projectileRepository;
public ReloadCommand(HuskyPlugin plugin) {
this.plugin = plugin;
- this.localeService = plugin.provide(LocaleService.class);
- this.particleService = plugin.provide(ParticleService.class);
- this.projectileService = plugin.provide(ProjectileService.class);
+ this.localizationHandler = plugin.provide(LocalizationHandler.class);
+ this.particleRepository = plugin.provide(ParticleRepository.class);
+ this.projectileRepository = plugin.provide(ProjectileRepository.class);
}
@Override
- public void run(Player player, String[] strings) {
- localeService.getLocale().reload(plugin);
- localeService.getMenu().reload(plugin);
+ public void onCommand(CommandSender commandSender, String[] strings) {
+ localizationHandler.getLocale().reload(plugin);
+ localizationHandler.getMenu().reload(plugin);
- particleService.serialize(plugin);
- projectileService.serialize(plugin);
+ particleRepository.postDeserialize(plugin);
+ projectileRepository.postDeserialize(plugin);
- player.sendMessage(Locale.RELOAD.prefix());
- }
-
- @Override
- public void run(ConsoleCommandSender sender, String[] strings) {
- localeService.getLocale().reload(plugin);
- localeService.getMenu().reload(plugin);
-
- particleService.serialize(plugin);
- projectileService.serialize(plugin);
-
- sender.sendMessage(Locale.RELOAD.prefix());
+ commandSender.sendMessage(Locale.RELOAD.prefix());
}
}
\ No newline at end of file
diff --git a/src/main/java/com/huskydreaming/bouncyball/data/particles/ParticleData.java b/src/main/java/com/huskydreaming/bouncyball/data/particles/ParticleData.java
index ca604ae..88f53d4 100644
--- a/src/main/java/com/huskydreaming/bouncyball/data/particles/ParticleData.java
+++ b/src/main/java/com/huskydreaming/bouncyball/data/particles/ParticleData.java
@@ -17,6 +17,10 @@ public static ParticleData create(Particle particle, Color color) {
return new ParticleData(particle, color);
}
+ public ParticleData() {
+
+ }
+
public ParticleData(Particle particle, Color color) {
this.particle = particle;
this.color = color;
diff --git a/src/main/java/com/huskydreaming/bouncyball/pareseables/Locale.java b/src/main/java/com/huskydreaming/bouncyball/enumerations/Locale.java
similarity index 74%
rename from src/main/java/com/huskydreaming/bouncyball/pareseables/Locale.java
rename to src/main/java/com/huskydreaming/bouncyball/enumerations/Locale.java
index f79a0a1..fbcf230 100644
--- a/src/main/java/com/huskydreaming/bouncyball/pareseables/Locale.java
+++ b/src/main/java/com/huskydreaming/bouncyball/enumerations/Locale.java
@@ -1,6 +1,7 @@
-package com.huskydreaming.bouncyball.pareseables;
+package com.huskydreaming.bouncyball.enumerations;
+
import com.google.common.base.Functions;
-import com.huskydreaming.huskycore.interfaces.Parseable;
+import com.huskydreaming.huskycore.utilities.general.Parseable;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -11,19 +12,20 @@
public enum Locale implements Parseable {
PREFIX("&aBouncyballs: &7"),
- BOUNCY_BALL_CREATE("You have created the &b{0}&7 bouncy ball."),
- BOUNCY_BALL_EXISTS("The bouncy ball &b{0} &7 already exists."),
- BOUNCY_BALL_NULL("The &b{0}&7 bouncy ball does not seem to exist."),
- BOUNCY_BALL_GIVE("You have been given the &b{0}&7 bouncy ball."),
- BOUNCY_BALL_GIVE_AMOUNT("You have been given &ex{0} {1}&7 bouncy ball(s)."),
- BOUNCY_BALL_SEND("You have given &a{0} &7a {1}&7 bouncy ball."),
- BOUNCY_BALL_SEND_AMOUNT("You have given &a{0} &ex{1} {2}&7 bouncy ball(s)."),
+ BOUNCY_BALL_CREATE("You have created the &b<0>&7 bouncy ball."),
+ BOUNCY_BALL_EXISTS("The bouncy ball &b<0> &7 already exists."),
+ BOUNCY_BALL_NULL("The &b<0>&7 bouncy ball does not seem to exist."),
+ BOUNCY_BALL_GIVE("You have been given the &b<0>&7 bouncy ball."),
+ BOUNCY_BALL_GIVE_AMOUNT("You have been given &ex<0> <1>&7 bouncy ball(s)."),
+ BOUNCY_BALL_SEND("You have given &a<0> &7a <1>&7 bouncy ball."),
+ BOUNCY_BALL_SEND_AMOUNT("You have given &a<0> &ex<1> <2>&7 bouncy ball(s)."),
INVALID_NUMBER("You must provide a valid number"),
PLAYER_NULL("That player does not seem to exist."),
PLAYER_OFFLINE("You do not have permissions to run that command."),
NO_PERMISSIONS("You do not have permissions to run that command."),
NO_BOUNCY_BALLS("No bouncy balls have been created... type &b/bouncyballs create [name]"),
- RELOAD("You have successfully reloaded the configuration and saved data.");
+ RELOAD("You have successfully reloaded the configuration and saved data."),
+ USAGE("&7Usage: &b/bouncyballs [create|give|reload]");
private final String def;
private final List list;
diff --git a/src/main/java/com/huskydreaming/bouncyball/pareseables/Menu.java b/src/main/java/com/huskydreaming/bouncyball/enumerations/Menu.java
similarity index 55%
rename from src/main/java/com/huskydreaming/bouncyball/pareseables/Menu.java
rename to src/main/java/com/huskydreaming/bouncyball/enumerations/Menu.java
index a4b8989..11af501 100644
--- a/src/main/java/com/huskydreaming/bouncyball/pareseables/Menu.java
+++ b/src/main/java/com/huskydreaming/bouncyball/enumerations/Menu.java
@@ -1,54 +1,54 @@
-package com.huskydreaming.bouncyball.pareseables;
+package com.huskydreaming.bouncyball.enumerations;
import com.google.common.base.Functions;
-import com.huskydreaming.huskycore.interfaces.Parseable;
+import com.huskydreaming.huskycore.utilities.general.Parseable;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public enum Menu implements Parseable {
// Projectile Menu
- PROJECTILE_TITLE("&f{0}"),
- PROJECTILE_LORE(Collections.singletonList("&7Left-Click to retrieve bouncy ball.")),
+ PROJECTILE_TITLE("&f<0>"),
+ PROJECTILE_LORE(List.of("&7Left-Click to retrieve bouncy ball.")),
PROJECTILE_EDIT("&7Right-Click to edit"),
// Edit Menu
-
- EDIT_AMOUNT_TITLE("&cAmount: &b{0}"),
+ EDIT_AMOUNT_TITLE("&cAmount: &b<0>"),
EDIT_AMOUNT_LORE(List.of("", "&7Left-Click to increase", "&7Right-Click to decrease")),
-
- EDIT_COLOR_TITLE("{0}{1}"),
- EDIT_COLOR_LORE(Collections.singletonList("&7Click to select color")),
+ EDIT_BLOCK_TITLE("&eEdit Blocks"),
+ EDIT_BLOCK_LORE(List.of("&7Click to edit allowed blocks.")),
+ EDIT_COLOR_TITLE("<0><1>"),
+ EDIT_COLOR_LORE(List.of("&7Click to select color")),
EDIT_DELETE_TITLE("&cDelete"),
- EDIT_DELETE_LORE(Collections.singletonList("&7Click to delete bouncy ball")),
+ EDIT_DELETE_LORE(List.of("&7Click to delete bouncy ball")),
EDIT_MATERIAL_TITLE("&eEdit Materials"),
- EDIT_MATERIAL_LORE(Collections.singletonList("&7Click to edit material.")),
-
- EDIT_PHYSICS_TITLE("&b{0}"),
+ EDIT_MATERIAL_LORE(List.of("&7Click to edit material.")),
+ EDIT_PHYSICS_TITLE("&b<0>"),
EDIT_PHYSICS_LORE(List.of(
- "&f{0}",
+ "&f<0>",
"",
- "&7Amount: &f{1}",
+ "&7Amount: &f<1>",
"",
"&7Left-Click to increment",
"&7Right-Click to decrement")),
-
EDIT_PARTICLE_TITLE("&eEdit Particles"),
- EDIT_PARTICLE_LORE(Collections.singletonList("&7Click to edit particles.")),
-
- EDIT_SET_MATERIAL_TITLE("&e{0}"),
- EDIT_SET_PARTICLE_TITLE("&e{0}"),
- EDIT_SET_MATERIAL_LORE(Collections.singletonList("&7Click to set material.")),
- EDIT_SET_PARTICLE_LORE(Collections.singletonList("&7Click to set particle.")),
- EDIT_CURRENT_MATERIAL_TITLE("&b{0}"),
- EDIT_CURRENT_PARTICLE_TITLE("&b{0}"),
- EDIT_CURRENT_MATERIAL_LORE(Collections.singletonList("&7This is the current material.")),
- EDIT_CURRENT_PARTICLE_LORE(Collections.singletonList("&7This is the current particle."));
+ EDIT_PARTICLE_LORE(List.of("&7Click to edit particles.")),
+ EDIT_SET_BLOCK_TITLE("&e<0>"),
+ EDIT_SET_MATERIAL_TITLE("&e<0>"),
+ EDIT_SET_PARTICLE_TITLE("&e<0>"),
+ EDIT_SET_BLOCK_LORE(List.of("&7Click to set block as bounce-able.")),
+ EDIT_SET_MATERIAL_LORE(List.of("&7Click to set material.")),
+ EDIT_SET_PARTICLE_LORE(List.of("&7Click to set particle.")),
+ EDIT_CURRENT_BLOCK_TITLE("&b<0>"),
+ EDIT_CURRENT_MATERIAL_TITLE("&b<0>"),
+ EDIT_CURRENT_PARTICLE_TITLE("&b<0>"),
+ EDIT_CURRENT_BLOCK_LORE(List.of("&7You can bounce on this block.")),
+ EDIT_CURRENT_MATERIAL_LORE(List.of("&7This is the current material.")),
+ EDIT_CURRENT_PARTICLE_LORE(List.of("&7This is the current particle."));
private final String def;
private final List list;
diff --git a/src/main/java/com/huskydreaming/bouncyball/services/implementations/InventoryServiceImpl.java b/src/main/java/com/huskydreaming/bouncyball/handlers/implementations/InventoryHandlerImpl.java
similarity index 62%
rename from src/main/java/com/huskydreaming/bouncyball/services/implementations/InventoryServiceImpl.java
rename to src/main/java/com/huskydreaming/bouncyball/handlers/implementations/InventoryHandlerImpl.java
index cff4354..5bcd73c 100644
--- a/src/main/java/com/huskydreaming/bouncyball/services/implementations/InventoryServiceImpl.java
+++ b/src/main/java/com/huskydreaming/bouncyball/handlers/implementations/InventoryHandlerImpl.java
@@ -1,9 +1,10 @@
-package com.huskydreaming.bouncyball.services.implementations;
+package com.huskydreaming.bouncyball.handlers.implementations;
import com.huskydreaming.bouncyball.data.particles.ParticleColor;
+import com.huskydreaming.bouncyball.data.projectiles.ProjectileData;
+import com.huskydreaming.bouncyball.handlers.interfaces.InventoryHandler;
import com.huskydreaming.bouncyball.inventories.*;
-import com.huskydreaming.bouncyball.services.interfaces.InventoryService;
-import com.huskydreaming.bouncyball.services.interfaces.ProjectileService;
+import com.huskydreaming.bouncyball.repositories.interfaces.ProjectileRepository;
import com.huskydreaming.huskycore.HuskyPlugin;
import com.huskydreaming.huskycore.utilities.Util;
import fr.minuskube.inv.InventoryManager;
@@ -13,15 +14,25 @@
import org.bukkit.World;
import java.util.Arrays;
+import java.util.Map;
-public class InventoryServiceImpl implements InventoryService {
+public class InventoryHandlerImpl implements InventoryHandler {
private InventoryManager inventoryManager;
+ private ProjectileRepository projectileRepository;
+
+ @Override
+ public void postInitialize(HuskyPlugin plugin) {
+ projectileRepository = plugin.provide(ProjectileRepository.class);
+
+ inventoryManager = new InventoryManager(plugin);
+ inventoryManager.init();
+ }
@Override
public SmartInventory getBouncyBallsInventory(HuskyPlugin plugin) {
- ProjectileService projectileService = plugin.provide(ProjectileService.class);
- String[] keys = projectileService.getProjectileDataMap().keySet().toArray(new String[0]);
+ Map projectileDataMap = projectileRepository.getProjectileDataMap();
+ String[] keys = projectileDataMap.keySet().toArray(new String[0]);
int rows = (int) Math.ceil((double) keys.length / 9);
MainInventory mainInventory = new MainInventory(plugin, rows, keys);
return SmartInventory.builder()
@@ -36,11 +47,11 @@ public SmartInventory getBouncyBallsInventory(HuskyPlugin plugin) {
@Override
public SmartInventory getEditInventory(HuskyPlugin plugin, String key) {
EditInventory mainInventory = new EditInventory(plugin, key);
- String name = Util.capitalize(key.replace("_", " "));
+ String name = Util.capitalize(key.replace("_", " "));
return SmartInventory.builder()
.manager(inventoryManager)
.id("editInventory")
- .size(4, 9)
+ .size(5, 9)
.provider(mainInventory)
.title("Editing: " + name)
.build();
@@ -56,24 +67,45 @@ public SmartInventory getMaterialInventory(World world, HuskyPlugin plugin, Stri
.toArray(new Material[0]);
int rows = (int) Math.ceil((double) supportedMaterials.length / 9);
- MaterialInventory mainInventory = new MaterialInventory(plugin, key, rows, supportedMaterials);
- String name = Util.capitalize(key.replace("_", " "));
+ MaterialInventory materialInventory = new MaterialInventory(plugin, key, rows, supportedMaterials, false);
+ String name = Util.capitalize(key.replace("_", " "));
return SmartInventory.builder()
.manager(inventoryManager)
.id("materialInventory")
.size(Math.min(rows + 2, 5), 9)
- .provider(mainInventory)
+ .provider(materialInventory)
.title("Materials: " + name)
.build();
}
+ @Override
+ public SmartInventory getBlockInventory(World world, HuskyPlugin plugin, String key) {
+ Material[] materials = Material.values();
+ Material[] materialsWithoutAir = Arrays.copyOfRange(materials, 1, materials.length);
+ Material[] supportedMaterials = Arrays.stream(materialsWithoutAir)
+ .filter(material -> isEnabled(world, material) && material.isItem() && material.isBlock())
+ .toList()
+ .toArray(new Material[0]);
+
+ int rows = (int) Math.ceil((double) supportedMaterials.length / 9);
+ MaterialInventory materialInventory = new MaterialInventory(plugin, key, rows, supportedMaterials, true);
+ String name = Util.capitalize(key.replace("_", " "));
+ return SmartInventory.builder()
+ .manager(inventoryManager)
+ .id("blockInventory")
+ .size(Math.min(rows + 2, 5), 9)
+ .provider(materialInventory)
+ .title("Blocks: " + name)
+ .build();
+ }
+
@Override
public SmartInventory getParticleInventory(HuskyPlugin plugin, String key) {
Particle[] particles = Particle.values();
int rows = (int) Math.ceil((double) particles.length / 9);
ParticleInventory particleInventory = new ParticleInventory(plugin, key, rows, particles);
- String name = Util.capitalize(key.replace("_", " "));
+ String name = Util.capitalize(key.replace("_", " "));
return SmartInventory.builder()
.manager(inventoryManager)
.id("particleInventory")
@@ -98,14 +130,8 @@ public SmartInventory getColorInventory(HuskyPlugin plugin, String key) {
.build();
}
- @Override
- public void deserialize(HuskyPlugin plugin) {
- inventoryManager = new InventoryManager(plugin);
- inventoryManager.init();
- }
-
private boolean isEnabled(World world, Material material) {
- if(Util.getVersion().get(1) < 20) return true;
+ if (Util.getVersion().get(1) < 20) return true;
return material.isEnabledByFeature(world);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/huskydreaming/bouncyball/services/implementations/LocaleServiceImpl.java b/src/main/java/com/huskydreaming/bouncyball/handlers/implementations/LocalizationHandlerImpl.java
similarity index 74%
rename from src/main/java/com/huskydreaming/bouncyball/services/implementations/LocaleServiceImpl.java
rename to src/main/java/com/huskydreaming/bouncyball/handlers/implementations/LocalizationHandlerImpl.java
index 4afe6ed..960dba5 100644
--- a/src/main/java/com/huskydreaming/bouncyball/services/implementations/LocaleServiceImpl.java
+++ b/src/main/java/com/huskydreaming/bouncyball/handlers/implementations/LocalizationHandlerImpl.java
@@ -1,19 +1,18 @@
-package com.huskydreaming.bouncyball.services.implementations;
+package com.huskydreaming.bouncyball.handlers.implementations;
-import com.huskydreaming.bouncyball.services.interfaces.LocaleService;
-import com.huskydreaming.bouncyball.pareseables.Locale;
-import com.huskydreaming.bouncyball.pareseables.Menu;
+import com.huskydreaming.bouncyball.handlers.interfaces.LocalizationHandler;
+import com.huskydreaming.bouncyball.enumerations.Locale;
+import com.huskydreaming.bouncyball.enumerations.Menu;
import com.huskydreaming.huskycore.HuskyPlugin;
import com.huskydreaming.huskycore.storage.Yaml;
-public class LocaleServiceImpl implements LocaleService {
+public class LocalizationHandlerImpl implements LocalizationHandler {
private Yaml locale;
private Yaml menu;
@Override
- public void deserialize(HuskyPlugin plugin) {
-
+ public void initialize(HuskyPlugin plugin) {
// Localization for general messages
locale = new Yaml("localisation/locale");
locale.load(plugin);
@@ -44,4 +43,4 @@ public Yaml getLocale() {
public Yaml getMenu() {
return menu;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/huskydreaming/bouncyball/handlers/implementations/ParticleHandlerImpl.java b/src/main/java/com/huskydreaming/bouncyball/handlers/implementations/ParticleHandlerImpl.java
new file mode 100644
index 0000000..56240d5
--- /dev/null
+++ b/src/main/java/com/huskydreaming/bouncyball/handlers/implementations/ParticleHandlerImpl.java
@@ -0,0 +1,43 @@
+package com.huskydreaming.bouncyball.handlers.implementations;
+
+import com.huskydreaming.bouncyball.data.particles.ParticleData;
+import com.huskydreaming.bouncyball.handlers.interfaces.ParticleHandler;
+import com.huskydreaming.bouncyball.handlers.interfaces.ProjectileHandler;
+import com.huskydreaming.bouncyball.repositories.interfaces.ParticleRepository;
+import com.huskydreaming.huskycore.HuskyPlugin;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Particle;
+import org.bukkit.World;
+import org.bukkit.entity.Projectile;
+
+import java.util.Map;
+
+public class ParticleHandlerImpl implements ParticleHandler {
+
+ private ParticleRepository particleRepository;
+
+ @Override
+ public void postInitialize(HuskyPlugin plugin) {
+ particleRepository = plugin.provide(ParticleRepository.class);
+
+ ProjectileHandler projectileHandler = plugin.provide(ProjectileHandler.class);
+ Map projectileMap = projectileHandler.getProjectileMap();
+
+ Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> projectileMap.forEach((projectile, s) -> {
+ Location location = projectile.getLocation();
+ World world = location.getWorld();
+ if (world == null) return;
+
+ ParticleData particleData = particleRepository.getParticleData(s);
+ if (particleData == null) return;
+
+ if (particleData.getParticle() == Particle.REDSTONE) {
+ Particle.DustOptions dustOptions = new Particle.DustOptions(particleData.getColor(), 1);
+ world.spawnParticle(particleData.getParticle(), location, particleData.getCount(), dustOptions);
+ } else {
+ world.spawnParticle(particleData.getParticle(), location, particleData.getCount());
+ }
+ }), 0L, 1L);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/huskydreaming/bouncyball/services/implementations/ProjectileServiceImpl.java b/src/main/java/com/huskydreaming/bouncyball/handlers/implementations/ProjectileHandlerImpl.java
similarity index 79%
rename from src/main/java/com/huskydreaming/bouncyball/services/implementations/ProjectileServiceImpl.java
rename to src/main/java/com/huskydreaming/bouncyball/handlers/implementations/ProjectileHandlerImpl.java
index a716b19..b71804b 100644
--- a/src/main/java/com/huskydreaming/bouncyball/services/implementations/ProjectileServiceImpl.java
+++ b/src/main/java/com/huskydreaming/bouncyball/handlers/implementations/ProjectileHandlerImpl.java
@@ -1,13 +1,11 @@
-package com.huskydreaming.bouncyball.services.implementations;
+package com.huskydreaming.bouncyball.handlers.implementations;
-import com.google.common.reflect.TypeToken;
import com.huskydreaming.bouncyball.data.projectiles.ProjectileData;
-import com.huskydreaming.bouncyball.data.projectiles.ProjectileDefault;
import com.huskydreaming.bouncyball.data.projectiles.ProjectilePhysics;
import com.huskydreaming.bouncyball.data.projectiles.ProjectileSetting;
-import com.huskydreaming.bouncyball.services.interfaces.ProjectileService;
+import com.huskydreaming.bouncyball.handlers.interfaces.ProjectileHandler;
+import com.huskydreaming.bouncyball.repositories.interfaces.ProjectileRepository;
import com.huskydreaming.huskycore.HuskyPlugin;
-import com.huskydreaming.huskycore.storage.Json;
import com.huskydreaming.huskycore.utilities.Util;
import org.bukkit.*;
import org.bukkit.block.Block;
@@ -21,45 +19,30 @@
import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector;
-import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-public class ProjectileServiceImpl implements ProjectileService {
+public class ProjectileHandlerImpl implements ProjectileHandler {
private NamespacedKey projectileNameSpacedKey;
- private Map projectileDataMap;
+ private ProjectileRepository projectileRepository;
private final Map projectileMap = new ConcurrentHashMap<>();
@Override
- public void deserialize(HuskyPlugin plugin) {
- Type type = new TypeToken