Skip to content

Commit

Permalink
chunky update :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skullians committed Aug 26, 2024
1 parent b1cf0cc commit 4571628
Show file tree
Hide file tree
Showing 46 changed files with 659 additions and 167 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
<exclude>org.apache.commons:commons-collections4</exclude>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>org.jetbrains:annotations</exclude>
<exclude>com.neovisionaries:nv-websocket-client</exclude>
<exclude>com.squareup.okhttp3:okhttp</exclude>
<exclude>com.squareup.okio:okio</exclude>
<exclude>com.squareup.okio:okio-jvm</exclude>
<exclude>net.sf.trove4j:core</exclude>
<exclude>com.fasterxml.jackson.core:jackson-core</exclude>
<exclude>com.fasterxml.jackson.core:jackson-annotations</exclude>
<exclude>com.jeff-media:custom-block-data</exclude>
</excludes>
</artifactSet>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public final class SkyFactionsReborn extends JavaPlugin {
____ _ _ _ _ ____ ____ ____ ___ _ ____ _ _ ____\s
[__ |_/ \\_/ |___ |__| | | | | | |\\ | [__ \s
___] | \\_ | | | | |___ | | |__| | \\| ___]
___] | \\_ | | | | |___ | | |__| | \\| ___]\s
""";

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static void createFaction(Player player, String name) {
Faction faction = FactionAPI.getFaction(name);
faction.createAuditLog(player.getUniqueId(), AuditLogType.FACTION_CREATE, "%player_name%", player.getName(), "%faction_name%", name);
createIsland(player, name);
NotificationAPI.factionInviteStore.put(faction.getName(), 0);
}

/**
Expand Down
24 changes: 4 additions & 20 deletions src/main/java/net/skullian/torrent/skyfactions/api/GUIAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ public static List<PaginationItemData> getPaginationData(Player player) throws R
}
}

public static ItemStack createItem(ItemData data, Player player) {
public static ItemStack createItem(ItemData data, UUID playerUUID) {
ItemStack stack;
if (data.getMATERIAL().equalsIgnoreCase("PLAYER_HEAD")) {
String texture = data.getBASE64_TEXTURE();
if (texture.equalsIgnoreCase("%player_skull%")) {
stack = SkullAPI.getPlayerSkull(new ItemStack(Material.PLAYER_HEAD), player);
stack = SkullAPI.getPlayerSkull(new ItemStack(Material.PLAYER_HEAD), playerUUID);
} else {
stack = SkullAPI.convertToSkull(new ItemStack(Material.PLAYER_HEAD), data.getBASE64_TEXTURE());
}
Expand All @@ -130,28 +130,12 @@ public static ItemStack createItem(ItemData data, Player player) {
return stack;
}

public static ItemStack createItem(ItemData data, OfflinePlayer player) {
public static ItemStack createItem(PaginationItemData data, UUID playerUUID) {
ItemStack stack;
if (data.getMATERIAL().equalsIgnoreCase("PLAYER_HEAD")) {
String texture = data.getBASE64_TEXTURE();
if (texture.equalsIgnoreCase("%player_skull%")) {
stack = SkullAPI.getPlayerSkull(new ItemStack(Material.PLAYER_HEAD), player.getPlayer());
} else {
stack = SkullAPI.convertToSkull(new ItemStack(Material.PLAYER_HEAD), data.getBASE64_TEXTURE());
}
} else {
stack = new ItemStack(Material.getMaterial(data.getMATERIAL()));
}

return stack;
}

public static ItemStack createItem(PaginationItemData data, Player player) {
ItemStack stack;
if (data.getMATERIAL().equalsIgnoreCase("PLAYER_HEAD")) {
String texture = data.getBASE64_TEXTURE();
if (texture.equalsIgnoreCase("%player_skull%")) {
stack = SkullAPI.getPlayerSkull(new ItemStack(Material.PLAYER_HEAD), player);
stack = SkullAPI.getPlayerSkull(new ItemStack(Material.PLAYER_HEAD), playerUUID);
} else {
stack = SkullAPI.convertToSkull(new ItemStack(Material.PLAYER_HEAD), data.getBASE64_TEXTURE());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public static ItemStack convertToSkull(ItemStack item, String skullValue) {
return item;
}

public static ItemStack getPlayerSkull(ItemStack item, Player player) {
public static ItemStack getPlayerSkull(ItemStack item, UUID playerUUID) {
if (item.getType() == Material.PLAYER_HEAD) {
SkullMeta meta = (SkullMeta) item.getItemMeta();
meta.setOwningPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
meta.setOwningPlayer(Bukkit.getOfflinePlayer(playerUUID));
item.setItemMeta(meta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.skullian.torrent.skyfactions.SkyFactionsReborn;
import net.skullian.torrent.skyfactions.api.FactionAPI;
import net.skullian.torrent.skyfactions.api.NotificationAPI;
import net.skullian.torrent.skyfactions.command.CommandTemplate;
import net.skullian.torrent.skyfactions.command.CooldownHandler;
import net.skullian.torrent.skyfactions.command.PermissionsHandler;
Expand Down Expand Up @@ -54,6 +55,8 @@ public void perform(Player player, String[] args) {

faction.createJoinRequest(Bukkit.getOfflinePlayer(player.getUniqueId()));
Messages.JOIN_REQUEST_CREATE_SUCCESS.send(player, "%faction_name%", factionName);
NotificationAPI.factionInviteStore.replace(factionName, (NotificationAPI.factionInviteStore.get(factionName) + 1));

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum GUIEnums {
OBELISK_INVITE_SELECTION_GUI("guis/obelisk/invites/invite_selection"),
OBELISK_INVITE_INCOMING_GUI("guis/obelisk/invites/incoming_requests"),
OBELISK_INVITE_OUTGOING_GUI("guis/obelisk/invites/outgoing_invites"),
OBELISK_PLAYER_INVITE_MANAGE_GUI("guis/obelisk/invites/player_invite_manage"),
OBELISK_PLAYER_INCOMING_INVITES_GUI("guis/obelisk/invites/player_faction_invites"),
OBELISK_PLAYER_INVITE_TYPE_SELECTION_GUI("guis/obelisk/invites/player_invite_selection"),
OBELISK_PLAYER_JOIN_REQUEST_MANAGE_GUI("guis/obelisk/invites/player_join_request"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public enum Messages {
FACTION_JOIN_REQUEST_NOT_EXIST("Factions.FACTION_INVITE.JOIN_REQUEST_NOT_EXIST"),
FACTION_JOIN_REQUEST_REVOKE_SUCCESS("Factions.FACTION_INVITE.JOIN_REQUEST_REVOKE_SUCCESS"),
FACTION_JOIN_REQUEST_DENY_SUCCESS("Factions.FACTION_INVITE.JOIN_REQUEST_DENY_SUCCESS"),
FACTION_PLAYER_JOIN_REQUEST_ACCEPT("Factions.FACTION_INVITE.PLAYER_JOIN_REQUEST_ACCEPT_SUCCESS"),
PLAYER_FACTION_JOIN_SUCCESS("Factions.FACTION_INVITE.PLAYER_FACTION_JOIN_SUCCESS"),
FACTION_INVITE_DENY_SUCCESS("Factions.FACTION_INVITE.FACTION_INVITE_DENY_SUCCESS"),

ALREADY_IN_FACTION("Factions.ALREADY_IN_FACTION"),
NOT_IN_FACTION("Factions.NOT_IN_FACTION"),
Expand Down Expand Up @@ -160,6 +161,10 @@ public enum Messages {
AUDIT_FACTION_PLAYER_JOIN_REQUEST_REVOKE_DESCRIPTION("Audit_Logs.PLAYER_JOIN_REQUEST_REVOKE_DESCRIPTION"),
AUDIT_FACTION_PLAYER_JOIN_REQUEST_DENY_TITLE("Audit_Logs.PLAYER_JOIN_REQUEST_DENY_TITLE"),
AUDIT_FACTION_PLAYER_JOIN_REQUEST_DENY_DESCRIPTION("Audit_Logs.PLAYER_JOIN_REQUEST_DENY_DESCRIPTION"),
AUDIT_FACTION_PLAYER_INVITE_ACCEPT_TITLE("Audit_Logs.INVITE_ACCEPT_TITLE"),
AUDIT_FACTION_PLAYER_INVITE_ACCEPT_DESCRIPTION("Audit_Logs.INVITE_ACCEPT_TITLE"),
AUDIT_FACTION_PLAYER_INVITE_DENY_TITLE("Audit_Logs.INVITE_DENY_TITLE"),
AUDIT_FACTION_PLAYER_INVITE_DENY_DESCRIPTION("Audit_Logs.INVITE_DENY_DESCRIPTION"),

NOTIFICATION_TIMESTAMP_FORMAT("Notifications.NOTIFICATION_TYPES.NOTIFICATION_TIMESTAMP"),
NOTIFICATION_FACTION_INVITE_TITLE("Notifications.NOTIFICATION_TYPES.FACTION_INVITE_TITLE"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void setupTables() throws SQLException {
PreparedStatement islandsTable = connection.prepareStatement("""
CREATE TABLE IF NOT EXISTS islands (
[id] INTEGER PRIMARY KEY,
[uuid] BLOB NOT NULL,
[uuid] TEXT NOT NULL,
[level] INTEGER NOT NULL,
[gems] INTEGER NOT NULL,
[runes] INTEGER NOT NULL,
Expand All @@ -125,7 +125,7 @@ CREATE TABLE IF NOT EXISTS islands (

PreparedStatement playerDataTable = connection.prepareStatement("""
CREATE TABLE IF NOT EXISTS playerData (
[uuid] BLOB PRIMARY KEY UNIQUE NOT NULL,
[uuid] TEXT PRIMARY KEY UNIQUE NOT NULL,
[faction] TEXT NOT NULL,
[discord_id] TEXT NOT NULL,
[last_raid] INTEGER NOT NULL
Expand All @@ -135,7 +135,7 @@ CREATE TABLE IF NOT EXISTS playerData (
PreparedStatement factionIslandTable = connection.prepareStatement("""
CREATE TABLE IF NOT EXISTS factionIslands (
[id] INTEGER PRIMARY KEY,
[faction_name] BLOB NOT NULL,
[faction_name] TEXT NOT NULL,
[runes] INTEGER NOT NULL,
[gems] INTEGER NOT NULL,
[last_raided] INTEGER NOT NULL
Expand All @@ -153,52 +153,52 @@ CREATE TABLE IF NOT EXISTS factions(

PreparedStatement factionMemberTable = connection.prepareStatement("""
CREATE TABLE IF NOT EXISTS factionMembers (
[faction_name] TEXT PRIMARY KEY NOT NULL,
[uuid] BLOB NOT NULL,
[faction_name] TEXT NOT NULL,
[uuid] TEXT PRIMARY KEY NOT NULL,
[rank] TEXT NOT NULL
) STRICT;
""");

PreparedStatement trustedPlayerTable = connection.prepareStatement("""
CREATE TABLE IF NOT EXISTS trustedPlayers (
[island_id] INTEGER PRIMARY KEY NOT NULL,
[uuid] BLOB NOT NULL
[uuid] TEXT NOT NULL
) STRICT;
""");

PreparedStatement auditLogTable = connection.prepareStatement("""
CREATE TABLE IF NOT EXISTS auditLogs (
[faction_name] TEXT NOT NULL,
[type] TEXT NOT NULL,
[uuid] BLOB NOT NULL,
[description] BLOB NOT NULL,
[uuid] TEXT NOT NULL,
[description] TEXT NOT NULL,
[timestamp] INTEGER NOT NULL
) STRICT;
""");

PreparedStatement factionBannedMembers = connection.prepareStatement("""
CREATE TABLE IF NOT EXISTS factionBans (
[faction_name] TEXT NOT NULL,
[uuid] BLOB NOT NULL
[uuid] TEXT NOT NULL
) STRICT;
""");

PreparedStatement factionInvitesTable = connection.prepareStatement("""
CREATE TABLE IF NOT EXISTS factionInvites (
[faction_name] TEXT NOT NULL,
[uuid] BLOB NOT NULL,
[inviter] BLOB NOT NULL,
[uuid] TEXT NOT NULL,
[inviter] TEXT NOT NULL,
[type] TEXT NOT NULL,
[accepted] BOOLEAN NOT NULL,
[accepted] INTEGER NOT NULL,
[timestamp] INTEGER NOT NULL
) STRICT;
""");

PreparedStatement notificationTable = connection.prepareStatement("""
CREATE TABLE IF NOT EXISTS notifications (
[uuid] BLOB NOT NULL,
[type] BLOB NOT NULL,
[description] BLOB NOT NULL,
[uuid] TEXT NOT NULL,
[type] TEXT NOT NULL,
[description] TEXT NOT NULL,
[timestamp] INTEGER NOT NULL
) STRICT;
""")) {
Expand Down Expand Up @@ -1490,7 +1490,7 @@ public CompletableFuture<JoinRequestData> getPlayerOutgoingJoinRequest(Player pl
ResultSet set = statement.executeQuery();

if (set.next()) {
String factionName = set.getString("faction+name");
String factionName = set.getString("faction_name");
long timestamp = set.getLong("timestamp");
boolean accepted = set.getBoolean("accepted");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public enum AuditLogType {
JOIN_REQUEST_ACCEPT(Messages.AUDIT_FACTION_JOIN_REQUEST_ACCEPT_TITLE, Messages.AUDIT_FACTION_JOIN_REQUEST_ACCEPT_DESCRIPTION),
JOIN_REQUEST_REJECT(Messages.AUDIT_FACTION_JOIN_REQUEST_REJECT_TITLE, Messages.AUDIT_FACTION_JOIN_REQUEST_REJECT_DESCRIPTION),
PLAYER_JOIN_REQUEST_REVOKE(Messages.AUDIT_FACTION_PLAYER_JOIN_REQUEST_REVOKE_TITLE, Messages.AUDIT_FACTION_PLAYER_JOIN_REQUEST_REVOKE_DESCRIPTION),
PLAYER_JOIN_REQUEST_DENY(Messages.AUDIT_FACTION_PLAYER_JOIN_REQUEST_DENY_TITLE, Messages.AUDIT_FACTION_PLAYER_JOIN_REQUEST_DENY_DESCRIPTION);
PLAYER_JOIN_REQUEST_DENY(Messages.AUDIT_FACTION_PLAYER_JOIN_REQUEST_DENY_TITLE, Messages.AUDIT_FACTION_PLAYER_JOIN_REQUEST_DENY_DESCRIPTION),
INVITE_ACCEPT(Messages.AUDIT_FACTION_PLAYER_INVITE_ACCEPT_TITLE, Messages.AUDIT_FACTION_PLAYER_INVITE_ACCEPT_DESCRIPTION),
INVITE_DENY(Messages.AUDIT_FACTION_PLAYER_INVITE_DENY_TITLE, Messages.AUDIT_FACTION_PLAYER_INVITE_DENY_DESCRIPTION);

private final Messages title;
private final Messages description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@
import net.skullian.torrent.skyfactions.gui.items.GeneralBorderItem;
import net.skullian.torrent.skyfactions.gui.items.GeneralPromptItem;
import net.skullian.torrent.skyfactions.gui.items.faction_leave.LeaveConfirmationItem;
import net.skullian.torrent.skyfactions.gui.items.island_creation.CreationCancelItem;
import net.skullian.torrent.skyfactions.gui.items.island_creation.CreationConfirmationItem;
import net.skullian.torrent.skyfactions.gui.items.GeneralCancelItem;
import net.skullian.torrent.skyfactions.util.SoundUtil;
import net.skullian.torrent.skyfactions.util.text.TextUtility;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.entity.Player;
import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.window.Window;

import java.io.IOException;
import java.util.List;

public class FactionLeaveConfirmationUI {

public static void promptPlayer(Player player) {
try {
GUIData data = GUIAPI.getGUIData("confirmatioms/faction_leave");
GUIData data = GUIAPI.getGUIData("confirmations/faction_leave");
Gui.Builder.Normal gui = registerItems(Gui.normal()
.setStructure(data.getLAYOUT()), player);

Expand All @@ -48,13 +45,16 @@ private static Gui.Builder.Normal registerItems(Gui.Builder.Normal builder, Play
switch (itemData.getITEM_ID()) {

case "PROMPT":
builder.addIngredient(itemData.getCHARACTER(), new GeneralPromptItem(itemData, GUIAPI.createItem(itemData, player)));
builder.addIngredient(itemData.getCHARACTER(), new GeneralPromptItem(itemData, GUIAPI.createItem(itemData, player.getUniqueId())));
break;
case "CONFIRM":
builder.addIngredient(itemData.getCHARACTER(), new LeaveConfirmationItem(itemData, GUIAPI.createItem(itemData, player)));
builder.addIngredient(itemData.getCHARACTER(), new LeaveConfirmationItem(itemData, GUIAPI.createItem(itemData, player.getUniqueId())));
break;
case "CANCEL":
builder.addIngredient(itemData.getCHARACTER(), new GeneralCancelItem(itemData, GUIAPI.createItem(itemData, player.getUniqueId())));
break;
case "BORDER":
builder.addIngredient(itemData.getCHARACTER(), new GeneralBorderItem(itemData, GUIAPI.createItem(itemData, player)));
builder.addIngredient(itemData.getCHARACTER(), new GeneralBorderItem(itemData, GUIAPI.createItem(itemData, player.getUniqueId())));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
import net.skullian.torrent.skyfactions.gui.data.GUIData;
import net.skullian.torrent.skyfactions.gui.data.ItemData;
import net.skullian.torrent.skyfactions.gui.items.GeneralPromptItem;
import net.skullian.torrent.skyfactions.gui.items.island_creation.CreationCancelItem;
import net.skullian.torrent.skyfactions.gui.items.GeneralCancelItem;
import net.skullian.torrent.skyfactions.gui.items.island_creation.CreationConfirmationItem;
import net.skullian.torrent.skyfactions.gui.items.GeneralBorderItem;
import net.skullian.torrent.skyfactions.util.SoundUtil;
import net.skullian.torrent.skyfactions.util.text.TextUtility;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.window.Window;

import java.io.IOException;
import java.util.List;

public class IslandCreationConfirmationUI implements Listener {
Expand Down Expand Up @@ -48,16 +46,16 @@ private static Gui.Builder.Normal registerItems(Gui.Builder.Normal builder, Play
switch (itemData.getITEM_ID()) {

case "CANCEL":
builder.addIngredient(itemData.getCHARACTER(), new CreationCancelItem(itemData, GUIAPI.createItem(itemData, player)));
builder.addIngredient(itemData.getCHARACTER(), new GeneralCancelItem(itemData, GUIAPI.createItem(itemData, player.getUniqueId())));
break;
case "CONFIRM":
builder.addIngredient(itemData.getCHARACTER(), new CreationConfirmationItem(itemData, GUIAPI.createItem(itemData, player)));
builder.addIngredient(itemData.getCHARACTER(), new CreationConfirmationItem(itemData, GUIAPI.createItem(itemData, player.getUniqueId())));
break;
case "PROMPT":
builder.addIngredient(itemData.getCHARACTER(), new GeneralPromptItem(itemData, GUIAPI.createItem(itemData, player)));
builder.addIngredient(itemData.getCHARACTER(), new GeneralPromptItem(itemData, GUIAPI.createItem(itemData, player.getUniqueId())));
break;
case "BORDER":
builder.addIngredient(itemData.getCHARACTER(), new GeneralBorderItem(itemData, GUIAPI.createItem(itemData, player)));
builder.addIngredient(itemData.getCHARACTER(), new GeneralBorderItem(itemData, GUIAPI.createItem(itemData, player.getUniqueId())));
break;
}
}
Expand Down
Loading

0 comments on commit 4571628

Please sign in to comment.