Skip to content

Commit

Permalink
Add message permission to teleport portal
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya committed Aug 28, 2024
1 parent 66b0009 commit 5beba6e
Show file tree
Hide file tree
Showing 35 changed files with 243 additions and 235 deletions.
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.vfs.watch=false
org.gradle.jvmargs=-Xmx8g
2 changes: 1 addition & 1 deletion nms/v1_21_R1/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

dependencies {
paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.21-R0.1-SNAPSHOT")
compileOnly(project(":nms:v1_20_R4"))
compileOnly(project(":api"))
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/java/fr/euphyllia/skyllia/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private void loadListener() {
pluginManager.registerEvents(new PlayerEvent(this.interneAPI), this);
pluginManager.registerEvents(new DamageEvent(this.interneAPI), this);
pluginManager.registerEvents(new InteractEvent(this.interneAPI), this);
pluginManager.registerEvents(new TeleportEvent(this.interneAPI), this); // Todo Don't work with folia 1.19.4-1.20.6 (can work on Bloom, but don't use it)
pluginManager.registerEvents(new TeleportEvent(this.interneAPI), this); // Todo Don't work with folia 1.19.4-1.21.1 (can work on Bloom, but don't use it)
pluginManager.registerEvents(new PistonEvent(this.interneAPI), this);
if (VersionUtils.IS_FOLIA) {
pluginManager.registerEvents(new PortalAlternativeFoliaEvent(this.interneAPI), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
return true;
}
if (!player.hasPermission("skyllia.admins.commands.island.delete")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerPermissionDenied);
return true;
}

if (args.length < 2) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageADeleteCommandNotEnoughArgs);
LanguageToml.sendMessage(player, LanguageToml.messageADeleteCommandNotEnoughArgs);
return true;
}
String playerName = args[0];
String confirm = args[1];
if (!confirm.equalsIgnoreCase("confirm")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageADeleteNotConfirmedArgs);
LanguageToml.sendMessage(player, LanguageToml.messageADeleteNotConfirmedArgs);
return true;
}
try {
Expand All @@ -59,7 +59,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(playerId).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerHasNotIsland);
return true;
}

Expand All @@ -71,13 +71,13 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
WorldEditUtils.deleteIsland(plugin, island, Bukkit.getWorld(worldConfig.name()));
}

LanguageToml.sendMessage(plugin, player, LanguageToml.messageIslandDeleteSuccess);
LanguageToml.sendMessage(player, LanguageToml.messageIslandDeleteSuccess);
} else {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageError);
LanguageToml.sendMessage(player, LanguageToml.messageError);
}
} catch (Exception e) {
logger.log(Level.FATAL, e.getMessage(), e);
LanguageToml.sendMessage(plugin, player, LanguageToml.messageError);
LanguageToml.sendMessage(player, LanguageToml.messageError);
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
return true;
}
if (!player.hasPermission("skyllia.admins.commands.island.setmaxmembers")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerPermissionDenied);
return true;
}

if (args.length < 3) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetMaxMembersCommandNotEnoughArgs);
LanguageToml.sendMessage(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);
LanguageToml.sendMessage(player, LanguageToml.messageASetMaxMembersNotConfirmedArgs);
return true;
}
try {
Expand All @@ -53,24 +53,24 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(playerId).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerHasNotIsland);
return true;
}

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

} catch (Exception e) {
if (e instanceof NumberFormatException ignored) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetMaxMembersNAN);
LanguageToml.sendMessage(player, LanguageToml.messageASetMaxMembersNAN);
} else {
logger.log(Level.FATAL, e.getMessage(), e);
LanguageToml.sendMessage(plugin, player, LanguageToml.messageError);
LanguageToml.sendMessage(player, LanguageToml.messageError);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
return true;
}
if (!player.hasPermission("skyllia.admins.commands.island.setsize")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerPermissionDenied);
return true;
}

