Skip to content

Commit

Permalink
Invite System WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Skullians committed Aug 2, 2024
1 parent 95ae871 commit f4e517b
Show file tree
Hide file tree
Showing 61 changed files with 1,914 additions and 310 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

80 changes: 0 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,86 +11,6 @@ This plugin contains an abundance of smart features, including:
- Custom unique currency system called "gems" and a provided (optional) resource pack for them
- Much, much more

# Development TODO
- [ ] Faction Functionality - 15%
- [x] Faction Create
- [x] Faction Help
- [ ] Faction Rename - WIP
- [x] Faction Information
- [x] Faction Broadcast
- [x] Faction Leave
- [ ] Faction Kick & Ban
- [ ] Faction Taxes
- [ ] Faction Joining
- [ ] Faction Invites
- [ ] Faction Request Join
- [ ] Command Version
- [ ] GUI Version
- [ ] Faction Levelling
- [x] Faction Audit Logs GUI

- [ ] Nations - 5%

- [ ] Raiding 25%
- [ ] Player Raiding
- [ ] Faction Raiding
- [ ] Faction Surrender

- [ ] Discord Integration - 10%
- [ ] Raid notifications
- [ ] Tax Notifications
- [ ] Dedicated channels for factions
- [ ] Broadcast Notifications

- [ ] Island - 25%
- [x] Island Creation
- [x] Island Trust
- [x] Island Untrust
- [x] Island Visit
- [x] Island Teleport
- [ ] Island Purging
- [ ] Island Levelling

- [ ] Defences 10%
- [ ] Configuration
- [ ] Basic Functionality
- [ ] Upgrades

- [ ] Obelisk 10%
- [x] Custom Block Data
- [ ] Relocation - WIP
- [ ] Faction Member Management - WIP
- [ ] Rank Promotion
- [ ] Permission Handling
- [ ] Defence purchase UI
- [ ] Player & Faction UI differentiation
- [x] Rune conversion UI - WIP
- [x] help me
- [ ] Audit Logs

- [ ] Gems - 5%
- [x] Pay
- [x] Balance
- [ ] Item Form
- [ ] Custom Model Data

- [ ] Extras
- [ ] Website
- [ ] Top Factions
- [ ] Top Players
- [ ] Current Raids
- [ ] Top Nations
- [ ] API
- [ ] Events
- [ ] Get factions etc

- [ ] Misc
- [ ] Refactor & Improve Code Quality
- [ ] Split configs into further dedicated files.
- [ ] Config Versioning & Update Detection
- [ ] Move away from Lombok logger
- [ ] Verbose logging

