commit 7f5efd6427366839aadb80c2b7aad446a6a1b77a Author: Matheus Date: Fri Jun 14 13:34:49 2024 -0400 upload diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..51b6c03 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,24 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Java CI with Maven + +on: + push: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + + - name: Build with Maven + run: mvn -B package --file pom.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a523339 --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +# Created by .ignore support plugin (hsz.mobi) +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +.idea +*.iml + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Kotlin template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* diff --git a/API/pom.xml b/API/pom.xml new file mode 100644 index 0000000..24dbf6c --- /dev/null +++ b/API/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + com.solexgames + Scandium + 1.0-SNAPSHOT + + API + + API + + + + com.solexgames + Bukkit + 1.0-SNAPSHOT + provided + + + diff --git a/API/src/main/java/com/solexgames/api/CoreAccess.java b/API/src/main/java/com/solexgames/api/CoreAccess.java new file mode 100644 index 0000000..413bf5e --- /dev/null +++ b/API/src/main/java/com/solexgames/api/CoreAccess.java @@ -0,0 +1,91 @@ +package com.solexgames.api; + +import com.solexgames.core.CorePlugin; +import com.solexgames.core.chat.IChatFormat; +import com.solexgames.core.manager.PlayerManager; +import com.solexgames.core.manager.ServerManager; +import com.solexgames.core.player.PotPlayer; +import com.solexgames.core.player.global.NetworkPlayer; +import com.solexgames.core.player.grant.Grant; +import com.solexgames.core.player.prefixes.Prefix; +import com.solexgames.core.player.punishment.Punishment; +import com.solexgames.core.util.Color; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @author GrowlyX + * @since 4/2/2021 + */ + +public class CoreAccess { + + private final CorePlugin plugin; + + public CoreAccess() { + this.plugin = CorePlugin.getInstance(); + } + + public ServerManager getServerManager() { + return this.plugin.getServerManager(); + } + + public PlayerManager getPlayerManager() { + return this.plugin.getPlayerManager(); + } + + public PotPlayer fetchProfile(Player player) { + return this.plugin.getPlayerManager().getPlayer(player); + } + + public int getExperience(Player player) { + return this.plugin.getPlayerManager().getPlayer(player).getExperience(); + } + + public List getPunishments(Player player) { + return this.plugin.getPlayerManager().getPlayer(player).getPunishments(); + } + + public List getPrefixes(Player player) { + return this.plugin.getPlayerManager().getPlayer(player).getAllPrefixes().stream().map(Prefix::getByName).filter(Objects::nonNull).collect(Collectors.toList()); + } + + public List getGrants(Player player) { + return this.plugin.getPlayerManager().getPlayer(player).getAllGrants(); + } + + public Prefix getPrefix(Player player) { + return this.plugin.getPlayerManager().getPlayer(player).getAppliedPrefix(); + } + + public String getRankPrefix(Player player) { + return Color.translate(this.plugin.getPlayerManager().getPlayer(player).getActiveGrant().getRank().getPrefix()); + } + + public String getRankSuffix(Player player) { + return Color.translate(this.plugin.getPlayerManager().getPlayer(player).getActiveGrant().getRank().getSuffix()); + } + + public boolean isRestricted(Player player) { + return this.plugin.getPlayerManager().getPlayer(player).isCurrentlyRestricted(); + } + + public NetworkPlayer fetchGlobalProfile(Player player) { + return this.plugin.getPlayerManager().getNetworkPlayer(player); + } + + public PotPlayer fetchProfile(String player) { + return this.plugin.getPlayerManager().getPlayer(player); + } + + public NetworkPlayer fetchGlobalProfile(String player) { + return this.plugin.getPlayerManager().getNetworkPlayer(player); + } + + public void registerNewChatFormat(IChatFormat chatFormat) { + this.getServerManager().setChatFormat(chatFormat); + } +} diff --git a/API/src/main/java/com/solexgames/api/example/ExampleAccess.java b/API/src/main/java/com/solexgames/api/example/ExampleAccess.java new file mode 100644 index 0000000..5f0a57e --- /dev/null +++ b/API/src/main/java/com/solexgames/api/example/ExampleAccess.java @@ -0,0 +1,32 @@ +package com.solexgames.api.example; + +import com.solexgames.api.CoreAccess; +import com.solexgames.core.player.global.NetworkPlayer; + +/** + * @author GrowlyX + * @since 4/2/2021 + *