if (args.length < 3) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetSizeCommandNotEnoughArgs);
LanguageToml.sendMessage(player, LanguageToml.messageASetSizeCommandNotEnoughArgs);
return true;
}
String playerName = args[0];
String changeValue = args[1];
String confirm = args[2];
if (!confirm.equalsIgnoreCase("confirm")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetSizeNotConfirmedArgs);
LanguageToml.sendMessage(player, LanguageToml.messageASetSizeNotConfirmedArgs);
return true;
}
try {
Expand All @@ -53,24 +53,24 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(playerId).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerHasNotIsland);
return true;
}

double newSize = Double.parseDouble(changeValue);
boolean updated = island.setSize(newSize);
if (updated) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetSizeSuccess);
LanguageToml.sendMessage(player, LanguageToml.messageASetSizeSuccess);
} else {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetSizeFailed);
LanguageToml.sendMessage(player, LanguageToml.messageASetSizeFailed);
}

} catch (Exception e) {
if (e instanceof NumberFormatException ignored) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageASetSizeNAN);
LanguageToml.sendMessage(player, LanguageToml.messageASetSizeNAN);
} else {
logger.log(Level.FATAL, e.getMessage(), e);
LanguageToml.sendMessage(plugin, player, LanguageToml.messageError);
LanguageToml.sendMessage(player, LanguageToml.messageError);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ public enum SubCommands {
VISIT(new VisitSubCommand(), "visit"),
WARP(new WarpSubCommand(), "warp");

private final SubCommandInterface commandInterface;
private final String[] aliases;

private static final Map<String, SubCommands> commandMap = new HashMap<>();

static {
Expand All @@ -46,6 +43,9 @@ public enum SubCommands {
}
}

private final SubCommandInterface commandInterface;
private final String[] aliases;

SubCommands(SubCommandInterface subCommandInterface, String... aliases) {
this.commandInterface = subCommandInterface;
this.aliases = aliases;
Expand All @@ -55,11 +55,11 @@ public static SubCommands subCommandByName(@NotNull String name) {
return commandMap.get(name.toLowerCase());
}

public SubCommandInterface getSubCommandInterface() {
return this.commandInterface;
}

public static Map<String, SubCommands> getCommandMap() {
return commandMap;
}

public SubCommandInterface getSubCommandInterface() {
return this.commandInterface;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
return true;
}
if (!player.hasPermission("skyllia.island.command.access")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerPermissionDenied);
return true;
}

SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();

if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerHasNotIsland);
return true;
}

Expand All @@ -55,7 +55,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N

PermissionManager permissionManager = new PermissionManager(permissionRoleIsland.permission());
if (!permissionManager.hasPermission(PermissionsCommandIsland.ACCESS)) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerPermissionDenied);
return true;
}
}
Expand All @@ -65,7 +65,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
boolean isUpdate = island.setPrivateIsland(statusAccessUpdate);
if (isUpdate) {
if (statusAccessUpdate) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageAccessIslandClose);
LanguageToml.sendMessage(player, LanguageToml.messageAccessIslandClose);
ConfigToml.worldConfigs.forEach(worldConfig -> {
RegionUtils.getEntitiesInRegion(plugin, EntityType.PLAYER, Bukkit.getWorld(worldConfig.name()), island.getPosition().x(), island.getPosition().z(), entity -> {
Player playerInIsland = (Player) entity;
Expand All @@ -77,7 +77,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
});
});
} else {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageAccessIslandOpen);
LanguageToml.sendMessage(player, LanguageToml.messageAccessIslandOpen);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
return true;
}
if (!player.hasPermission("skyllia.island.command.ban")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerPermissionDenied);
return true;
}
if (args.length < 1) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageBanCommandNotEnoughArgs);
LanguageToml.sendMessage(player, LanguageToml.messageBanCommandNotEnoughArgs);
return true;
}
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerHasNotIsland);
return true;
}

Expand All @@ -53,7 +53,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N

PermissionManager permissionManager = new PermissionManager(permissionRoleIsland.permission());
if (!permissionManager.hasPermission(PermissionsCommandIsland.BAN)) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerPermissionDenied);
return true;
}
}
Expand All @@ -62,20 +62,20 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
Players players = island.getMember(playerBan);

