Skip to content

Commit

Permalink
Add Permission for use biome
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya committed Jul 8, 2024
1 parent 237c2c1 commit 318ed3b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jdk:
- openjdk17
- openjdk21

projectDir: api
2 changes: 0 additions & 2 deletions plugin/src/main/java/fr/euphyllia/skyllia/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class Main extends JavaPlugin {

@Override
public void onEnable() {
logger.log(Level.INFO, "Plugin Start");
try {
this.interneAPI = new InterneAPI(this);
} catch (UnsupportedMinecraftVersionException e) {
Expand Down Expand Up @@ -87,7 +86,6 @@ public void onEnable() {

@Override
public void onDisable() {
this.logger.log(Level.INFO, "Plugin Off");
Bukkit.getAsyncScheduler().cancelTasks(this);
Bukkit.getGlobalRegionScheduler().cancelTasks(this);
if (this.interneAPI.getDatabaseLoader() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
return true;
}

if (!player.hasPermission("skyllia.island.command.biome.%s".formatted(biome.name()))) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageBiomePermissionDenied.formatted(selectBiome));
}

if (Boolean.FALSE.equals(WorldUtils.isWorldSkyblock(playerLocation.getWorld().getName()))) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageBiomeOnlyIsland);
return true;
Expand Down Expand Up @@ -125,7 +129,9 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
List<String> biomesList = new ArrayList<>();
if (args.length == 1) {
for (Biome biome : Biome.values()) {
biomesList.add(biome.name());
if (sender.hasPermission("skyllia.island.command.biome.%s".formatted(biome.name()))) {
biomesList.add(biome.name());
}
}
}
return biomesList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class LanguageToml {
public static String messageBiomeCommandNotEnoughArgs = "La commande n'est pas complète : /skyllia biome <biome>";
public static String messageBiomeOnlyIsland = "La commande ne peut être exécuté seulement sur une île";
public static String messageBiomeNotExist = "Le biome %s n'existe pas.";
public static String messageBiomePermissionDenied = "Vous n'avez pas la permission d'utiliser ce biome.";
public static String messageBiomeChangeInProgress = "Changement de biome en cours. Veuillez notez que ça prends du temps... Un message vous avertira quand le processus sera achevé.";
public static String messageBiomeChangeSuccess = "Le changement de biome dans le chunk où vous étiez est terminé ! Vous devez quitter et revenir sur votre île pour voir le changement.";
public static String messageInviteAlreadyIsland = "Vous êtes déjà sur une île !";
Expand Down Expand Up @@ -235,6 +236,7 @@ private static void islandBiomeLanguage() {
messageBiomeCommandNotEnoughArgs = getString("island.biome.not-enough-args", messageBiomeCommandNotEnoughArgs);
messageBiomeOnlyIsland = getString("island.biome.only-island", messageBiomeOnlyIsland);
messageBiomeNotExist = getString("island.biome.biome-not-exist", messageBiomeNotExist);
messageBiomePermissionDenied = getString("island.biome.permission-denied", messageBiomePermissionDenied);
messageBiomeChangeInProgress = getString("island.biome.change-in-progress", messageBiomeChangeInProgress);
messageBiomeChangeSuccess = getString("island.biome.success", messageBiomeChangeSuccess);
}
Expand Down

0 comments on commit 318ed3b

Please sign in to comment.