+ * Example of how the {@link CoreAccess} is used. + */ + +public class ExampleAccess { + + /** + * Starts the ExampleAccess class. + * + * @param args Startup Arguments + */ + public static void main(String[] args) { + // Make sure to make a public variable for this to prevent memory leaks. + final CoreAccess coreAccess = new CoreAccess(); + final NetworkPlayer networkPlayer = coreAccess.fetchGlobalProfile("GrowlyX"); + + // Do whatever with the methods available in the CoreAccess Class. + if (networkPlayer != null) { + System.out.println(networkPlayer.getServerName()); + } else { + System.out.println("Growly's not online!"); + } + } +} diff --git a/API/target/maven-archiver/pom.properties b/API/target/maven-archiver/pom.properties new file mode 100644 index 0000000..ccf5efb --- /dev/null +++ b/API/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=API +groupId=com.solexgames +version=1.0-SNAPSHOT diff --git a/API/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/API/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..0d98557 --- /dev/null +++ b/API/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,2 @@ +com\solexgames\api\CoreAccess.class +com\solexgames\api\example\ExampleAccess.class diff --git a/API/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/API/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..b420915 --- /dev/null +++ b/API/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,2 @@ +C:\Users\lu\Downloads\scandium-core-plugin-master\scandium-core-plugin-master\API\src\main\java\com\solexgames\api\example\ExampleAccess.java +C:\Users\lu\Downloads\scandium-core-plugin-master\scandium-core-plugin-master\API\src\main\java\com\solexgames\api\CoreAccess.java diff --git a/Bukkit/.gitignore b/Bukkit/.gitignore new file mode 100644 index 0000000..27d5dde --- /dev/null +++ b/Bukkit/.gitignore @@ -0,0 +1,112 @@ +# User-specific stuff +.idea/ + +*.iml +*.ipr +*.iws + +# IntelliJ +out/ + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Package Files # +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +target/ + +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next + +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +# Common working directory +run/ diff --git a/Bukkit/docs/documentation.txt b/Bukkit/docs/documentation.txt new file mode 100644 index 0000000..1bb46cc --- /dev/null +++ b/Bukkit/docs/documentation.txt @@ -0,0 +1,86 @@ +Auth - scandium.2fa +AuthSetup - scandium.2fa +Force authentication for player - scandium.2fa.forced +StaffChat - scandium.channels.staff +AdminChat - scandium.channels.admin +DevChat - scandium.channels.dev +ManagerChat - scandium.channels.manager +HostChat - scandium.channels.host +HelpOP +Broadcast - scandium.command.broadcast +Kill - scandium.command.kill +Feed - scandium.command.feed +Heal - scandium.command.heal +TPPos - scandium.command.tppos +SocialSpy - scandium.command.socialspy +Sudo - scandium.command.sudo +SudoAll - scandium.command.sudoall +TPHere - scandium.command.tphere +GMC - scandium.command.gmc +GMS - scandium.command.gms +GMSP - scandium.command.gmsp +StaffAnnounce - scandium.command.staffannounce +TP - scandium.command.tp +Report +ShutDown - scandium.command.shutdown +Freeze - scandium.command.freeze +Ignore +CheckDisguise - scandium.command.checkdisguise +Rank [And Other Rank Commands such as rank create] - scandium.command.rank +Media +Discord +Import +Experience - scandium.experience.management +Alts - scandium.command.alts +Options - +History - scandium.command.history +Twitter +Website +Permissions - scandium.command.permissions +Find - scandium.command.find +ForceUpdate - scandium.command.forceupdate +Network - scandium.command.network +Store +Sync +Unsync +Reply +Grant - scandium.command.grant +cGrant +Prefix - scandium.command.prefix +Grants - scandium.command.grants +SetSlots - scandium.command.setslots +Clear - scandium.command.clear +Vanish - scandium.command.vanish +ModMode - scandium.command.modmode +ClearChat - scandium.command.clearchat +TPAll - scandium.command.tpall +Color - scandium.chat.colors +OwnerChat - scandium.channels.owner +MuteChat - scandium.command.mutechat +Fly - scandium.command.fly +User - scandium.command.user +Language +Give - scandium.command.give +Craft - scandium.command.crafting +Enchant - scandium.command.enchant +EnderChest - scandium.command.enchant.other [To view other peoples thing its scandium.command.crafting.other] +MaxItem - scandium.command.maxitem +SetSpawn - scandium.command.setspawn +Spawn - scandium.command.spawn +ToggleTips +ToggleStaffMessages - scandium.staff +ToggleAutoModMode - scandium.staff +ToggleAutoVanish - scandium.staff +ToggleFilteredMessages - scandium.staff +SlowChat - scandium.command.slowchat +Message +List - To show up as staff like in vanish or staff mode or something they need this node scandium.staff +Ping +Ban - scandium.command.ban +Blacklist - scandium.command.blacklist +Kick - scandium.command.kick +Mute - scandium.command.mute +Warn - scandium.command.warn +Unban - scandium.command.unban +Unblacklist - scandium.command.unblacklist +Unmute - scandium.command.unmute diff --git a/Bukkit/pom.xml b/Bukkit/pom.xml new file mode 100644 index 0000000..7382df0 --- /dev/null +++ b/Bukkit/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + + + com.solexgames + Scandium + 1.0-SNAPSHOT + + Bukkit + + + 1.8 + UTF-8 + + + + + Scandium + + + + + jitpack.io + https://jitpack.io + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + bintray-jcenter + https://jcenter.bintray.com + + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + + + papermc + https://papermc.io/repo/repository/maven-public/ + + + + + + + com.comphenix.protocol + ProtocolLib + 4.6.0 + system + ${basedir}/lib/ProtocolLib.jar + + + com.solexgames.lib + commons-bukkit + devbuild + system + ${basedir}/lib/commonslibs-bukkit.jar + + + + + org.projectlombok + lombok + LATEST + provided + + + org.apache.commons + commons-lang3 + 3.12.0 + + + io.papermc + paperlib + 1.0.6 + compile + + + + + + me.clip + placeholderapi + 2.10.9 + provided + + + + + com.lunarclient + bukkitapi + 1.0-SNAPSHOT + system + ${basedir}/lib/LunarClientAPI.jar + + + + + org.spigotmc + spigot-1_8-api + 1.8.8-R0.1-SNAPSHOT + system + ${basedir}/lib/Spigot_1_8.jar + + + org.spigotmc + spigot-19-api + 1.9-R0.1-SNAPSHOT + system + ${basedir}/lib/Spigot_1_9.jar + + + org.spigotmc + spigot-1_7-api + 1.7.10-R0.1-SNAPSHOT + system + ${basedir}/lib/Spigot_1_7.jar + + + org.spigotmc + spigot-1_12-api + 1.12.1-R0.1-SNAPSHOT + system + ${basedir}/lib/Spigot_1_12.jar + + + org.spigotmc + spigot-1_16-api + 1.16.5-R0.1-SNAPSHOT + system + ${basedir}/lib/Spigot_1_16.jar + + + diff --git a/Bukkit/src/main/java/com/solexgames/core/CorePlugin.java b/Bukkit/src/main/java/com/solexgames/core/CorePlugin.java new file mode 100644 index 0000000..b609e98 --- /dev/null +++ b/Bukkit/src/main/java/com/solexgames/core/CorePlugin.java @@ -0,0 +1,397 @@ +package com.solexgames.core; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.solexgames.core.adapter.DateTypeAdapter; +import com.solexgames.core.adapter.LocationTypeAdapter; +import com.solexgames.core.chat.IChatCheck; +import com.solexgames.core.command.impl.CoreCommand; +import com.solexgames.core.command.impl.other.WebPostCommand; +import com.solexgames.core.database.Database; +import com.solexgames.core.disguise.DisguiseCache; +import com.solexgames.core.enums.NetworkServerType; +import com.solexgames.core.enums.ServerType; +import com.solexgames.core.hooks.client.IClient; +import com.solexgames.core.hooks.client.impl.LunarClientImpl; +import com.solexgames.core.hooks.nms.INMS; +import com.solexgames.core.hooks.nms.impl.*; +import com.solexgames.core.hooks.protocol.AbstractPacketHandler; +import com.solexgames.core.hooks.protocol.impl.ProtocolPacketHandler; +import com.solexgames.core.manager.*; +import com.solexgames.core.menu.impl.SettingsMenu; +import com.solexgames.core.player.punishment.PunishmentStrings; +import com.solexgames.core.server.NetworkServer; +import com.solexgames.core.util.BungeeUtil; +import com.solexgames.core.util.builder.ItemBuilder; +import com.solexgames.core.util.external.Button; +import com.solexgames.lib.commons.redis.JedisBuilder; +import com.solexgames.lib.commons.redis.JedisManager; +import com.solexgames.lib.commons.redis.JedisSettings; +import com.solexgames.core.redis.JedisAdapter; +import com.solexgames.core.serializer.DataLibrary; +import com.solexgames.core.serializer.impl.ItemStackSerializer; +import com.solexgames.core.serializer.impl.LocationSerializer; +import com.solexgames.core.settings.ServerSettings; +import com.solexgames.core.settings.player.ISettings; +import com.solexgames.core.task.*; +import com.solexgames.core.util.BukkitUtil; +import com.solexgames.core.util.Color; +import com.solexgames.core.util.RedisUtil; +import com.solexgames.core.util.config.FileConfig; +import com.solexgames.core.uuid.UUIDCache; +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang.time.DurationFormatUtils; +import org.apache.http.client.HttpClient; +import org.apache.http.impl.client.DefaultHttpClient; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandMap; +import org.bukkit.conversations.ConversationFactory; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.SimplePluginManager; +import org.bukkit.plugin.java.JavaPlugin; + +import java.lang.reflect.Field; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * @author GrowlyX + * @since 3/1/2021 + */ + +@Getter +@Setter +public final class CorePlugin extends JavaPlugin { + + public static final SimpleDateFormat FORMAT = new SimpleDateFormat("MM/dd/yyyy HH:mma"); + public static final Random RANDOM = new Random(); + public static final Gson GSON = new GsonBuilder() + .registerTypeAdapter(Location.class, new LocationTypeAdapter()) + .registerTypeAdapter(Date.class, new DateTypeAdapter()) + .setPrettyPrinting() + .disableHtmlEscaping() + .create(); + + @Getter + private static CorePlugin instance; + + private ServerManager serverManager; + private ReportManager reportManager; + private PlayerManager playerManager; + private RankManager rankManager; + private ShutdownManager shutdownManager; + private DiscordManager discordManager; + private CryptoManager cryptoManager; + private FilterManager filterManager; + private PrefixManager prefixManager; + private PunishmentManager punishmentManager; + private NameTagManager nameTagManager; + private DisguiseManager disguiseManager; + + private JedisManager jedisManager; + private JedisSettings defaultJedisSettings; + + private UUIDCache uuidCache; + private DisguiseCache disguiseCache; + private ServerSettings serverSettings; + + private String serverName; + private HttpClient httpClient; + private Database coreDatabase; + private String pluginName; + + private FileConfig ranksConfig; + private FileConfig databaseConfig; + private FileConfig filterConfig; + + private DataLibrary library; + + private AbstractPacketHandler packetHandler; + private IClient clientHook; + private INMS NMS; + + private boolean debugging; + private boolean disallow; + + private final ConversationFactory conversationFactory = new ConversationFactory(this); + private final TPSUpdateTask tpsRunnable = new TPSUpdateTask(); + + private final List settingsList = new ArrayList<>(); + private final List chatCheckList = new ArrayList<>(); + + @Override + public void onEnable() { + instance = this; + + final long milli = System.currentTimeMillis(); + + this.httpClient = new DefaultHttpClient(); + + this.saveDefaultConfig(); + this.getConfig().options().copyDefaults(); + + this.pluginName = this.getConfig().getString("theming.command-prefix"); + + CorePlugin.FORMAT.setTimeZone(TimeZone.getTimeZone(this.getConfig().getString("settings.time-zone"))); + + this.ranksConfig = new FileConfig("ranks"); + this.databaseConfig = new FileConfig("database"); + this.filterConfig = new FileConfig("filtered"); + + this.serverSettings = new ServerSettings(); + + this.library = new DataLibrary(); + this.library.getDataManager().registerSerializer(new LocationSerializer()); + this.library.getDataManager().registerSerializer(new ItemStackSerializer()); + + this.serverName = this.getConfig().getString("server.id"); + + this.setupSettings(); + this.setupHooks(); + + this.debugging = false; + this.disallow = false; + + this.disableLoggers(); + + this.coreDatabase = new Database(); + + this.uuidCache = new UUIDCache(); + this.disguiseCache = new DisguiseCache(); + + this.punishmentManager = new PunishmentManager(); + this.cryptoManager = new CryptoManager(); + this.reportManager = new ReportManager(); + this.serverManager = new ServerManager(); + this.rankManager = new RankManager(); + this.prefixManager = new PrefixManager(); + this.playerManager = new PlayerManager(); + this.discordManager = new DiscordManager(); + this.filterManager = new FilterManager(); + this.shutdownManager = new ShutdownManager(); + this.nameTagManager = new NameTagManager(); + this.disguiseManager = new DisguiseManager(); + + this.defaultJedisSettings = new JedisSettings( + this.databaseConfig.getString("redis.host"), + this.databaseConfig.getInt("redis.port"), + this.databaseConfig.getBoolean("redis.authentication.enabled"), + this.databaseConfig.getString("redis.authentication.password") + ); + + this.jedisManager = new JedisBuilder() + .withChannel("scandium:bukkit") + .withSettings(this.defaultJedisSettings) + .withHandler(new JedisAdapter()) + .build(); + + this.setupExtra(); + this.logInformation(milli); + + new ServerLoadingTask(); + + this.getServer().getMessenger().registerOutgoingPluginChannel(this, "core:permissions"); + this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); + + new MenuAutoUpdateThread().start(); + ISettings is = new ISettings() { + @Override + public List