Skip to content

Commit

Permalink
chore: use NeoSkies
Browse files Browse the repository at this point in the history
Signed-off-by: Awakened-Redstone <[email protected]>
  • Loading branch information
Awakened-Redstone committed May 14, 2024
1 parent 501eac7 commit 6cd733e
Show file tree
Hide file tree
Showing 66 changed files with 433 additions and 433 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.awakenedredstone.neoskies;

import com.awakenedredstone.neoskies.command.SkylandsCommands;
import com.awakenedredstone.neoskies.command.NeoSkiesCommands;
import com.awakenedredstone.neoskies.font.FontManager;
import com.awakenedredstone.neoskies.logic.Skylands;
import com.awakenedredstone.neoskies.logic.SkylandsEventListeners;
import com.awakenedredstone.neoskies.logic.EventListeners;
import com.awakenedredstone.neoskies.logic.IslandLogic;
import com.awakenedredstone.neoskies.logic.registry.NeoSkiesIslandSettings;
import com.awakenedredstone.neoskies.logic.registry.SkylandsPermissionLevels;
import com.awakenedredstone.neoskies.logic.registry.NeoSkiesPermissionLevels;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.fabricmc.api.ModInitializer;
Expand All @@ -17,7 +17,7 @@
import java.util.HashSet;
import java.util.Set;

