Skip to content

Commit

Permalink
Plusieurs fix et modification :
Browse files Browse the repository at this point in the history
Fix : #17
Fix : #18
Fix : Les commandes admins ne fonctionnait pas quand j'ai mis à jour le code
Fix : Je m'étais trompé de fichier pour le setsize et setmaxmembers pour le admin
Fix : La WorldBorder ne se mettait pas à jour quand on changeait la taille de l'ile
Fix : La suppression de l'ile s'arrêter sur avant la suppression total, c'est fixé et prends la taille de l'ile
Add : Ajout de l'API SkyblockChangeSizeEvent
Add : le /skyllia visit supporte maintenant les UUID

Version 1.0-RC2
  • Loading branch information
Euphillya committed Jan 30, 2024
1 parent ab6a97c commit c16823e
Show file tree
Hide file tree
Showing 27 changed files with 319 additions and 197 deletions.
8 changes: 5 additions & 3 deletions .idea/sonarlint/issuestore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions .idea/sonarlint/securityhotspotstore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
}

group = "fr.euphyllia.skyllia";
version = "1.0-RC1";
version = "1.0-RC2";

publishing {
repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package fr.euphyllia.skyllia.api.event;

import fr.euphyllia.skyllia.api.skyblock.Island;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class SkyblockChangeSizeEvent extends Event {


private static final HandlerList handlerList = new HandlerList();
private final Island island;
private final double sizeIsland;

public SkyblockChangeSizeEvent(Island island, double rayon) {
super(true);
this.island = island;
this.sizeIsland = rayon;
}


public static HandlerList getHandlerList() {
return handlerList;
}

@Override
public @NotNull HandlerList getHandlers() {
return getHandlerList();
}

public Island getIsland() {
return this.island;
}

public double getSizeIsland() {
return this.sizeIsland;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class Island {

public abstract double getSize();

public abstract void setSize(double rayon) throws MaxIslandSizeExceedException;
public abstract boolean setSize(double rayon) throws MaxIslandSizeExceedException;

public abstract @Nullable CopyOnWriteArrayList<WarpIsland> getWarps();

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "fr.euphyllia";
version = "1.0-RC1";
version = "1.0-RC2";
description = "Plugin Skyblock pour Folia / PaperMC";

val paperRepo = "https://repo.papermc.io/repository/maven-public/";
Expand Down
1 change: 1 addition & 0 deletions plugin/src/main/java/fr/euphyllia/skyllia/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void onEnable() {
this.interneAPI.setManagers(new Managers(interneAPI));
this.interneAPI.getManagers().init();
this.setupCommands();
this.setupAdminCommands();
this.loadListener();
this.runCache();
this.disabledConfig();
Expand Down
13 changes: 11 additions & 2 deletions plugin/src/main/java/fr/euphyllia/skyllia/cache/CacheManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import fr.euphyllia.skyllia.api.skyblock.Island;
import fr.euphyllia.skyllia.api.skyblock.Players;
import fr.euphyllia.skyllia.api.skyblock.model.PermissionRoleIsland;
import fr.euphyllia.skyllia.api.skyblock.model.Position;
import fr.euphyllia.skyllia.api.skyblock.model.RoleType;
import fr.euphyllia.skyllia.api.skyblock.model.permissions.PermissionsType;
import fr.euphyllia.skyllia.managers.skyblock.SkyblockManager;
import fr.euphyllia.skyllia.utils.RegionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bukkit.entity.Player;

import java.util.List;
import java.util.UUID;
import java.util.concurrent.Executors;

Expand Down Expand Up @@ -45,7 +48,10 @@ public void deleteCacheIsland(Island island) {

PlayersInIslandCache.delete(island.getId());
// ============= position island cache
PositionIslandCache.delete(island.getPosition());
List<Position> islandPositionWithRadius = RegionUtils.getRegionsInRadius(island.getPosition(), (int) Math.round(island.getSize()));
for (Position possiblePosition : islandPositionWithRadius) {
PositionIslandCache.delete(possiblePosition);
}
// ============= permission role cache
for (RoleType roleType : RoleType.values()) {
for (PermissionsType permissionsType : PermissionsType.values()) {
Expand All @@ -61,7 +67,10 @@ public void updateCacheIsland(Island island, UUID playerId) {
PlayersInIslandCache.getIslandIdByPlayerId().put(playerId, island.getId());
PlayersInIslandCache.add(island.getId(), island.getMembers());
// ============= position island cache
PositionIslandCache.add(island.getPosition(), island);
List<Position> islandPositionWithRadius = RegionUtils.getRegionsInRadius(island.getPosition(), (int) Math.round(island.getSize()));
for (Position possiblePosition : islandPositionWithRadius) {
PositionIslandCache.add(possiblePosition, island);
}
// ============= permission role cache
this.updatePermissionCacheIsland(island);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import fr.euphyllia.skyllia.commands.SubCommandInterface;
import fr.euphyllia.skyllia.commands.admin.subcommands.ForceDeleteSubCommands;
import fr.euphyllia.skyllia.commands.admin.subcommands.InfoSubCommands;
import fr.euphyllia.skyllia.commands.admin.subcommands.SetMaxMembersSubCommands;
import fr.euphyllia.skyllia.commands.admin.subcommands.SetSizeSubCommands;
import org.jetbrains.annotations.NotNull;

public enum SubAdminCommands {
FORCEDELETE(new ForceDeleteSubCommands()),
INFO(new InfoSubCommands()),
SETMAXMEMBERS(new SetMaxMembersSubCommands()),
SETSIZE(new SetSizeSubCommands()),
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
}
String playerName = args[0];
String confirm = args[1];
if (confirm.equalsIgnoreCase("confirm")) {
if (!confirm.equalsIgnoreCase("confirm")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageADeleteNotConfirmedArgs);
return true;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package fr.euphyllia.skyllia.commands.admin.subcommands;

import fr.euphyllia.skyllia.Main;
import fr.euphyllia.skyllia.api.skyblock.Island;
import fr.euphyllia.skyllia.commands.SubCommandInterface;
import fr.euphyllia.skyllia.configuration.LanguageToml;
import fr.euphyllia.skyllia.managers.skyblock.SkyblockManager;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

public class SetMaxMembersSubCommands implements SubCommandInterface {

private final Logger logger = LogManager.getLogger(SetMaxMembersSubCommands.class);

@Override
public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player player)) {
return true;
}
if (!player.hasPermission("skyllia.admins.commands.island.setmaxmembers")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
return true;
}

if (args.length < 3) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetMaxMembersCommandNotEnoughArgs);
return true;
}
String playerName = args[0];
String changeValue = args[1];
String confirm = args[2];
if (!confirm.equalsIgnoreCase("confirm")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetMaxMembersNotConfirmedArgs);
return true;
}
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
try {
executor.execute(() -> {
try {
UUID playerId;
try {
playerId = UUID.fromString(playerName);
} catch (IllegalArgumentException ignored) {
playerId = Bukkit.getPlayerUniqueId(playerName);
}
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(playerId).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
}

int members = Integer.parseInt(changeValue);
boolean updated = island.setMaxMembers(members);
if (updated) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetSizeSuccess);
} else {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetSizeFailed);
}

} catch (Exception e) {
if (e instanceof NumberFormatException ignored) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetMaxMembersNAN);
} else {
logger.log(Level.FATAL, e.getMessage(), e);
LanguageToml.sendMessage(plugin, player, LanguageToml.messageError);
}
}
});
} finally {
executor.shutdown();
}
return true;
}

