├── gradle.properties ├── settings.gradle.kts ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── core ├── src │ └── main │ │ ├── java │ │ └── dev │ │ │ └── pgm │ │ │ └── community │ │ │ ├── network │ │ │ ├── updates │ │ │ │ ├── NetworkUpdate.java │ │ │ │ ├── types │ │ │ │ │ ├── AssistUpdate.java │ │ │ │ │ ├── ChatUpdate.java │ │ │ │ │ ├── PunishmentUpdate.java │ │ │ │ │ └── RefreshPunishmentUpdate.java │ │ │ │ └── NetworkUpdateBase.java │ │ │ ├── feature │ │ │ │ ├── NetworkFeatureBase.java │ │ │ │ └── NetworkFeature.java │ │ │ ├── Channels.java │ │ │ ├── subs │ │ │ │ ├── types │ │ │ │ │ ├── ChatSubscriber.java │ │ │ │ │ ├── AssistanceSubscriber.java │ │ │ │ │ ├── PunishmentSubscriber.java │ │ │ │ │ └── RefreshPunishmentSubscriber.java │ │ │ │ └── NetworkSubscriber.java │ │ │ └── NetworkConfig.java │ │ │ ├── users │ │ │ ├── UserProfileWithSessionCallback.java │ │ │ ├── UsersConfig.java │ │ │ ├── services │ │ │ │ └── UserQuery.java │ │ │ ├── UserProfile.java │ │ │ ├── feature │ │ │ │ └── UsersFeatureBase.java │ │ │ └── UserProfileImpl.java │ │ │ ├── polls │ │ │ ├── events │ │ │ │ ├── PollEndEvent.java │ │ │ │ ├── PollStartEvent.java │ │ │ │ ├── PollEvent.java │ │ │ │ └── PollVoteEvent.java │ │ │ ├── ending │ │ │ │ └── EndAction.java │ │ │ ├── response │ │ │ │ ├── SingleChoiceResponseConverter.java │ │ │ │ └── MultiChoiceResponseConverter.java │ │ │ ├── Poll.java │ │ │ ├── PollConfig.java │ │ │ ├── commands │ │ │ │ └── PollVoteCommands.java │ │ │ └── PollThreshold.java │ │ │ ├── feature │ │ │ ├── SQLFeature.java │ │ │ ├── Feature.java │ │ │ ├── SQLFeatureBase.java │ │ │ ├── config │ │ │ │ ├── FeatureConfig.java │ │ │ │ └── FeatureConfigImpl.java │ │ │ └── FeatureBase.java │ │ │ ├── menu │ │ │ ├── StaticMenuItem.java │ │ │ ├── PageableInventory.java │ │ │ ├── CommunityInventoryProvider.java │ │ │ └── MenuItem.java │ │ │ ├── database │ │ │ ├── Savable.java │ │ │ ├── Query.java │ │ │ ├── DatabaseConnection.java │ │ │ └── DatabaseConfig.java │ │ │ ├── party │ │ │ ├── exceptions │ │ │ │ ├── MapPartySetupException.java │ │ │ │ └── MapPartyException.java │ │ │ ├── events │ │ │ │ ├── MapPartyEndEvent.java │ │ │ │ ├── MapPartyCreateEvent.java │ │ │ │ ├── MapPartyStartEvent.java │ │ │ │ ├── MapPartyRestartEvent.java │ │ │ │ └── MapPartyEvent.java │ │ │ ├── settings │ │ │ │ ├── PartySetting.java │ │ │ │ ├── PartyBooleanSetting.java │ │ │ │ └── MapPartySettings.java │ │ │ ├── MapPartyStatusType.java │ │ │ ├── MapPartyType.java │ │ │ ├── presets │ │ │ │ └── MapPartyPreset.java │ │ │ ├── MapParty.java │ │ │ └── menu │ │ │ │ └── MapPartyTypeSelectionMenu.java │ │ │ ├── assistance │ │ │ ├── menu │ │ │ │ ├── ReportReason.java │ │ │ │ ├── ReportCategory.java │ │ │ │ └── ReportReasonsMenu.java │ │ │ ├── PlayerHelpRequest.java │ │ │ ├── services │ │ │ │ └── AssistanceQuery.java │ │ │ ├── feature │ │ │ │ ├── AssistanceFeature.java │ │ │ │ └── types │ │ │ │ │ └── NoDBAssistanceFeature.java │ │ │ ├── AssistanceRequest.java │ │ │ ├── Report.java │ │ │ └── commands │ │ │ │ └── PlayerHelpCommand.java │ │ │ ├── friends │ │ │ ├── FriendRequestStatus.java │ │ │ ├── FriendshipConfig.java │ │ │ ├── services │ │ │ │ └── FriendshipQuery.java │ │ │ └── feature │ │ │ │ └── PGMFriendIntegration.java │ │ │ ├── mobs │ │ │ └── MobConfig.java │ │ │ ├── squads │ │ │ └── SquadConfig.java │ │ │ ├── mutations │ │ │ ├── MutationConfig.java │ │ │ ├── types │ │ │ │ ├── BowMutation.java │ │ │ │ ├── mechanics │ │ │ │ │ ├── BlindMutation.java │ │ │ │ │ ├── HealthMutation.java │ │ │ │ │ ├── FriendlyFireMutation.java │ │ │ │ │ └── KnockbackMutation.java │ │ │ │ ├── ScheduledMutationBase.java │ │ │ │ ├── gameplay │ │ │ │ │ ├── RageMutation.java │ │ │ │ │ ├── GhostMutation.java │ │ │ │ │ └── BlitzMutation.java │ │ │ │ └── arrows │ │ │ │ │ ├── TNTBowMutation.java │ │ │ │ │ ├── EnderpearlMutation.java │ │ │ │ │ └── FireballBowMutation.java │ │ │ ├── options │ │ │ │ ├── MutationBooleanOption.java │ │ │ │ ├── MutationOption.java │ │ │ │ ├── MutationRangeOption.java │ │ │ │ └── MutationListOption.java │ │ │ ├── MutationBase.java │ │ │ └── Mutation.java │ │ │ ├── events │ │ │ ├── UserProfileLoadEvent.java │ │ │ ├── PlayerHelpRequestEvent.java │ │ │ ├── PlayerReportEvent.java │ │ │ ├── CommunityEvent.java │ │ │ └── PlayerPunishmentEvent.java │ │ │ ├── history │ │ │ ├── MatchHistoryConfig.java │ │ │ └── MatchHistoryCommand.java │ │ │ ├── utils │ │ │ ├── compatibility │ │ │ │ ├── EntityTypes.java │ │ │ │ ├── Enchantments.java │ │ │ │ └── PotionEffects.java │ │ │ ├── gson │ │ │ │ ├── GsonProvider.java │ │ │ │ └── types │ │ │ │ │ └── DurationConverter.java │ │ │ ├── VisibilityUtils.java │ │ │ ├── AFKDetection.java │ │ │ ├── NameUtils.java │ │ │ ├── ranks │ │ │ │ └── RankUtils.java │ │ │ ├── CenterUtils.java │ │ │ ├── DatabaseUtils.java │ │ │ ├── NetworkUtils.java │ │ │ ├── CommandAudience.java │ │ │ └── SkullUtils.java │ │ │ ├── chat │ │ │ ├── network │ │ │ │ ├── NetworkChatConfig.java │ │ │ │ └── NetworkChatMessage.java │ │ │ └── management │ │ │ │ └── ChatManagementConfig.java │ │ │ ├── nick │ │ │ ├── skin │ │ │ │ └── SkinManager.java │ │ │ ├── NickConfig.java │ │ │ ├── data │ │ │ │ └── NickSelection.java │ │ │ ├── services │ │ │ │ └── NickQuery.java │ │ │ ├── NickImpl.java │ │ │ ├── Nick.java │ │ │ └── feature │ │ │ │ └── NickFeature.java │ │ │ ├── moderation │ │ │ ├── punishments │ │ │ │ ├── NetworkPunishment.java │ │ │ │ └── types │ │ │ │ │ ├── KickPunishment.java │ │ │ │ │ ├── BanPunishment.java │ │ │ │ │ ├── TempBanPunishment.java │ │ │ │ │ ├── UsernameBanPunishment.java │ │ │ │ │ ├── WarnPunishment.java │ │ │ │ │ └── ExpirablePunishment.java │ │ │ ├── tools │ │ │ │ ├── Tool.java │ │ │ │ ├── buttons │ │ │ │ │ ├── ToolButton.java │ │ │ │ │ ├── TranslatableToolButton.java │ │ │ │ │ ├── ToolButtonBase.java │ │ │ │ │ └── types │ │ │ │ │ │ └── NightVisionButton.java │ │ │ │ ├── types │ │ │ │ │ ├── ModerationMenuTool.java │ │ │ │ │ └── LookupSign.java │ │ │ │ ├── ModerationTools.java │ │ │ │ └── ToolBase.java │ │ │ ├── services │ │ │ │ └── ModerationQuery.java │ │ │ └── commands │ │ │ │ ├── WarnCommand.java │ │ │ │ └── ToolCommand.java │ │ │ ├── requests │ │ │ ├── MapCooldown.java │ │ │ ├── SponsorRequest.java │ │ │ ├── commands │ │ │ │ └── supervotes │ │ │ │ │ └── SuperVoteCommand.java │ │ │ ├── services │ │ │ │ └── RequestQuery.java │ │ │ ├── supervotes │ │ │ │ └── SuperVoteComponents.java │ │ │ └── feature │ │ │ │ └── types │ │ │ │ ├── SQLRequestFeature.java │ │ │ │ └── NoDBRequestFeature.java │ │ │ ├── sessions │ │ │ ├── feature │ │ │ │ ├── SessionFeature.java │ │ │ │ └── types │ │ │ │ │ └── SQLSessionFeature.java │ │ │ ├── VanishedSessionListener.java │ │ │ ├── SessionQuery.java │ │ │ └── services │ │ │ │ └── SessionDataQuery.java │ │ │ ├── teleports │ │ │ └── TeleportConfig.java │ │ │ ├── commands │ │ │ ├── injectors │ │ │ │ └── CommandAudienceProvider.java │ │ │ ├── ServerInfoCommand.java │ │ │ ├── providers │ │ │ │ └── GameModeParser.java │ │ │ ├── VanishedCommand.java │ │ │ ├── SudoCommand.java │ │ │ ├── StaffCommand.java │ │ │ └── player │ │ │ │ └── TargetPlayer.java │ │ │ ├── freeze │ │ │ └── FreezeConfig.java │ │ │ ├── motd │ │ │ ├── MotdConfig.java │ │ │ └── MotdFeature.java │ │ │ ├── info │ │ │ ├── InfoCommandConfig.java │ │ │ ├── InfoCommandsFeature.java │ │ │ └── InfoCommandData.java │ │ │ ├── broadcast │ │ │ └── BroadcastCommand.java │ │ │ ├── text │ │ │ └── UTF8Control.java │ │ │ └── CommunityConfig.java │ │ └── resources │ │ ├── plugin.yml │ │ └── strings.properties └── build.gradle.kts ├── .gitignore ├── README.md └── .github └── workflows └── build.yml /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.configuration-cache=true 2 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "community" 2 | 3 | include(":core") 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PGMDev/Community/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/updates/NetworkUpdate.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network.updates; 2 | 3 | public interface NetworkUpdate { 4 | 5 | String getChannel(); 6 | 7 | String getData(); 8 | } 9 | -------------------------------------------------------------------------------- /core/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Community 2 | description: ${description} 3 | main: ${mainClass} 4 | version: ${version} (git-${commitHash}) 5 | website: ${url} 6 | author: ${author} 7 | softdepend: [PGM, Environment, AFK] 8 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/users/UserProfileWithSessionCallback.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.users; 2 | 3 | import dev.pgm.community.sessions.Session; 4 | 5 | public interface UserProfileWithSessionCallback { 6 | 7 | public void run(UserProfile profile, Session session); 8 | } 9 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/events/PollEndEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls.events; 2 | 3 | import dev.pgm.community.polls.Poll; 4 | 5 | public class PollEndEvent extends PollEvent { 6 | 7 | public PollEndEvent(Poll poll) { 8 | super(poll); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/events/PollStartEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls.events; 2 | 3 | import dev.pgm.community.polls.Poll; 4 | 5 | public class PollStartEvent extends PollEvent { 6 | 7 | public PollStartEvent(Poll poll) { 8 | super(poll); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/feature/SQLFeature.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.feature; 2 | 3 | import dev.pgm.community.database.Savable; 4 | 5 | public interface SQLFeature extends Savable { 6 | 7 | /** Create the SQL table for a data set */ 8 | void createTable(); 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/menu/StaticMenuItem.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.menu; 2 | 3 | import java.util.List; 4 | import org.bukkit.Material; 5 | 6 | public class StaticMenuItem extends MenuItem { 7 | 8 | public StaticMenuItem(Material icon, String name, List description) { 9 | super(icon, name, description); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/database/Savable.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.database; 2 | 3 | import java.util.List; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | public interface Savable { 7 | 8 | void save(T t); 9 | 10 | CompletableFuture> queryList(R target); 11 | 12 | CompletableFuture query(R target); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/exceptions/MapPartySetupException.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party.exceptions; 2 | 3 | import dev.pgm.community.party.MapParty; 4 | 5 | public class MapPartySetupException extends MapPartyException { 6 | 7 | public MapPartySetupException(String error, MapParty party) { 8 | super(party, error); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/events/MapPartyEndEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party.events; 2 | 3 | import dev.pgm.community.party.MapParty; 4 | import org.bukkit.command.CommandSender; 5 | 6 | public class MapPartyEndEvent extends MapPartyEvent { 7 | 8 | public MapPartyEndEvent(MapParty party, CommandSender sender) { 9 | super(party, sender); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/events/MapPartyCreateEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party.events; 2 | 3 | import dev.pgm.community.party.MapParty; 4 | import org.bukkit.command.CommandSender; 5 | 6 | public class MapPartyCreateEvent extends MapPartyEvent { 7 | 8 | public MapPartyCreateEvent(MapParty party, CommandSender sender) { 9 | super(party, sender); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/events/MapPartyStartEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party.events; 2 | 3 | import dev.pgm.community.party.MapParty; 4 | import org.bukkit.command.CommandSender; 5 | 6 | public class MapPartyStartEvent extends MapPartyEvent { 7 | 8 | public MapPartyStartEvent(MapParty party, CommandSender sender) { 9 | super(party, sender); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/events/MapPartyRestartEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party.events; 2 | 3 | import dev.pgm.community.party.MapParty; 4 | import org.bukkit.command.CommandSender; 5 | 6 | public class MapPartyRestartEvent extends MapPartyEvent { 7 | 8 | public MapPartyRestartEvent(MapParty party, CommandSender sender) { 9 | super(party, sender); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/assistance/menu/ReportReason.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.assistance.menu; 2 | 3 | import dev.pgm.community.menu.MenuItem; 4 | import java.util.List; 5 | import org.bukkit.Material; 6 | 7 | public class ReportReason extends MenuItem { 8 | 9 | public ReportReason(String name, List description, Material icon) { 10 | super(icon, name, description); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/friends/FriendRequestStatus.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.friends; 2 | 3 | // Status code returned when adding a friend 4 | public enum FriendRequestStatus { 5 | ACCEPTED_EXISTING, // The target had already sent a friend request, so request was auto accepted 6 | PENDING, // Target and sender have no prior requests 7 | EXISTING; // The sender has already sent a friend request 8 | } 9 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/mobs/MobConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.mobs; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public class MobConfig extends FeatureConfigImpl { 7 | 8 | private static final String KEY = "mobs"; 9 | 10 | public MobConfig(Configuration config) { 11 | super(KEY, config); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/squads/SquadConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.squads; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public class SquadConfig extends FeatureConfigImpl { 7 | 8 | private static final String KEY = "squads"; 9 | 10 | public SquadConfig(Configuration config) { 11 | super(KEY, config); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/mutations/MutationConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.mutations; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public class MutationConfig extends FeatureConfigImpl { 7 | 8 | private static final String KEY = "mutations"; 9 | 10 | public MutationConfig(Configuration config) { 11 | super(KEY, config); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/events/UserProfileLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.events; 2 | 3 | import dev.pgm.community.users.UserProfile; 4 | 5 | public class UserProfileLoadEvent extends CommunityEvent { 6 | 7 | private UserProfile profile; 8 | 9 | public UserProfileLoadEvent(UserProfile profile) { 10 | this.profile = profile; 11 | } 12 | 13 | public UserProfile getUser() { 14 | return profile; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/history/MatchHistoryConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.history; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public class MatchHistoryConfig extends FeatureConfigImpl { 7 | 8 | private static final String KEY = "history"; 9 | 10 | public MatchHistoryConfig(Configuration config) { 11 | super(KEY, config); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/events/PollEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls.events; 2 | 3 | import dev.pgm.community.events.CommunityEvent; 4 | import dev.pgm.community.polls.Poll; 5 | 6 | public abstract class PollEvent extends CommunityEvent { 7 | 8 | private final Poll poll; 9 | 10 | public PollEvent(Poll poll) { 11 | this.poll = poll; 12 | } 13 | 14 | public Poll getPoll() { 15 | return poll; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/compatibility/EntityTypes.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils.compatibility; 2 | 3 | import org.bukkit.entity.EntityType; 4 | import tc.oc.pgm.util.bukkit.BukkitUtils; 5 | 6 | public interface EntityTypes { 7 | EntityType PIG_ZOMBIE = parse("PIG_ZOMBIE", "ZOMBIFIED_PIGLIN"); 8 | 9 | private static EntityType parse(String... names) { 10 | return BukkitUtils.parse(EntityType::valueOf, names); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/chat/network/NetworkChatConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.chat.network; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public class NetworkChatConfig extends FeatureConfigImpl { 7 | 8 | private static final String KEY = "network.chat"; 9 | 10 | public NetworkChatConfig(Configuration config) { 11 | super(KEY, config); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/gson/GsonProvider.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils.gson; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import dev.pgm.community.utils.gson.types.DurationConverter; 6 | import java.time.Duration; 7 | 8 | public class GsonProvider { 9 | 10 | public static Gson get() { 11 | return new GsonBuilder().registerTypeAdapter(Duration.class, new DurationConverter()).create(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/exceptions/MapPartyException.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party.exceptions; 2 | 3 | import dev.pgm.community.party.MapParty; 4 | 5 | public abstract class MapPartyException extends Exception { 6 | 7 | private MapParty party; 8 | 9 | public MapPartyException(MapParty party, String error) { 10 | super(error); 11 | this.party = party; 12 | } 13 | 14 | public MapParty getParty() { 15 | return party; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/mutations/types/BowMutation.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.mutations.types; 2 | 3 | import dev.pgm.community.mutations.Mutation; 4 | import java.util.Set; 5 | 6 | // Denotes a mutation that modifies projectile type of a bow (only 1 per match) 7 | public interface BowMutation { 8 | 9 | default boolean hasBowMutation(Set activeMutations) { 10 | return activeMutations.stream().anyMatch(m -> m instanceof BowMutation); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/events/PollVoteEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls.events; 2 | 3 | import dev.pgm.community.polls.Poll; 4 | import org.bukkit.entity.Player; 5 | 6 | public class PollVoteEvent extends PollEvent { 7 | 8 | private Player player; 9 | 10 | public PollVoteEvent(Player player, Poll poll) { 11 | super(poll); 12 | this.player = player; 13 | } 14 | 15 | public Player getPlayer() { 16 | return player; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/events/PlayerHelpRequestEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.events; 2 | 3 | import dev.pgm.community.assistance.PlayerHelpRequest; 4 | 5 | public class PlayerHelpRequestEvent extends CommunityEvent { 6 | 7 | private final PlayerHelpRequest request; 8 | 9 | public PlayerHelpRequestEvent(PlayerHelpRequest request) { 10 | this.request = request; 11 | } 12 | 13 | public PlayerHelpRequest getRequest() { 14 | return request; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/events/PlayerReportEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.events; 2 | 3 | import dev.pgm.community.assistance.Report; 4 | 5 | /** PlayerReportEvent - Called when a report is created */ 6 | public class PlayerReportEvent extends CommunityEvent { 7 | 8 | private final Report report; 9 | 10 | public PlayerReportEvent(Report report) { 11 | this.report = report; 12 | } 13 | 14 | public Report getReport() { 15 | return report; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/ending/EndAction.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls.ending; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import org.bukkit.entity.Player; 5 | 6 | public interface EndAction { 7 | 8 | void execute(Player creator); 9 | 10 | Component getName(); 11 | 12 | Component getPreviewValue(); 13 | 14 | Component getDefaultQuestion(); 15 | 16 | Component getButtonValue(boolean mixed); 17 | 18 | String getValue(); 19 | 20 | String getTypeName(); 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/nick/skin/SkinManager.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.nick.skin; 2 | 3 | import dev.pgm.community.Community; 4 | import org.bukkit.Skin; 5 | import org.bukkit.entity.Player; 6 | 7 | public class SkinManager { 8 | 9 | private SkinCache cache; 10 | 11 | public SkinManager() { 12 | this.cache = new SkinCache(); 13 | Community.get().registerListener(cache); 14 | } 15 | 16 | public void setSkin(Player player, Skin skin) { 17 | cache.onSkinRefresh(player, skin); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/compatibility/Enchantments.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils.compatibility; 2 | 3 | import org.bukkit.enchantments.Enchantment; 4 | import tc.oc.pgm.util.bukkit.BukkitUtils; 5 | 6 | public interface Enchantments { 7 | Enchantment INFINITY = parse("ARROW_INFINITE", "infinity"); 8 | Enchantment LUCK_OF_THE_SEA = parse("LUCK", "luck_of_the_sea"); 9 | 10 | private static Enchantment parse(String... names) { 11 | return BukkitUtils.parse(Enchantment::getByName, names); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/events/CommunityEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.events; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | /** The foundation for all Community Events */ 7 | public class CommunityEvent extends Event { 8 | 9 | private static final HandlerList handlers = new HandlerList(); 10 | 11 | @Override 12 | public HandlerList getHandlers() { 13 | return handlers; 14 | } 15 | 16 | public static HandlerList getHandlerList() { 17 | return handlers; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/moderation/punishments/NetworkPunishment.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.moderation.punishments; 2 | 3 | public class NetworkPunishment { 4 | 5 | private String serverId; 6 | private Punishment punishment; 7 | 8 | public NetworkPunishment(Punishment punishment, String serverId) { 9 | this.punishment = punishment; 10 | this.serverId = serverId; 11 | } 12 | 13 | public String getServer() { 14 | return serverId; 15 | } 16 | 17 | public Punishment getPunishment() { 18 | return punishment; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/updates/types/AssistUpdate.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network.updates.types; 2 | 3 | import dev.pgm.community.assistance.AssistanceRequest; 4 | import dev.pgm.community.network.Channels; 5 | import dev.pgm.community.network.updates.NetworkUpdateBase; 6 | 7 | /** AssistUpdate - Called when an {@link AssistanceRequest} is made */ 8 | public class AssistUpdate extends NetworkUpdateBase { 9 | 10 | public AssistUpdate(AssistanceRequest request) { 11 | super(request, Channels.ASSISTANCE); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/moderation/tools/Tool.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.moderation.tools; 2 | 3 | import java.util.List; 4 | import org.bukkit.Material; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.inventory.ItemStack; 7 | import tc.oc.pgm.api.player.event.ObserverInteractEvent; 8 | 9 | public interface Tool { 10 | 11 | void onInteract(ObserverInteractEvent event); 12 | 13 | void give(Player player); 14 | 15 | String getName(); 16 | 17 | List getLore(); 18 | 19 | Material getMaterial(); 20 | 21 | ItemStack getItem(); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/updates/types/ChatUpdate.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network.updates.types; 2 | 3 | import dev.pgm.community.chat.network.NetworkChatMessage; 4 | import dev.pgm.community.network.Channels; 5 | import dev.pgm.community.network.updates.NetworkUpdateBase; 6 | 7 | /** ChatUpdate - Relay chat across the network. See {@link MatchPlayerChatEvent} */ 8 | public class ChatUpdate extends NetworkUpdateBase { 9 | 10 | public ChatUpdate(NetworkChatMessage message) { 11 | super(message, Channels.CHAT); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/updates/types/PunishmentUpdate.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network.updates.types; 2 | 3 | import dev.pgm.community.moderation.punishments.NetworkPunishment; 4 | import dev.pgm.community.network.Channels; 5 | import dev.pgm.community.network.updates.NetworkUpdateBase; 6 | 7 | /** PunishmentUpdate - Called when a {@link Punishment} is issued */ 8 | public class PunishmentUpdate extends NetworkUpdateBase { 9 | 10 | public PunishmentUpdate(NetworkPunishment punishment) { 11 | super(punishment, Channels.PUNISHMENTS); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/database/Query.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.database; 2 | 3 | import static tc.oc.pgm.util.Assert.assertNotNull; 4 | 5 | public class Query { 6 | 7 | public static String createTable(String tableName, String fields) { 8 | assertNotNull(tableName); 9 | assertNotNull(fields); 10 | 11 | return String.format("CREATE TABLE IF NOT EXISTS %s %s", tableName, fields); 12 | } 13 | 14 | public static String countTable(String tableName) { 15 | assertNotNull(tableName); 16 | return String.format("SELECT count(*) from %s", tableName); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/settings/PartySetting.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party.settings; 2 | 3 | import org.bukkit.Material; 4 | 5 | public abstract class PartySetting { 6 | 7 | private String name; 8 | private String description; 9 | 10 | public PartySetting(String name, String description) { 11 | this.name = name; 12 | this.description = description; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public String getDescription() { 20 | return description; 21 | } 22 | 23 | public abstract Material getIcon(); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/VisibilityUtils.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils; 2 | 3 | import java.util.UUID; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.entity.Player; 6 | import tc.oc.pgm.api.integration.Integration; 7 | 8 | public class VisibilityUtils { 9 | 10 | public static boolean isDisguised(UUID playerId) { 11 | Player player = Bukkit.getPlayer(playerId); 12 | return player != null && isDisguised(player); 13 | } 14 | 15 | public static boolean isDisguised(Player player) { 16 | return Integration.isVanished(player) || Integration.getNick(player) != null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/feature/Feature.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.feature; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfig; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** A Feature is something can be enabled/disabled, may contain commands, and a config */ 7 | public interface Feature { 8 | 9 | boolean isEnabled(); 10 | 11 | void setEnabled(boolean on); 12 | 13 | void enable(); 14 | 15 | void disable(); 16 | 17 | FeatureConfig getConfig(); 18 | 19 | default CompletableFuture count() { 20 | return CompletableFuture.completedFuture(0); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/assistance/menu/ReportCategory.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.assistance.menu; 2 | 3 | import dev.pgm.community.menu.MenuItem; 4 | import java.util.List; 5 | import org.bukkit.Material; 6 | 7 | public class ReportCategory extends MenuItem { 8 | 9 | private final List reasons; 10 | 11 | public ReportCategory( 12 | String name, List description, Material icon, List reasons) { 13 | super(icon, name, description); 14 | this.reasons = reasons; 15 | } 16 | 17 | public List getReasons() { 18 | return reasons; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/requests/MapCooldown.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.requests; 2 | 3 | import java.time.Duration; 4 | import java.time.Instant; 5 | import tc.oc.pgm.util.TimeUtils; 6 | 7 | public class MapCooldown { 8 | private final Instant endsAt; 9 | 10 | public MapCooldown(Duration cooldown) { 11 | this.endsAt = Instant.now().plus(cooldown); 12 | } 13 | 14 | public boolean hasExpired() { 15 | return !getTimeRemaining().isPositive(); 16 | } 17 | 18 | public Duration getTimeRemaining() { 19 | return TimeUtils.max(Duration.ZERO, Duration.between(Instant.now(), endsAt)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/assistance/PlayerHelpRequest.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.assistance; 2 | 3 | import java.time.Instant; 4 | import java.util.UUID; 5 | import org.bukkit.entity.Player; 6 | 7 | public class PlayerHelpRequest extends AssistanceRequest { 8 | 9 | public PlayerHelpRequest(Player player, String reason, String server) { 10 | this(player.getUniqueId(), reason, Instant.now().toEpochMilli(), server); 11 | } 12 | 13 | public PlayerHelpRequest(UUID playerId, String reason, long time, String server) { 14 | super(playerId, playerId, time, reason, server, RequestType.PLAYER_HELP); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/sessions/feature/SessionFeature.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.sessions.feature; 2 | 3 | import dev.pgm.community.feature.Feature; 4 | import dev.pgm.community.sessions.Session; 5 | import java.util.UUID; 6 | import java.util.concurrent.CompletableFuture; 7 | import org.bukkit.entity.Player; 8 | 9 | public interface SessionFeature extends Feature { 10 | 11 | CompletableFuture getLatestSession(UUID playerId, boolean ignoreDisguised); 12 | 13 | Session startSession(Player player); 14 | 15 | void endSession(Session session); 16 | 17 | boolean isPlayerJoining(Player player); 18 | 19 | void endOngoingSessions(); 20 | } 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | dependency-reduced-pom.xml 8 | buildNumber.properties 9 | .mvn/timing.properties 10 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar 11 | .mvn/wrapper/maven-wrapper.jar 12 | bin/ 13 | *.class 14 | *.log 15 | *.ctxt 16 | *.war 17 | *.nar 18 | *.ear 19 | *.zip 20 | *.tar.gz 21 | *.rar 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | # IntelliJ files 25 | .idea 26 | *.iml 27 | # Eclipse 28 | .classpath 29 | .project 30 | .settings 31 | build 32 | .gradle 33 | .DS_Store 34 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/events/MapPartyEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party.events; 2 | 3 | import dev.pgm.community.events.CommunityEvent; 4 | import dev.pgm.community.party.MapParty; 5 | import org.bukkit.command.CommandSender; 6 | 7 | public abstract class MapPartyEvent extends CommunityEvent { 8 | 9 | private final MapParty party; 10 | private final CommandSender sender; 11 | 12 | public MapPartyEvent(MapParty party, CommandSender sender) { 13 | this.party = party; 14 | this.sender = sender; 15 | } 16 | 17 | public MapParty getParty() { 18 | return party; 19 | } 20 | 21 | public CommandSender getSender() { 22 | return sender; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/requests/SponsorRequest.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.requests; 2 | 3 | import java.util.UUID; 4 | import tc.oc.pgm.api.map.MapInfo; 5 | 6 | public class SponsorRequest { 7 | 8 | private UUID playerId; 9 | private MapInfo map; 10 | private boolean canRefund; 11 | 12 | public SponsorRequest(UUID playerId, MapInfo map, boolean canRefund) { 13 | this.playerId = playerId; 14 | this.map = map; 15 | this.canRefund = canRefund; 16 | } 17 | 18 | public UUID getPlayerId() { 19 | return playerId; 20 | } 21 | 22 | public MapInfo getMap() { 23 | return map; 24 | } 25 | 26 | public boolean canRefund() { 27 | return canRefund; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/updates/NetworkUpdateBase.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network.updates; 2 | 3 | import com.google.gson.Gson; 4 | import dev.pgm.community.utils.gson.GsonProvider; 5 | 6 | public abstract class NetworkUpdateBase implements NetworkUpdate { 7 | 8 | private T item; 9 | private String channel; 10 | private Gson gson; 11 | 12 | public NetworkUpdateBase(T item, String channel) { 13 | this.item = item; 14 | this.channel = channel; 15 | this.gson = GsonProvider.get(); 16 | } 17 | 18 | @Override 19 | public String getChannel() { 20 | return channel; 21 | } 22 | 23 | @Override 24 | public String getData() { 25 | return gson.toJson(item); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/nick/NickConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.nick; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public class NickConfig extends FeatureConfigImpl { 7 | 8 | private static final String KEY = "nick"; 9 | 10 | private boolean pgmIntegration; 11 | 12 | public NickConfig(Configuration config) { 13 | super(KEY, config); 14 | } 15 | 16 | public boolean isIntegrationEnabled() { 17 | return pgmIntegration; 18 | } 19 | 20 | @Override 21 | public void reload(Configuration config) { 22 | super.reload(config); 23 | this.pgmIntegration = config.getBoolean(getKey() + ".pgm-integration"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/MapPartyStatusType.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party; 2 | 3 | import static net.kyori.adventure.text.Component.text; 4 | 5 | import net.kyori.adventure.text.Component; 6 | import net.kyori.adventure.text.format.NamedTextColor; 7 | 8 | public enum MapPartyStatusType { 9 | START("started", NamedTextColor.GREEN), 10 | END("stopped", NamedTextColor.RED), 11 | RESTART("restarted", NamedTextColor.DARK_GREEN); 12 | 13 | String name; 14 | NamedTextColor color; 15 | 16 | MapPartyStatusType(String name, NamedTextColor color) { 17 | this.name = name; 18 | this.color = color; 19 | } 20 | 21 | public Component getNameComponent() { 22 | return text(name, color); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/AFKDetection.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.plugin.Plugin; 6 | import tc.oc.occ.afk.AFKPlugin; 7 | 8 | public class AFKDetection { 9 | 10 | private Plugin afkPlugin; 11 | 12 | public AFKDetection() { 13 | afkPlugin = Bukkit.getPluginManager().getPlugin("AFK"); 14 | } 15 | 16 | public boolean isAFK(Player player) { 17 | if (afkPlugin != null && afkPlugin.isEnabled()) { 18 | return isPlayerAFK(player); 19 | } 20 | return false; 21 | } 22 | 23 | private boolean isPlayerAFK(Player player) { 24 | return AFKPlugin.get() != null && AFKPlugin.get().getManager().isAFK(player); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/friends/FriendshipConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.friends; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public class FriendshipConfig extends FeatureConfigImpl { 7 | 8 | public static final String KEY = "friends"; 9 | 10 | private boolean pgmIntegration; 11 | 12 | public FriendshipConfig(Configuration config) { 13 | super(KEY, config); 14 | } 15 | 16 | public boolean isIntegrationEnabled() { 17 | return pgmIntegration; 18 | } 19 | 20 | @Override 21 | public void reload(Configuration config) { 22 | super.reload(config); 23 | this.pgmIntegration = config.getBoolean(getKey() + ".pgm-integration"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/updates/types/RefreshPunishmentUpdate.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network.updates.types; 2 | 3 | import dev.pgm.community.network.Channels; 4 | import dev.pgm.community.network.updates.NetworkUpdate; 5 | import java.util.UUID; 6 | 7 | /** RefreshPunishmentUpdate - Called on ban pardon or unmute */ 8 | public class RefreshPunishmentUpdate implements NetworkUpdate { 9 | 10 | private final UUID playerId; 11 | 12 | public RefreshPunishmentUpdate(UUID playerId) { 13 | this.playerId = playerId; 14 | } 15 | 16 | @Override 17 | public String getChannel() { 18 | return Channels.PUNISHMENT_UPDATE; 19 | } 20 | 21 | @Override 22 | public String getData() { 23 | return playerId.toString(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/NameUtils.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils; 2 | 3 | import java.util.UUID; 4 | import java.util.regex.Pattern; 5 | 6 | public class NameUtils { 7 | 8 | static final Pattern NAME_REGEX = Pattern.compile("[a-zA-Z0-9_]{1,16}"); 9 | 10 | public static boolean isMinecraftName(String name) { 11 | return NAME_REGEX.matcher(name).matches(); 12 | } 13 | 14 | public static boolean isPlayerId(String uuid) { 15 | try { 16 | UUID playerId = UUID.fromString(uuid); 17 | return true; 18 | } catch (IllegalArgumentException e) { 19 | return false; 20 | } 21 | } 22 | 23 | public static boolean isIdentifier(String input) { 24 | return isMinecraftName(input) || isPlayerId(input); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/nick/data/NickSelection.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.nick.data; 2 | 3 | import java.time.Duration; 4 | import java.time.Instant; 5 | import java.util.List; 6 | 7 | public class NickSelection { 8 | 9 | private List names; 10 | private Instant lastRefresh; 11 | 12 | public NickSelection(List names) { 13 | this.names = names; 14 | this.lastRefresh = Instant.now(); 15 | } 16 | 17 | public List getNames() { 18 | return names; 19 | } 20 | 21 | public boolean canRefresh() { 22 | return Duration.between(lastRefresh, Instant.now()).toHours() > 1; 23 | } 24 | 25 | public boolean isValid(String input) { 26 | return names.stream().anyMatch(s -> s.equalsIgnoreCase(input)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/mutations/options/MutationBooleanOption.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.mutations.options; 2 | 3 | import org.bukkit.Material; 4 | 5 | public class MutationBooleanOption extends MutationOption { 6 | 7 | private boolean value; 8 | private boolean def; 9 | 10 | public MutationBooleanOption( 11 | String name, String description, Material iconMaterial, boolean def, boolean prereq) { 12 | super(name, description, iconMaterial, prereq); 13 | this.value = def; 14 | this.def = def; 15 | } 16 | 17 | public boolean getValue() { 18 | return value; 19 | } 20 | 21 | public boolean getDefaultValue() { 22 | return def; 23 | } 24 | 25 | public void setValue(boolean value) { 26 | this.value = value; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/teleports/TeleportConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.teleports; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public class TeleportConfig extends FeatureConfigImpl { 7 | 8 | private static final String KEY = "teleports"; 9 | 10 | private boolean sound; 11 | 12 | public TeleportConfig(Configuration config) { 13 | super(KEY, config); 14 | } 15 | 16 | public boolean isSoundPlayed() { 17 | return sound; 18 | } 19 | 20 | @Override 21 | public void reload(Configuration config) { 22 | super.reload(config); // TODO: Cooldowns, sounds message format, and other config settings 23 | 24 | this.sound = config.getBoolean(getKey() + ".sound"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/users/UsersConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.users; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import java.util.List; 5 | import org.bukkit.configuration.Configuration; 6 | 7 | public class UsersConfig extends FeatureConfigImpl { 8 | 9 | public static final String KEY = "users"; 10 | 11 | private List firstJoinCommands; 12 | 13 | public UsersConfig(Configuration config) { 14 | super(KEY, config); 15 | } 16 | 17 | public List getFirstJoinCommands() { 18 | return firstJoinCommands; 19 | } 20 | 21 | @Override 22 | public void reload(Configuration config) { 23 | super.reload(config); 24 | 25 | this.firstJoinCommands = config.getStringList(getKey() + ".first-join"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/assistance/services/AssistanceQuery.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.assistance.services; 2 | 3 | public interface AssistanceQuery { 4 | 5 | static final String TABLE_NAME = "reports"; 6 | static final String TABLE_FIELDS = 7 | "(id VARCHAR(36) PRIMARY KEY, " 8 | + "sender VARCHAR(36), " 9 | + "reported VARCHAR(36), " 10 | + "reason VARCHAR(255), " 11 | + "time LONG, " 12 | + "server VARCHAR(255))"; 13 | static final String INSERT_REPORT_QUERY = 14 | "INSERT INTO " 15 | + TABLE_NAME 16 | + "(id, sender, reported, reason, time, server) VALUES (?, ?, ?, ?, ?, ?)"; 17 | static final String SELECT_REPORT_QUERY = 18 | "SELECT id, sender, reason, time FROM " + TABLE_NAME + " WHERE reported = ?"; 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/moderation/tools/buttons/ToolButton.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.moderation.tools.buttons; 2 | 3 | import fr.minuskube.inv.ClickableItem; 4 | import java.util.List; 5 | import java.util.function.Consumer; 6 | import org.bukkit.Material; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.inventory.InventoryClickEvent; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | public interface ToolButton { 12 | 13 | Player getViewer(); 14 | 15 | Material getMaterial(); 16 | 17 | int getAmount(); 18 | 19 | String getName(); 20 | 21 | List getLore(); 22 | 23 | ItemStack getIcon(); 24 | 25 | Consumer getClickEvent(); 26 | 27 | default ClickableItem getItem() { 28 | return ClickableItem.of(getIcon(), getClickEvent()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/commands/injectors/CommandAudienceProvider.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.commands.injectors; 2 | 3 | import dev.pgm.community.utils.CommandAudience; 4 | import org.bukkit.command.CommandSender; 5 | import org.jetbrains.annotations.NotNull; 6 | import tc.oc.pgm.lib.org.incendo.cloud.context.CommandContext; 7 | import tc.oc.pgm.lib.org.incendo.cloud.injection.ParameterInjector; 8 | import tc.oc.pgm.lib.org.incendo.cloud.util.annotation.AnnotationAccessor; 9 | 10 | public final class CommandAudienceProvider 11 | implements ParameterInjector { 12 | 13 | @Override 14 | public @NotNull CommandAudience create( 15 | CommandContext context, @NotNull AnnotationAccessor annotations) { 16 | return new CommandAudience(context.sender()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/users/services/UserQuery.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.users.services; 2 | 3 | public interface UserQuery { 4 | 5 | static final String TABLE_FIELDS = 6 | "(id VARCHAR(36) PRIMARY KEY, name VARCHAR(16), first_join LONG, join_count INT)"; 7 | static final String TABLE_NAME = "users"; 8 | 9 | static final String INSERT_USER_QUERY = 10 | "INSERT INTO " + TABLE_NAME + "(id, name, first_join, join_count) VALUES (?,?,?,?)"; 11 | 12 | static final String USERNAME_QUERY = 13 | "SELECT * from " + TABLE_NAME + " WHERE LOWER(name) = LOWER(?) LIMIT 1"; 14 | static final String PLAYERID_QUERY = "SELECT * from " + TABLE_NAME + " WHERE id = ? LIMIT 1"; 15 | 16 | static final String UPDATE_USER_QUERY = 17 | "UPDATE " + TABLE_NAME + " SET name = ?, join_count = ? WHERE id = ? "; 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/ranks/RankUtils.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils.ranks; 2 | 3 | import dev.pgm.community.Community; 4 | import java.util.List; 5 | import org.bukkit.entity.Player; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | public class RankUtils { 9 | 10 | @Nullable 11 | public static RanksConfig.Rank getHighestLevelRank(Player player) { 12 | List allRanks = 13 | Community.get().getServerConfig().getRanksConfig().getRanks(); 14 | RanksConfig.Rank highestRank = null; 15 | 16 | for (RanksConfig.Rank rank : allRanks) { 17 | if (player.hasPermission(rank.getPermission())) { 18 | if (highestRank == null || rank.getWeight() > highestRank.getWeight()) { 19 | highestRank = rank; 20 | } 21 | } 22 | } 23 | 24 | return highestRank; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/feature/NetworkFeatureBase.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network.feature; 2 | 3 | import dev.pgm.community.feature.FeatureBase; 4 | import dev.pgm.community.network.NetworkConfig; 5 | import java.util.logging.Logger; 6 | import org.bukkit.configuration.Configuration; 7 | 8 | public abstract class NetworkFeatureBase extends FeatureBase implements NetworkFeature { 9 | 10 | public NetworkFeatureBase(Configuration config, Logger logger, String featureName) { 11 | super(new NetworkConfig(config), logger, featureName); 12 | if (getConfig().isEnabled()) { 13 | enable(); 14 | } 15 | } 16 | 17 | public NetworkConfig getNetworkConfig() { 18 | return (NetworkConfig) getConfig(); 19 | } 20 | 21 | @Override 22 | public String getNetworkId() { 23 | return getNetworkConfig().getNetworkId(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/feature/SQLFeatureBase.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.feature; 2 | 3 | import co.aikar.idb.DB; 4 | import dev.pgm.community.database.Query; 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | /** Base implementation of {@link SQLFeature} * */ 8 | public abstract class SQLFeatureBase implements SQLFeature { 9 | 10 | private final String tableName; 11 | private final String fields; 12 | 13 | public SQLFeatureBase(String tableName, String fields) { 14 | this.tableName = tableName; 15 | this.fields = fields; 16 | createTable(); 17 | } 18 | 19 | @Override 20 | public void createTable() { 21 | DB.executeUpdateAsync(Query.createTable(tableName, fields)); 22 | } 23 | 24 | public CompletableFuture count() { 25 | return DB.getFirstColumnAsync(Query.countTable(tableName)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/feature/config/FeatureConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.feature.config; 2 | 3 | import dev.pgm.community.assistance.feature.AssistanceFeature; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public interface FeatureConfig { 7 | 8 | /** Reloads config values with those from the file */ 9 | void reload(Configuration config); 10 | 11 | /** 12 | * The key associated with the feature e.g "reports" for {@link AssistanceFeature} 13 | * 14 | * @return the string key 15 | */ 16 | String getKey(); 17 | 18 | /** 19 | * Enables or disables the feature 20 | * 21 | * @param yes whether to enable or disable 22 | */ 23 | void setEnabled(boolean yes); 24 | 25 | /** 26 | * Gets whether the feature is enabled or disabled 27 | * 28 | * @return whether enabled 29 | */ 30 | boolean isEnabled(); 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/compatibility/PotionEffects.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils.compatibility; 2 | 3 | import org.bukkit.potion.PotionEffectType; 4 | import tc.oc.pgm.util.bukkit.BukkitUtils; 5 | 6 | public interface PotionEffects { 7 | PotionEffectType NAUSEA = parse("CONFUSION", "nausea"); 8 | PotionEffectType RESISTANCE = parse("DAMAGE_RESISTANCE", "resistance"); 9 | PotionEffectType HASTE = parse("FAST_DIGGING", "HASTE"); 10 | PotionEffectType STRENGTH = parse("INCREASE_DAMAGE", "strength"); 11 | PotionEffectType JUMP_BOOST = parse("JUMP", "jump_boost"); 12 | PotionEffectType SLOWNESS = parse("SLOW", "slowness"); 13 | PotionEffectType MINING_FATIGUE = parse("SLOW_DIGGING", "mining_fatigue"); 14 | 15 | private static PotionEffectType parse(String... names) { 16 | return BukkitUtils.parse(PotionEffectType::getByName, names); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/nick/services/NickQuery.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.nick.services; 2 | 3 | public interface NickQuery { 4 | 5 | static final String TABLE_NAME = "nicknames"; 6 | static final String TABLE_FIELDS = 7 | "(playerId VARCHAR(36) PRIMARY KEY, nickname VARCHAR(16), date LONG, enabled BOOL)"; 8 | 9 | static final String INSERT_NICKNAME_QUERY = 10 | "INSERT INTO " + TABLE_NAME + "(playerId, nickname, date, enabled) VALUES (?,?,?,?)"; 11 | 12 | static final String SELECT_NICKNAME_BY_ID_QUERY = 13 | "SELECT * from " + TABLE_NAME + " where playerId = ? LIMIT 1"; 14 | 15 | static final String UPDATE_NICKNAME_QUERY = 16 | "UPDATE " + TABLE_NAME + " set nickname = ?, enabled = ?, date = ? where playerId = ?"; 17 | 18 | static final String SELECT_NICKNAME_BY_NAME_QUERY = 19 | "SELECT * from " + TABLE_NAME + " where LOWER(nickname) = LOWER(?)"; 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/freeze/FreezeConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.freeze; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import org.bukkit.configuration.Configuration; 5 | 6 | public class FreezeConfig extends FeatureConfigImpl { 7 | 8 | private static final String KEY = "freeze"; 9 | 10 | private boolean pgmIntegration; 11 | private int itemSlot; 12 | 13 | public FreezeConfig(Configuration config) { 14 | super(KEY, config); 15 | } 16 | 17 | public boolean isIntegrationEnabled() { 18 | return pgmIntegration; 19 | } 20 | 21 | public int getItemSlot() { 22 | return itemSlot; 23 | } 24 | 25 | @Override 26 | public void reload(Configuration config) { 27 | super.reload(config); 28 | this.pgmIntegration = config.getBoolean(getKey() + ".pgm-integration"); 29 | this.itemSlot = config.getInt(getKey() + ".item-slot"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/CenterUtils.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils; 2 | 3 | import static net.kyori.adventure.text.Component.text; 4 | 5 | import com.google.common.base.Strings; 6 | import net.kyori.adventure.text.Component; 7 | import tc.oc.pgm.util.LegacyFormatUtils; 8 | import tc.oc.pgm.util.text.TextTranslations; 9 | 10 | public class CenterUtils { 11 | 12 | public static Component centerComponent(Component component) { 13 | int textWidth = 14 | LegacyFormatUtils.pixelWidth(TextTranslations.translateLegacy(component.asComponent())); 15 | int spaceCount = 16 | Math.max( 17 | 0, 18 | ((LegacyFormatUtils.MAX_CHAT_WIDTH - textWidth) / 2 + 1) 19 | / (LegacyFormatUtils.SPACE_PIXEL_WIDTH + 1)); 20 | String line = Strings.repeat(" ", spaceCount); 21 | return text().append(text(line)).append(component).build(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/response/SingleChoiceResponseConverter.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls.response; 2 | 3 | import static tc.oc.pgm.util.text.TextException.exception; 4 | 5 | public class SingleChoiceResponseConverter { 6 | 7 | public static boolean convert(String input) { 8 | String cleanInput = input.trim().toLowerCase(); 9 | 10 | switch (cleanInput) { 11 | case "true": 12 | case "yes": 13 | case "y": 14 | case "affirmative": 15 | case "ok": 16 | case "okay": 17 | case "yeah": 18 | return true; 19 | case "false": 20 | case "no": 21 | case "n": 22 | case "negative": 23 | case "nope": 24 | case "not okay": 25 | return false; 26 | default: 27 | throw exception( 28 | "Invalid input: '" + input + "'! Please provide a valid 'yes' or 'no' response."); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/Channels.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network; 2 | 3 | /** Channels - Names of Channels used by NetworkUpdates * */ 4 | public class Channels { 5 | 6 | // PUNISHMENTS - Used to alert which a new punishment was issued for a player 7 | public static final String PUNISHMENTS = formatChannel("punishments"); 8 | 9 | // ASSISTANCE - Used to broadcast reports/assist requests to other servers 10 | public static final String ASSISTANCE = formatChannel("assistance"); 11 | 12 | // CHAT - Used to broadcast chat messages to other servers 13 | public static final String CHAT = formatChannel("chat"); 14 | 15 | // PUNISHMENT_UPDATE - Used to alert servers of unmuted or unbanned players 16 | public static final String PUNISHMENT_UPDATE = formatChannel("punishment_update"); 17 | 18 | private static final String formatChannel(String name) { 19 | return "community_" + name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/settings/PartyBooleanSetting.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party.settings; 2 | 3 | import org.bukkit.Material; 4 | 5 | public class PartyBooleanSetting extends PartySetting { 6 | 7 | private Material trueIcon; 8 | private Material falseIcon; 9 | 10 | private boolean value; 11 | 12 | public PartyBooleanSetting( 13 | String name, String description, boolean def, Material trueIcon, Material falseIcon) { 14 | super(name, description); 15 | this.value = def; 16 | this.trueIcon = trueIcon; 17 | this.falseIcon = falseIcon; 18 | } 19 | 20 | public boolean getValue() { 21 | return value; 22 | } 23 | 24 | public void setValue(boolean value) { 25 | this.value = value; 26 | } 27 | 28 | @Override 29 | public Material getIcon() { 30 | return getValue() ? trueIcon : falseIcon; 31 | } 32 | 33 | public void toggle() { 34 | setValue(!getValue()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/events/PlayerPunishmentEvent.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.events; 2 | 3 | import dev.pgm.community.moderation.punishments.Punishment; 4 | import dev.pgm.community.utils.CommandAudience; 5 | 6 | /** PlayerPunishmentEvent - Called when a punishment is issued to a player */ 7 | public class PlayerPunishmentEvent extends CommunityEvent { 8 | 9 | private final CommandAudience sender; 10 | private final Punishment punishment; 11 | private final boolean silent; 12 | 13 | public PlayerPunishmentEvent(CommandAudience audience, Punishment punishment, boolean silent) { 14 | this.sender = audience; 15 | this.punishment = punishment; 16 | this.silent = silent; 17 | } 18 | 19 | public CommandAudience getSender() { 20 | return sender; 21 | } 22 | 23 | public Punishment getPunishment() { 24 | return punishment; 25 | } 26 | 27 | public boolean isSilent() { 28 | return silent; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/mutations/options/MutationOption.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.mutations.options; 2 | 3 | import org.bukkit.Material; 4 | 5 | public abstract class MutationOption { 6 | 7 | private final String name; 8 | private final String description; 9 | private final Material iconMaterial; 10 | private final boolean prerequisite; 11 | 12 | public MutationOption( 13 | String name, String description, Material iconMaterial, boolean prerequisite) { 14 | this.name = name; 15 | this.description = description; 16 | this.iconMaterial = iconMaterial; 17 | this.prerequisite = prerequisite; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public String getDescription() { 25 | return description; 26 | } 27 | 28 | public Material getIconMaterial() { 29 | return iconMaterial; 30 | } 31 | 32 | public boolean isPrerequisite() { 33 | return prerequisite; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/Poll.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls; 2 | 3 | import dev.pgm.community.polls.ending.EndAction; 4 | import java.time.Duration; 5 | import java.time.Instant; 6 | import java.util.List; 7 | import java.util.UUID; 8 | import net.kyori.adventure.text.Component; 9 | import org.bukkit.entity.Player; 10 | 11 | public interface Poll { 12 | 13 | Component getQuestion(); 14 | 15 | UUID getCreator(); 16 | 17 | Instant getStartTime(); 18 | 19 | Instant getEndTime(); 20 | 21 | void setEndTime(Instant time); 22 | 23 | boolean isRunning(); 24 | 25 | List getEndAction(); 26 | 27 | boolean vote(Player player, String option); 28 | 29 | long getTotalVotes(); 30 | 31 | PollThreshold getRequiredThreshold(); 32 | 33 | Duration getTimeLeft(); 34 | 35 | boolean hasVoted(Player player); 36 | 37 | void tallyVotes(); 38 | 39 | void start(); 40 | 41 | Component getVoteButtons(boolean compact); 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/motd/MotdConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.motd; 2 | 3 | import dev.pgm.community.feature.config.FeatureConfigImpl; 4 | import dev.pgm.community.utils.MessageUtils; 5 | import java.util.List; 6 | import java.util.stream.Collectors; 7 | import net.kyori.adventure.text.Component; 8 | import org.bukkit.configuration.Configuration; 9 | 10 | public class MotdConfig extends FeatureConfigImpl { 11 | 12 | private static final String KEY = "motd"; 13 | 14 | private List lines; 15 | 16 | public MotdConfig(Configuration config) { 17 | super(KEY, config); 18 | } 19 | 20 | public List getLines() { 21 | return lines; 22 | } 23 | 24 | @Override 25 | public void reload(Configuration config) { 26 | super.reload(config); 27 | this.lines = config.getStringList(getKey() + ".lines").stream() 28 | .map(MessageUtils::parseComponentWithURL) 29 | .collect(Collectors.toList()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/requests/commands/supervotes/SuperVoteCommand.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.requests.commands.supervotes; 2 | 3 | import dev.pgm.community.Community; 4 | import dev.pgm.community.CommunityCommand; 5 | import dev.pgm.community.requests.feature.RequestFeature; 6 | import dev.pgm.community.utils.CommandAudience; 7 | import org.bukkit.entity.Player; 8 | import tc.oc.pgm.lib.org.incendo.cloud.annotations.Command; 9 | import tc.oc.pgm.lib.org.incendo.cloud.annotations.CommandDescription; 10 | 11 | public class SuperVoteCommand extends CommunityCommand { 12 | 13 | private final RequestFeature requests; 14 | 15 | public SuperVoteCommand() { 16 | this.requests = Community.get().getFeatures().getRequests(); 17 | } 18 | 19 | @Command("supervote") 20 | @CommandDescription("Activate a supervote for the active map vote") 21 | public void superVote(CommandAudience audience, Player sender) { 22 | requests.superVote(sender); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/subs/types/ChatSubscriber.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network.subs.types; 2 | 3 | import dev.pgm.community.chat.network.NetworkChatFeature; 4 | import dev.pgm.community.chat.network.NetworkChatMessage; 5 | import dev.pgm.community.network.Channels; 6 | import dev.pgm.community.network.subs.NetworkSubscriber; 7 | import java.util.logging.Logger; 8 | 9 | /** ChatSubscriber - Listens for {@link NetworkChatMessage} */ 10 | public class ChatSubscriber extends NetworkSubscriber { 11 | 12 | private NetworkChatFeature chat; 13 | 14 | public ChatSubscriber(NetworkChatFeature chat, String networkId, Logger logger) { 15 | super(Channels.CHAT, networkId, logger); 16 | this.chat = chat; 17 | } 18 | 19 | @Override 20 | public void onReceiveUpdate(String data) { 21 | NetworkChatMessage message = gson.fromJson(data, NetworkChatMessage.class); 22 | if (message != null) { 23 | chat.recieveUpdate(message); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/friends/services/FriendshipQuery.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.friends.services; 2 | 3 | public interface FriendshipQuery { 4 | 5 | static final String TABLE_NAME = "friendships"; 6 | static final String TABLE_FIELDS = 7 | "(id VARCHAR(36) PRIMARY KEY, " 8 | + "requester VARCHAR(36), " 9 | + "requested VARCHAR(36), " 10 | + "status VARCHAR(8), " 11 | + "requestDate LONG, " 12 | + "updateDate LONG)"; 13 | 14 | static final String INSERT_FRIENDSHIP_QUERY = 15 | "INSERT INTO " 16 | + TABLE_NAME 17 | + "(id, requester, requested, status, requestDate, updateDate) VALUES (?, ?, ?, ?, ?, ?)"; 18 | 19 | static final String SELECT_FRIENDSHIPS_QUERY = 20 | "SELECT * from " + TABLE_NAME + " where (requester = ? OR requested = ?)"; 21 | 22 | static final String UPDATE_FRIENDSHIP_QUERY = 23 | "UPDATE " + TABLE_NAME + " SET status = ?, updateDate = ? WHERE id = ? "; 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/response/MultiChoiceResponseConverter.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls.response; 2 | 3 | import static tc.oc.pgm.util.text.TextException.exception; 4 | 5 | import dev.pgm.community.polls.ending.EndAction; 6 | import java.util.List; 7 | 8 | public class MultiChoiceResponseConverter { 9 | 10 | public static int convert(String input, List options) { 11 | for (int i = 0; i < options.size(); i++) { 12 | EndAction option = options.get(i); 13 | if (input.equalsIgnoreCase(option.getValue())) { 14 | return i; 15 | } 16 | } 17 | 18 | try { 19 | int selectedOption = Integer.parseInt(input); 20 | if (selectedOption >= 0 && selectedOption < options.size()) { 21 | return selectedOption; 22 | } 23 | } catch (NumberFormatException ignored) { 24 | throw exception("'" + input + "' is not a valid option!"); 25 | } 26 | 27 | return -1; // No valid option was found! 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/requests/services/RequestQuery.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.requests.services; 2 | 3 | public interface RequestQuery { 4 | 5 | static final String TABLE_FIELDS = 6 | "(id VARCHAR(36) PRIMARY KEY, last_request_time LONG, last_request_map VARCHAR(255), last_sponsor_time LONG, last_sponsor_map VARCHAR(255), tokens INT, last_token_refresh LONG, super_votes INT, last_super_vote LONG)"; 7 | static final String TABLE_NAME = "requests"; 8 | 9 | static final String INSERT_REQUESTS_QUERY = 10 | "INSERT INTO " + TABLE_NAME + " VALUES (?,?,?,?,?,?,?,?,?)"; 11 | 12 | static final String UPDATE_REQUEST_QUERY = "UPDATE " 13 | + TABLE_NAME 14 | + " SET last_request_time = ?, last_request_map = ?, last_sponsor_time = ?, last_sponsor_map = ?, tokens = ?, last_token_refresh = ?, super_votes = ?, last_super_vote = ? WHERE id = ? "; 15 | 16 | static final String SELECT_REQUEST_QUERY = 17 | "SELECT * from " + TABLE_NAME + " WHERE id = ? LIMIT 1"; 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/mutations/types/mechanics/BlindMutation.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.mutations.types.mechanics; 2 | 3 | import com.google.common.collect.Sets; 4 | import dev.pgm.community.mutations.Mutation; 5 | import dev.pgm.community.mutations.MutationType; 6 | import dev.pgm.community.mutations.types.KitMutationBase; 7 | import java.util.Set; 8 | import org.bukkit.potion.PotionEffect; 9 | import org.bukkit.potion.PotionEffectType; 10 | import tc.oc.pgm.api.match.Match; 11 | import tc.oc.pgm.kits.PotionKit; 12 | 13 | public class BlindMutation extends KitMutationBase { 14 | 15 | public BlindMutation(Match match) { 16 | super(match, MutationType.BLIND, getBlindKit()); 17 | } 18 | 19 | @Override 20 | public boolean canEnable(Set existing) { 21 | return true; 22 | } 23 | 24 | private static PotionKit getBlindKit() { 25 | return new PotionKit( 26 | Sets.newHashSet(new PotionEffect(PotionEffectType.BLINDNESS, Integer.MAX_VALUE, 1))); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/utils/gson/types/DurationConverter.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.utils.gson.types; 2 | 3 | import com.google.gson.JsonDeserializationContext; 4 | import com.google.gson.JsonDeserializer; 5 | import com.google.gson.JsonElement; 6 | import com.google.gson.JsonParseException; 7 | import com.google.gson.JsonPrimitive; 8 | import com.google.gson.JsonSerializationContext; 9 | import com.google.gson.JsonSerializer; 10 | import java.lang.reflect.Type; 11 | import java.time.Duration; 12 | 13 | public class DurationConverter implements JsonSerializer, JsonDeserializer { 14 | 15 | @Override 16 | public JsonElement serialize(Duration src, Type typeOfSrc, JsonSerializationContext context) { 17 | return new JsonPrimitive(src.toString()); 18 | } 19 | 20 | @Override 21 | public Duration deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) 22 | throws JsonParseException { 23 | return Duration.parse(json.getAsString()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/feature/config/FeatureConfigImpl.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.feature.config; 2 | 3 | import org.bukkit.configuration.Configuration; 4 | 5 | /** An implementation of {@link FeatureConfig} * */ 6 | public abstract class FeatureConfigImpl implements FeatureConfig { 7 | 8 | private final String key; 9 | 10 | private boolean enabled; 11 | 12 | public FeatureConfigImpl(String key, Configuration config) { 13 | this.key = key; 14 | reload(config); 15 | } 16 | 17 | @Override 18 | public String getKey() { 19 | return key; 20 | } 21 | 22 | @Override 23 | public boolean isEnabled() { 24 | return enabled; 25 | } 26 | 27 | @Override 28 | public void setEnabled(boolean yes) { 29 | this.enabled = yes; 30 | } 31 | 32 | @Override 33 | public void reload(Configuration config) { 34 | this.enabled = config.getBoolean(getEnabledKey(key)); 35 | } 36 | 37 | protected String getEnabledKey(String key) { 38 | return key + ".enabled"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/network/subs/types/AssistanceSubscriber.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.network.subs.types; 2 | 3 | import dev.pgm.community.assistance.AssistanceRequest; 4 | import dev.pgm.community.assistance.feature.AssistanceFeature; 5 | import dev.pgm.community.network.Channels; 6 | import dev.pgm.community.network.subs.NetworkSubscriber; 7 | import java.util.logging.Logger; 8 | 9 | /** AssistanceSubscriber - Listens for {@link AssistanceRequest} */ 10 | public class AssistanceSubscriber extends NetworkSubscriber { 11 | 12 | private AssistanceFeature assist; 13 | 14 | public AssistanceSubscriber(AssistanceFeature assist, String networkId, Logger logger) { 15 | super(Channels.ASSISTANCE, networkId, logger); 16 | this.assist = assist; 17 | } 18 | 19 | @Override 20 | public void onReceiveUpdate(String data) { 21 | AssistanceRequest request = gson.fromJson(data, AssistanceRequest.class); 22 | if (request != null) { 23 | assist.recieveUpdate(request); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/sessions/VanishedSessionListener.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.sessions; 2 | 3 | import dev.pgm.community.sessions.feature.SessionFeature; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import tc.oc.pgm.api.player.event.PlayerVanishEvent; 8 | 9 | public class VanishedSessionListener implements Listener { 10 | 11 | private final SessionFeature sessions; 12 | 13 | public VanishedSessionListener(SessionFeature sessions) { 14 | this.sessions = sessions; 15 | } 16 | 17 | @EventHandler 18 | public void onVanish(PlayerVanishEvent event) { 19 | Player player = event.getPlayer().getBukkit(); 20 | if (sessions.isPlayerJoining(player)) return; 21 | 22 | sessions 23 | .getLatestSession(player.getUniqueId(), false) 24 | .thenAcceptAsync( 25 | session -> { 26 | sessions.endSession(session); 27 | sessions.startSession(player); 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/party/MapPartyType.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.party; 2 | 3 | import org.apache.commons.lang.WordUtils; 4 | import org.bukkit.Material; 5 | 6 | public enum MapPartyType { 7 | REGULAR(Material.IRON_INGOT, "Use an existing map pool"), 8 | CUSTOM(Material.GOLD_INGOT, "Select a custom list of maps"); 9 | 10 | private Material material; 11 | private String description; 12 | 13 | MapPartyType(Material material, String description) { 14 | this.material = material; 15 | this.description = description; 16 | } 17 | 18 | public String getName() { 19 | return WordUtils.capitalize(name().toLowerCase()); 20 | } 21 | 22 | public String getDescription() { 23 | return description; 24 | } 25 | 26 | public Material getMaterial() { 27 | return material; 28 | } 29 | 30 | public static MapPartyType parse(String name) { 31 | if (name.toLowerCase().equalsIgnoreCase("custom")) { 32 | return MapPartyType.CUSTOM; 33 | } 34 | return MapPartyType.REGULAR; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/PollConfig.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls; 2 | 3 | import static tc.oc.pgm.util.text.TextParser.parseDuration; 4 | 5 | import dev.pgm.community.feature.config.FeatureConfigImpl; 6 | import java.time.Duration; 7 | import org.bukkit.configuration.Configuration; 8 | 9 | public class PollConfig extends FeatureConfigImpl { 10 | 11 | private static final String KEY = "polls"; 12 | 13 | private Duration duration; 14 | private PollThreshold threshold; 15 | 16 | public PollConfig(Configuration config) { 17 | super(KEY, config); 18 | } 19 | 20 | public Duration getDuration() { 21 | return duration; 22 | } 23 | 24 | public PollThreshold getThreshold() { 25 | return threshold; 26 | } 27 | 28 | @Override 29 | public void reload(Configuration config) { 30 | super.reload(config); 31 | this.duration = parseDuration(config.getString(KEY + ".duration")); 32 | this.threshold = PollThreshold.valueOf(config.getString(KEY + ".threshold").toUpperCase()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/dev/pgm/community/polls/commands/PollVoteCommands.java: -------------------------------------------------------------------------------- 1 | package dev.pgm.community.polls.commands; 2 | 3 | import dev.pgm.community.Community; 4 | import dev.pgm.community.CommunityCommand; 5 | import dev.pgm.community.polls.feature.PollFeature; 6 | import dev.pgm.community.utils.CommandAudience; 7 | import org.bukkit.entity.Player; 8 | import tc.oc.pgm.lib.org.incendo.cloud.annotation.specifier.Greedy; 9 | import tc.oc.pgm.lib.org.incendo.cloud.annotations.Argument; 10 | import tc.oc.pgm.lib.org.incendo.cloud.annotations.Command; 11 | 12 | public class PollVoteCommands extends CommunityCommand { 13 | 14 | public static final String COMMAND = "pollvote"; 15 | 16 | private final PollFeature polls; 17 | 18 | public PollVoteCommands() { 19 | this.polls = Community.get().getFeatures().getPolls(); 20 | } 21 | 22 | @Command(COMMAND + "