## Links
- [Discord](https://discord.gg/Y7DVR9gpwa) - For general questions, support, and chatting about the plugin. For bug reports, use Github issues.
- [Torrent Network](https://www.torrentsmp.com) - The first server to use this plugin!
Expand Down
40 changes: 28 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,21 @@
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<relocations>
<relocation>
<pattern>com.jeff_media.customblockdata</pattern>
<shadedPattern>YOUR.PACKAGE.NAME.customblockdata</shadedPattern>
</relocation>
</relocations>
<artifactSet>
<excludes>
<exclude>com.zaxxer:HikariCP</exclude>
<exclude>org.xerial:sqlite-jdbc</exclude>
<exclude>net.dv8tion:JDA</exclude>
<exclude>com.fasterxml.jackson.core:jackson-databind</exclude>
<exclude>org.jetbrains.kotlin:kotlin-stdlib-common</exclude>
<exclude>org.jetbrains.kotlin:kotlin-stdlib-jdk8</exclude>
<exclude>org.jetbrains.kotlin:kotlin-stdlib</exclude>
<exclude>org.jetbrains.kotlin:kotlin-stdlib-jdk7</exclude>
<exclude>org.apache.commons:commons-collections4</exclude>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>org.jetbrains:annotations</exclude>
</excludes>
</artifactSet>
</configuration>
<executions>
<execution>
Expand All @@ -51,15 +60,22 @@
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<outputDirectory>D:\Code\Torrent\SkyFactionsReborn\Server\plugins</outputDirectory>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<outputDirectory>D:\Code\Torrent\SkyFactionsReborn\Server\plugins</outputDirectory>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>.</directory>
<filtering>false</filtering>
<includes>
<include>LICENSE</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import net.skullian.torrent.skyfactions.discord.DiscordHandler;
import net.skullian.torrent.skyfactions.event.ObeliskInteractionListener;
import net.skullian.torrent.skyfactions.event.PlayerHandler;
import net.skullian.torrent.skyfactions.obelisk.ObeliskBlockManager;
import net.skullian.torrent.skyfactions.util.DependencyHandler;
import net.skullian.torrent.skyfactions.util.EconomyHandler;
import org.bukkit.Bukkit;
Expand All @@ -36,7 +35,6 @@ public final class SkyFactionsReborn extends JavaPlugin {
public static HikariHandler db;
public static DiscordHandler dc;
public static EconomyHandler ec;
public static ObeliskBlockManager obeliskBlockManager;

String text = """
Expand All @@ -49,9 +47,11 @@ public final class SkyFactionsReborn extends JavaPlugin {
public void onEnable() {
LOGGER.info(text);

// Store an instance of the ConfigHandler class in case it is needed.
// Primarily used for the discord integration.
LOGGER.info("Initialising Configs.");
configHandler = new ConfigFileHandler();
configHandler.loadFiles(this);
configHandler.loadFiles(this); // Load all files (and create them if they don't exist already).

LOGGER.info("Initialising Economy.");
ec = new EconomyHandler();
Expand All @@ -61,6 +61,8 @@ public void onEnable() {
getCommand("island").setExecutor(new IslandCommandHandler());
getCommand("island").setTabCompleter(new IslandCommandTabCompletion());

// There is the option to disable the discord integration if you don't want it.
// To avoid later confusion, we only register the discord related commands if it is enabled.
boolean discordEnabled = SkyFactionsReborn.configHandler.DISCORD_CONFIG.getBoolean("Discord.ENABLED");
if (discordEnabled) {
getCommand("link").setExecutor(new LinkCommand());
Expand All @@ -79,31 +81,36 @@ public void onEnable() {
getCommand("faction").setExecutor(new FactionCommandHandler());
getCommand("faction").setTabCompleter(new FactionCommandTabCompletion());


LOGGER.info("Registering Events.");
getServer().getPluginManager().registerEvents(new PlayerHandler(), this);
getServer().getPluginManager().registerEvents(new ObeliskInteractionListener(), this);

// We store an instance of the DiscordHandler class as that is how other internals
// access methods related to Discord (e.g. raid notifications).
LOGGER.info("Initialising JDA / Discord.");
dc = new DiscordHandler();
dc.initialiseBot();

LOGGER.info("Handling Obelisk BlockEntities.");
obeliskBlockManager = new ObeliskBlockManager();

// This is kind of pointless.
// Just a class for handling dependencies and optional dependencies.
// Majorly incomplete.
LOGGER.info("Handling optional dependencies.");
DependencyHandler.init();

// Player Data Container (CustomBlockData API) listener.
LOGGER.info("Handling PDC Listener.");
CustomBlockData.registerListener(this);

// Initialise the database last.
initialiseDatabaseConnection();
}

@Override
public void onDisable() {
LOGGER.info("Closing Database connection.");
closeDatabase();
dc.disconnect();

LOGGER.info(text);
LOGGER.info("SkyFactions has been disabled.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void teleportToFactionIsland(Player player) {
public static void createFaction(Player player, String name) {
SkyFactionsReborn.db.registerFaction(player, name).join();
Faction faction = FactionAPI.getFaction(name);
faction.createAuditLog(Bukkit.getOfflinePlayer(player.getUniqueId()), AuditLogType.FACTION_CREATE, "%player_name%", player.getName(), "%faction_name%", name);
faction.createAuditLog(player.getUniqueId(), AuditLogType.FACTION_CREATE, "%player_name%", player.getName(), "%faction_name%", name);
createIsland(player, name);
}

Expand Down
15 changes: 12 additions & 3 deletions src/main/java/net/skullian/torrent/skyfactions/api/IslandAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public static void createIsland(Player player) {

SkyFactionsReborn.db.createIsland(player, island).join();
pasteIslandSchematic(player, island.getCenter(world), world.getName(), "player").thenAccept(ac -> {
if (!ac) {
Messages.ERROR.send(player, "%operation%", "create your island", "%debug%", "SCHEMATIC_NOT_EXIST");
SkyFactionsReborn.db.removeIsland(player);
return;
}

teleportPlayerToLocation(player, island.getCenter(world));

ObeliskHandler.spawnPlayerObelisk(player, island);
Expand All @@ -71,8 +77,8 @@ public static void createIsland(Player player) {
});
}

public static CompletableFuture<Void> pasteIslandSchematic(Player player, Location location, String worldName, String type) {
return CompletableFuture.runAsync(() -> {
public static CompletableFuture<Boolean> pasteIslandSchematic(Player player, Location location, String worldName, String type) {
return CompletableFuture.supplyAsync(() -> {
try {
World world = Bukkit.getWorld(worldName);
if (world == null) {
Expand All @@ -85,6 +91,7 @@ public static CompletableFuture<Void> pasteIslandSchematic(Player player, Locati
} else if (type.equals("faction")) {
schemFile = FileUtil.getSchematicFile(Settings.ISLAND_FACTION_SCHEMATIC.getString());
}
if (schemFile == null) return false;

com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world);
Clipboard clipboard;
Expand All @@ -104,6 +111,8 @@ public static CompletableFuture<Void> pasteIslandSchematic(Player player, Locati

Thread.sleep(750);
} catch (InterruptedException ignored) {}

return true;
}
} catch (IOException e) {
LOGGER.error("Error pasting island schematic", e);
Expand Down Expand Up @@ -134,7 +143,7 @@ private static void createRegion(Player player, PlayerIsland island, World world
}

public static void removePlayerIsland(Player player) {
SkyFactionsReborn.db.getPlayerIsland(player).thenAccept(island -> {
SkyFactionsReborn.db.getPlayerIsland(player.getUniqueId()).thenAccept(island -> {
World world = Bukkit.getWorld(Settings.ISLAND_PLAYER_WORLD.getString());
if (world != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public static void createCycle(Player player) {
/**
* Create a notification for a Player.
*
* @param player Player who the notification should be sent to [{@link Player}]
* @param playerUUID UUID of the player who the notification should be sent to [{@link UUID}]
* @param type Type of notification [{@link net.skullian.torrent.skyfactions.faction.AuditLogType}]
* @param replacements Replacements for the notification title / desc.
*/
public static void createNotification(OfflinePlayer player, NotificationType type, Object... replacements) {
SkyFactionsReborn.db.createNotification(player, type.getTitle(replacements), type.getDescription(replacements)).join();
public static void createNotification(UUID playerUUID, NotificationType type, Object... replacements) {
SkyFactionsReborn.db.createNotification(playerUUID, type.getTitle(replacements), type.getDescription(replacements)).join();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static void handlePlayers(Player attacker, UUID uuid) {
alertPlayer(def, attacker);
teleportToPreparationArea(def);

SkyFactionsReborn.db.getPlayerIsland(def).thenAccept(is -> SkyFactionsReborn.db.setIslandCooldown(is, System.currentTimeMillis())).exceptionally(ex -> {
SkyFactionsReborn.db.getPlayerIsland(def.getUniqueId()).thenAccept(is -> SkyFactionsReborn.db.setIslandCooldown(is, System.currentTimeMillis())).exceptionally(ex -> {
cancel.set(true);

ex.printStackTrace();
Expand All @@ -113,7 +113,7 @@ private static void handlePlayers(Player attacker, UUID uuid) {

Bukkit.getScheduler().runTaskLater(SkyFactionsReborn.getInstance(), () -> {
if (!def.isOnline()) return;
SkyFactionsReborn.db.getPlayerIsland(def).thenAccept(island -> {
SkyFactionsReborn.db.getPlayerIsland(def.getUniqueId()).thenAccept(island -> {
World islandWorld = Bukkit.getWorld(Settings.ISLAND_PLAYER_WORLD.getString());
if (islandWorld != null && island != null) {
Location returnLoc = island.getCenter(islandWorld);
Expand Down Expand Up @@ -257,7 +257,7 @@ private static void handleRaidExecutionError(Player player, boolean isDefendant)
SkyFactionsReborn.db.addGems(player, Settings.RAIDING_COST.getInt()).join();

if (isDefendant) {
SkyFactionsReborn.db.getPlayerIsland(player).thenAccept(island -> SkyFactionsReborn.db.setIslandCooldown(island, 0).exceptionally(ex -> {
SkyFactionsReborn.db.getPlayerIsland(player.getUniqueId()).thenAccept(island -> SkyFactionsReborn.db.setIslandCooldown(island, 0).exceptionally(ex -> {
ex.printStackTrace();
Messages.ERROR.send(player, "%operation%", "handle raid errors", "%debug%", "SQL_ISLAND_COOLDOWN");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void perform(Player player, String[] args) {
if (faction.isOwner(player) || faction.isAdmin(player) || faction.isModerator(player)) {
String message = msg.toString().trim();
if (FactionAPI.hasValidName(player, message)) {
faction.createAuditLog(Bukkit.getOfflinePlayer(player.getUniqueId()), AuditLogType.BROADCAST_CREATE, "%player_name%", player.getName());
faction.createAuditLog(player.getUniqueId(), AuditLogType.BROADCAST_CREATE, "%player_name%", player.getName());
faction.createBroadcast(player, message);
}

Expand All @@ -54,14 +54,6 @@ public void perform(Player player, String[] args) {
}

}

StringBuilder msg = new StringBuilder();
for (int i = 1; i < args.length; i++) {
msg.append(args[i]).append(" ");
}



}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public void perform(Player player, String[] args) {

if (FactionAPI.isInFaction(player)) {
Messages.ALREADY_IN_FACTION.send(player);
} else if (FactionAPI.getFaction(name) != null) {
Messages.FACTION_CREATION_NAME_DUPLICATE.send(player);

} else {
if (FactionAPI.hasValidName(player, name)) {
int cost = Settings.FACTION_CREATION_COST.getInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void perform(Player player, String[] args) {
} else if (faction.getAllMembers().contains(Bukkit.getOfflinePlayer(player.getUniqueId()))) {
Messages.JOIN_REQUEST_SAME_FACTION.send(player);
return;
} else if (SkyFactionsReborn.db.joinRequestExists(factionName, player).join()) {
Messages.JOIN_REQUEST_DUPLICATE.send(player);
} else if (SkyFactionsReborn.db.hasJoinRequest(player).join()) {
Messages.JOIN_REQUEST_ALREADY_EXISTS.send(player);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public List<String> onTabComplete(CommandSender sender, Command cmd, String labe
if (sender.hasPermission("skyfactions.gems.balance")) {
completions.add("balance");
}
if (sender.hasPermission("skyfactions.gems.give")) {
completions.add("give");
}

return StringUtil.copyPartialMatches(arg, completions, new ArrayList<>(completions.size()));
}else if (args.length == 2) {
Expand All @@ -45,6 +48,11 @@ public List<String> onTabComplete(CommandSender sender, Command cmd, String labe
completions.add(player.getName());
}
}
if (sender.hasPermission("skyfactions.gems.give") && subcmd.equals("give")) {
for (Player player : Bukkit.getOnlinePlayers()) {
completions.add(player.getName());
}
}

return StringUtil.copyPartialMatches(arg, completions, new ArrayList<>(completions.size()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public void perform(Player player, String[] args) {
return;
} else {
IslandCreationConfirmationUI.promptPlayer(player);
SoundUtil.playSound(player, "ui.button.click", 1f, 1f);
}
} catch (InterruptedException | ExecutionException error) {
error.printStackTrace();
Expand Down
Loading

0 comments on commit f4e517b

Please sign in to comment.