@Override
public @Nullable List<String> onTabComplete(@NotNull Main plugin, @NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Executors;
Expand All @@ -41,7 +42,8 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
String playerName = args[0];
String changeValue = args[1];
String confirm = args[2];
if (confirm.equalsIgnoreCase("confirm")) {
System.out.println(Arrays.toString(args));
if (!confirm.equalsIgnoreCase("confirm")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetSizeNotConfirmedArgs);
return true;
}
Expand All @@ -62,8 +64,8 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
return;
}

int members = Integer.parseInt(changeValue);
boolean updated = island.setMaxMembers(members);
double newSize = Double.parseDouble(changeValue);
boolean updated = island.setSize(newSize);
if (updated) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetSizeSuccess);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
executor.execute(() -> {
try {
String visitPlayer = args[0];
UUID visitPlayerId = Bukkit.getPlayerUniqueId(visitPlayer);
UUID visitPlayerId;
try {
visitPlayerId = UUID.fromString(visitPlayer);
} catch (IllegalArgumentException ignored) {
visitPlayerId = Bukkit.getPlayerUniqueId(visitPlayer);
}
if (visitPlayerId == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerNotFound);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public class LanguageToml {
public static String messageUntrustFailed = "Une erreur s'est produite lors de la suppression de la personne dans votre liste de confiance. Etait-il bien en confiance sur votre île ?";
public static String messageUntrustSuccess = "Le membre ne fait dorénavant plus partie de vos confiances";
public static String messageUntrustCommandNotEnoughArgs = "La commande est incomplète : /skyllia untrust <player>";
public static String messageASetMaxMembersCommandNotEnoughArgs = "La commande est incomplète : /skyllia setmaxmembres value confirm";
public static String messageASetMaxMembersNotConfirmedArgs = "Vous n'avez pas ajouter le \"confirm\" à la fin";
public static String messageASetMaxMembersNAN = "Le nombre indiqué est incorrect.";
private static boolean verbose;

public static void init(File configFile) {
Expand Down Expand Up @@ -189,6 +192,10 @@ private static void adminLanguage() {
messageASetSizeFailed = getString("admin.commands.island.setsize.failed", messageASetSizeFailed);
messageASetSizeNAN = getString("admin.commands.island.setsize.nan", messageASetSizeNAN);
messageASetSizeNotConfirmedArgs = getString("admin.commands.island.setsize.no-confirm", messageASetSizeNotConfirmedArgs);
// setSize
messageASetMaxMembersCommandNotEnoughArgs = getString("admin.commands.island.setmaxmembers.not-enough-args", messageASetMaxMembersCommandNotEnoughArgs);
messageASetMaxMembersNotConfirmedArgs = getString("admin.commands.island.setmaxmembers.no-confirm", messageASetMaxMembersNotConfirmedArgs);
messageASetMaxMembersNAN = getString("admin.commands.island.setmaxmembers.nan", messageASetMaxMembersNAN);

}

Expand Down
Loading

0 comments on commit c16823e

Please sign in to comment.