if (players != null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageBanImpossiblePlayerInIsland);
LanguageToml.sendMessage(player, LanguageToml.messageBanImpossiblePlayerInIsland);
return true;
}

Player bPlayerBan = Bukkit.getPlayerExact(playerBan);
if (bPlayerBan == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerNotFound);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerNotFound);
return true;
}

players = new Players(bPlayerBan.getUniqueId(), playerBan, island.getId(), RoleType.BAN);

island.updateMember(players);
LanguageToml.sendMessage(plugin, player, LanguageToml.messageBanPlayerSuccess);
LanguageToml.sendMessage(player, LanguageToml.messageBanPlayerSuccess);
ExpelSubCommand.expelPlayer(plugin, island, bPlayerBan, player, true);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
return true;
}
if (!player.hasPermission("skyllia.island.command.create")) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerPermissionDenied);
return true;
}
GameMode olgGM = player.getGameMode();
Expand All @@ -65,26 +65,26 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
}
Map<String, SchematicSetting> schematicSettingMap = IslandUtils.getSchematic(schemKey);
if (schematicSettingMap == null || schematicSettingMap.isEmpty()) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageIslandSchemNotExist);
LanguageToml.sendMessage(player, LanguageToml.messageIslandSchemNotExist);
return true;
}
IslandSettings islandSettings = IslandUtils.getIslandSettings(schemKey);

if (islandSettings == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageIslandTypeNotExist);
LanguageToml.sendMessage(player, LanguageToml.messageIslandTypeNotExist);
return true;
}

if (!player.hasPermission("skyllia.island.command.create.%s".formatted(schemKey))) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerPermissionDenied);
LanguageToml.sendMessage(player, LanguageToml.messagePlayerPermissionDenied);
return true;
}

LanguageToml.sendMessage(plugin, player, LanguageToml.messageIslandInProgress);
LanguageToml.sendMessage(player, LanguageToml.messageIslandInProgress);
UUID idIsland = UUID.randomUUID();
boolean isCreate = Boolean.TRUE.equals(skyblockManager.createIsland(idIsland, islandSettings).join());
if (!isCreate) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageIslandError);
LanguageToml.sendMessage(player, LanguageToml.messageIslandError);
return true;
}
islandAtomic.set(skyblockManager.getIslandByIslandId(idIsland).join());
Expand All @@ -101,10 +101,11 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
this.setFirstHome(islandAtomic.get(), centerPaste);
this.setPermissionsRole(islandAtomic.get());
player.teleportAsync(centerPaste, PlayerTeleportEvent.TeleportCause.PLUGIN);
if (ConfigToml.changeGameModeWhenTeleportIsland) PlayerFolia.setGameMode(player, GameMode.SURVIVAL);
if (ConfigToml.changeGameModeWhenTeleportIsland)
PlayerFolia.setGameMode(player, GameMode.SURVIVAL);
this.addOwnerIslandInMember(islandAtomic.get(), player);
plugin.getInterneAPI().getPlayerNMS().setOwnWorldBorder(plugin, player, centerPaste, islandAtomic.get().getSize(), 0, 0);
LanguageToml.sendMessage(plugin, player, LanguageToml.messageIslandCreateFinish);
LanguageToml.sendMessage(player, LanguageToml.messageIslandCreateFinish);
CompletableFuture.runAsync(() -> Bukkit.getPluginManager().callEvent(new SkyblockLoadEvent(islandAtomic.get())));
isFirstIteration = false;
}
Expand All @@ -115,7 +116,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
} catch (Exception e) {
logger.log(Level.FATAL, e.getMessage(), e);
if (ConfigToml.changeGameModeWhenTeleportIsland) PlayerFolia.setGameMode(player, olgGM);
LanguageToml.sendMessage(plugin, player, LanguageToml.messageError);
LanguageToml.sendMessage(player, LanguageToml.messageError);
}
return true;
}
Expand Down
Loading

0 comments on commit 5beba6e

Please sign in to comment.