Skip to content

Commit

Permalink
Hotfix Commandes :
Browse files Browse the repository at this point in the history
Seulement les propriétaires pouvait executer les commandes...

Disparition de owner_uuid de la base de donnée Island qui me servait dans mes testes et a eu également par conséquence de devoir réparer toutes les commandes
  • Loading branch information
Euphillya committed Jan 27, 2024
1 parent 417a86e commit 91e9b7b
Show file tree
Hide file tree
Showing 32 changed files with 203 additions and 110 deletions.
16 changes: 15 additions & 1 deletion .idea/sonarlint/issuestore/index.pb

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

16 changes: 15 additions & 1 deletion .idea/sonarlint/securityhotspotstore/index.pb

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

import java.util.UUID;

/**
* Appelé quand l'île est créée. <br />
*/
public class SkyblockCreateEvent extends Event {

private static final HandlerList handlerList = new HandlerList();
private final Island island;
private final UUID owner;

public SkyblockCreateEvent(Island islandCreate) {
public SkyblockCreateEvent(Island islandCreate, UUID owner) {
super(true);
this.island = islandCreate;
this.owner = owner;
}


Expand All @@ -31,4 +35,8 @@ public static HandlerList getHandlerList() {
public Island getIsland() {
return this.island;
}

public UUID getOwnerId() {
return this.owner;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ public abstract class Island {

public abstract boolean updatePermissionIsland(PermissionsType permissionsType, RoleType roleType, long permissions);

public abstract UUID getOwnerId();

public abstract void setOwnerId(UUID ownerId);

public abstract Position getPosition();

public abstract IslandType getIslandType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ static GameType getGameType(GameMode gameMode) {
};
}

public static void addWorldTemp(ServerLevel internal) {
io.papermc.paper.threadedregions.RegionizedServer.getInstance().addWorld(internal);
}

public static void ensureGlobalTickThread() {
io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("World create can be done only on global tick thread");
}

@Override
public WorldFeedback.FeedbackWorld createWorld(WorldCreator creator) {
ensureGlobalTickThread();
Expand Down Expand Up @@ -200,12 +208,4 @@ public void resetChunk(World craftWorld, Position position) {
serverChunkCache.blockChanged(blockPos);
}
}

public static void addWorldTemp(ServerLevel internal) {
io.papermc.paper.threadedregions.RegionizedServer.getInstance().addWorld(internal);
}

public static void ensureGlobalTickThread() {
io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("World create can be done only on global tick thread");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ static GameType getGameType(GameMode gameMode) {
};
}

private static void setRandom(ServerLevel serverLevel) {
try {
Class<?> clazz = serverLevel.getClass();

// Obtention du champ 'randomSpawnSelection'
Field randomSpawnSelectionField = clazz.getDeclaredField("randomSpawnSelection");
randomSpawnSelectionField.setAccessible(true);

ChunkPos newValue = new ChunkPos(serverLevel.getChunkSource().randomState().sampler().findSpawnPosition());
randomSpawnSelectionField.set(serverLevel, newValue);

} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public WorldFeedback.FeedbackWorld createWorld(WorldCreator creator) {
//io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("World create can be done only on global tick thread");
Expand Down Expand Up @@ -196,7 +212,7 @@ public WorldFeedback.FeedbackWorld createWorld(WorldCreator creator) {
// Paper start - fix and optimise world upgrading
if (console.options.has("forceUpgrade")) {
net.minecraft.server.Main.convertWorldButItWorks(
actualDimension, worldSession, DataFixers.getDataFixer(), worlddimension.generator().getTypeNameForDataFixer(), console.options.has("eraseCache")
actualDimension, worldSession, DataFixers.getDataFixer(), worlddimension.generator().getTypeNameForDataFixer(), console.options.has("eraseCache")
);
}
// Paper end - fix and optimise world upgrading
Expand Down Expand Up @@ -242,20 +258,4 @@ public void resetChunk(World craftWorld, Position position) {
serverChunkCache.blockChanged(blockPos);
}
}

private static void setRandom(ServerLevel serverLevel) {
try {
Class<?> clazz = serverLevel.getClass();

// Obtention du champ 'randomSpawnSelection'
Field randomSpawnSelectionField = clazz.getDeclaredField("randomSpawnSelection");
randomSpawnSelectionField.setAccessible(true);

ChunkPos newValue = new ChunkPos(serverLevel.getChunkSource().randomState().sampler().findSpawnPosition());
randomSpawnSelectionField.set(serverLevel, newValue);

} catch (Exception e) {
e.printStackTrace();
}
}
}
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
executor.execute(() -> {
try {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();

if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
try {
executor.execute(() -> {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.euphyllia.skyllia.commands.subcommands;

import fr.euphyllia.skyllia.Main;
import fr.euphyllia.skyllia.api.event.SkyblockCreateEvent;
import fr.euphyllia.skyllia.api.event.SkyblockLoadEvent;
import fr.euphyllia.skyllia.api.skyblock.Island;
import fr.euphyllia.skyllia.api.skyblock.Players;
Expand Down Expand Up @@ -28,6 +29,7 @@

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

Expand Down Expand Up @@ -72,13 +74,17 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
}

LanguageToml.sendMessage(plugin, player, LanguageToml.messageIslandInProgress);
UUID idIsland = UUID.randomUUID();

island = skyblockManager.createIsland(player.getUniqueId(), islandType).join();
if (island == null) {
boolean isCreate = Boolean.TRUE.equals(skyblockManager.createIsland(idIsland, islandType).join());
if (!isCreate) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageIslandError);
return;
}

island = skyblockManager.getIslandByIslandId(idIsland).join();
Bukkit.getPluginManager().callEvent(new SkyblockCreateEvent(island, player.getUniqueId()));

Location center = RegionUtils.getCenterRegion(Bukkit.getWorld(schematicWorld.worldName()), island.getPosition().x(), island.getPosition().z());
center.setY(schematicWorld.height()); // Fix
this.pasteSchematic(plugin, island, center, schematicWorld);
Expand Down Expand Up @@ -139,7 +145,7 @@ private boolean setFirstHome(Island island, Location center) {
}

private void addOwnerIslandInMember(Island island, Player player) {
Players owners = new Players(player.getUniqueId(), player.getName(), island.getOwnerId(), RoleType.OWNER);
Players owners = new Players(player.getUniqueId(), player.getName(), island.getId(), RoleType.OWNER);
island.updateMember(owners);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
executor.execute(() -> {
try {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
String playerName = args[0];

SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
executor.execute(() -> {
try {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();

if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
executor.execute(() -> {
try {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
private void invitePlayer(Main plugin, Player ownerIsland, String playerInvited) {
try {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(ownerIsland.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(ownerIsland.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, ownerIsland, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down Expand Up @@ -127,7 +127,7 @@ private void invitePlayer(Main plugin, Player ownerIsland, String playerInvited)
private void acceptPlayer(Main plugin, Player playerWantJoin, String ownerIsland) {
try {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island islandPlayer = skyblockManager.getIslandByOwner(playerWantJoin.getUniqueId()).join();
Island islandPlayer = skyblockManager.getIslandByPlayerId(playerWantJoin.getUniqueId()).join();
if (islandPlayer != null) {
LanguageToml.sendMessage(plugin, playerWantJoin, LanguageToml.messageInviteAlreadyIsland);
return;
Expand Down Expand Up @@ -159,7 +159,7 @@ private void acceptPlayer(Main plugin, Player playerWantJoin, String ownerIsland
private void declinePlayer(Main plugin, Player playerWantDecline, String ownerIsland) {
try {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(playerWantDecline.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(playerWantDecline.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, playerWantDecline, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
try {
executor.execute(() -> {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
try {
executor.execute(() -> {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N

try {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
String playerName = args[0];

SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,13 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N
return;
}

SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();

if (Boolean.FALSE.equals(WorldUtils.isWorldSkyblock(playerLocation.getWorld().getName()))) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messageBiomeOnlyIsland);
return;
}

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

if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
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
executor.execute(() -> {
try {
SkyblockManager skyblockManager = plugin.getInterneAPI().getSkyblockManager();
Island island = skyblockManager.getIslandByOwner(player.getUniqueId()).join();
Island island = skyblockManager.getIslandByPlayerId(player.getUniqueId()).join();
if (island == null) {
LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland);
return;
Expand Down
Loading

0 comments on commit 91e9b7b

Please sign in to comment.