public class SkylandsMain implements ModInitializer {
public class NeoSkies implements ModInitializer {
public static final String MOD_ID = "neoskies";
public static final Logger LOGGER = LoggerFactory.getLogger("NeoSkies");
public static final Set<PlayerEntity> PROTECTION_BYPASS = new HashSet<>();
Expand All @@ -30,12 +30,12 @@ public class SkylandsMain implements ModInitializer {
@Override
public void onInitialize() {
NeoSkiesIslandSettings.init();
SkylandsPermissionLevels.init();
SkylandsEventListeners.registerEvents();
SkylandsCommands.init();
NeoSkiesPermissionLevels.init();
EventListeners.registerEvents();
NeoSkiesCommands.init();
FontManager.init();

Skylands.getConfig().load();
IslandLogic.getConfig().load();
}

public static Identifier id(String path) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.awakenedredstone.neoskies.api;

import com.awakenedredstone.neoskies.logic.Island;
import com.awakenedredstone.neoskies.logic.Skylands;
import com.awakenedredstone.neoskies.logic.IslandLogic;
import com.awakenedredstone.neoskies.util.Constants;
import eu.pb4.common.economy.api.EconomyAccount;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -12,8 +12,8 @@
import java.util.Optional;
import java.util.UUID;

public class SkylandsAPI {
public static final Skylands SKYLANDS = Skylands.getInstance();
public class NeoSkiesAPI {
public static final IslandLogic NEO_SKIES_LOGIC = IslandLogic.getInstance();

public static boolean isHub(World world) {
return world.getRegistryKey() == World.OVERWORLD;
Expand Down Expand Up @@ -48,28 +48,28 @@ public static boolean isEnd(RegistryKey<World> registryKey) {
}

public static Optional<Island> getIslandByPlayer(PlayerEntity player) {
return SKYLANDS.islands.getFromMember(player);
return NEO_SKIES_LOGIC.islands.getFromMember(player);
}

public static Optional<Island> getIslandByPlayer(String playerName) {
return SKYLANDS.islands.getByPlayer(playerName);
return NEO_SKIES_LOGIC.islands.getByPlayer(playerName);
}

public static Optional<Island> getIslandByPlayer(UUID playerUuid) {
return SKYLANDS.islands.getByPlayer(playerUuid);
return NEO_SKIES_LOGIC.islands.getByPlayer(playerUuid);
}

public static Optional<Island> getIsland(UUID islandId) {
return SKYLANDS.islands.get(islandId);
return NEO_SKIES_LOGIC.islands.get(islandId);
}

public static Optional<Island> getIsland(World world) {
return getIsland(world.getRegistryKey());
}

public static Optional<Island> getIsland(RegistryKey<World> registryKey) {
if (SkylandsAPI.isIsland(registryKey)) {
return SKYLANDS.islands.getByPlayer(UUID.fromString(registryKey.getValue().getPath()));
if (NeoSkiesAPI.isIsland(registryKey)) {
return NEO_SKIES_LOGIC.islands.getByPlayer(UUID.fromString(registryKey.getValue().getPath()));
}
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.awakenedredstone.neoskies.api.island;

import com.awakenedredstone.neoskies.logic.registry.SkylandsRegistries;
import com.awakenedredstone.neoskies.logic.registry.NeoSkiesRegistries;
import net.minecraft.util.Identifier;

import java.util.concurrent.atomic.AtomicReference;
Expand All @@ -25,14 +25,14 @@ public int getLevel() {
}

private Identifier getIdentifierFromRegistry() {
return SkylandsRegistries.PERMISSION_LEVELS.getId(this);
return NeoSkiesRegistries.PERMISSION_LEVELS.getId(this);
}

public static PermissionLevel fromValue(Identifier id) {
return SkylandsRegistries.PERMISSION_LEVELS.get(id);
return NeoSkiesRegistries.PERMISSION_LEVELS.get(id);
}

public static PermissionLevel fromValue(String id) {
return SkylandsRegistries.PERMISSION_LEVELS.get(new Identifier(id));
return NeoSkiesRegistries.PERMISSION_LEVELS.get(new Identifier(id));
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.awakenedredstone.neoskies.command;

import com.awakenedredstone.neoskies.SkylandsMain;
import com.awakenedredstone.neoskies.NeoSkies;
import com.awakenedredstone.neoskies.command.admin.*;
import com.awakenedredstone.neoskies.command.island.*;
import com.awakenedredstone.neoskies.logic.Skylands;
import com.awakenedredstone.neoskies.logic.IslandLogic;
import com.awakenedredstone.neoskies.util.Texts;
import com.mojang.brigadier.CommandDispatcher;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
Expand All @@ -18,14 +18,14 @@
import static com.awakenedredstone.neoskies.command.utils.CommandUtils.adminNode;
import static com.awakenedredstone.neoskies.command.utils.CommandUtils.registerAdmin;

public class SkylandsCommands {
public class NeoSkiesCommands {

public static void init() {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> SkylandsCommands.register(dispatcher));
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> NeoSkiesCommands.register(dispatcher));
}

private static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
SkylandsMain.LOGGER.debug("Registering commands...");
NeoSkies.LOGGER.debug("Registering commands...");
registerPublicCommands(dispatcher);
registerAdminCommands(dispatcher);
}
Expand Down Expand Up @@ -58,7 +58,7 @@ private static void registerAdminCommands(CommandDispatcher<ServerCommandSource>
.then(CommandManager.literal("reload")
.executes(context -> {
context.getSource().sendFeedback(() -> Texts.prefixed(Text.translatable("commands.neoskies.reload")), true);
Skylands.getConfig().load();
IslandLogic.getConfig().load();
return 1;
})
)
Expand All @@ -75,7 +75,7 @@ private static void registerAdminCommands(CommandDispatcher<ServerCommandSource>

ServerPlayerEntity player = source.getPlayer();

Set<PlayerEntity> protectionBypass = SkylandsMain.PROTECTION_BYPASS;
Set<PlayerEntity> protectionBypass = NeoSkies.PROTECTION_BYPASS;
boolean overrideMode = protectionBypass.contains(player);
if (overrideMode) {
protectionBypass.remove(player);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.awakenedredstone.neoskies.command.admin;

import com.awakenedredstone.neoskies.api.SkylandsAPI;
import com.awakenedredstone.neoskies.api.NeoSkiesAPI;
import com.awakenedredstone.neoskies.command.utils.CommandUtils;
import com.awakenedredstone.neoskies.logic.Island;
import com.awakenedredstone.neoskies.util.MapBuilder;
Expand Down Expand Up @@ -30,30 +30,30 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
.then(literal("get")
.executes(context -> {
String islandId = StringArgumentType.getString(context, "island");
return getBalance(context.getSource(), SkylandsAPI.getIsland(UUID.fromString(islandId)).orElse(null));
return getBalance(context.getSource(), NeoSkiesAPI.getIsland(UUID.fromString(islandId)).orElse(null));
})
).then(literal("set")
.then(argument("amount", LongArgumentType.longArg())
.executes(context -> {
String islandId = StringArgumentType.getString(context, "island");
long amount = LongArgumentType.getLong(context, "amount");
return setBalance(context.getSource(), SkylandsAPI.getIsland(UUID.fromString(islandId)).orElse(null), amount);
return setBalance(context.getSource(), NeoSkiesAPI.getIsland(UUID.fromString(islandId)).orElse(null), amount);
})
)
).then(literal("add")
.then(argument("amount", LongArgumentType.longArg())
.executes(context -> {
String islandId = StringArgumentType.getString(context, "island");
long amount = LongArgumentType.getLong(context, "amount");
return addBalance(context.getSource(), SkylandsAPI.getIsland(UUID.fromString(islandId)).orElse(null), amount);
return addBalance(context.getSource(), NeoSkiesAPI.getIsland(UUID.fromString(islandId)).orElse(null), amount);
})
)
).then(literal("remove")
.then(argument("amount", LongArgumentType.longArg())
.executes(context -> {
String islandId = StringArgumentType.getString(context, "island");
long amount = LongArgumentType.getLong(context, "amount");
return removeBalance(context.getSource(), SkylandsAPI.getIsland(UUID.fromString(islandId)).orElse(null), amount);
return removeBalance(context.getSource(), NeoSkiesAPI.getIsland(UUID.fromString(islandId)).orElse(null), amount);
})
)
)
Expand All @@ -67,7 +67,7 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
source.sendError(Texts.of("message.neoskies.error.island_not_found"));
return null;
}
EconomyAccount islandWallet = SkylandsAPI.getIslandWallet(island);
EconomyAccount islandWallet = NeoSkiesAPI.getIslandWallet(island);
if (islandWallet == null) {
source.sendError(Texts.of("message.neoskies.error.island_wallet_not_found"));
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.awakenedredstone.neoskies.command.admin;

import com.awakenedredstone.neoskies.logic.Skylands;
import com.awakenedredstone.neoskies.logic.IslandLogic;
import com.awakenedredstone.neoskies.util.Texts;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
Expand All @@ -20,10 +20,10 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
.then(argument("player", word())
.executes(context -> {
var playerName = StringArgumentType.getString(context, "player");
var island = Skylands.getInstance().islands.getByPlayer(playerName);
var island = IslandLogic.getInstance().islands.getByPlayer(playerName);

if (island.isPresent()) {
Skylands.getInstance().islands.delete(playerName);
IslandLogic.getInstance().islands.delete(playerName);
context.getSource().sendFeedback(() -> Texts.of("message.neoskies.force_delete.success", map -> map.put("player", playerName)), true);
} else {
context.getSource().sendFeedback(() -> Texts.of("message.neoskies.force_delete.fail", map -> map.put("player", playerName)), true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.awakenedredstone.neoskies.command.admin;

import com.awakenedredstone.neoskies.api.SkylandsAPI;
import com.awakenedredstone.neoskies.api.NeoSkiesAPI;
import com.awakenedredstone.neoskies.command.utils.CommandUtils;
import com.awakenedredstone.neoskies.logic.Island;
import com.awakenedredstone.neoskies.logic.Skylands;
import com.awakenedredstone.neoskies.logic.IslandLogic;
import com.awakenedredstone.neoskies.util.MapBuilder;
import com.awakenedredstone.neoskies.util.Texts;
import com.mojang.brigadier.CommandDispatcher;
Expand All @@ -29,7 +29,7 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
.requires(Permissions.require("neoskies.admin.island.data.find", 4))
.then(argument("player", StringArgumentType.word())
.suggests((context, builder) -> {
List<Island> islands = Skylands.getInstance().islands.stuck;
List<Island> islands = IslandLogic.getInstance().islands.stuck;
for (Island island : islands) {
builder.suggest(island.owner.name);
island.members.forEach(member -> {
Expand All @@ -39,7 +39,7 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
return builder.buildFuture();
}).executes(context -> {
String playerName = StringArgumentType.getString(context, "player");
Optional<Island> islandOptional = SkylandsAPI.getIslandByPlayer(playerName);
Optional<Island> islandOptional = NeoSkiesAPI.getIslandByPlayer(playerName);
return getIslandData(context.getSource(), islandOptional.orElse(null));
})
)
Expand All @@ -48,7 +48,7 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
.suggests(CommandUtils.ISLAND_SUGGESTIONS)
.executes(context -> {
String islandId = StringArgumentType.getString(context, "id");
Optional<Island> islandOptional = SkylandsAPI.getIsland(UUID.fromString(islandId));
Optional<Island> islandOptional = NeoSkiesAPI.getIsland(UUID.fromString(islandId));
return getIslandData(context.getSource(), islandOptional.orElse(null));
})
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.awakenedredstone.neoskies.command.admin;

import com.awakenedredstone.neoskies.api.SkylandsAPI;
import com.awakenedredstone.neoskies.api.NeoSkiesAPI;
import com.awakenedredstone.neoskies.command.utils.CommandUtils;
import com.awakenedredstone.neoskies.logic.Island;
import com.awakenedredstone.neoskies.util.MapBuilder;
Expand Down Expand Up @@ -35,14 +35,14 @@ public <T extends GameRules.Rule<T>> void visit(GameRules.Key<T> key, GameRules.
.then(literal(key.getName())
.executes(context -> {
String islandId = StringArgumentType.getString(context, "island");
Island island = SkylandsAPI.getIsland(UUID.fromString(islandId)).orElse(null);
Island island = NeoSkiesAPI.getIsland(UUID.fromString(islandId)).orElse(null);

return getGamerule(context.getSource(), key, island);
})
.then(type.argument("value")
.executes(context -> {
String islandId = StringArgumentType.getString(context, "island");
Island island = SkylandsAPI.getIsland(UUID.fromString(islandId)).orElse(null);
Island island = NeoSkiesAPI.getIsland(UUID.fromString(islandId)).orElse(null);

return setGamerule(context, key, island);
})
Expand All @@ -60,7 +60,7 @@ public <T extends GameRules.Rule<T>> void visit(GameRules.Key<T> key, GameRules.
.executes(context -> {
String islandId = StringArgumentType.getString(context, "island");
int size = IntegerArgumentType.getInteger(context, "size");
return modifyIslandSize(context.getSource(), SkylandsAPI.getIsland(UUID.fromString(islandId)).orElse(null), size);
return modifyIslandSize(context.getSource(), NeoSkiesAPI.getIsland(UUID.fromString(islandId)).orElse(null), size);
})
)
).then(gameruleArgumentBuilder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
return 0;
}

//new ConfigScreen(source.getPlayer(), SkylandsMain.MAIN_CONFIG, null, null);
//new ConfigScreen(source.getPlayer(), NeoSkies.MAIN_CONFIG, null, null);
source.sendFeedback(() -> Text.literal("In development, they will likely require the client mod"), false);

return 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.awakenedredstone.neoskies.command.island;

import com.awakenedredstone.neoskies.logic.Skylands;
import com.awakenedredstone.neoskies.logic.IslandLogic;
import com.awakenedredstone.neoskies.util.Players;
import com.awakenedredstone.neoskies.util.Texts;
import com.mojang.brigadier.CommandDispatcher;
Expand Down Expand Up @@ -40,13 +40,13 @@ static void run(ServerPlayerEntity player, String ownerName) {
return;
}

var island = Skylands.getInstance().islands.getByPlayer(inviter.get());
var island = IslandLogic.getInstance().islands.getByPlayer(inviter.get());
if (island.isEmpty()) {
player.sendMessage(Texts.prefixed("message.neoskies.accept.no_island"));
return;
}

var invite = Skylands.getInstance().invites.get(island.get(), player);
var invite = IslandLogic.getInstance().invites.get(island.get(), player);
if (invite.isEmpty()) {
player.sendMessage(Texts.prefixed("message.neoskies.accept.fail"));
return;
Expand Down
Loading

0 comments on commit 6cd733e

Please sign in to comment.