├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── CHANGELOG ├── CONTRIBUTING.md ├── LICENSE ├── Logger-BungeeCord ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── me │ │ └── prism3 │ │ └── loggerbungeecord │ │ ├── Logger.java │ │ ├── api │ │ ├── LiteBansUtil.java │ │ └── PartyAndFriendsUtil.java │ │ ├── commands │ │ ├── Discord.java │ │ └── Reload.java │ │ ├── database │ │ ├── external │ │ │ ├── External.java │ │ │ ├── ExternalData.java │ │ │ └── ExternalUpdater.java │ │ └── sqlite │ │ │ ├── SQLite.java │ │ │ └── SQLiteData.java │ │ ├── discord │ │ ├── Discord.java │ │ ├── DiscordFile.java │ │ └── DiscordStatus.java │ │ ├── events │ │ ├── OnChat.java │ │ ├── OnLeave.java │ │ ├── OnLogin.java │ │ ├── onServerSwitch.java │ │ ├── oncommands │ │ │ ├── OnCommand.java │ │ │ └── OnCommandWhitelist.java │ │ └── plugindependent │ │ │ └── litebans │ │ │ ├── OnLiteBanEvents.java │ │ │ └── OnPartyAndFriends.java │ │ ├── serverside │ │ ├── OnReload.java │ │ ├── RAM.java │ │ ├── Start.java │ │ └── Stop.java │ │ └── utils │ │ ├── ASCIIArt.java │ │ ├── ConfigManager.java │ │ ├── Data.java │ │ ├── FileHandler.java │ │ ├── Messages.java │ │ ├── Metrics.java │ │ ├── UpdateChecker.java │ │ └── litebanutil │ │ └── UsernameFetcher.java │ └── resources │ ├── bungee.yml │ ├── config - Bungee.yml │ ├── discord - Bungee.yml │ └── messages - Bungee.yml ├── Logger-Shaded └── pom.xml ├── Logger-Spigot ├── pom.xml └── src │ └── main │ ├── java │ └── me │ │ └── prism3 │ │ └── logger │ │ ├── Logger.java │ │ ├── api │ │ ├── AdvancedBanUtil.java │ │ ├── AuthMeUtil.java │ │ ├── EssentialsUtil.java │ │ ├── FloodGateUtil.java │ │ ├── GeyserUtil.java │ │ ├── LiteBansUtil.java │ │ ├── PlaceHolderAPIUtil.java │ │ ├── SuperiorSkyblockUtil.java │ │ ├── SuperiourSkyblockUtil.java │ │ └── VaultUtil.java │ │ ├── commands │ │ ├── CommandManager.java │ │ ├── SubCommand.java │ │ ├── getting │ │ │ ├── Chat.java │ │ │ ├── Pager.java │ │ │ └── PlayerMessageSearch.java │ │ └── subcommands │ │ │ ├── Discord.java │ │ │ ├── Dump.java │ │ │ ├── PlayerInventory.java │ │ │ ├── Reload.java │ │ │ └── ToggleSpy.java │ │ ├── database │ │ ├── external │ │ │ ├── External.java │ │ │ ├── ExternalData.java │ │ │ └── ExternalUpdater.java │ │ └── sqlite │ │ │ ├── global │ │ │ ├── SQLite.java │ │ │ └── SQLiteData.java │ │ │ └── registration │ │ │ ├── SQLiteDataRegistration.java │ │ │ └── SQLiteRegistration.java │ │ ├── discord │ │ ├── Discord.java │ │ ├── DiscordFile.java │ │ └── DiscordStatus.java │ │ ├── events │ │ ├── OnAnvil.java │ │ ├── OnBlockBreak.java │ │ ├── OnBlockPlace.java │ │ ├── OnBook.java │ │ ├── OnBucketEmpty.java │ │ ├── OnBucketFill.java │ │ ├── OnEnchant.java │ │ ├── OnEntityDeath.java │ │ ├── OnGameMode.java │ │ ├── OnItemDrop.java │ │ ├── OnItemPickup.java │ │ ├── OnPlayerChat.java │ │ ├── OnPlayerDeath.java │ │ ├── OnPlayerJoin.java │ │ ├── OnPlayerKick.java │ │ ├── OnPlayerLeave.java │ │ ├── OnPlayerLevel.java │ │ ├── OnPlayerRegister.java │ │ ├── OnPlayerTeleport.java │ │ ├── OnSignChange.java │ │ ├── OnSignPlacing.java │ │ ├── misc │ │ │ ├── OnPrimedTNT.java │ │ │ └── OnSpawnEgg.java │ │ ├── oncommands │ │ │ ├── OnCommand.java │ │ │ └── OnCommandWhitelist.java │ │ ├── oninventories │ │ │ ├── OnChestInteraction.java │ │ │ ├── OnCraft.java │ │ │ └── OnFurnace.java │ │ ├── onversioncompatibility │ │ │ └── OnWoodStripping.java │ │ ├── plugindependent │ │ │ ├── OnAFK.java │ │ │ ├── OnAdvancedBan.java │ │ │ ├── OnAuthMePassword.java │ │ │ ├── OnLiteBanEvents.java │ │ │ ├── OnSuperiorSkyblock.java │ │ │ └── OnVault.java │ │ └── spy │ │ │ ├── OnAnvilSpy.java │ │ │ ├── OnBookSpy.java │ │ │ ├── OnCommandSpy.java │ │ │ └── OnSignSpy.java │ │ ├── manager │ │ └── Messages.java │ │ ├── serverside │ │ ├── Console.java │ │ ├── OnCommandBlock.java │ │ ├── PortalCreation.java │ │ ├── RAM.java │ │ ├── RCON.java │ │ ├── Start.java │ │ ├── Stop.java │ │ └── TPS.java │ │ └── utils │ │ ├── ASCIIArt.java │ │ ├── BedrockChecker.java │ │ ├── Data.java │ │ ├── FileHandler.java │ │ ├── FileUpdater.java │ │ ├── Log.java │ │ ├── Metrics.java │ │ ├── Pastebin.java │ │ ├── enums │ │ ├── FriendlyEnchants.java │ │ ├── Languages.java │ │ ├── NmsVersions.java │ │ └── ViaProtocolVersions.java │ │ ├── litebansutil │ │ └── UsernameFetcher.java │ │ └── playerdeathutils │ │ ├── InventoryToBase64.java │ │ └── PlayerFolder.java │ └── resources │ ├── config.yml │ ├── discord.yml │ ├── messages │ ├── ar.yml │ ├── da.yml │ ├── de.yml │ ├── en_en.yml │ ├── eu.yml │ ├── fr_fr.yml │ ├── ja.yml │ ├── nl.yml │ ├── ru.yml │ ├── tr.yml │ ├── zh_cht.yml │ └── zh_cn.yml │ └── plugin.yml ├── Logger-Velocity ├── dependency-reduced-pom.xml ├── pom.xml └── src │ └── main │ ├── java │ └── me │ │ └── prism3 │ │ └── loggervelocity │ │ ├── Logger.java │ │ ├── api │ │ └── LiteBansUtil.java │ │ ├── commands │ │ ├── DiscordCMD.java │ │ └── Reload.java │ │ ├── database │ │ ├── external │ │ │ ├── External.java │ │ │ ├── ExternalData.java │ │ │ └── ExternalUpdater.java │ │ └── sqlite │ │ │ ├── SQLite.java │ │ │ └── SQLiteData.java │ │ ├── discord │ │ ├── Discord.java │ │ ├── DiscordFile.java │ │ └── DiscordStatus.java │ │ ├── events │ │ ├── OnChat.java │ │ ├── OnLeave.java │ │ ├── OnLogin.java │ │ ├── oncommands │ │ │ ├── OnCommand.java │ │ │ └── OnCommandWhitelist.java │ │ └── plugindependent │ │ │ └── litebans │ │ │ └── OnLiteBanEvents.java │ │ ├── serverside │ │ ├── Console.java │ │ ├── RAM.java │ │ ├── Start.java │ │ └── Stop.java │ │ └── utils │ │ ├── ConfigManager.java │ │ ├── Data.java │ │ ├── FileHandler.java │ │ ├── Messages.java │ │ ├── config │ │ ├── Configuration.java │ │ ├── ConfigurationProvider.java │ │ ├── StringUtils.java │ │ └── YamlConfiguration.java │ │ └── litebansutil │ │ └── UsernameFetcher.java │ └── resources │ ├── config - Velocity.yml │ ├── discord - Velocity.yml │ └── messages - Velocity.yml ├── README.md └── pom.xml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://paypal.me/carpour 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Server & Version (please complete the following information):** 27 | - Version [e.g. 1.6] 28 | - Server Type [e.g Spigot / Proxy] 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this plugin 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | /Logger-Spigot/.env 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### 💬 Looking for support? 2 | 3 | Details about support for the project can be found [here, on the Wiki Homepage](https://prism3.gitbook.io/logger/). 4 | 5 | ### 🐛 Reporting bugs? 6 | 7 | Before reporting a bug or issue, please make sure that the issue is actually being caused by or related to Logger. 8 | 9 | Bugs or issues should be reported using the [GitHub Issues tab](https://github.com/ExceptedPrism3/Logger/issues) or via [Discord Support Server](https://discord.gg/MfR5mcpVfX). 10 | 11 | ### 📝 Want to contribute code? 12 | #### Pull Requests 13 | If you make any changes or improvements to the plugin which you think would be beneficial to others, please consider making a pull request to merge your changes back into the upstream project. (especially if your changes are bug fixes!) 14 | 15 | If you're considering submitting a substantial pull request, please open an issue, so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an impact on the maintainability of the project, and require more consideration. -------------------------------------------------------------------------------- /Logger-BungeeCord/.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | 11 | # Compiled class file 12 | *.class 13 | 14 | # Log file 15 | *.log 16 | 17 | # BlueJ files 18 | *.ctxt 19 | 20 | # Package Files # 21 | *.jar 22 | *.war 23 | *.nar 24 | *.ear 25 | *.zip 26 | *.tar.gz 27 | *.rar 28 | 29 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 30 | hs_err_pid* 31 | 32 | *~ 33 | 34 | # temporary files which can be created if a process still has a handle open of a deleted file 35 | .fuse_hidden* 36 | 37 | # KDE directory preferences 38 | .directory 39 | 40 | # Linux trash folder which might appear on any partition or disk 41 | .Trash-* 42 | 43 | # .nfs files are created when an open file is removed but is still being accessed 44 | .nfs* 45 | 46 | # General 47 | .DS_Store 48 | .AppleDouble 49 | .LSOverride 50 | 51 | # Icon must end with two \r 52 | Icon 53 | 54 | # Thumbnails 55 | ._* 56 | 57 | # Files that might appear in the root of a volume 58 | .DocumentRevisions-V100 59 | .fseventsd 60 | .Spotlight-V100 61 | .TemporaryItems 62 | .Trashes 63 | .VolumeIcon.icns 64 | .com.apple.timemachine.donotpresent 65 | 66 | # Directories potentially created on remote AFP share 67 | .AppleDB 68 | .AppleDesktop 69 | Network Trash Folder 70 | Temporary Items 71 | .apdisk 72 | 73 | # Windows thumbnail cache files 74 | Thumbs.db 75 | Thumbs.db:encryptable 76 | ehthumbs.db 77 | ehthumbs_vista.db 78 | 79 | # Dump file 80 | *.stackdump 81 | 82 | # Folder config file 83 | [Dd]esktop.ini 84 | 85 | # Recycle Bin used on file shares 86 | $RECYCLE.BIN/ 87 | 88 | # Windows Installer files 89 | *.cab 90 | *.msi 91 | *.msix 92 | *.msm 93 | *.msp 94 | 95 | # Windows shortcuts 96 | *.lnk 97 | 98 | target/ 99 | 100 | pom.xml.tag 101 | pom.xml.releaseBackup 102 | pom.xml.versionsBackup 103 | pom.xml.next 104 | 105 | release.properties 106 | dependency-reduced-pom.xml 107 | buildNumber.properties 108 | .mvn/timing.properties 109 | .mvn/wrapper/maven-wrapper.jar 110 | .flattened-pom.xml 111 | 112 | # Common working directory 113 | run/ 114 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/api/LiteBansUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.api; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import net.md_5.bungee.api.plugin.Plugin; 5 | 6 | public class LiteBansUtil { 7 | 8 | private LiteBansUtil() {} 9 | 10 | public static Plugin getLiteBansAPI() { 11 | 12 | return Logger.getInstance().getProxy().getPluginManager().getPlugin("LiteBans"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/api/PartyAndFriendsUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.api; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import net.md_5.bungee.api.plugin.Plugin; 5 | 6 | public class PartyAndFriendsUtil { 7 | 8 | private PartyAndFriendsUtil() {} 9 | 10 | public static Plugin getPartyAndFriendsAPI() { 11 | 12 | return Logger.getInstance().getProxy().getPluginManager().getPlugin("PartyAndFriends"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/commands/Discord.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.commands; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import me.prism3.loggerbungeecord.utils.Data; 5 | import net.md_5.bungee.api.ChatColor; 6 | import net.md_5.bungee.api.CommandSender; 7 | import net.md_5.bungee.api.chat.TextComponent; 8 | import net.md_5.bungee.api.plugin.Command; 9 | 10 | import static me.prism3.loggerbungeecord.utils.Data.discordSupportServer; 11 | import static me.prism3.loggerbungeecord.utils.Data.pluginVersion; 12 | 13 | public class Discord extends Command { 14 | 15 | public Discord() { super("loggerb"); } 16 | 17 | @Override 18 | public void execute(CommandSender sender, String[] args) { 19 | 20 | final Logger main = Logger.getInstance(); 21 | 22 | if (sender.hasPermission(Data.loggerStaff) || sender.hasPermission(Data.loggerReload)) { 23 | 24 | if (args.length == 0) { 25 | 26 | sender.sendMessage(new TextComponent(ChatColor.translateAlternateColorCodes('&', "Running Logger &b&l" + Data.pluginVersion))); 27 | 28 | } else if (args.length == 1 && args[0].equalsIgnoreCase("discord")) { 29 | 30 | sender.sendMessage(new TextComponent(ChatColor.translateAlternateColorCodes('&', pluginVersion + discordSupportServer))); 31 | 32 | } else { 33 | 34 | sender.sendMessage(new TextComponent(ChatColor.translateAlternateColorCodes('&', main.getMessages().getString("General.Invalid-Syntax").replace("%prefix%", pluginVersion)))); 35 | 36 | } 37 | } else { 38 | 39 | sender.sendMessage(new TextComponent(ChatColor.translateAlternateColorCodes('&', main.getMessages().getString("General.No-Permission").replace("%prefix%", pluginVersion)))); 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/commands/Reload.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.commands; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import me.prism3.loggerbungeecord.utils.Data; 5 | import net.md_5.bungee.api.ChatColor; 6 | import net.md_5.bungee.api.CommandSender; 7 | import net.md_5.bungee.api.chat.TextComponent; 8 | import net.md_5.bungee.api.plugin.Command; 9 | 10 | import static me.prism3.loggerbungeecord.utils.Data.pluginVersion; 11 | 12 | public class Reload extends Command { 13 | 14 | public Reload() { super("loggerb"); } 15 | 16 | @Override 17 | public void execute(CommandSender sender, String[] args) { 18 | 19 | final Logger main = Logger.getInstance(); 20 | 21 | if (sender.hasPermission(Data.loggerStaff) || sender.hasPermission(Data.loggerReload)) { 22 | 23 | if (args.length == 0) { 24 | 25 | sender.sendMessage(new TextComponent(ChatColor.translateAlternateColorCodes('&', "Running Logger &b&l" + Data.pluginVersion))); 26 | 27 | } else if (args.length == 1 && args[0].equalsIgnoreCase("reload")) { 28 | 29 | main.getConfig().init(); 30 | main.getMessages().init(); 31 | main.initializer(new Data()); 32 | sender.sendMessage(new TextComponent(ChatColor.translateAlternateColorCodes('&', main.getMessages().getString("General.Reload").replace("%prefix%", pluginVersion)))); 33 | 34 | } else { 35 | 36 | sender.sendMessage(new TextComponent(ChatColor.translateAlternateColorCodes('&', main.getMessages().getString("General.Invalid-Syntax").replace("%prefix%", pluginVersion)))); 37 | 38 | } 39 | } else { 40 | 41 | sender.sendMessage(new TextComponent(ChatColor.translateAlternateColorCodes('&', main.getMessages().getString("General.No-Permission").replace("%prefix%", pluginVersion)))); 42 | 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/database/external/External.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.database.external; 2 | 3 | import com.zaxxer.hikari.HikariDataSource; 4 | import me.prism3.loggerbungeecord.Logger; 5 | import me.prism3.loggerbungeecord.utils.Data; 6 | 7 | public class External { 8 | 9 | private final Logger main = Logger.getInstance(); 10 | 11 | private String jdbc; 12 | private static final String DATATYPE = Data.dbType.toLowerCase(); 13 | private static final String HOST = Data.dbHost; 14 | private static final int PORT = Data.dbPort; 15 | private static final String USERNAME = Data.dbUserName; 16 | private static final String PASSWORD = Data.dbPassword; 17 | private static final String DATABASE = Data.dbName; 18 | private HikariDataSource hikari; 19 | 20 | public boolean isConnected() { 21 | return this.hikari != null; 22 | } 23 | 24 | public void connect() { 25 | 26 | String jdbcDriver; 27 | final String mySQL = "MySQL"; 28 | final String mySQLDriver = "com.mysql.cj.jdbc.Driver"; 29 | final String mariaDB = "mariadb"; 30 | final String mariaDBDriver = "org.mariadb.jdbc.Driver"; 31 | 32 | switch (DATATYPE) { 33 | 34 | case "mysql": 35 | this.jdbc = mySQL; 36 | jdbcDriver = mySQLDriver; 37 | break; 38 | 39 | case "mariadb": 40 | this.jdbc = mariaDB; 41 | jdbcDriver = mariaDBDriver; 42 | break; 43 | 44 | default: 45 | this.main.getLogger().severe("Unknown Database Type. Available ones are: MySQL and MariaDB."); 46 | return; 47 | 48 | } 49 | 50 | if (!isConnected()) { 51 | 52 | hikari = new HikariDataSource(); 53 | hikari.setDriverClassName(jdbcDriver); 54 | hikari.setJdbcUrl(this.getJdbcUrl()); 55 | hikari.addDataSourceProperty("user", USERNAME); 56 | hikari.addDataSourceProperty("password", PASSWORD); 57 | this.main.getLogger().info(this.jdbc + " Connection has been established!"); 58 | 59 | } 60 | } 61 | 62 | public void disconnect() { 63 | 64 | if (isConnected()) { 65 | 66 | this.hikari.close(); 67 | this.main.getLogger().info(this.jdbc + " Connection has been closed!"); 68 | 69 | } 70 | } 71 | 72 | private String getJdbcUrl() { 73 | return "jdbc:" + this.jdbc + "://" + External.HOST + ":" + External.PORT + "/" + External.DATABASE 74 | + "?AllowPublicKeyRetrieval=true?useSSL=false&jdbcCompliantTruncation=false"; 75 | 76 | } 77 | 78 | public HikariDataSource getHikari() { 79 | return this.hikari; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/database/external/ExternalUpdater.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.database.external; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import me.prism3.loggerbungeecord.utils.Data; 5 | 6 | import java.sql.Connection; 7 | import java.sql.DatabaseMetaData; 8 | import java.sql.PreparedStatement; 9 | import java.sql.ResultSet; 10 | import java.util.List; 11 | 12 | public class ExternalUpdater { 13 | 14 | private ExternalUpdater() {} 15 | 16 | public static void updater() { 17 | final Logger main = Logger.getInstance(); 18 | 19 | int i = 0; 20 | boolean keys = false; 21 | boolean playerName = false; 22 | 23 | if (Data.isExternal && main.getExternal().isConnected()) { 24 | 25 | final List index = ExternalData.getTablesNames(); 26 | 27 | // Primary Key removal Method 28 | try { 29 | 30 | for (String ignored : index) { 31 | 32 | final Connection connection = main.getExternal().getHikari().getConnection(); 33 | final DatabaseMetaData databaseMetaData = connection.getMetaData(); 34 | 35 | final ResultSet resultSet = databaseMetaData.getPrimaryKeys(null, null, index.get(i)); 36 | 37 | while (resultSet.next()) { 38 | 39 | final String primaryKeys = resultSet.getString(4); 40 | 41 | if (primaryKeys.contains("Date")) { 42 | 43 | final PreparedStatement ps1 = connection.prepareStatement("ALTER TABLE " + index.get(i) + " DROP PRIMARY KEY"); 44 | ps1.executeUpdate(); 45 | ps1.close(); 46 | 47 | keys = true; 48 | } 49 | } 50 | 51 | // Playername Renaming method 52 | 53 | final PreparedStatement desc = connection.prepareStatement("DESC " + index.get(i)); 54 | final ResultSet query = desc.executeQuery(); 55 | 56 | while (query.next()) { 57 | 58 | final String field = query.getString("Field"); 59 | 60 | if (field.contains("Playername")) { 61 | 62 | final PreparedStatement pS2 = connection.prepareStatement("ALTER TABLE " + index.get(i) + " CHANGE Playername Player_Name Varchar(30)"); 63 | pS2.executeUpdate(); 64 | pS2.close(); 65 | 66 | playerName = true; 67 | } 68 | } 69 | i++; 70 | } 71 | } catch (Exception e) { 72 | 73 | main.getLogger().severe("Unable to update the tables. If the issue persists contact the Author!"); 74 | e.printStackTrace(); 75 | 76 | } 77 | } 78 | if (keys && playerName) main.getLogger().info("All Tables have been Updated!"); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/database/sqlite/SQLite.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.database.sqlite; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | 5 | import java.io.File; 6 | import java.sql.Connection; 7 | import java.sql.DriverManager; 8 | import java.sql.SQLException; 9 | 10 | public class SQLite { 11 | 12 | private final Logger main = Logger.getInstance(); 13 | 14 | private Connection connection; 15 | 16 | private final File databaseFile = new File(this.main.getDataFolder(), "LoggerData - Bungee.db"); 17 | 18 | public boolean isConnected() { 19 | return (this.connection != null); 20 | } 21 | 22 | public void connect() { 23 | 24 | if (!isConnected()) { 25 | 26 | try { 27 | 28 | Class.forName("org.sqlite.JDBC"); 29 | this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.databaseFile.getAbsolutePath()); 30 | this.main.getLogger().info("SQLite Connection has been established!"); 31 | 32 | } catch (ClassNotFoundException | SQLException e) { 33 | 34 | this.main.getLogger().severe("Couldn't load SQLite Database, if the issue persists contact the Authors!"); 35 | e.printStackTrace(); 36 | 37 | } 38 | } 39 | } 40 | 41 | public void disconnect() { 42 | 43 | if (isConnected()) { 44 | 45 | try { 46 | 47 | this.connection.close(); 48 | this.main.getLogger().info("SQLite Database has been closed!"); 49 | 50 | } catch (SQLException e) { 51 | 52 | this.main.getLogger().severe("SQLite Database couldn't be closed safely, if the issue persists contact the Authors!"); 53 | e.printStackTrace(); 54 | 55 | } 56 | } 57 | } 58 | public Connection getConnection() { return this.connection; } 59 | } -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/discord/DiscordFile.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.discord; 2 | 3 | import com.google.common.io.ByteStreams; 4 | import me.prism3.loggerbungeecord.Logger; 5 | import net.md_5.bungee.api.ChatColor; 6 | import net.md_5.bungee.config.Configuration; 7 | import net.md_5.bungee.config.ConfigurationProvider; 8 | import net.md_5.bungee.config.YamlConfiguration; 9 | 10 | import java.io.*; 11 | 12 | public class DiscordFile { 13 | 14 | private Configuration discord = null; 15 | 16 | public void init() { 17 | 18 | this.saveDefaultConfig(); 19 | 20 | try { 21 | 22 | this.discord = ConfigurationProvider.getProvider(YamlConfiguration.class).load(getFile()); 23 | 24 | } catch (IOException e) { e.printStackTrace(); } 25 | } 26 | 27 | public boolean getBoolean(String key) { 28 | return this.discord.getBoolean(key); 29 | } 30 | 31 | public String getString(String key) { 32 | 33 | String str = this.discord.getString(key); 34 | 35 | str = ChatColor.translateAlternateColorCodes('&', str); 36 | 37 | return str; 38 | } 39 | 40 | public File getFile() { 41 | return new File(Logger.getInstance().getDataFolder(), "discord - Bungee.yml"); 42 | } 43 | 44 | public Configuration get() { return this.discord; } 45 | 46 | private void saveDefaultConfig() { 47 | 48 | if (!Logger.getInstance().getDataFolder().exists()) Logger.getInstance().getDataFolder().mkdir(); 49 | 50 | final File file = getFile(); 51 | 52 | if (!file.exists()) { 53 | 54 | try { 55 | 56 | file.createNewFile(); 57 | 58 | try (InputStream is = Logger.getInstance().getResourceAsStream("discord - Bungee.yml")) { 59 | 60 | OutputStream os = new FileOutputStream(file); 61 | ByteStreams.copy(is, os); 62 | os.close(); 63 | 64 | } 65 | } catch (IOException e) { e.printStackTrace(); } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/discord/DiscordStatus.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.discord; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import net.dv8tion.jda.api.JDA; 5 | import net.dv8tion.jda.api.entities.Activity; 6 | 7 | import java.util.Collections; 8 | import java.util.List; 9 | import java.util.concurrent.Executors; 10 | import java.util.concurrent.ScheduledExecutorService; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | public class DiscordStatus { 14 | 15 | private final Logger main = Logger.getInstance(); 16 | private final JDA jda = new Discord().getJda(); 17 | 18 | private int currentIndex = 0; 19 | private final List> activities = (List>) main.getDiscordFile().get().get("ActivityCycling.Activities"); 20 | 21 | private static final ScheduledExecutorService threadPool = Executors.newSingleThreadScheduledExecutor(); 22 | 23 | public DiscordStatus() { 24 | 25 | try { 26 | 27 | assert this.activities != null; 28 | this.activities.forEach((list -> Activity.ActivityType.valueOf(list. 29 | get(0).replace("playing", "streaming").toUpperCase()))); 30 | 31 | } catch (Exception e) { 32 | 33 | Logger.getInstance().getLogger().severe("Discord Status Activity is invalid. It has been disabled."); 34 | return; 35 | 36 | } 37 | 38 | if (main.getDiscordFile().get().getBoolean("ActivityCycling.Random")) { 39 | 40 | Collections.shuffle(this.activities); 41 | 42 | } 43 | 44 | threadPool.scheduleWithFixedDelay(() -> { 45 | 46 | this.jda.getPresence().setActivity(Activity.of(Activity.ActivityType.valueOf( 47 | this.activities.get(this.currentIndex).get(0).replace("playing", "streaming") 48 | .toUpperCase()), this.activities.get(this.currentIndex).get(1))); 49 | 50 | this.currentIndex = (this.currentIndex + 1) % this.activities.size(); 51 | 52 | }, 0, main.getDiscordFile().get().getInt("ActivityCycling.Time"), TimeUnit.SECONDS); 53 | } 54 | 55 | public static ScheduledExecutorService getThreadPool() { return threadPool; } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/events/onServerSwitch.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.events; 2 | 3 | import me.prism3.loggerbungeecord.utils.Data; 4 | import net.md_5.bungee.api.connection.ProxiedPlayer; 5 | import net.md_5.bungee.api.connection.Server; 6 | import net.md_5.bungee.api.event.ServerSwitchEvent; 7 | import net.md_5.bungee.api.plugin.Listener; 8 | import net.md_5.bungee.event.EventHandler; 9 | 10 | import java.time.ZonedDateTime; 11 | import java.util.Objects; 12 | import java.util.Timer; 13 | import java.util.TimerTask; 14 | 15 | public class onServerSwitch implements Listener { 16 | /* 17 | 18 | @EventHandler 19 | public void onServerSwitch(ServerSwitchEvent event) { 20 | Player player = event.getPlayer(); 21 | 22 | // If the player just joined, and DIDN'T switched from server. 23 | if (event.getFrom() == null) { 24 | return; 25 | } 26 | 27 | // We need to use a timer to get the new server, otherwise it will return the previous server! 28 | Timer timer = new Timer(); 29 | timer.schedule(new TimerTask() { 30 | @Override 31 | public void run() { 32 | Server from = event.getPlayer().getServer().getInfo().getName(); 33 | Server destination = event.getPlayer().getServer().getInfo().getName(); 34 | 35 | // I only did discord for now 36 | 37 | // Discord Integration 38 | if (!player.hasPermission(Data.loggerExemptDiscord)) { 39 | 40 | if (Data.isStaffEnabled && player.hasPermission(Data.loggerStaffLog)) { 41 | 42 | if (!this.main.getMessages().getString("Discord.Player-ServerSwitch-Staff").isEmpty()) { 43 | 44 | this.main.getDiscord().staffChat(player, Objects.requireNonNull(this.main.getMessages().getString("Discord.Player-ServerSwitch-Staff")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%from%", from).replace("%destination%", destination), false); 45 | 46 | } else { 47 | } 48 | 49 | if (!this.main.getMessages().getString("Discord.Player-ServerSwitch").isEmpty()) { 50 | 51 | this.main.getDiscord().playerChat(player, Objects.requireNonNull(this.main.getMessages().getString("Discord.Player-ServerSwitch")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%from%", from).replace("%destination%", destination), false); 52 | } 53 | } 54 | } 55 | 56 | } 57 | }, 0, 500); // 0,5s 58 | } 59 | */ 60 | } 61 | 62 | 63 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/events/plugindependent/litebans/OnPartyAndFriends.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.events.plugindependent.litebans; 2 | 3 | import de.simonsator.partyandfriends.api.events.message.FriendMessageEvent; 4 | import net.md_5.bungee.api.connection.ProxiedPlayer; 5 | import net.md_5.bungee.api.plugin.Listener; 6 | import net.md_5.bungee.event.EventHandler; 7 | 8 | public class OnPartyAndFriends implements Listener { 9 | 10 | @EventHandler 11 | public void onMessage(final FriendMessageEvent event) { 12 | 13 | final ProxiedPlayer sender = event.getSender().getPlayer(); 14 | final ProxiedPlayer receiver = (ProxiedPlayer) event.getReceiver(); 15 | final String message = event.getMessage(); 16 | 17 | System.out.println(sender + " " + receiver + " " + message); 18 | 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/serverside/RAM.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.serverside; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import me.prism3.loggerbungeecord.database.external.ExternalData; 5 | import me.prism3.loggerbungeecord.database.sqlite.SQLiteData; 6 | import me.prism3.loggerbungeecord.utils.FileHandler; 7 | 8 | import java.io.BufferedWriter; 9 | import java.io.FileWriter; 10 | import java.io.IOException; 11 | import java.time.ZonedDateTime; 12 | import java.util.Objects; 13 | 14 | import static me.prism3.loggerbungeecord.utils.Data.*; 15 | 16 | public class RAM implements Runnable { 17 | 18 | private final Logger main = Logger.getInstance(); 19 | 20 | public void run() { 21 | 22 | if (this.main.getConfig().getBoolean("Log-Server.RAM")) { 23 | 24 | if (ramPercent <= 0 || ramPercent >= 100) return; 25 | 26 | long maxMemory = Runtime.getRuntime().maxMemory() / 1048576L; 27 | long freeMemory = Runtime.getRuntime().freeMemory() / 1048576L; 28 | long usedMemory = maxMemory - freeMemory; 29 | double percentUsed = usedMemory * 100.0D / maxMemory; 30 | 31 | if (ramPercent <= percentUsed) { 32 | 33 | // Log To Files Handling 34 | if (isLogToFiles) { 35 | 36 | try { 37 | 38 | final BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getRamLogFile(), true)); 39 | out.write(Objects.requireNonNull(this.main.getMessages().getString("Files.Server-Side.RAM")).replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())).replace("%max%", String.valueOf(maxMemory)).replace("%used%", String.valueOf(usedMemory)).replace("%free%", String.valueOf(freeMemory)) + "\n"); 40 | out.close(); 41 | 42 | } catch (IOException e) { 43 | 44 | Logger.getInstance().getLogger().severe("An error occurred while logging into the appropriate file."); 45 | e.printStackTrace(); 46 | 47 | } 48 | } 49 | 50 | // Discord 51 | if (!this.main.getMessages().getString("Discord.Server-Side.RAM").isEmpty()) { 52 | 53 | this.main.getDiscord().ram(Objects.requireNonNull(this.main.getMessages().getString("Discord.Server-Side.RAM")).replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())).replace("%max%", String.valueOf(maxMemory)).replace("%used%", String.valueOf(usedMemory)).replace("%free%", String.valueOf(freeMemory)), false); 54 | 55 | } 56 | 57 | // External 58 | if (isExternal && this.main.getExternal().isConnected()) { 59 | 60 | try { 61 | 62 | ExternalData.ram(serverName, maxMemory, usedMemory, freeMemory); 63 | 64 | } catch (Exception e) { e.printStackTrace(); } 65 | } 66 | 67 | // SQLite 68 | if (isSqlite && this.main.getSqLite().isConnected()) { 69 | 70 | try { 71 | 72 | SQLiteData.insertRAM(serverName, maxMemory, usedMemory, freeMemory); 73 | 74 | } catch (Exception e) { e.printStackTrace(); } 75 | } 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/serverside/Start.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.serverside; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import me.prism3.loggerbungeecord.database.external.ExternalData; 5 | import me.prism3.loggerbungeecord.database.sqlite.SQLiteData; 6 | import me.prism3.loggerbungeecord.utils.Data; 7 | import me.prism3.loggerbungeecord.utils.FileHandler; 8 | 9 | import java.io.BufferedWriter; 10 | import java.io.FileWriter; 11 | import java.io.IOException; 12 | import java.time.ZonedDateTime; 13 | 14 | public class Start { 15 | 16 | private final Logger main = Logger.getInstance(); 17 | 18 | public void run() { 19 | 20 | if (this.main.getConfig().getBoolean("Log-Server.Start")) { 21 | 22 | // Log To Files 23 | if (Data.isLogToFiles) { 24 | 25 | try { 26 | 27 | final BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getServerStartLogFile(), true)); 28 | out.write(this.main.getMessages().getString("Files.Server-Side.Start").replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())) + "\n"); 29 | out.close(); 30 | 31 | } catch (IOException e) { 32 | 33 | Logger.getInstance().getLogger().severe("An error occurred while logging into the appropriate file."); 34 | e.printStackTrace(); 35 | 36 | } 37 | } 38 | 39 | // Discord 40 | if (!this.main.getMessages().getString("Discord.Server-Side.Start").isEmpty()) { 41 | 42 | this.main.getDiscord().serverStart(this.main.getMessages().getString("Discord.Server-Side.Start").replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())), false); 43 | 44 | } 45 | 46 | // External 47 | if (Data.isExternal && this.main.getExternal().isConnected()) { 48 | 49 | try { 50 | 51 | ExternalData.serverStart(Data.serverName); 52 | 53 | } catch (Exception e) { e.printStackTrace(); } 54 | } 55 | 56 | // SQLite 57 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 58 | 59 | try { 60 | 61 | SQLiteData.insertServerStart(Data.serverName); 62 | 63 | } catch (Exception e) { e.printStackTrace(); } 64 | } 65 | } 66 | if (Data.isWhitelisted && Data.isBlacklisted) { 67 | 68 | this.main.getLogger().warning("Enabling both Whitelist and Blacklist isn't supported. " + 69 | "Disable one of them to continue logging Player Commands."); 70 | 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/serverside/Stop.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.serverside; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import me.prism3.loggerbungeecord.database.external.ExternalData; 5 | import me.prism3.loggerbungeecord.database.sqlite.SQLiteData; 6 | import me.prism3.loggerbungeecord.utils.Data; 7 | import me.prism3.loggerbungeecord.utils.FileHandler; 8 | 9 | import java.io.BufferedWriter; 10 | import java.io.FileWriter; 11 | import java.io.IOException; 12 | import java.time.ZonedDateTime; 13 | 14 | public class Stop { 15 | 16 | private final Logger main = Logger.getInstance(); 17 | 18 | public void run() { 19 | 20 | if (this.main.getConfig().getBoolean("Log-Server.Stop")) { 21 | 22 | // Log To Files 23 | if (Data.isLogToFiles) { 24 | 25 | try { 26 | 27 | final BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getServerStopLogFile(), true)); 28 | out.write(this.main.getMessages().getString("Files.Server-Side.Stop").replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())) + "\n"); 29 | out.close(); 30 | 31 | } catch (IOException e) { 32 | 33 | Logger.getInstance().getLogger().severe("An error occurred while logging into the appropriate file."); 34 | e.printStackTrace(); 35 | 36 | } 37 | } 38 | 39 | // Discord 40 | if (!this.main.getMessages().getString("Discord.Server-Side.Stop").isEmpty()) { 41 | 42 | this.main.getDiscord().serverStop(this.main.getMessages().getString("Discord.Server-Side.Stop").replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())), false); 43 | 44 | } 45 | 46 | // External 47 | if (Data.isExternal && this.main.getExternal().isConnected()) { 48 | 49 | try { 50 | 51 | ExternalData.serverStop(Data.serverName); 52 | 53 | } catch (Exception e) { e.printStackTrace(); } 54 | } 55 | 56 | // SQLite 57 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 58 | 59 | try { 60 | 61 | SQLiteData.insertServerStop(Data.serverName); 62 | 63 | } catch (Exception e) { e.printStackTrace(); } 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/utils/ASCIIArt.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.utils; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import net.md_5.bungee.api.ChatColor; 5 | 6 | public class ASCIIArt { 7 | 8 | private final Logger main = Logger.getInstance(); 9 | 10 | public void art() { 11 | 12 | main.getLogger().info(ChatColor.DARK_PURPLE + "|\n" + 13 | ChatColor.DARK_PURPLE + "|" + ChatColor.AQUA + " __ \n" + 14 | ChatColor.DARK_PURPLE + "|" + ChatColor.AQUA + " / / ____ ____ _____ ____ _____\n" + 15 | ChatColor.DARK_PURPLE + "|" + ChatColor.AQUA + " / / / __ \\/ __ `/ __ `/ _ \\/ ___/\n" + 16 | ChatColor.DARK_PURPLE + "|" + ChatColor.AQUA + " / /___/ /_/ / /_/ / /_/ / __/ / \n" + 17 | ChatColor.DARK_PURPLE + "|" + ChatColor.AQUA + " /_____/\\____/\\__, /\\__, /\\___/_/ \n" + 18 | ChatColor.DARK_PURPLE + "|" + ChatColor.AQUA + " /____//____/ " + ChatColor.RED + Data.pluginVersion + ChatColor.BLUE + " [ Proxy Version ] \n" + 19 | ChatColor.DARK_PURPLE + "|\n" + 20 | ChatColor.DARK_PURPLE + "|" + ChatColor.GOLD + " This is a DEV Build, please report any issues!\n" + ChatColor.DARK_PURPLE + "|\n" + 21 | ChatColor.DARK_PURPLE + "|" + ChatColor.WHITE + " Discord " + ChatColor.BLUE + "https://discord.gg/MfR5mcpVfX\n" + 22 | ChatColor.DARK_PURPLE + "|"); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/utils/ConfigManager.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.utils; 2 | 3 | import com.google.common.io.ByteStreams; 4 | import me.prism3.loggerbungeecord.Logger; 5 | import net.md_5.bungee.api.ChatColor; 6 | import net.md_5.bungee.config.Configuration; 7 | import net.md_5.bungee.config.ConfigurationProvider; 8 | import net.md_5.bungee.config.YamlConfiguration; 9 | 10 | import java.io.*; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class ConfigManager { 15 | 16 | private Configuration config = null; 17 | 18 | public void init() { 19 | 20 | this.saveDefaultConfig(); 21 | 22 | try { 23 | 24 | this.config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(getFile()); 25 | 26 | } catch (IOException e) { 27 | 28 | e.printStackTrace(); 29 | 30 | } 31 | } 32 | 33 | public String getString(String key) { 34 | String str = config.getString(key); 35 | str = ChatColor.translateAlternateColorCodes('&', str); 36 | return str; 37 | } 38 | 39 | public int getInt(String key) { return this.config.getInt(key); } 40 | 41 | public boolean getBoolean(String key) { 42 | return this.config.getBoolean(key); 43 | } 44 | 45 | public List getStringList(String key) { 46 | final List list = this.config.getStringList(key); 47 | final List avail = new ArrayList<>(); 48 | for (String str : list) 49 | avail.add(ChatColor.translateAlternateColorCodes('&', str)); 50 | return avail; 51 | } 52 | 53 | public File getFile() { 54 | return new File(Logger.getInstance().getDataFolder(), "config - Bungee.yml"); 55 | } 56 | 57 | private void saveDefaultConfig() { 58 | 59 | if (!Logger.getInstance().getDataFolder().exists()) Logger.getInstance().getDataFolder().mkdir(); 60 | 61 | final File file = getFile(); 62 | 63 | if (!file.exists()) { 64 | 65 | try { 66 | 67 | file.createNewFile(); 68 | 69 | try (InputStream is = Logger.getInstance().getResourceAsStream("config - Bungee.yml")) { 70 | 71 | OutputStream os = new FileOutputStream(file); 72 | ByteStreams.copy(is, os); 73 | os.close(); 74 | 75 | } 76 | } catch (IOException e) { 77 | 78 | e.printStackTrace(); 79 | 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/utils/Messages.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.utils; 2 | 3 | import com.google.common.io.ByteStreams; 4 | import me.prism3.loggerbungeecord.Logger; 5 | import net.md_5.bungee.api.ChatColor; 6 | import net.md_5.bungee.config.Configuration; 7 | import net.md_5.bungee.config.ConfigurationProvider; 8 | import net.md_5.bungee.config.YamlConfiguration; 9 | 10 | import java.io.*; 11 | 12 | public class Messages { 13 | 14 | private Configuration messagesFile = null; 15 | 16 | public void init() { 17 | 18 | this.saveDefaultConfig(); 19 | 20 | try { 21 | 22 | this.messagesFile = ConfigurationProvider.getProvider(YamlConfiguration.class).load(getFile()); 23 | 24 | } catch (IOException e) { 25 | 26 | e.printStackTrace(); 27 | 28 | } 29 | } 30 | 31 | public String getString(String key) { 32 | 33 | String str = this.messagesFile.getString(key); 34 | 35 | str = ChatColor.translateAlternateColorCodes('&', str); 36 | 37 | return str; 38 | } 39 | 40 | public File getFile() { 41 | return new File(Logger.getInstance().getDataFolder(), "messages - Bungee.yml"); 42 | } 43 | 44 | private void saveDefaultConfig() { 45 | 46 | if (!Logger.getInstance().getDataFolder().exists()) Logger.getInstance().getDataFolder().mkdir(); 47 | 48 | final File file = getFile(); 49 | 50 | if (!file.exists()) { 51 | 52 | try { 53 | 54 | file.createNewFile(); 55 | 56 | try (final InputStream is = Logger.getInstance().getResourceAsStream("messages - Bungee.yml")) { 57 | 58 | final OutputStream os = new FileOutputStream(file); 59 | ByteStreams.copy(is, os); 60 | os.close(); 61 | 62 | } 63 | } catch (IOException e) { 64 | 65 | e.printStackTrace(); 66 | 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/utils/UpdateChecker.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.utils; 2 | 3 | import me.prism3.loggerbungeecord.Logger; 4 | import net.md_5.bungee.api.ChatColor; 5 | import net.md_5.bungee.api.ProxyServer; 6 | 7 | import javax.net.ssl.HttpsURLConnection; 8 | import java.io.BufferedReader; 9 | import java.io.IOException; 10 | import java.io.InputStreamReader; 11 | import java.net.URL; 12 | 13 | public class UpdateChecker { 14 | 15 | private static final String VERSION = Data.pluginVersion; 16 | private static final String DOWNLOAD_URL = "https://www.spigotmc.org/resources/logger.94236/updates/"; 17 | 18 | public void checkUpdates() { 19 | 20 | ProxyServer.getInstance().getScheduler().runAsync(Logger.getInstance(), () -> { 21 | 22 | final String httpsUrl = "https://api.spigotmc.org/legacy/update.php?resource=94236/"; 23 | 24 | try { 25 | 26 | final URL url = new URL(httpsUrl); 27 | final HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); 28 | if (con != null) { 29 | 30 | try { 31 | 32 | final BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); 33 | 34 | String input; 35 | 36 | while ((input = br.readLine()) != null) { 37 | 38 | if (!input.trim().equalsIgnoreCase(VERSION.trim())) { 39 | 40 | Logger.getInstance().getLogger().info(ChatColor.GOLD + "A new version is available for download " + ChatColor.GREEN + VERSION); 41 | Logger.getInstance().getLogger().info(ChatColor.GOLD + "Download Link: " + ChatColor.GREEN + DOWNLOAD_URL); 42 | 43 | } 44 | } 45 | 46 | br.close(); 47 | 48 | } catch (IOException e) { 49 | 50 | Logger.getInstance().getLogger().warning("Could not check for Updates, if the issue persists contact the Authors!"); 51 | 52 | e.printStackTrace(); 53 | 54 | } 55 | } 56 | 57 | } catch (IOException e) { 58 | 59 | Logger.getInstance().getLogger().warning("Could not check for Updates, if the issue persists contact the Authors!"); 60 | 61 | e.printStackTrace(); 62 | 63 | } 64 | }); 65 | } 66 | } -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/java/me/prism3/loggerbungeecord/utils/litebanutil/UsernameFetcher.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggerbungeecord.utils.litebanutil; 2 | 3 | import litebans.api.Database; 4 | 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | 9 | public class UsernameFetcher { 10 | 11 | private UsernameFetcher() {} 12 | 13 | public static String playerNameFetcher(String uuid) { 14 | 15 | String name = ""; 16 | final String query = "SELECT name from {history} WHERE uuid=? ORDER BY date DESC LIMIT 1"; 17 | 18 | try (final PreparedStatement st = Database.get().prepareStatement(query)) { 19 | 20 | st.setString(1, uuid); 21 | 22 | try (ResultSet rs = st.executeQuery()) { 23 | 24 | if (rs.next()) { 25 | 26 | name = rs.getString("name"); 27 | 28 | } 29 | } 30 | 31 | } catch (SQLException e) { e.printStackTrace(); } 32 | 33 | return name; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/resources/bungee.yml: -------------------------------------------------------------------------------- 1 | name: Logger-BungeeCord 2 | version: '${project.version}' 3 | main: me.prism3.loggerbungeecord.Logger 4 | description: Log all Activities from Players and Server Side! 5 | author: Prism3 & Sidna 6 | softdepends: [LiteBans, PartyAndFriends] 7 | commands: 8 | loggerb reload: 9 | description: "Reloads the plugin configs." 10 | loggerb discord: 11 | description: "Shows discord support server." 12 | permissions: 13 | loggerproxy.staff: 14 | description: "Allows to view Plugin commands." 15 | children: 16 | loggerproxy.exempt: true 17 | loggerproxy.reload: true 18 | loggerproxy.exempt: 19 | description: "Prevents the player from getting logged." 20 | children: 21 | logger.exempt.discord: true 22 | loggerproxy.exempt.discord: 23 | description: "Prevents the Player from getting discord logged." 24 | loggerproxy.reload: 25 | description: "Allows to reload the Plugin." 26 | default: op 27 | loggerproxy.staff.log: 28 | description: "Logs staff members." 29 | children: 30 | loggerproxy.exempt: false 31 | -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/resources/config - Bungee.yml: -------------------------------------------------------------------------------- 1 | # ///////////////////////////////////////////////////////////// 2 | # / / 3 | # / Logger Plugin / 4 | # / / 5 | # / [ Proxy Version ] / 6 | # / / 7 | # ///////////////////////////////////////////////////////////// 8 | # 9 | # Thank you for using Logger Plugin! If you are experiencing any issues 10 | # or have any suggestions / features you want to be implemented into the plugin 11 | # feel free to join the support Discord Server! 12 | # 13 | # Spigot: Prism3 14 | # Discord: Prism3#9371 | ID: 403667971089760257 15 | # Discord Server: https://discord.gg/MfR5mcpVfX 16 | # 17 | # Config: 1.8.0.15 18 | 19 | 20 | # Server Name 21 | Server-Name: "Server_Name" 22 | 23 | # Date & Time Formatter 24 | Time-Formatter: "yyyy-MM-dd HH:mm:ss" 25 | 26 | # How many Days for the logs to be deleted 27 | # Set it to -1 to cancel the Deletion 28 | File-Deletion: 7 29 | 30 | # Log to Files 31 | Log-to-Files: true 32 | 33 | # This will log players with the "loggerproxy.staff.log" permission node in their own folder / file 34 | Staff: 35 | Enabled: false 36 | 37 | # Logging features 38 | Log-Player: 39 | Chat: true 40 | Commands: true 41 | Login: true 42 | Leave: true 43 | 44 | Log-Server: 45 | Reload: true 46 | Start: true 47 | Stop: true 48 | RAM: true 49 | 50 | Log-Extra: 51 | LiteBans: true 52 | 53 | # Player-Commands features 54 | Player-Commands: 55 | Whitelist-Commands: false 56 | Commands-to-Log: 57 | - /server 58 | - /lookup 59 | Blacklist-Commands: true 60 | Commands-to-Block: 61 | - /login 62 | - /register 63 | - /msg 64 | 65 | # Enable to show Player's IPs 66 | Player-Login: 67 | Player-IP: false 68 | 69 | # Server RAM 70 | # How often should we check for the Proxy's RAM 71 | # It's better to have it above 1 min to avoid any complications 72 | # Value in Ticks, 20 Ticks = 1 Second 73 | # Percent goes from 0 -> 100 74 | RAM: 75 | Checker: 6000 76 | Percent: 50 77 | 78 | # LiteBans Features to Log 79 | # It does not log revoked actions! 80 | # example: unban 81 | LiteBans: 82 | IP-Ban: true 83 | Temp-IP-Ban: true 84 | Ban: true 85 | Temp-Ban: true 86 | Mute: true 87 | Temp-Mute: true 88 | Kick: true 89 | 90 | # External Database Feature 91 | # Available Types are MySQL and MariaDB 92 | # Data-Deletion Value in Days, Set it -1 to cancel 93 | Database: 94 | Enable: false 95 | Type: MySQL 96 | Host: localhost 97 | Port: 3306 98 | Username: username 99 | Password: PassworD 100 | Database: database 101 | Data-Deletion: 7 102 | 103 | # SQLite Feature 104 | # Data-Deletion Value in Days, Set it -1 to cancel 105 | SQLite: 106 | Enable: false 107 | Data-Deletion: 7 108 | 109 | # Checks for Updates 110 | Update-Checker: true -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/resources/discord - Bungee.yml: -------------------------------------------------------------------------------- 1 | # Discord Bridge Configuration for Logger Plugin [ Proxy Version ] 2 | # Need Support? Join the Discord Server: https://discord.gg/MfR5mcpVfX 3 | # Config: 1.8.0.15 4 | # Leaving Channel-ID empty will disable the Channel 5 | Discord: 6 | Enable: false 7 | Bot-Token: BOT_KEY 8 | Staff: 9 | Channel-ID: 'CHANNEL_ID' 10 | Player-Chat: 11 | Channel-ID: 'CHANNEL_ID' 12 | Player-Commands: 13 | Channel-ID: 'CHANNEL_ID' 14 | Player-Login: 15 | Channel-ID: 'CHANNEL_ID' 16 | Player-Leave: 17 | Channel-ID: 'CHANNEL_ID' 18 | Server-Switch: 19 | Channel-ID: 'CHANNEL_ID' 20 | # Server Side 21 | Server-Side: 22 | Restart: 23 | Channel-ID: 'CHANNEL_ID' 24 | Start: 25 | Channel-ID: 'CHANNEL_ID' 26 | Stop: 27 | Channel-ID: 'CHANNEL_ID' 28 | RAM: 29 | Channel-ID: 'CHANNEL_ID' 30 | # Extra Side 31 | Extra: 32 | LiteBans: 33 | Channel-ID: 'CHANNEL_ID' 34 | # Bot Activity Status 35 | # Randomize the shown status 36 | # First Part must not be different from 37 | # Playing, Watching, Listening, Streaming, Competing 38 | # Otherwise it will not work 39 | # Time in Seconds 40 | ActivityCycling: 41 | Enabled: true 42 | Random: false 43 | Activities: 44 | - ["watching", "Minecraft Movie"] 45 | - ["playing", "Minecraft 1.7"] 46 | - ["listening", "Dragon's Heart Beats"] 47 | - ["streaming", "Minecraft Gameplay"] 48 | Time: 30 -------------------------------------------------------------------------------- /Logger-BungeeCord/src/main/resources/messages - Bungee.yml: -------------------------------------------------------------------------------- 1 | # Messages for Logger Plugin [ Proxy Version ] 2 | # Need Support? Join the Discord Server: https://discord.gg/MfR5mcpVfX 3 | # Config: 1.8.0.15 4 | # Plugin Messages 5 | General: 6 | No-Permission: "&cYou do not have permission to run this command." 7 | Reload: "&aConfigs Reloaded." 8 | Invalid-Syntax: "&cInvalid Syntax." 9 | # Files Instance 10 | Files: 11 | Player-Chat-Staff: "[%time%] [%server%] The Staff <%player%> has said => %msg%" 12 | Player-Chat: "[%time%] [%server%] The Player <%player%> has said => %msg%" 13 | Player-Commands-Staff: "[%time%] [%server%] The Staff <%player%> has executed => %command%" 14 | Player-Commands: "[%time%] [%server%] The Player <%player%> has executed => %command%" 15 | Player-Login-Staff: "[%time%] The Staff <%player%> has joined with the current IP -> %IP%" 16 | Player-Login: "[%time%] The Player <%player%> has joined with the current IP -> %IP%" 17 | Player-Leave-Staff: "[%time%] [%server%] The Staff <%player%> has left the server" 18 | Player-Leave: "[%time%] [%server%] The Player <%player%> has left the server" 19 | Server-Reload-Player-Staff: "[%time%] [%server%] The Staff <%player%> has reloaded the server" 20 | Server-Reload-Player: "[%time%] [%server%] The Player <%player%> has reloaded the server" 21 | # Server Side Part 22 | Server-Side: 23 | Reload-Console: "[%time%] The server has been reloaded" 24 | Start: "[%time%] The server has started" 25 | Stop: "[%time%] The server has stopped" 26 | RAM: "[%time%] The Server has exceeded the set amount of percentage of RAM Usage! Total Memory: %max% | Used Memory: %used% | Free Memory: %free%" 27 | # Extra Side Part 28 | Extra: 29 | LiteBans: "[%time%] The command '%command%' has been executed on %on% by %executor% for '%duration%' for the reason %reason% | %silent%" 30 | # Discord Instance 31 | # Emojis can be found here https://emojipedia.org/ or elsewhere. Emojis may not work on >1.12 Servers. 32 | Discord: 33 | Player-Chat-Staff: "**[%time%]** **[%server%]** **%msg%**" 34 | Player-Chat: "**[%time%]** **[%server%]** **%msg%**" 35 | Player-Commands-Staff: "**[%time%]** **[%server%]** **%command%**" 36 | Player-Commands: "**[%time%]** **[%server%]** **%command%**" 37 | Player-Login-Staff: "**[%time%]** ||**%IP%**||" 38 | Player-Login: "**[%time%]** ||**%IP%**||" 39 | Player-Leave-Staff: "**[%time%]** **[%server%]** Left the server" 40 | Player-Leave: "**[%time%]** **[%server%]** Left the server" 41 | Player-ServerSwitch-Staff: "**[%time%]** Has gone from server %from% to server %destination%!" 42 | Player-ServerSwitch: "**[%time%]** Has gone from server %from% to server %destination%!" 43 | Server-Reload-Player-Staff: "**[%time%]** **[%server%]** Has reloaded the server" 44 | Server-Reload-Player: "**[%time%]** **[%server%]** Has reloaded the server" 45 | # Server Side Part 46 | Server-Side: 47 | Restart-Console: "**[%time%]** The server has been reloaded" 48 | Start: "**[%time%]**" 49 | Stop: "**[%time%]**" 50 | RAM: "**[%time%]** The Server has exceeded the set amount of percentage of RAM Usage! Total Memory: **%max%** `|` Used Memory: **%used%** `|` Free Memory: **%free%**" 51 | # Extra Side Part 52 | Extra: 53 | LiteBans: "**[%time%]** The command **%command%** has been executed on **%on%** by **%executor%** for **%duration%** for the reason **%reason%** | **%silent%**" -------------------------------------------------------------------------------- /Logger-Shaded/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Logger 7 | me.prism3 8 | 1.8.0.15 9 | 10 | 11 | 4.0.0 12 | 13 | Logger-Shaded 14 | 15 | 16 | 1.8 17 | UTF-8 18 | 19 | 20 | jar 21 | 22 | 23 | 24 | 25 | org.apache.maven.plugins 26 | maven-shade-plugin 27 | 3.2.4 28 | 29 | 30 | package 31 | 32 | shade 33 | 34 | 35 | true 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-compiler-plugin 43 | 3.8.1 44 | 45 | ${java.version} 46 | ${java.version} 47 | 48 | 49 | 50 | 51 | 52 | src/main/resources 53 | true 54 | 55 | 56 | 57 | 58 | 59 | 60 | me.prism3 61 | Logger-Spigot 62 | 1.8.0.15 63 | 64 | 65 | me.prism3 66 | Logger-Bungeecord 67 | 1.8.0.15 68 | 69 | 70 | me.prism3 71 | Logger-Velocity 72 | 1.8.0.15 73 | 74 | 75 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/AdvancedBanUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | import me.prism3.logger.Logger; 4 | import org.bukkit.plugin.Plugin; 5 | 6 | public class AdvancedBanUtil { 7 | 8 | private AdvancedBanUtil() {} 9 | 10 | public static Plugin getAdvancedBanAPI() { 11 | return Logger.getInstance().getServer().getPluginManager().getPlugin("AdvancedBan"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/AuthMeUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | import fr.xephi.authme.AuthMe; 4 | import org.bukkit.Bukkit; 5 | 6 | public class AuthMeUtil { 7 | 8 | private AuthMeUtil() {} 9 | 10 | public static AuthMe getAuthMeAPI() { 11 | 12 | return (AuthMe) Bukkit.getPluginManager().getPlugin("AuthMe"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/EssentialsUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | import com.earth2me.essentials.Essentials; 4 | import com.earth2me.essentials.IEssentials; 5 | import org.bukkit.Bukkit; 6 | 7 | public class EssentialsUtil { 8 | 9 | private EssentialsUtil() {} 10 | 11 | public static Essentials getEssentialsAPI() { 12 | 13 | final IEssentials essentials = (IEssentials) Bukkit.getPluginManager().getPlugin("Essentials"); 14 | 15 | if (essentials instanceof Essentials) { 16 | 17 | return (Essentials) essentials; 18 | 19 | } else return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/FloodGateUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | public class FloodGateUtil { 4 | 5 | private FloodGateUtil() {} 6 | 7 | public static boolean getFloodGateAPI() { 8 | 9 | try { 10 | 11 | Class.forName("org.geysermc.floodgate.api.FloodgateApi"); 12 | 13 | } catch (Exception ignored) { return false; } 14 | 15 | return true; 16 | } 17 | } -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/GeyserUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.plugin.Plugin; 5 | 6 | public class GeyserUtil { 7 | 8 | private GeyserUtil() {} 9 | 10 | public static Plugin getGeyserAPI() { 11 | 12 | return Bukkit.getPluginManager().getPlugin("geyser-spigot"); 13 | } 14 | } -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/LiteBansUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | import me.prism3.logger.Logger; 4 | import org.bukkit.plugin.Plugin; 5 | 6 | public class LiteBansUtil { 7 | 8 | private LiteBansUtil() {} 9 | 10 | public static Plugin getLiteBansAPI() { 11 | 12 | return Logger.getInstance().getServer().getPluginManager().getPlugin("LiteBans"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/PlaceHolderAPIUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | import me.prism3.logger.Logger; 4 | import org.bukkit.plugin.Plugin; 5 | 6 | public class PlaceHolderAPIUtil { 7 | 8 | private PlaceHolderAPIUtil() {} 9 | 10 | public static Plugin getPlaceHolderAPI() { 11 | 12 | return Logger.getInstance().getServer().getPluginManager().getPlugin("PlaceholderAPI"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/SuperiorSkyblockUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | import me.prism3.logger.Logger; 4 | import org.bukkit.plugin.Plugin; 5 | 6 | public class SuperiorSkyblockUtil { 7 | 8 | private SuperiorSkyblockUtil() {} 9 | 10 | public static Plugin getSuperiorSkyblockAPI() { 11 | 12 | return Logger.getInstance().getServer().getPluginManager().getPlugin("SuperiorSkyblock"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/SuperiourSkyblockUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | public class SuperiourSkyblockUtil { 4 | } 5 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/api/VaultUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.api; 2 | 3 | import net.milkbowl.vault.economy.Economy; 4 | import org.bukkit.plugin.RegisteredServiceProvider; 5 | 6 | import static org.bukkit.Bukkit.getServer; 7 | 8 | public class VaultUtil { 9 | 10 | private VaultUtil() {} 11 | 12 | private static Economy econ = null; 13 | 14 | public static boolean getVaultAPI() { 15 | 16 | if (getServer().getPluginManager().getPlugin("Vault") == null) return false; 17 | 18 | final RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Economy.class); 19 | 20 | if (rsp == null) return false; 21 | 22 | econ = rsp.getProvider(); 23 | 24 | return true; 25 | } 26 | public static Economy getVault() { return econ; } 27 | } 28 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/commands/CommandManager.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.commands; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.commands.subcommands.*; 5 | import me.prism3.logger.utils.Data; 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.command.Command; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.command.TabExecutor; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.io.IOException; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | import static me.prism3.logger.utils.Data.loggerStaff; 18 | import static me.prism3.logger.utils.Data.pluginPrefix; 19 | 20 | public class CommandManager implements TabExecutor { 21 | 22 | private final ArrayList subCommands = new ArrayList<>(); 23 | 24 | public CommandManager() { 25 | 26 | this.subCommands.add(new Reload()); 27 | this.subCommands.add(new PlayerInventory()); 28 | this.subCommands.add(new ToggleSpy()); 29 | this.subCommands.add(new Discord()); 30 | this.subCommands.add(new Dump()); 31 | } 32 | 33 | @Override 34 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { 35 | 36 | final Logger main = Logger.getInstance(); 37 | 38 | if (!sender.hasPermission(loggerStaff)) { 39 | 40 | sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getMessages().get() 41 | .getString("General.No-Permission").replace("%prefix%", pluginPrefix))); 42 | 43 | return false; 44 | } 45 | 46 | if (args.length > 0) { 47 | 48 | for (int i = 0; i < getSubCommands().size(); i++) { 49 | if (args[0].equalsIgnoreCase(getSubCommands().get(i).getName())) { 50 | try { 51 | getSubCommands().get(i).perform(sender, args); 52 | } catch (IOException e) { e.printStackTrace(); } 53 | } 54 | } 55 | } else { 56 | 57 | if (sender.hasPermission(loggerStaff)) { 58 | sender.sendMessage("--------------------------------------------"); 59 | sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "Running Logger: &a&l" + Data.pluginVersion)); 60 | for (int i = 0; i < getSubCommands().size(); i++) 61 | sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9&l" + getSubCommands().get(i).getSyntax() + " &8&l| &r" + getSubCommands().get(i).getDescription())); 62 | sender.sendMessage("--------------------------------------------"); 63 | } 64 | } 65 | return true; 66 | } 67 | 68 | public List getSubCommands() { return this.subCommands; } 69 | 70 | @Nullable 71 | @Override 72 | public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { 73 | 74 | if (args.length == 1) { 75 | 76 | final ArrayList subCommandsArgs = new ArrayList<>(); 77 | 78 | for (int i = 0; i < getSubCommands().size(); i++) 79 | subCommandsArgs.add(getSubCommands().get(i).getName()); 80 | 81 | return subCommandsArgs; 82 | } else if (args.length >= 2) { 83 | 84 | for (int i = 0; i < getSubCommands().size(); i++) 85 | if (args[0].equalsIgnoreCase(getSubCommands().get(i).getName())) 86 | return getSubCommands().get(i).getSubCommandsArgs(sender, args); 87 | 88 | } return null; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/commands/SubCommand.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.commands; 2 | 3 | import org.bukkit.command.CommandSender; 4 | 5 | import java.io.IOException; 6 | import java.util.List; 7 | 8 | public interface SubCommand { 9 | 10 | String getName(); 11 | 12 | String getDescription(); 13 | 14 | String getSyntax(); 15 | 16 | void perform(CommandSender commandSender, String[] args) throws IOException; 17 | 18 | List getSubCommandsArgs(CommandSender commandSender, String[] args); 19 | } 20 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/commands/getting/Chat.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.commands.getting; 2 | 3 | import net.md_5.bungee.api.ChatColor; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandExecutor; 6 | import org.bukkit.command.CommandSender; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class Chat implements CommandExecutor { 10 | 11 | @Override 12 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, 13 | @NotNull String label, String[] args) { 14 | try { 15 | if (args.length == 2) { 16 | int currentPage = Integer.parseInt(args[1]) - 1; 17 | if (currentPage < 0) { 18 | sender.sendMessage(ChatColor.RED + "Allowed page values are 1 - *!"); 19 | return true; 20 | } 21 | Pager pager = new Pager(PlayerMessageSearch.getMessagesCount(args[0]), 10, 5, currentPage); 22 | 23 | PlayerMessageSearch playerMessageSearch = 24 | new PlayerMessageSearch(args[0], sender, pager, label); 25 | playerMessageSearch.fetchAndSendResults(); 26 | } else if (args.length == 1) { 27 | int currentPage = 0; 28 | Pager pager = new Pager(PlayerMessageSearch.getMessagesCount(args[0]), 10, 5, currentPage); 29 | 30 | PlayerMessageSearch playerMessageSearch = 31 | new PlayerMessageSearch(args[0], sender, pager, label); 32 | playerMessageSearch.fetchAndSendResults(); 33 | } else 34 | sender.sendMessage(ChatColor.RED + command.getUsage()); 35 | 36 | return true; 37 | } catch (Exception e) { 38 | e.printStackTrace(); 39 | return false; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/commands/getting/PlayerMessageSearch.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.commands.getting; 2 | 3 | import me.prism3.logger.Logger; 4 | import net.md_5.bungee.api.ChatColor; 5 | import org.bukkit.command.CommandSender; 6 | 7 | import java.sql.Connection; 8 | import java.sql.PreparedStatement; 9 | import java.sql.ResultSet; 10 | import java.sql.SQLException; 11 | 12 | public class PlayerMessageSearch { 13 | 14 | public static Connection getNewConnection() throws SQLException { 15 | return Logger.getInstance().getExternal().getHikari().getConnection(); 16 | } 17 | 18 | private final CommandSender sender; 19 | private final String searchedPlayer; 20 | private final Pager pager; 21 | private final String commandLabel; 22 | 23 | /** 24 | * @param searchedPlayer player name to search 25 | * @param sender Entity that initiated the search 26 | * @param pager Pager 27 | * @param commandLabel command label 28 | */ 29 | public PlayerMessageSearch(String searchedPlayer, CommandSender sender, Pager pager, 30 | String commandLabel) { 31 | this.searchedPlayer = searchedPlayer; 32 | this.sender = sender; 33 | this.pager = pager; 34 | this.commandLabel = commandLabel; 35 | } 36 | 37 | /** 38 | * Fetches results from database then sends results to the sender 39 | */ 40 | public void fetchAndSendResults() { 41 | String sql = 42 | "SELECT message, id, date FROM player_chat WHERE player_name=? ORDER BY DATE ASC, id DESC LIMIT 10 OFFSET ?"; 43 | try (Connection connection = PlayerMessageSearch.getNewConnection(); 44 | final PreparedStatement getStatement = connection.prepareStatement(sql)) { 45 | getStatement.setString(1, this.searchedPlayer); 46 | getStatement.setInt(2, this.pager.getCurrentOffset()); 47 | ResultSet rs = getStatement.executeQuery(); 48 | this.sendResults(rs); 49 | 50 | if (pager.getCurrentOffset() > pager.getCount()) { 51 | this.sender.sendMessage("No results found for that page!"); 52 | return; 53 | } 54 | this.sender.spigot() 55 | .sendMessage(this.pager.preparePaging(this.commandLabel, this.searchedPlayer)); 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | } 59 | } 60 | 61 | /** 62 | * @param playerName searched player name 63 | * @return int 64 | */ 65 | public static int getMessagesCount(String playerName) { 66 | try (Connection connection = PlayerMessageSearch.getNewConnection(); 67 | final PreparedStatement getStatement = connection 68 | .prepareStatement("SELECT COUNT(*) as total FROM player_chat WHERE player_name = ?")) { 69 | getStatement.setString(1, playerName); 70 | ResultSet rs = getStatement.executeQuery(); 71 | 72 | rs.next(); 73 | 74 | return rs.getInt("total"); 75 | } catch (Exception e) { 76 | e.printStackTrace(); 77 | return 0; 78 | } 79 | } 80 | 81 | /** 82 | * Send results to sender 83 | * 84 | * @param ResultSet rs 85 | */ 86 | private void sendResults(ResultSet rs) { 87 | // TODO format datetime 88 | try { 89 | while (rs.next()) { 90 | this.sender.sendMessage(ChatColor.RED + rs.getTimestamp("date").toString() + " " 91 | + searchedPlayer + ": " + ChatColor.GREEN + rs.getString("Message")); 92 | } 93 | rs.close(); 94 | } catch (Exception e) { 95 | e.printStackTrace(); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/commands/subcommands/Discord.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.commands.subcommands; 2 | 3 | import me.prism3.logger.commands.SubCommand; 4 | import org.bukkit.ChatColor; 5 | import org.bukkit.command.CommandSender; 6 | 7 | import java.util.Collections; 8 | import java.util.List; 9 | 10 | import static me.prism3.logger.utils.Data.discordSupportServer; 11 | import static me.prism3.logger.utils.Data.pluginPrefix; 12 | 13 | public class Discord implements SubCommand { 14 | 15 | @Override 16 | public String getName() { return "discord"; } 17 | 18 | @Override 19 | public String getDescription() { return "Display the discord support server link"; } 20 | 21 | @Override 22 | public String getSyntax() { return "/logger discord"; } 23 | 24 | @Override 25 | public void perform(CommandSender commandSender, String[] args) { 26 | 27 | commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', pluginPrefix + "Discord Support Server: &b" + discordSupportServer)); 28 | } 29 | 30 | @Override 31 | public List getSubCommandsArgs(CommandSender commandSender, String[] args) { return Collections.emptyList(); } 32 | } 33 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/commands/subcommands/Dump.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.commands.subcommands; 2 | 3 | import com.google.common.io.Files; 4 | import io.github.cdimascio.dotenv.Dotenv; 5 | import me.prism3.logger.Logger; 6 | import me.prism3.logger.commands.SubCommand; 7 | import me.prism3.logger.utils.Pastebin; 8 | import org.bukkit.ChatColor; 9 | import org.bukkit.command.CommandSender; 10 | 11 | import java.io.File; 12 | import java.io.IOException; 13 | import java.nio.charset.StandardCharsets; 14 | import java.util.Collections; 15 | import java.util.List; 16 | 17 | import static me.prism3.logger.utils.Data.pluginPrefix; 18 | import static me.prism3.logger.utils.Data.selectedLang; 19 | 20 | 21 | public class Dump implements SubCommand { 22 | 23 | private final File dataFolder = Logger.getInstance().getDataFolder(); 24 | 25 | @Override 26 | public String getName() { return "dump"; } 27 | 28 | @Override 29 | public String getDescription() { 30 | return "Creates an online pastebin url of the plugin's config, discord, the used messages file and server's latest.log file"; 31 | } 32 | 33 | @Override 34 | public String getSyntax() { return "/logger " + this.getName(); } 35 | 36 | @Override 37 | public void perform(CommandSender commandSender, String[] args) throws IOException { this.pastebinExecution(commandSender); } 38 | 39 | @Override 40 | public List getSubCommandsArgs(CommandSender commandSender, String[] args) { return Collections.emptyList(); } 41 | 42 | private void pastebinExecution(CommandSender commandSender) throws IOException { 43 | 44 | final Dotenv dotenv = Dotenv.load(); 45 | 46 | final String config = Files.asCharSource(new File(dataFolder + "/config.yml"), StandardCharsets.UTF_8).read(); 47 | final String discord = Files.asCharSource(new File(dataFolder + "/discord.yml"), StandardCharsets.UTF_8).read(); 48 | final String messages = Files.asCharSource(new File(dataFolder + "/messages/" + selectedLang + ".yml"), StandardCharsets.UTF_8).read(); 49 | final String latest = Files.asCharSource(new File("logs/latest.log"), StandardCharsets.UTF_8).read(); 50 | final Pastebin.PasteRequest request = new Pastebin.PasteRequest(dotenv.get("PASTEBIN_API"), config + " \n\n\n\nDISCORD CONFIG\n\n\n\n " + discord + " \n\n\n\nMESSAGES PART\n\n\n\n " + messages + " \n\n\n\nLATEST LOG PART\n\n\n\n " + latest); 51 | 52 | if (request.postPaste() == null) 53 | return; 54 | 55 | request.setPasteName("Logger MC Plugin"); 56 | request.setPasteFormat("yaml"); 57 | request.setPasteState(1); 58 | request.setPasteExpire("10M"); 59 | commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', 60 | pluginPrefix + request.postPaste() + "\n&cDo not share this link at all!")); 61 | } 62 | } -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/commands/subcommands/Reload.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.commands.subcommands; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.commands.SubCommand; 5 | import me.prism3.logger.utils.Data; 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.command.CommandSender; 8 | 9 | import java.util.Collections; 10 | import java.util.List; 11 | 12 | import static me.prism3.logger.utils.Data.pluginPrefix; 13 | 14 | public class Reload implements SubCommand { 15 | 16 | private final Logger main = Logger.getInstance(); 17 | 18 | @Override 19 | public String getName() { 20 | return "reload"; 21 | } 22 | 23 | @Override 24 | public String getDescription() { 25 | return "Reloads the plugin files"; 26 | } 27 | 28 | @Override 29 | public String getSyntax() { 30 | return "/logger reload"; 31 | } 32 | 33 | @Override 34 | public void perform(CommandSender commandSender, String[] args) { 35 | 36 | this.main.reloadConfig(); 37 | this.main.getMessages().reload(); 38 | this.main.getDiscordFile().reload(); 39 | Data.initializer(); 40 | commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.main.getMessages().get().getString("General.Reload").replace("%prefix%", pluginPrefix))); 41 | } 42 | 43 | @Override 44 | public List getSubCommandsArgs(CommandSender commandSender, String[] args) { return Collections.emptyList(); } 45 | } 46 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/commands/subcommands/ToggleSpy.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.commands.subcommands; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.commands.SubCommand; 5 | import org.bukkit.ChatColor; 6 | import org.bukkit.command.CommandSender; 7 | 8 | import java.util.Arrays; 9 | import java.util.Collections; 10 | import java.util.List; 11 | 12 | import static me.prism3.logger.utils.Data.pluginPrefix; 13 | 14 | 15 | public class ToggleSpy implements SubCommand { 16 | 17 | public String getName() { return "toggle"; } 18 | 19 | public String getDescription() { return "Toggle spy features ON/OFF"; } 20 | 21 | public String getSyntax() { return "/logger " + this.getName() + " spy [Commands | Book | Sign | Anvil]"; } 22 | 23 | public void perform(final CommandSender commandSender, final String[] args) { 24 | 25 | final Logger main = Logger.getInstance(); 26 | 27 | if (args.length < 3 || !args[1].equalsIgnoreCase("spy")) { 28 | commandSender.sendMessage(this.getSyntax()); 29 | return; 30 | } 31 | 32 | final String option = args[2].toLowerCase(); 33 | final String[] validOptions = {"commands", "book", "sign", "anvil"}; 34 | 35 | if (!Arrays.asList(validOptions).contains(option)) { 36 | commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', 37 | pluginPrefix + "&cInvalid option, correct options are [Commands | Book | Sign | Anvil]")); 38 | return; 39 | } 40 | 41 | final String path = "Spy-Features." + option + "-Spy.Enable"; 42 | final boolean isToggled = main.getConfig().getBoolean(path); 43 | 44 | main.getConfig().set(path, !isToggled); 45 | main.saveConfig(); 46 | commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', 47 | pluginPrefix + option + " Spy Toggled.")); 48 | } 49 | 50 | public List getSubCommandsArgs(CommandSender commandSender, String[] args) { return Collections.emptyList(); } 51 | } -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/database/external/External.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.database.external; 2 | 3 | import com.zaxxer.hikari.HikariDataSource; 4 | import me.prism3.logger.Logger; 5 | import me.prism3.logger.utils.Data; 6 | import me.prism3.logger.utils.Log; 7 | 8 | public class External { 9 | 10 | private final Logger main = Logger.getInstance(); 11 | 12 | private String jdbc; 13 | private static final String DATATYPE = Data.dbType.toLowerCase(); 14 | private static final String HOST = Data.dbHost; 15 | private static final int PORT = Data.dbPort; 16 | private static final String USERNAME = Data.dbUserName; 17 | private static final String PASSWORD = Data.dbPassword; 18 | private static final String DATABASE = Data.dbName; 19 | private HikariDataSource hikari; 20 | 21 | public boolean isConnected() { 22 | return this.hikari != null; 23 | } 24 | 25 | public void connect() { 26 | 27 | String jdbcDriver; 28 | final String mySQL = "MySQL"; 29 | final String mySQLDriver = "com.mysql.cj.jdbc.Driver"; 30 | final String mariaDB = "mariadb"; 31 | final String mariaDBDriver = "org.mariadb.jdbc.Driver"; 32 | 33 | switch (DATATYPE) { 34 | 35 | case "mysql": 36 | this.jdbc = mySQL; 37 | jdbcDriver = mySQLDriver; 38 | break; 39 | 40 | case "mariadb": 41 | this.jdbc = mariaDB; 42 | jdbcDriver = mariaDBDriver; 43 | break; 44 | 45 | default: 46 | Log.severe("Unknown Database Type. Available ones are: MySQL and MariaDB."); 47 | return; 48 | 49 | } 50 | 51 | if (!isConnected()) { 52 | 53 | hikari = new HikariDataSource(); 54 | hikari.setDriverClassName(jdbcDriver); 55 | hikari.setJdbcUrl(this.getJdbcUrl()); 56 | hikari.addDataSourceProperty("user", USERNAME); 57 | hikari.addDataSourceProperty("password", PASSWORD); 58 | Log.info(this.jdbc + " Connection has been established!"); 59 | } 60 | } 61 | 62 | public void disconnect() { 63 | 64 | if (isConnected()) { 65 | 66 | this.hikari.close(); 67 | Log.info(this.jdbc + " Connection has been closed!"); 68 | 69 | } 70 | } 71 | 72 | private String getJdbcUrl() { 73 | return "jdbc:" + this.jdbc + "://" + External.HOST + ":" + External.PORT + "/" + External.DATABASE 74 | + "?AllowPublicKeyRetrieval=true&useSSL=false&jdbcCompliantTruncation=false"; 75 | 76 | } 77 | 78 | public HikariDataSource getHikari() { 79 | return this.hikari; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/database/external/ExternalUpdater.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.database.external; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.utils.Data; 5 | import me.prism3.logger.utils.Log; 6 | 7 | import java.sql.Connection; 8 | import java.sql.DatabaseMetaData; 9 | import java.sql.ResultSet; 10 | import java.sql.Statement; 11 | import java.util.ArrayList; 12 | import java.util.Collections; 13 | import java.util.List; 14 | 15 | public class ExternalUpdater { 16 | 17 | private ExternalUpdater() {} 18 | 19 | public static List getLoggerTables(ResultSet dbTables) { 20 | try { 21 | String name; 22 | List currentTables = new ArrayList<>(40); 23 | List oldTables = ExternalData.getTableNames(); 24 | 25 | while (dbTables.next()) { 26 | name = dbTables.getString("TABLE_NAME"); 27 | 28 | if (oldTables.stream().anyMatch(name::equalsIgnoreCase)) 29 | currentTables.add(name); 30 | } 31 | 32 | return currentTables; 33 | } catch (Exception e) { 34 | e.printStackTrace(); 35 | return Collections.emptyList(); 36 | } 37 | } 38 | 39 | public static void updater() { 40 | final Logger main = Logger.getInstance(); 41 | 42 | if (Data.isExternal && main.getExternal().isConnected()) { 43 | // Primary Key removal and adding method 44 | try (final Connection connection = main.getExternal().getHikari().getConnection(); 45 | final Statement stsm = connection.createStatement()) { 46 | 47 | final DatabaseMetaData databaseMetaData = connection.getMetaData(); 48 | final ResultSet tables = databaseMetaData.getTables(Data.dbName, null, null, null); 49 | List currentTables = ExternalUpdater.getLoggerTables(tables); 50 | 51 | int j; 52 | 53 | for (j = 0; j < currentTables.size(); j++) { 54 | stsm.execute("ALTER TABLE " + currentTables.get(j) + " CONVERT TO CHARACTER SET utf8mb4"); 55 | 56 | ResultSet primaryKeys = 57 | databaseMetaData.getPrimaryKeys(Data.dbName, null, currentTables.get(j)); 58 | 59 | ResultSet columns = 60 | databaseMetaData.getColumns(Data.dbName, null, currentTables.get(j), null); 61 | while (primaryKeys.next()) { 62 | final String pkName = primaryKeys.getString("COLUMN_NAME"); 63 | 64 | if (pkName.contains("Date")) { 65 | stsm.executeUpdate("ALTER TABLE " + currentTables.get(j) + " DROP PRIMARY KEY"); 66 | } 67 | 68 | if (!pkName.contains("id")) { 69 | stsm.executeUpdate("ALTER TABLE " + currentTables.get(j) 70 | + " ADD id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT FIRST"); 71 | } 72 | } 73 | 74 | String columnName; 75 | String lowerName; 76 | 77 | while (columns.next()) { 78 | columnName = columns.getString("COLUMN_NAME"); 79 | List x = new ArrayList<>(); 80 | int m; 81 | 82 | for (m = 1; m <= 24; m++) 83 | x.add(columns.getString(m)); 84 | 85 | String dataType = columns.getString(6); 86 | String length = String.valueOf(columns.getInt(7)); 87 | String nullType = columns.getBoolean(18) ? "NULL" : "NOT NULL"; 88 | String defaultVal = columns.getString(13); 89 | String attribute; 90 | dataType = dataType.equalsIgnoreCase("DATETIME") ? "DATETIME(6)" 91 | : dataType + "(" + length + ") "; 92 | 93 | if (dataType.contains("UNSIGNED")) { 94 | String[] arr = dataType.split(" "); 95 | dataType = arr[0]; 96 | attribute = arr[1].replaceAll("[0-9()]", ""); 97 | dataType = dataType + "(" + length + ") " + attribute; 98 | } 99 | 100 | lowerName = columnName.toLowerCase(); 101 | if (columnName.contains("Playername")) { 102 | stsm.executeUpdate("ALTER TABLE " + currentTables.get(j) + " CHANGE COLUMN " 103 | + columnName + " " + "player_name" + " " + dataType + " " + nullType 104 | + " DEFAULT " + defaultVal); 105 | } 106 | 107 | if (!columnName.equals(lowerName)) { 108 | 109 | String sql = "ALTER TABLE " + currentTables.get(j) + " CHANGE COLUMN " + columnName 110 | + " " + lowerName + " " + dataType + " " + nullType + " DEFAULT " + defaultVal; 111 | stsm.executeUpdate(sql); 112 | 113 | } 114 | } 115 | 116 | String oldName = currentTables.get(j); 117 | String newName = currentTables.get(j).toLowerCase(); 118 | 119 | if (!oldName.equals(newName)) { 120 | stsm.executeUpdate("RENAME TABLE " + oldName + " TO " + newName); 121 | } 122 | } 123 | 124 | } catch (Exception e) { 125 | Log.severe("Unable to update the tables. If the issue persists contact the Authors!"); 126 | e.printStackTrace(); 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/database/sqlite/global/SQLite.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.database.sqlite.global; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.utils.Log; 5 | 6 | import java.io.File; 7 | import java.sql.Connection; 8 | import java.sql.DriverManager; 9 | import java.sql.SQLException; 10 | 11 | public class SQLite { 12 | 13 | private final Logger main = Logger.getInstance(); 14 | 15 | private Connection connection; 16 | 17 | private final File databaseFile = new File(this.main.getDataFolder(), "LoggerData.db"); 18 | 19 | public boolean isConnected() { 20 | return (this.connection != null); 21 | } 22 | 23 | public void connect() { 24 | 25 | if (!isConnected()) { 26 | 27 | try { 28 | 29 | Class.forName("org.sqlite.JDBC"); 30 | this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.databaseFile.getAbsolutePath()); 31 | Log.info("SQLite Connection has been established!"); 32 | 33 | } catch (ClassNotFoundException | SQLException e) { 34 | 35 | Log.severe("Couldn't load SQLite Database, if the issue persists contact the Authors!"); 36 | e.printStackTrace(); 37 | 38 | } 39 | } 40 | } 41 | 42 | public void disconnect() { 43 | 44 | if (isConnected()) { 45 | 46 | try { 47 | 48 | this.connection.close(); 49 | Log.info("SQLite Database has been closed!"); 50 | 51 | } catch (SQLException e) { 52 | 53 | Log.severe("SQLite Database couldn't be closed safely, if the issue persists contact the Authors!"); 54 | e.printStackTrace(); 55 | 56 | } 57 | } 58 | } 59 | 60 | public Connection getConnection() { return this.connection; } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/database/sqlite/registration/SQLiteDataRegistration.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.database.sqlite.registration; 2 | 3 | import me.prism3.logger.Logger; 4 | import org.bukkit.entity.Player; 5 | 6 | import java.sql.PreparedStatement; 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | import java.time.ZonedDateTime; 10 | import java.time.format.DateTimeFormatter; 11 | 12 | public class SQLiteDataRegistration { 13 | 14 | private static final Logger plugin = Logger.getInstance(); 15 | 16 | private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss:SSSXXX"); 17 | 18 | public void createTable() { 19 | 20 | try { 21 | 22 | final PreparedStatement registration = plugin.getSqLiteReg().getConnection().prepareStatement("CREATE TABLE" + 23 | " IF NOT EXISTS registration (date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, player_name TEXT(20)," + 24 | "player_uuid INTEGER(70))"); 25 | 26 | registration.executeUpdate(); 27 | registration.close(); 28 | 29 | } catch (SQLException e) { e.printStackTrace(); } 30 | } 31 | 32 | public static void insertRegistration(Player player) { 33 | 34 | try { 35 | 36 | final PreparedStatement register = plugin.getSqLiteReg().getConnection().prepareStatement("INSERT INTO" + 37 | " registration (date, player_name, player_uuid) VALUES (?,?,?)"); 38 | 39 | register.setString(1, dateTimeFormatter.format(ZonedDateTime.now())); 40 | register.setString(2, player.getName()); 41 | register.setString(3, String.valueOf(player.getUniqueId())); 42 | 43 | register.executeUpdate(); 44 | register.close(); 45 | 46 | } catch (SQLException e) { e.printStackTrace(); } 47 | } 48 | 49 | public static boolean playerExists(Player player) { 50 | 51 | try { 52 | 53 | final PreparedStatement statement = plugin.getSqLiteReg().getConnection().prepareStatement("SELECT " + 54 | "* FROM registration WHERE player_uuid=? LIMIT 1"); 55 | 56 | statement.setString(1, String.valueOf(player.getUniqueId())); 57 | final ResultSet results = statement.executeQuery(); 58 | 59 | if (results.next()) return true; 60 | 61 | } catch (SQLException e) { e.printStackTrace(); } 62 | 63 | return false; 64 | } 65 | } -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/database/sqlite/registration/SQLiteRegistration.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.database.sqlite.registration; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.utils.Log; 5 | 6 | import java.io.File; 7 | import java.sql.Connection; 8 | import java.sql.DriverManager; 9 | import java.sql.SQLException; 10 | 11 | public class SQLiteRegistration { 12 | 13 | private final Logger main = Logger.getInstance(); 14 | 15 | private Connection connection; 16 | 17 | private final File databaseFile = new File(this.main.getDataFolder(), "." + File.separator + "Logs" + File.separator + "Registration" + File.separator + "Registration_Data" + File.separator + "Registration.db"); 18 | 19 | public boolean isConnected() { 20 | return (this.connection != null); 21 | } 22 | 23 | public void connect() { 24 | 25 | if (!isConnected()) { 26 | 27 | try { 28 | 29 | Class.forName("org.sqlite.JDBC"); 30 | this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.databaseFile.getAbsolutePath()); 31 | 32 | } catch (ClassNotFoundException | SQLException e) { 33 | 34 | Log.severe("Couldn't load Registration Database, if the issue persists contact the Authors!"); 35 | e.printStackTrace(); 36 | 37 | } 38 | } 39 | } 40 | 41 | public void disconnect() { 42 | 43 | if (isConnected()) { 44 | 45 | try { 46 | 47 | this.connection.close(); 48 | 49 | } catch (SQLException e) { 50 | 51 | Log.severe("Registration Database couldn't be closed safely, if the issue persists contact the Authors!"); 52 | e.printStackTrace(); 53 | 54 | } 55 | } 56 | } 57 | public Connection getConnection() { return this.connection; } 58 | } 59 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/discord/DiscordFile.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.discord; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.configuration.file.FileConfiguration; 5 | import org.bukkit.configuration.file.YamlConfiguration; 6 | 7 | import java.io.File; 8 | import java.util.Objects; 9 | 10 | public class DiscordFile { 11 | 12 | private File theDiscordFile; 13 | private FileConfiguration file; 14 | 15 | public void setup() { 16 | 17 | this.theDiscordFile = new File(Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("Logger")).getDataFolder(), "discord.yml"); 18 | 19 | if (!this.theDiscordFile.exists()) { 20 | 21 | Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("Logger")).saveResource("discord.yml", false); 22 | 23 | } 24 | 25 | this.file = YamlConfiguration.loadConfiguration(this.theDiscordFile); 26 | 27 | } 28 | 29 | public FileConfiguration get() { return this.file; } 30 | 31 | public void reload() { 32 | 33 | this.file = YamlConfiguration.loadConfiguration(this.theDiscordFile); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/discord/DiscordStatus.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.discord; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.utils.Log; 5 | import net.dv8tion.jda.api.JDA; 6 | import net.dv8tion.jda.api.entities.Activity; 7 | 8 | import java.util.Collections; 9 | import java.util.List; 10 | import java.util.concurrent.Executors; 11 | import java.util.concurrent.ScheduledExecutorService; 12 | import java.util.concurrent.TimeUnit; 13 | 14 | public class DiscordStatus { 15 | 16 | private final Logger main = Logger.getInstance(); 17 | private final JDA jda; 18 | 19 | private int currentIndex = 0; 20 | private final List> activities = (List>) this.main.getDiscordFile().get().get("ActivityCycling.Activities"); 21 | 22 | private static final ScheduledExecutorService threadPool = Executors.newSingleThreadScheduledExecutor(); 23 | 24 | public DiscordStatus(JDA jda) { 25 | 26 | this.jda = jda; 27 | 28 | try { 29 | 30 | assert this.activities != null; 31 | this.activities.forEach((list -> Activity.ActivityType.valueOf(list. 32 | get(0).replace("playing", "streaming").toUpperCase()))); 33 | 34 | } catch (Exception exception) { 35 | 36 | Log.severe("Discord Status Activity is invalid. It has been disabled."); 37 | return; 38 | 39 | } 40 | 41 | if (this.main.getDiscordFile().get().getBoolean("ActivityCycling.Random")) { 42 | 43 | Collections.shuffle(this.activities); 44 | 45 | } 46 | 47 | threadPool.scheduleWithFixedDelay(() -> { 48 | 49 | this.jda.getPresence().setActivity(Activity.of(Activity.ActivityType.valueOf( 50 | this.activities.get(this.currentIndex).get(0).replace("playing", "streaming") 51 | .toUpperCase()), this.activities.get(this.currentIndex).get(1))); 52 | 53 | this.currentIndex = (this.currentIndex + 1) % this.activities.size(); 54 | 55 | }, 0, this.main.getDiscordFile().get().getInt("ActivityCycling.Time"), TimeUnit.SECONDS); 56 | } 57 | 58 | public static ScheduledExecutorService getThreadPool() { return threadPool; } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/events/OnPlayerRegister.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.events; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.database.external.ExternalData; 5 | import me.prism3.logger.database.sqlite.global.SQLiteData; 6 | import me.prism3.logger.utils.Data; 7 | import me.prism3.logger.utils.FileHandler; 8 | import me.prism3.logger.utils.Log; 9 | import org.bukkit.Bukkit; 10 | import org.bukkit.entity.Player; 11 | 12 | import java.io.BufferedWriter; 13 | import java.io.FileWriter; 14 | import java.io.IOException; 15 | import java.time.Instant; 16 | import java.time.LocalDateTime; 17 | import java.time.ZoneId; 18 | import java.time.ZonedDateTime; 19 | import java.time.format.DateTimeFormatter; 20 | import java.util.Objects; 21 | 22 | public class OnPlayerRegister { 23 | 24 | private final Logger main = Logger.getInstance(); 25 | 26 | public OnPlayerRegister() { 27 | 28 | for (Player player : Bukkit.getServer().getOnlinePlayers()) { 29 | 30 | this.onRegister(player); 31 | 32 | } 33 | } 34 | 35 | private void onRegister(Player player) { 36 | 37 | final String playerName = player.getName(); 38 | 39 | final LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(player.getFirstPlayed()), ZoneId.systemDefault()); 40 | 41 | final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); 42 | 43 | // Log To Files 44 | if (Data.isLogToFiles) { 45 | 46 | try { 47 | 48 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getRegistrationFile(), true)); 49 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Player-Registration")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%player%", playerName).replace("%date%", dateFormat.format(ZonedDateTime.now())) + "\n"); 50 | out.close(); 51 | 52 | } catch (IOException e) { 53 | 54 | Log.warning("An error occurred while logging into the appropriate file."); 55 | e.printStackTrace(); 56 | 57 | } 58 | } 59 | 60 | // Discord Integration 61 | if (!player.hasPermission(Data.loggerExemptDiscord)) { 62 | 63 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Player-Registration")).isEmpty()) { 64 | 65 | this.main.getDiscord().playerRegistration(player, Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Player-Registration")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%player%", playerName).replace("%date%", dateFormat.format(ZonedDateTime.now())), false); 66 | } 67 | } 68 | 69 | // External 70 | if (Data.isExternal && this.main.getExternal().isConnected()) { 71 | 72 | try { 73 | 74 | ExternalData.playerRegistration(Data.serverName, player, dateFormat.format(ZonedDateTime.now())); 75 | 76 | } catch (Exception e) { e.printStackTrace(); } 77 | } 78 | 79 | // SQLite 80 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 81 | 82 | try { 83 | 84 | SQLiteData.insertRegistration(Data.serverName, player, dateFormat.format(ZonedDateTime.now())); 85 | 86 | } catch (Exception e) { e.printStackTrace(); } 87 | } 88 | } 89 | } 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/events/misc/OnSpawnEgg.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.events.misc; 2 | 3 | import org.bukkit.event.Listener; 4 | import org.bukkit.event.player.PlayerInteractEvent; 5 | 6 | public class OnSpawnEgg implements Listener { 7 | 8 | // @EventHandler(priority = EventPriority.HIGHEST) 9 | public void onSpawn(final PlayerInteractEvent event) { 10 | 11 | /*if (event.getAction() == Action.RIGHT_CLICK_BLOCK && Objects.requireNonNull(event.getItem()).getType().name().contains("MONSTER_EGG")) { 12 | 13 | Player player = event.getPlayer(); 14 | String playerName = player.getName(); 15 | 16 | System.out.println(playerName + event.getItem().getType().name()); 17 | 18 | }*/ 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/events/spy/OnAnvilSpy.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.events.spy; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.utils.Data; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.EventPriority; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.inventory.InventoryClickEvent; 12 | import org.bukkit.inventory.AnvilInventory; 13 | import org.bukkit.inventory.Inventory; 14 | import org.bukkit.inventory.InventoryView; 15 | import org.bukkit.inventory.ItemStack; 16 | import org.bukkit.inventory.meta.ItemMeta; 17 | 18 | import java.util.Objects; 19 | 20 | public class OnAnvilSpy implements Listener { 21 | 22 | private final Logger main = Logger.getInstance(); 23 | 24 | @EventHandler(priority = EventPriority.HIGHEST) 25 | public void onAnvilSpy(final InventoryClickEvent event) { 26 | 27 | if (this.main.getConfig().getBoolean("Log-Player.Anvil") 28 | && this.main.getConfig().getBoolean("Spy-Features.Anvil-Spy.Enable")) { 29 | 30 | final Player player = (Player) event.getWhoClicked(); 31 | 32 | if (player.hasPermission(Data.loggerExempt) || player.hasPermission(Data.loggerSpyBypass)) return; 33 | 34 | final Inventory inv = event.getInventory(); 35 | 36 | if (inv instanceof AnvilInventory) { 37 | 38 | final InventoryView view = event.getView(); 39 | 40 | final int rawSlot = event.getRawSlot(); 41 | 42 | if (rawSlot == view.convertSlot(rawSlot)) { 43 | 44 | if (rawSlot == 2) { 45 | 46 | final ItemStack item = event.getCurrentItem(); 47 | 48 | if (item != null) { 49 | 50 | final ItemMeta meta = item.getItemMeta(); 51 | 52 | if (meta != null && meta.hasDisplayName()) { 53 | 54 | final String displayName = meta.getDisplayName().replace("\\", "\\\\"); 55 | 56 | for (Player players : Bukkit.getOnlinePlayers()) { 57 | 58 | if (players.hasPermission(Data.loggerSpy)) { 59 | 60 | players.sendMessage(ChatColor.translateAlternateColorCodes('&', 61 | Objects.requireNonNull(this.main.getConfig().getString("Spy-Features.Anvil-Spy.Message")). 62 | replace("%player%", player.getName()). 63 | replace("%renamed%", displayName))); 64 | 65 | } 66 | } 67 | } 68 | } 69 | } 70 | } 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/events/spy/OnBookSpy.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.events.spy; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.utils.Data; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.EventPriority; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.player.PlayerEditBookEvent; 12 | 13 | import java.util.List; 14 | import java.util.Objects; 15 | 16 | public class OnBookSpy implements Listener{ 17 | 18 | private final Logger main = Logger.getInstance(); 19 | 20 | @EventHandler(priority = EventPriority.HIGHEST) 21 | public void onBookSpy(final PlayerEditBookEvent event) { 22 | 23 | if (this.main.getConfig().getBoolean("Log-Player.Book-Editing") 24 | && this.main.getConfig().getBoolean("Spy-Features.Book-Spy.Enable")) { 25 | 26 | final Player player = event.getPlayer(); 27 | 28 | if (player.hasPermission(Data.loggerExempt) || player.hasPermission(Data.loggerSpyBypass)) return; 29 | 30 | final List pageContent = event.getNewBookMeta().getPages(); 31 | 32 | for (Player players : Bukkit.getOnlinePlayers()) { 33 | 34 | if (players.hasPermission(Data.loggerSpy)) { 35 | 36 | players.sendMessage(ChatColor.translateAlternateColorCodes('&', 37 | Objects.requireNonNull(this.main.getConfig().getString("Spy-Features.Book-Spy.Message")). 38 | replace("%player%", player.getName()). 39 | replace("%content%", pageContent.toString().replace("\\", "\\\\")))); 40 | 41 | } 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/events/spy/OnCommandSpy.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.events.spy; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.utils.Data; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.EventPriority; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.player.PlayerCommandPreprocessEvent; 12 | 13 | import java.util.Objects; 14 | 15 | public class OnCommandSpy implements Listener { 16 | 17 | private final Logger main = Logger.getInstance(); 18 | 19 | @EventHandler(priority = EventPriority.HIGHEST) 20 | public void onCmdSpy(final PlayerCommandPreprocessEvent event) { 21 | 22 | if (this.main.getConfig().getBoolean("Log-Player.Commands") 23 | && this.main.getConfig().getBoolean("Spy-Features.Commands-Spy.Enable")) { 24 | 25 | final Player player = event.getPlayer(); 26 | 27 | if (player.hasPermission(Data.loggerExempt) || player.hasPermission(Data.loggerSpyBypass)) return; 28 | 29 | for (Player players : Bukkit.getOnlinePlayers()) { 30 | 31 | if (players.hasPermission(Data.loggerSpy)) { 32 | 33 | players.sendMessage(ChatColor.translateAlternateColorCodes('&', 34 | Objects.requireNonNull(this.main.getConfig().getString("Spy-Features.Commands-Spy.Message")). 35 | replace("%player%", player.getName()). 36 | replace("%cmd%", event.getMessage().replace("\\", "\\\\")))); 37 | 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/events/spy/OnSignSpy.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.events.spy; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.utils.Data; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.EventPriority; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.block.SignChangeEvent; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | import java.util.Objects; 16 | 17 | public class OnSignSpy implements Listener { 18 | 19 | private final Logger main = Logger.getInstance(); 20 | 21 | @EventHandler(priority = EventPriority.HIGHEST) 22 | public void onSignSpy(final SignChangeEvent event) { 23 | 24 | if (this.main.getConfig().getBoolean("Log-Player.Sign-Text") 25 | && this.main.getConfig().getBoolean("Spy-Features.Sign-Spy.Enable")) { 26 | 27 | final Player player = event.getPlayer(); 28 | 29 | if (player.hasPermission(Data.loggerExempt) || player.hasPermission(Data.loggerSpyBypass)) return; 30 | 31 | final List lines = Arrays.asList(event.getLines()); 32 | 33 | for (Player players : Bukkit.getOnlinePlayers()) { 34 | 35 | if (players.hasPermission(Data.loggerSpy)) { 36 | 37 | players.sendMessage(ChatColor.translateAlternateColorCodes('&', 38 | Objects.requireNonNull(this.main.getConfig().getString("Spy-Features.Sign-Spy.Message")). 39 | replace("%player%", player.getName()). 40 | replace("%line1%", lines.get(0).replace("\\", "\\\\")). 41 | replace("%line2%", lines.get(1).replace("\\", "\\\\")). 42 | replace("%line3%", lines.get(2).replace("\\", "\\\\")). 43 | replace("%line4%", lines.get(3).replace("\\", "\\\\")))); 44 | 45 | } 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/manager/Messages.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.manager; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.utils.Log; 5 | import me.prism3.logger.utils.enums.Languages; 6 | import org.bukkit.configuration.file.FileConfiguration; 7 | import org.bukkit.configuration.file.YamlConfiguration; 8 | 9 | import java.io.File; 10 | import java.util.Set; 11 | import java.util.stream.Collectors; 12 | import java.util.stream.Stream; 13 | 14 | import static me.prism3.logger.utils.Data.*; 15 | 16 | 17 | public class Messages { 18 | 19 | private final Logger main = Logger.getInstance(); 20 | private FileConfiguration messagesFile; 21 | private final Set langFiles = Stream.of(Languages.values()).map(Languages::getMessageFile).collect(Collectors.toSet()); 22 | 23 | public Messages() { 24 | 25 | this.copyLangFiles(); 26 | 27 | String selectedLanguage = selectedLang; 28 | 29 | // Check if the selected Language is Valid | Exists 30 | if (!this.langFiles.contains(selectedLanguage.toLowerCase())) { 31 | Log.severe("Unknown selected language file: '" + selectedLanguage + "'"); 32 | Log.severe("Using en_en instead"); 33 | selectedLanguage = "en_en"; 34 | selectedLang = "en_en"; 35 | } 36 | 37 | if (selectedLanguage != null) { 38 | final File configFile = new File(this.main.getDataFolder(), langPath + File.separator + selectedLanguage + fileType); 39 | messagesFile = YamlConfiguration.loadConfiguration(configFile); 40 | } 41 | } 42 | 43 | public FileConfiguration get() { return messagesFile; } 44 | 45 | public void reload() { 46 | 47 | if (messagesFile != null) { 48 | 49 | final String languageFileName = this.main.getConfig().getString("Language"); 50 | 51 | if (languageFileName != null) { 52 | File configFile = new File(this.main.getDataFolder(), langPath + File.separator + languageFileName + fileType); 53 | messagesFile = YamlConfiguration.loadConfiguration(configFile); 54 | } 55 | } 56 | } 57 | 58 | // Create language files that don't exist 59 | private void copyLangFiles() { 60 | this.langFiles.stream() 61 | .map(lang -> new File(this.main.getDataFolder(), langPath + File.separator + lang + fileType)) 62 | .filter(langFile -> !langFile.exists()) 63 | .forEach(langFile -> this.main.saveResource(langPath + File.separator + langFile.getName(), false)); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/serverside/Console.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.serverside; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.database.external.ExternalData; 5 | import me.prism3.logger.database.sqlite.global.SQLiteData; 6 | import me.prism3.logger.utils.Data; 7 | import me.prism3.logger.utils.FileHandler; 8 | import me.prism3.logger.utils.Log; 9 | import org.bukkit.command.BlockCommandSender; 10 | import org.bukkit.event.EventHandler; 11 | import org.bukkit.event.EventPriority; 12 | import org.bukkit.event.Listener; 13 | import org.bukkit.event.server.ServerCommandEvent; 14 | 15 | import java.io.BufferedWriter; 16 | import java.io.FileWriter; 17 | import java.io.IOException; 18 | import java.time.ZonedDateTime; 19 | import java.util.Arrays; 20 | import java.util.List; 21 | import java.util.Objects; 22 | 23 | public class Console implements Listener { 24 | 25 | private final Logger main = Logger.getInstance(); 26 | 27 | @EventHandler(priority = EventPriority.HIGHEST) 28 | public void onConsoleCommand(final ServerCommandEvent event) { 29 | 30 | if (event.getSender() instanceof BlockCommandSender) return; 31 | 32 | final String command = event.getCommand().replace("\\", "\\\\"); 33 | final List commandParts = Arrays.asList(event.getCommand().split("\\s+")); 34 | 35 | // Blacklisted Commands 36 | if (Data.isConsoleCommands) { 37 | 38 | for (String m : Data.consoleCommandsToBlock) { 39 | 40 | if (commandParts.get(0).equalsIgnoreCase(m)) { 41 | event.setCancelled(true); 42 | return; 43 | } 44 | } 45 | } 46 | 47 | if (this.main.getConfig().getBoolean("Log-Server.Console-Commands")) { 48 | 49 | // Log To Files 50 | if (Data.isLogToFiles) { 51 | 52 | try { 53 | 54 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getConsoleLogFile(), true)); 55 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Server-Side.Console-Commands")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%command%", command) + "\n"); 56 | out.close(); 57 | 58 | } catch (IOException e) { 59 | 60 | Log.warning("An error occurred while logging into the appropriate file."); 61 | e.printStackTrace(); 62 | 63 | } 64 | } 65 | 66 | // Discord 67 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Console-Commands")).isEmpty()) { 68 | 69 | this.main.getDiscord().console(Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Console-Commands")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%command%", command), false); 70 | } 71 | 72 | // External 73 | if (Data.isExternal && this.main.getExternal().isConnected()) { 74 | 75 | try { 76 | 77 | ExternalData.consoleCommands(Data.serverName, command); 78 | 79 | } catch (Exception e) { e.printStackTrace(); } 80 | } 81 | 82 | // SQLite 83 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 84 | 85 | try { 86 | 87 | SQLiteData.insertConsoleCommands(Data.serverName, command); 88 | 89 | } catch (Exception e) { e.printStackTrace(); } 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/serverside/OnCommandBlock.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.serverside; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.database.external.ExternalData; 5 | import me.prism3.logger.database.sqlite.global.SQLiteData; 6 | import me.prism3.logger.utils.Data; 7 | import me.prism3.logger.utils.FileHandler; 8 | import me.prism3.logger.utils.Log; 9 | import org.bukkit.command.BlockCommandSender; 10 | import org.bukkit.event.EventHandler; 11 | import org.bukkit.event.EventPriority; 12 | import org.bukkit.event.Listener; 13 | import org.bukkit.event.server.ServerCommandEvent; 14 | 15 | import java.io.BufferedWriter; 16 | import java.io.FileWriter; 17 | import java.io.IOException; 18 | import java.time.ZonedDateTime; 19 | import java.util.Objects; 20 | 21 | public class OnCommandBlock implements Listener { 22 | 23 | private final Logger main = Logger.getInstance(); 24 | 25 | @EventHandler(priority = EventPriority.HIGHEST) 26 | public void onCommandBlocks(ServerCommandEvent event) { 27 | 28 | if (event.getSender() instanceof BlockCommandSender) { 29 | 30 | final String command = event.getCommand().replace("\\", "\\\\"); 31 | 32 | if (this.main.getConfig().getBoolean("Log-Server.Command-Block")) { 33 | 34 | // Log To Files 35 | if (Data.isLogToFiles) { 36 | 37 | try { 38 | 39 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getCommandBlockFile(), true)); 40 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Server-Side.Command-Block")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%command%", command) + "\n"); 41 | out.close(); 42 | 43 | } catch (IOException e) { 44 | 45 | Log.warning("An error occurred while logging into the appropriate file."); 46 | e.printStackTrace(); 47 | 48 | } 49 | } 50 | 51 | // Discord 52 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Command-Block")).isEmpty()) { 53 | 54 | this.main.getDiscord().commandBlock(Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Command-Block")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%command%", command), false); 55 | } 56 | 57 | // External 58 | if (Data.isExternal && this.main.getExternal().isConnected()) { 59 | 60 | try { 61 | 62 | ExternalData.commandBlock(Data.serverName, command); 63 | 64 | } catch (Exception e) { e.printStackTrace(); } 65 | } 66 | 67 | // SQLite 68 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 69 | 70 | try { 71 | 72 | SQLiteData.insertCommandBlock(Data.serverName, command); 73 | 74 | } catch (Exception e) { e.printStackTrace(); } 75 | } 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/serverside/PortalCreation.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.serverside; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.database.external.ExternalData; 5 | import me.prism3.logger.database.sqlite.global.SQLiteData; 6 | import me.prism3.logger.utils.Data; 7 | import me.prism3.logger.utils.FileHandler; 8 | import me.prism3.logger.utils.Log; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.EventPriority; 11 | import org.bukkit.event.Listener; 12 | import org.bukkit.event.world.PortalCreateEvent; 13 | 14 | import java.io.BufferedWriter; 15 | import java.io.FileWriter; 16 | import java.io.IOException; 17 | import java.time.ZonedDateTime; 18 | import java.util.Objects; 19 | 20 | public class PortalCreation implements Listener { 21 | 22 | private final Logger main = Logger.getInstance(); 23 | 24 | @EventHandler(priority = EventPriority.HIGHEST) 25 | public void onPortalCreate(final PortalCreateEvent event) { 26 | 27 | if (!event.isCancelled() && this.main.getConfig().getBoolean("Log-Server.Portal-Creation")) { 28 | 29 | final String worldName = event.getWorld().getName(); 30 | final PortalCreateEvent.CreateReason reason = event.getReason(); 31 | 32 | // Log To Files 33 | if (Data.isLogToFiles) { 34 | 35 | try { 36 | 37 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getPortalCreateFile(), true)); 38 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Server-Side.Portal-Creation")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%world%", worldName).replace("%material%", String.valueOf(reason)) + "\n"); 39 | out.close(); 40 | 41 | } catch (IOException e) { 42 | 43 | Log.warning("An error occurred while logging into the appropriate file."); 44 | e.printStackTrace(); 45 | 46 | } 47 | } 48 | 49 | // Discord 50 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Portal-Creation")).isEmpty()) { 51 | 52 | this.main.getDiscord().portalCreation(Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Portal-Creation")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%world%", worldName).replace("%material%", String.valueOf(reason)), false); 53 | } 54 | 55 | // External 56 | if (Data.isExternal && this.main.getExternal().isConnected()) { 57 | 58 | try { 59 | 60 | ExternalData.portalCreate(Data.serverName, worldName, reason); 61 | 62 | } catch (Exception e) { e.printStackTrace(); } 63 | } 64 | 65 | // SQLite 66 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 67 | 68 | try { 69 | 70 | SQLiteData.insertPortalCreate(Data.serverName, worldName, reason); 71 | 72 | } catch (Exception e) { e.printStackTrace(); } 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/serverside/RAM.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.serverside; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.database.external.ExternalData; 5 | import me.prism3.logger.database.sqlite.global.SQLiteData; 6 | import me.prism3.logger.utils.Data; 7 | import me.prism3.logger.utils.FileHandler; 8 | import me.prism3.logger.utils.Log; 9 | 10 | import java.io.BufferedWriter; 11 | import java.io.FileWriter; 12 | import java.io.IOException; 13 | import java.time.ZonedDateTime; 14 | import java.util.Objects; 15 | 16 | public class RAM implements Runnable { 17 | 18 | private final Logger main = Logger.getInstance(); 19 | 20 | public void run() { 21 | 22 | if (this.main.getConfig().getBoolean("Log-Server.RAM")) { 23 | 24 | if (Data.ramPercent <= 0 || Data.ramPercent >= 100) return; 25 | 26 | final long maxMemory = Runtime.getRuntime().maxMemory() / 1048576L; 27 | final long freeMemory = Runtime.getRuntime().freeMemory() / 1048576L; 28 | final long usedMemory = maxMemory - freeMemory; 29 | final double percentUsed = usedMemory * 100.0D / maxMemory; 30 | 31 | if (Data.ramPercent <= percentUsed) { 32 | 33 | // Log To Files 34 | if (Data.isLogToFiles) { 35 | 36 | try { 37 | 38 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getRAMLogFile(), true)); 39 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Server-Side.RAM")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%max%", String.valueOf(maxMemory)).replace("%used%", String.valueOf(usedMemory)).replace("%free%", String.valueOf(freeMemory)) + "\n"); 40 | out.close(); 41 | 42 | } catch (IOException e) { 43 | 44 | Log.warning("An error occurred while logging into the appropriate file."); 45 | e.printStackTrace(); 46 | 47 | } 48 | } 49 | 50 | // Discord 51 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.RAM")).isEmpty()) { 52 | 53 | this.main.getDiscord().ram(Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.RAM")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%max%", String.valueOf(maxMemory)).replace("%used%", String.valueOf(usedMemory)).replace("%free%", String.valueOf(freeMemory)), false); 54 | } 55 | 56 | // External 57 | if (Data.isExternal && this.main.getExternal().isConnected()) { 58 | 59 | try { 60 | 61 | ExternalData.ram(Data.serverName, maxMemory, usedMemory, freeMemory); 62 | 63 | } catch (Exception e) { e.printStackTrace(); } 64 | } 65 | 66 | // SQLite 67 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 68 | 69 | try { 70 | 71 | SQLiteData.insertRAM(Data.serverName, maxMemory, usedMemory, freeMemory); 72 | 73 | } catch (Exception e) { e.printStackTrace(); } 74 | } 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/serverside/RCON.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.serverside; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.database.external.ExternalData; 5 | import me.prism3.logger.database.sqlite.global.SQLiteData; 6 | import me.prism3.logger.utils.Data; 7 | import me.prism3.logger.utils.FileHandler; 8 | import me.prism3.logger.utils.Log; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.EventPriority; 11 | import org.bukkit.event.Listener; 12 | import org.bukkit.event.server.RemoteServerCommandEvent; 13 | 14 | import java.io.BufferedWriter; 15 | import java.io.FileWriter; 16 | import java.io.IOException; 17 | import java.time.ZonedDateTime; 18 | import java.util.Objects; 19 | 20 | public class RCON implements Listener { 21 | 22 | private final Logger main = Logger.getInstance(); 23 | 24 | @EventHandler(priority = EventPriority.HIGH) 25 | public void onConnection(final RemoteServerCommandEvent event) { 26 | 27 | if (this.main.getConfig().getBoolean("Log-Server.RCON")) { 28 | 29 | final String command = event.getCommand(); 30 | 31 | // Log To Files 32 | if (Data.isLogToFiles) { 33 | 34 | try { 35 | 36 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getRconFile(), true)); 37 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Server-Side.RCON")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%command%", command) + "\n"); 38 | out.close(); 39 | 40 | } catch (IOException e) { 41 | 42 | Log.warning("An error occurred while logging into the appropriate file."); 43 | e.printStackTrace(); 44 | 45 | } 46 | } 47 | 48 | // Discord 49 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.RCON")).isEmpty()) { 50 | 51 | this.main.getDiscord().rCon(Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.RCON")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now()).replace("%command%", command)), false); 52 | } 53 | 54 | // External 55 | if (Data.isExternal && this.main.getExternal().isConnected()) { 56 | 57 | try { 58 | 59 | ExternalData.rCon(Data.serverName, command); 60 | 61 | } catch (Exception e) { e.printStackTrace(); } 62 | } 63 | 64 | // SQLite 65 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 66 | 67 | try { 68 | 69 | SQLiteData.insertRcon(Data.serverName, command); 70 | 71 | } catch (Exception e) { e.printStackTrace(); } 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/serverside/Start.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.serverside; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.database.external.ExternalData; 5 | import me.prism3.logger.database.sqlite.global.SQLiteData; 6 | import me.prism3.logger.utils.Data; 7 | import me.prism3.logger.utils.FileHandler; 8 | import me.prism3.logger.utils.Log; 9 | 10 | import java.io.BufferedWriter; 11 | import java.io.FileWriter; 12 | import java.io.IOException; 13 | import java.time.ZonedDateTime; 14 | import java.util.Objects; 15 | 16 | public class Start { 17 | 18 | private final Logger main = Logger.getInstance(); 19 | 20 | public void run() { 21 | 22 | if (this.main.getConfig().getBoolean("Log-Server.Start")) { 23 | 24 | // Log To Files 25 | if (Data.isLogToFiles) { 26 | 27 | try { 28 | 29 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getServerStartFile(), true)); 30 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Server-Side.Start")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())) + "\n"); 31 | out.close(); 32 | 33 | } catch (IOException e) { 34 | 35 | Log.warning("An error occurred while logging into the appropriate file."); 36 | e.printStackTrace(); 37 | 38 | } 39 | } 40 | 41 | // Discord 42 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Start")).isEmpty()) { 43 | 44 | this.main.getDiscord().serverStart(Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Start")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())), false); 45 | } 46 | 47 | // External 48 | if (Data.isExternal && this.main.getExternal().isConnected()) { 49 | 50 | try { 51 | 52 | ExternalData.serverStart(Data.serverName); 53 | 54 | } catch (Exception e) { e.printStackTrace(); } 55 | } 56 | 57 | // SQLite 58 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 59 | 60 | try { 61 | 62 | SQLiteData.insertServerStart(Data.serverName); 63 | 64 | } catch (Exception e) { e.printStackTrace(); } 65 | } 66 | } 67 | 68 | if (Data.isWhitelisted && Data.isBlacklisted) { 69 | 70 | Log.warning("Enabling both Whitelist and Blacklist isn't supported. " + 71 | "Disable one of them to continue logging Player Commands."); 72 | 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/serverside/Stop.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.serverside; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.database.external.ExternalData; 5 | import me.prism3.logger.database.sqlite.global.SQLiteData; 6 | import me.prism3.logger.utils.Data; 7 | import me.prism3.logger.utils.FileHandler; 8 | import me.prism3.logger.utils.Log; 9 | 10 | import java.io.BufferedWriter; 11 | import java.io.FileWriter; 12 | import java.io.IOException; 13 | import java.time.ZonedDateTime; 14 | import java.util.Objects; 15 | 16 | public class Stop { 17 | 18 | private final Logger main = Logger.getInstance(); 19 | 20 | public void run() { 21 | 22 | if (this.main.getConfig().getBoolean("Log-Server.Stop")) { 23 | 24 | // Log To Files 25 | if (Data.isLogToFiles) { 26 | 27 | try { 28 | 29 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getServerStopFile(), true)); 30 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Server-Side.Stop")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())) + "\n"); 31 | out.close(); 32 | 33 | } catch (IOException e) { 34 | 35 | Log.warning("An error occurred while logging into the appropriate file."); 36 | e.printStackTrace(); 37 | 38 | } 39 | } 40 | 41 | // Discord 42 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Stop")).isEmpty()) { 43 | 44 | this.main.getDiscord().serverStop(Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.Stop")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())), false); 45 | } 46 | 47 | // External 48 | if (Data.isExternal && this.main.getExternal().isConnected()) { 49 | 50 | try { 51 | 52 | ExternalData.serverStop(Data.serverName); 53 | 54 | } catch (Exception e) { e.printStackTrace(); } 55 | } 56 | 57 | // SQLite 58 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 59 | 60 | try { 61 | 62 | SQLiteData.insertServerStop(Data.serverName); 63 | 64 | } catch (Exception e) { e.printStackTrace(); } 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/serverside/TPS.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.serverside; 2 | 3 | import me.prism3.logger.Logger; 4 | import me.prism3.logger.database.external.ExternalData; 5 | import me.prism3.logger.database.sqlite.global.SQLiteData; 6 | import me.prism3.logger.utils.Data; 7 | import me.prism3.logger.utils.FileHandler; 8 | import me.prism3.logger.utils.Log; 9 | 10 | import java.io.BufferedWriter; 11 | import java.io.FileWriter; 12 | import java.io.IOException; 13 | import java.time.ZonedDateTime; 14 | import java.util.Objects; 15 | 16 | public class TPS implements Runnable { 17 | 18 | private final Logger main = Logger.getInstance(); 19 | 20 | private int tickCount = 0; 21 | private final long[] ticks = new long[600]; 22 | 23 | public void run() { 24 | 25 | // This should resolve the uncorrected TPS value e.g 0.125462498 26 | if (this.getTPS() <= 1 ) return; 27 | 28 | if (this.main.getConfig().getBoolean("Log-Server.TPS")) { 29 | 30 | if (Data.tpsMedium <= 0 || Data.tpsMedium >= 20 || Data.tpsCritical <= 0 || Data.tpsCritical >= 20) return; 31 | 32 | this.ticks[(this.tickCount % this.ticks.length)] = System.currentTimeMillis(); 33 | 34 | this.tickCount += 1; 35 | 36 | // Log To Files 37 | if (Data.isLogToFiles) { 38 | 39 | try { 40 | 41 | if (this.getTPS() <= Data.tpsMedium) { 42 | 43 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getTPSLogFile(), true)); 44 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Server-Side.TPS-Medium")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%TPS%", String.valueOf(getTPS())) + "\n"); 45 | out.close(); 46 | 47 | } else if (this.getTPS() <= Data.tpsCritical) { 48 | 49 | BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getTPSLogFile(), true)); 50 | out.write(Objects.requireNonNull(this.main.getMessages().get().getString("Files.Server-Side.TPS-Critical")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%TPS%", String.valueOf(getTPS())) + "\n"); 51 | out.close(); 52 | 53 | } 54 | 55 | } catch (IOException e) { 56 | 57 | Log.warning("An error occurred while logging into the appropriate file."); 58 | e.printStackTrace(); 59 | 60 | } 61 | 62 | // Discord 63 | if (this.getTPS() <= Data.tpsMedium) { 64 | 65 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.TPS-Medium")).isEmpty()) { 66 | 67 | this.main.getDiscord().tps(Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.TPS-Medium")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%TPS%", String.valueOf(getTPS())), false); 68 | 69 | } 70 | 71 | } else if (this.getTPS() <= Data.tpsCritical) { 72 | 73 | if (!Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.TPS-Critical")).isEmpty()) { 74 | 75 | this.main.getDiscord().tps(Objects.requireNonNull(this.main.getMessages().get().getString("Discord.Server-Side.TPS-Critical")).replace("%time%", Data.dateTimeFormatter.format(ZonedDateTime.now())).replace("%TPS%", String.valueOf(getTPS())), false); 76 | } 77 | } 78 | 79 | // External 80 | if (Data.isExternal && this.main.getExternal().isConnected()) { 81 | 82 | try { 83 | 84 | if (this.getTPS() <= Data.tpsMedium) { 85 | 86 | ExternalData.tps(Data.serverName, this.getTPS()); 87 | 88 | } else if (this.getTPS() <= Data.tpsCritical) { 89 | 90 | ExternalData.tps(Data.serverName, this.getTPS()); 91 | } 92 | } catch (Exception e) { e.printStackTrace(); } 93 | } 94 | 95 | // SQLite 96 | if (Data.isSqlite && this.main.getSqLite().isConnected()) { 97 | 98 | try { 99 | 100 | if (this.getTPS() <= Data.tpsMedium) { 101 | 102 | SQLiteData.insertTPS(Data.serverName, this.getTPS()); 103 | 104 | } else if (this.getTPS() <= Data.tpsCritical) { 105 | 106 | SQLiteData.insertTPS(Data.serverName, this.getTPS()); 107 | } 108 | } catch (Exception e) { e.printStackTrace(); } 109 | } 110 | } 111 | } 112 | } 113 | 114 | private double getTPS() { 115 | return getTPS(100); 116 | } 117 | 118 | private double getTPS(int ticks) { 119 | 120 | if (this.tickCount <= ticks) return 20.0D; 121 | int target = (this.tickCount - 1 - ticks) % this.ticks.length; 122 | long elapsed = System.currentTimeMillis() - this.ticks[target]; 123 | return ticks / (elapsed / 1000.0D); 124 | 125 | } 126 | } -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/ASCIIArt.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils; 2 | 3 | public class ASCIIArt { 4 | 5 | public void art() { 6 | 7 | final String reset = "\u001B[0m"; 8 | final String purple = "\u001B[35m"; 9 | final String aqua = "\u001B[36m"; 10 | final String red = "\u001B[31m"; 11 | final String yellow = "\u001B[33m"; 12 | final String gold = "\u001B[33m"; 13 | final String white = "\u001B[37m"; 14 | final String blue = "\u001B[34m"; 15 | 16 | Log.info(purple + "\n|\n" + 17 | purple + "|" + aqua + " __ \n" + 18 | purple + "|" + aqua + " / / ____ ____ _____ ____ _____\n" + 19 | purple + "|" + aqua + " / / / __ \\/ __ `/ __ `/ _ \\/ ___/\n" + 20 | purple + "|" + aqua + " / /___/ /_/ / /_/ / /_/ / __/ / \n" + 21 | purple + "|" + aqua + " /_____/\\____/\\__, /\\__, /\\___/_/ \n" + 22 | purple + "|" + aqua + " /____//____/ " + red + Data.pluginVersion + yellow + " [ Bukkit Version ] \n" + 23 | purple + "|\n" + 24 | purple + "|" + gold + " This is a DEV Build, please report any issues!\n" + purple + "|\n" + 25 | purple + "|" + white + " Discord " + blue + "https://discord.gg/MfR5mcpVfX\n" + 26 | purple + "|"+ reset); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/BedrockChecker.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils; 2 | 3 | import me.prism3.logger.api.FloodGateUtil; 4 | import org.geysermc.floodgate.api.FloodgateApi; 5 | 6 | import java.util.UUID; 7 | 8 | public class BedrockChecker { 9 | 10 | private BedrockChecker() {} 11 | 12 | public static boolean isBedrock(UUID playerUUID) { 13 | 14 | if (!FloodGateUtil.getFloodGateAPI()) return false; 15 | 16 | return FloodgateApi.getInstance().isFloodgatePlayer(playerUUID); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/FileUpdater.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils; 2 | 3 | import me.prism3.logger.Logger; 4 | import org.bukkit.configuration.file.YamlConfiguration; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.InputStreamReader; 9 | import java.nio.charset.StandardCharsets; 10 | import java.util.Objects; 11 | 12 | public class FileUpdater { 13 | 14 | public FileUpdater(final File dataFolder) { 15 | this.updateYamlConfig(dataFolder, "config.yml"); 16 | this.updateYamlConfig(dataFolder, "discord.yml"); 17 | } 18 | 19 | private void updateYamlConfig(final File dataFolder, final String fileName) { 20 | 21 | final File configFile = new File(dataFolder + File.separator + fileName); 22 | final YamlConfiguration externalYamlConfig = YamlConfiguration.loadConfiguration(configFile); 23 | 24 | final InputStreamReader defConfigStream = new InputStreamReader( 25 | Objects.requireNonNull(Logger.getInstance().getResource(fileName)), StandardCharsets.UTF_8); 26 | 27 | final YamlConfiguration internalConfigFile = YamlConfiguration.loadConfiguration(defConfigStream); 28 | 29 | for (String config : internalConfigFile.getKeys(true)) { 30 | if (!externalYamlConfig.contains(config)) { 31 | externalYamlConfig.set(config, internalConfigFile.get(config)); 32 | } 33 | } 34 | 35 | try { 36 | externalYamlConfig.save(configFile); 37 | } catch (final IOException io) { io.printStackTrace(); } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/Log.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils; 2 | 3 | import java.util.logging.Logger; 4 | 5 | 6 | /** 7 | * The Log class is a utility class that provides a simple interface for logging messages using the Java Logging API. 8 | * The class is final and contains only static methods, which cannot be overridden or instantiated, 9 | * making it impossible to create instances of it. 10 | */ 11 | public final class Log { 12 | 13 | private Log() {} 14 | 15 | private static Logger logger; 16 | 17 | /** 18 | * Sets up the logger to be used by the Log class. 19 | * 20 | * @param log The logger to be used. 21 | */ 22 | public static void setup(final Logger log) { Log.logger = log; } 23 | 24 | /** 25 | * Logs an info level message. 26 | * 27 | * @param message The message to be logged. 28 | */ 29 | public static void info(final String message) { logger.info(message); } 30 | 31 | /** 32 | * Logs a warning level message. 33 | * 34 | * @param message The message to be logged. 35 | */ 36 | public static void warning(final String message) { logger.warning(message); } 37 | 38 | /** 39 | * Logs a severe level message. 40 | * 41 | * @param message The message to be logged. 42 | */ 43 | public static void severe(final String message) { logger.severe(message); } 44 | } -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/enums/FriendlyEnchants.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils.enums; 2 | 3 | import org.bukkit.enchantments.Enchantment; 4 | 5 | public enum FriendlyEnchants { 6 | 7 | ARROW_DAMAGE("Power"), 8 | ARROW_FIRE("Flame"), 9 | ARROW_INFINITE("Infinite"), 10 | ARROW_KNOCKBACK("Punch"), 11 | BINDING_CURSE("Curse of Binding",true), 12 | CHANNELING("Channeling"), 13 | DAMAGE_ALL("Sharpness"), 14 | DAMAGE_ARTHROPODS("Bane of Arthropods"), 15 | DAMAGE_UNDEAD("Smite"), 16 | DEPTH_STRIDER("Depth Strider"), 17 | DIG_SPEED("Efficiency"), 18 | DURABILITY("Unbreaking"), 19 | FIRE_ASPECT("Fire Aspect"), 20 | FROST_WALKER("Frost Walker"), 21 | IMPALING("Impaling"), 22 | KNOCKBACK("Knockback"), 23 | LOOT_BONUS_BLOCKS("Fortune"), 24 | LOOT_BONUS_MOBS("Looting"), 25 | LOYALTY("Loyalty"), 26 | LUCK("Luck of the Sea"), 27 | LURE("Lure"), 28 | MENDING("Mending"), 29 | MULTISHOT("Multishot"), 30 | OXYGEN("Respiration"), 31 | PIERCING("Piercing"), 32 | PROTECTION_ENVIRONMENTAL("Protection"), 33 | PROTECTION_EXPLOSIONS("Blast Protection"), 34 | PROTECTION_FALL("Feather Falling"), 35 | PROTECTION_FIRE("Fire Protection"), 36 | PROTECTION_PROJECTILE("Projectile Protection"), 37 | QUICK_CHARGE("Quick Charge"), 38 | RIPTIDE("Riptide"), 39 | SILK_TOUCH("Silk Touch"), 40 | SOUL_SPEED("Soul Speed"), 41 | SWEEPING_EDGE("Sweeping Edge"), 42 | THORNS("Thorns"), 43 | VANISHING_CURSE("Curse of Vanishing",true), 44 | WATER_WORKER("Aqua Affinity"), 45 | BREACH("Breach"), 46 | DENSITY("Density"), 47 | WIND_BURST("Wind Burst"); 48 | private final String friendlyName; 49 | private final boolean isCurse; 50 | 51 | FriendlyEnchants(String friendlyName, boolean isCurse) { 52 | this.friendlyName = friendlyName; 53 | this.isCurse = isCurse; 54 | } 55 | 56 | FriendlyEnchants(String friendlyName) { 57 | this(friendlyName,false); 58 | } 59 | 60 | @SuppressWarnings("deprecation") 61 | public static FriendlyEnchants getFriendlyEnchantment(Enchantment ench) { 62 | return FriendlyEnchants.valueOf(ench.getName()); 63 | } 64 | 65 | public String getFriendlyName() { return friendlyName; } 66 | 67 | public boolean isCurse() { return isCurse; } 68 | } 69 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/enums/Languages.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils.enums; 2 | 3 | public enum Languages { 4 | 5 | AR("ar"), 6 | DA("da"), 7 | DE("de"), 8 | EN("en_en"), 9 | EU("eu"), 10 | FR("fr_fr"), 11 | JA("ja"), 12 | NL("nl"), 13 | RU("ru"), 14 | TR("tr"), 15 | ZHT("zh_cht"), 16 | ZH("zh_cn"); 17 | 18 | private final String messageFile; 19 | 20 | Languages(String status) { this.messageFile = status; } 21 | 22 | public String getMessageFile() { return this.messageFile; } 23 | } -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/enums/NmsVersions.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils.enums; 2 | 3 | public enum NmsVersions { 4 | 5 | v1_7_R1, 6 | v1_7_R2, 7 | v1_7_R3, 8 | v1_7_R4, 9 | v1_8_R1, 10 | v1_8_R2, 11 | v1_8_R3, 12 | v1_9_R1, 13 | v1_9_R2, 14 | v1_10_R1, 15 | v1_11_R1, 16 | v1_12_R1, 17 | v1_13_R1, 18 | v1_13_R2, 19 | v1_14_R1, 20 | v1_15_R1, 21 | v1_16_R1, 22 | v1_16_R2, 23 | v1_16_R3, 24 | v1_17_R1, 25 | v1_18_R1, 26 | v1_18_R2, 27 | v1_19_R1, 28 | v1_19_R2, 29 | v1_19_R3, 30 | v1_20_R1, 31 | v1_20_R2, 32 | v1_20_R3, 33 | v1_20_R4; 34 | 35 | public boolean isAtLeast(NmsVersions version) { 36 | return this.ordinal() >= version.ordinal(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/enums/ViaProtocolVersions.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils.enums; 2 | 3 | public enum ViaProtocolVersions { 4 | 5 | v1_8, 6 | 7 | } 8 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/litebansutil/UsernameFetcher.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils.litebansutil; 2 | 3 | import litebans.api.Database; 4 | 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | 9 | public class UsernameFetcher { 10 | 11 | private UsernameFetcher() {} 12 | 13 | public static String playerNameFetcher(String uuid) { 14 | 15 | String name = ""; 16 | final String query = "SELECT name from {history} WHERE uuid=? ORDER BY date DESC LIMIT 1"; 17 | 18 | try (final PreparedStatement st = Database.get().prepareStatement(query)) { 19 | 20 | st.setString(1, uuid); 21 | 22 | try (ResultSet rs = st.executeQuery()) { 23 | 24 | if (rs.next()) { 25 | 26 | name = rs.getString("name"); 27 | 28 | } 29 | } 30 | 31 | } catch (SQLException e) { e.printStackTrace(); } 32 | 33 | return name; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/playerdeathutils/InventoryToBase64.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils.playerdeathutils; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | import org.bukkit.util.io.BukkitObjectInputStream; 5 | import org.bukkit.util.io.BukkitObjectOutputStream; 6 | import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; 7 | 8 | import java.io.ByteArrayInputStream; 9 | import java.io.ByteArrayOutputStream; 10 | import java.io.IOException; 11 | 12 | public class InventoryToBase64 { 13 | 14 | private InventoryToBase64() {} 15 | 16 | public static String toBase64(ItemStack[] contents) { 17 | boolean convert = false; 18 | 19 | for (ItemStack item : contents) { 20 | if (item != null) { 21 | convert = true; 22 | break; 23 | } 24 | } 25 | 26 | if (convert) { 27 | try { 28 | final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 29 | final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); 30 | 31 | dataOutput.writeInt(contents.length); 32 | 33 | for (ItemStack stack : contents) { 34 | dataOutput.writeObject(stack); 35 | } 36 | 37 | dataOutput.close(); 38 | 39 | byte[] byteArr = outputStream.toByteArray(); 40 | 41 | return Base64Coder.encodeLines(byteArr); 42 | } catch (Exception e) { 43 | throw new IllegalStateException("An error has occurred whilst saving the Player Inventory. Does the proper file exists? If the issue persists, contact the Authors!", e); 44 | } 45 | } 46 | 47 | return null; 48 | } 49 | 50 | public static ItemStack[] stacksFromBase64(String data) { 51 | 52 | if (data == null) return new ItemStack[]{}; 53 | 54 | ByteArrayInputStream inputStream; 55 | 56 | try { 57 | inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); 58 | } catch (IllegalArgumentException e) { 59 | return new ItemStack[]{}; 60 | } 61 | 62 | BukkitObjectInputStream dataInput = null; 63 | ItemStack[] stacks = null; 64 | 65 | try { 66 | dataInput = new BukkitObjectInputStream(inputStream); 67 | stacks = new ItemStack[dataInput.readInt()]; 68 | } catch (IOException e1) { 69 | e1.printStackTrace(); 70 | } 71 | 72 | if (stacks == null) return new ItemStack[]{}; 73 | 74 | for (int i = 0; i < stacks.length; i++) { 75 | try { 76 | stacks[i] = (ItemStack) dataInput.readObject(); 77 | } catch (IOException | ClassNotFoundException | NullPointerException e) { 78 | 79 | try { dataInput.close(); } catch (IOException ignored) {} 80 | 81 | return new ItemStack[0]; 82 | } 83 | } 84 | 85 | try { dataInput.close(); } catch (IOException ignored) {} 86 | 87 | return stacks; 88 | } 89 | } -------------------------------------------------------------------------------- /Logger-Spigot/src/main/java/me/prism3/logger/utils/playerdeathutils/PlayerFolder.java: -------------------------------------------------------------------------------- 1 | package me.prism3.logger.utils.playerdeathutils; 2 | 3 | import me.prism3.logger.utils.FileHandler; 4 | import org.bukkit.configuration.InvalidConfigurationException; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | import org.bukkit.configuration.file.YamlConfiguration; 7 | import org.bukkit.entity.Player; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.nio.file.Files; 12 | import java.nio.file.Path; 13 | import java.nio.file.Paths; 14 | import java.text.SimpleDateFormat; 15 | import java.util.ArrayList; 16 | import java.util.Collection; 17 | import java.util.Date; 18 | import java.util.stream.Stream; 19 | 20 | import static me.prism3.logger.utils.Data.allowedBackups; 21 | 22 | public class PlayerFolder { 23 | 24 | private File playerFile; 25 | 26 | // Create the backup file for the appropriate player 27 | public void create(Player player) { 28 | 29 | final Date date = new Date(); 30 | final SimpleDateFormat filenameDateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); 31 | 32 | final File backupFolder = new File(FileHandler.getPlayerDeathBackupLogFolder(), player.getName()); 33 | 34 | this.playerFile = new File(backupFolder, filenameDateFormat.format(date) + ".yml"); 35 | 36 | try { 37 | 38 | if (!backupFolder.exists()) backupFolder.mkdir(); 39 | 40 | this.playerFile.createNewFile(); 41 | 42 | this.fileInput(this.playerFile, player); 43 | 44 | } catch (Exception e) { e.printStackTrace(); } 45 | } 46 | 47 | // Grabs the file from the above method and writes into it 48 | private void fileInput(File file, Player player) throws IOException, InvalidConfigurationException { 49 | 50 | final FileConfiguration yaml = YamlConfiguration.loadConfiguration(file); 51 | yaml.load(file); 52 | 53 | yaml.set("player-name", player.getName()); 54 | yaml.set("player-uuid", player.getUniqueId().toString()); 55 | yaml.set("world", player.getWorld().getName()); 56 | yaml.set("x", player.getLocation().getBlockX()); 57 | yaml.set("y", player.getLocation().getBlockY()); 58 | yaml.set("z", player.getLocation().getBlockZ()); 59 | yaml.set("xp", player.getLevel()); 60 | yaml.createSection("inventory"); 61 | yaml.createSection("armor"); 62 | 63 | yaml.save(file); 64 | 65 | } 66 | 67 | // Counts the total backup files of a player 68 | public static int backupCount(Player player) { 69 | 70 | final File backupFolder = new File(FileHandler.getPlayerDeathBackupLogFolder(), player.getName()); 71 | 72 | int backupCount = 0; 73 | 74 | if (backupFolder.getParentFile().list() != null) { 75 | try (Stream files = Files.list(Paths.get(String.valueOf(backupFolder)))) { 76 | long count = files.count(); 77 | backupCount = (int) count; 78 | } catch (Exception ignored) {} 79 | } 80 | return backupCount; 81 | } 82 | 83 | // Stores all backup files names 84 | public static String[] fileNames(Player player) { 85 | 86 | if (backupCount(player) == 0) return new String[0]; 87 | 88 | File dir = new File(FileHandler.getPlayerDeathBackupLogFolder(), player.getName()); 89 | 90 | Collection files = new ArrayList<>(); 91 | 92 | File[] listFiles = dir.listFiles(); 93 | 94 | assert listFiles != null; 95 | 96 | for (File file : listFiles) { 97 | files.add(file.getName().replace("\\.\\w+", "")); 98 | } 99 | 100 | return files.toArray(new String[0]); 101 | } 102 | 103 | // Check if it's allowed to make a new backup file 104 | public boolean isAllowed(Player player) { 105 | return backupCount(player) < allowedBackups; // We did '<' since backCount method starts at 0 106 | } 107 | 108 | public File getPlayerFile() { return this.playerFile; } 109 | } 110 | -------------------------------------------------------------------------------- /Logger-Spigot/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | # ///////////////////////////////////////////////////////////// 2 | # / / 3 | # / Logger Plugin / 4 | # / / 5 | # / [ Bukkit Version ] / 6 | # / / 7 | # ///////////////////////////////////////////////////////////// 8 | # Thank you for using Logger Plugin! If you are experiencing any issues 9 | # or have any suggestions / features you want to be implemented into the plugin 10 | # feel free to join the support Discord Server! 11 | # Spigot: Prism3 12 | # Discord: Prism3#9371 ID: 403667971089760257 13 | # Discord Server: https://discord.gg/MfR5mcpVfX 14 | # Config: 1.8.0.15 15 | Language: en_en 16 | Server-Name: "Server_Name" 17 | Plugin-Prefix: "&bLogger &8&l|&r " 18 | Time-Formatter: "yyyy-MM-dd HH:mm:ss" 19 | File-Deletion: 7 20 | Log-to-Files: true 21 | Staff: 22 | Enabled: false 23 | Log-Player: 24 | Chat: true 25 | Commands: true 26 | Sign-Text: true 27 | Join: true 28 | Leave: true 29 | Kick: true 30 | Death: true 31 | Teleport: true 32 | Level: true 33 | Block-Place: true 34 | Block-Break: true 35 | Bucket-Fill: true 36 | Bucket-Empty: true 37 | Anvil: true 38 | Item-Pickup: true 39 | Item-Drop: true 40 | Enchanting: true 41 | Book-Editing: true 42 | Furnace: true 43 | Game-Mode: true 44 | Craft: true 45 | Registration: true 46 | Primed-TNT: true 47 | Chest-Interaction: true 48 | Entity-Death: true 49 | Sign-Change: true 50 | Log-Server: 51 | Start: true 52 | Stop: true 53 | Console-Commands: true 54 | RAM: true 55 | TPS: true 56 | Portal-Creation: true 57 | RCON: true 58 | Command-Block: true 59 | Log-Extras: 60 | Essentials-AFK: true 61 | AuthMe-Wrong-Password: true 62 | Vault: true 63 | LiteBans: true 64 | AdvancedBan: true 65 | Log-Version-Exceptions: 66 | Wood-Stripping: true 67 | Player-Commands: 68 | Whitelist-Commands: false 69 | Commands-to-Log: 70 | - /msg 71 | - /sell 72 | - /plugins 73 | - /pl 74 | - /about 75 | Blacklist-Commands: true 76 | Commands-to-Block: 77 | - /login 78 | - /changepassword 79 | - /register 80 | Player-Join: 81 | Player-IP: false 82 | Player-Level: 83 | Log-Above: 100 84 | Game-Mode: Creative 85 | Player-Death-Backup: 86 | Enabled: true 87 | Max-Backup: 7 88 | Console-Commands: 89 | Blacklist-Commands: false 90 | Commands-to-Block: 91 | - list 92 | - op 93 | - ban 94 | RAM-TPS-Checker: 6000 95 | Vault-Checker: 6000 96 | RAM: 97 | Percent: 50 98 | TPS: 99 | Value-Medium: 16 100 | Value-Critical: 7 101 | Spy-Features: 102 | Commands-Spy: 103 | Enable: false 104 | Message: "&8[&bLogger &8&l| &eCommand-Spy&8] &7%player% >> %cmd%" 105 | Book-Spy: 106 | Enable: false 107 | Message: "&8[&bLogger &8&l| &eBook-Spy&8] &7%player% >> %content%" 108 | Sign-Spy: 109 | Enable: false 110 | Message: "&8[&bLogger &8&l| &eSign-Spy&8] &7%player% >> %line1%, %line2%, %line3%, %line4%" 111 | Anvil-Spy: 112 | Enable: false 113 | Message: "&8[&bLogger &8&l| &eAnvil-Spy&8] &7%player% >> %renamed%" 114 | Database: 115 | Enable: false 116 | Type: MySQL 117 | Host: localhost 118 | Port: 3306 119 | Username: username 120 | Password: PassworD 121 | Database: database 122 | Data-Deletion: 7 123 | SQLite: 124 | Enable: false 125 | Data-Deletion: 7 126 | Update-Checker: true -------------------------------------------------------------------------------- /Logger-Spigot/src/main/resources/discord.yml: -------------------------------------------------------------------------------- 1 | # Discord Bridge Configuration for Logger Plugin [ Bukkit Version] 2 | # Need Support Join the Discord Server: https://discord.gg/MfR5mcpVfX 3 | # Config: 1.8.0.15 4 | # Leaving Channel-ID empty will disable the Channel 5 | Discord: 6 | Enable: false 7 | Bot-Token: BOT_KEY 8 | Staff: 9 | Channel-ID: 'CHANNEL_ID' 10 | Player-Chat: 11 | Channel-ID: 'CHANNEL_ID' 12 | Player-Commands: 13 | Channel-ID: 'CHANNEL_ID' 14 | Player-Sign-Text: 15 | Channel-ID: 'CHANNEL_ID' 16 | Player-Join: 17 | Channel-ID: 'CHANNEL_ID' 18 | Player-Leave: 19 | Channel-ID: 'CHANNEL_ID' 20 | Player-Kick: 21 | Channel-ID: 'CHANNEL_ID' 22 | Player-Death: 23 | Channel-ID: 'CHANNEL_ID' 24 | Player-Teleport: 25 | Channel-ID: 'CHANNEL_ID' 26 | Player-Level: 27 | Channel-ID: 'CHANNEL_ID' 28 | Block-Place: 29 | Channel-ID: 'CHANNEL_ID' 30 | Block-Break: 31 | Channel-ID: 'CHANNEL_ID' 32 | Bucket-Fill: 33 | Channel-ID: 'CHANNEL_ID' 34 | Bucket-Empty: 35 | Channel-ID: 'CHANNEL_ID' 36 | Anvil: 37 | Channel-ID: 'CHANNEL_ID' 38 | Item-Pickup: 39 | Channel-ID: 'CHANNEL_ID' 40 | Item-Drop: 41 | Channel-ID: 'CHANNEL_ID' 42 | Enchanting: 43 | Channel-ID: 'CHANNEL_ID' 44 | Book-Editing: 45 | Channel-ID: 'CHANNEL_ID' 46 | Furnace: 47 | Channel-ID: 'CHANNEL_ID' 48 | Game-Mode: 49 | Channel-ID: 'CHANNEL_ID' 50 | Craft: 51 | Channel-ID: 'CHANNEL_ID' 52 | Registration: 53 | Channel-ID: 'CHANNEL_ID' 54 | Primed-TNT: 55 | Channel-ID: 'CHANNEL_ID' 56 | Chest-Interaction: 57 | Channel-ID: 'CHANNEL_ID' 58 | Entity-Death: 59 | Channel-ID: 'CHANNEL_ID' 60 | Sign-Change: 61 | Channel-ID: 'CHANNEL_ID' 62 | # Server Side Checkers 63 | Server-Side: 64 | Start: 65 | Channel-ID: 'CHANNEL_ID' 66 | Stop: 67 | Channel-ID: 'CHANNEL_ID' 68 | Console-Commands: 69 | Channel-ID: 'CHANNEL_ID' 70 | RAM: 71 | Channel-ID: 'CHANNEL_ID' 72 | TPS: 73 | Channel-ID: 'CHANNEL_ID' 74 | Portal-Creation: 75 | Channel-ID: 'CHANNEL_ID' 76 | RCON: 77 | Channel-ID: 'CHANNEL_ID' 78 | Command-Block: 79 | Channel-ID: 'CHANNEL_ID' 80 | # Extra Side Checkers 81 | Extras: 82 | AFK: 83 | Channel-ID: 'CHANNEL_ID' 84 | Wrong-Password: 85 | Channel-ID: 'CHANNEL_ID' 86 | Vault: 87 | Channel-ID: 'CHANNEL_ID' 88 | LiteBans: 89 | Channel-ID: 'CHANNEL_ID' 90 | AdvancedBan: 91 | Channel-ID: 'CHANNEL_ID' 92 | Version-Exceptions: 93 | Wood-Stripping: 94 | Channel-ID: 'CHANNEL_ID' 95 | # Bot Activity Status 96 | # Randomize the shown status 97 | # First Part must not be different from 98 | # Playing, Watching, Listening, Streaming, Competing 99 | # Otherwise it will not work 100 | # Time in Seconds 101 | ActivityCycling: 102 | Enabled: true 103 | Random: false 104 | Activities: 105 | - ["watching", "Minecraft Movie"] 106 | - ["playing", "Minecraft 1.7"] 107 | - ["listening", "Dragon's Heart Beats"] 108 | - ["streaming", "Minecraft Gameplay"] 109 | Time: 30 -------------------------------------------------------------------------------- /Logger-Spigot/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Logger 2 | version: ${project.version} 3 | main: me.prism3.logger.Logger 4 | api-version: 1.13 5 | authors: [ Prism3, Sidna ] 6 | description: Log all Activities from Players and Server Side! 7 | softdepend: [Essentials, AuthMe, Vault, PlaceholderAPI, LiteBans, AdvancedBan, PlaceholderAPI, Geyser, Floodgate, ViaVersion, SuperiorSkyblock2] 8 | commands: 9 | logger: 10 | description: "Plugin command." 11 | logger reload: 12 | description: "Reloads the Plugin configs." 13 | logger dump: 14 | description: "Creates an online pastebin url of the plugin's config and discord." 15 | logger discord: 16 | description: "Display the discord support server link." 17 | logger playerinventory: 18 | description: "Opens a menu with all online players and their available backups." 19 | logger toggle: 20 | description: "Toggle spy features ON/OFF." 21 | permissions: 22 | logger.staff: 23 | description: "Allows the Player to execute Plugin Commands, spy on others actions, and view Plugin Updates." 24 | children: 25 | logger.reload: true 26 | logger.spy: true 27 | logger.update: true 28 | logger.exempt: 29 | description: "Prevents the Player from getting logged." 30 | children: 31 | logger.exempt.discord: true 32 | logger.exempt.discord: 33 | description: "Prevents the Player from getting discord logged." 34 | logger.reload: 35 | description: "Allows to Reload the Plugin." 36 | default: op 37 | logger.spy: 38 | description: "Ability to see other players' and Staff's actions." 39 | default: op 40 | logger.spy.bypass: 41 | description: "Ability to see other players and staff's Actions but others can not." 42 | default: op 43 | logger.staff.log: 44 | description: "Logs Staff Members." 45 | default: op 46 | children: 47 | logger.exempt: false 48 | logger.update: 49 | description: "Ability to receive Plugin Updates." 50 | default: op -------------------------------------------------------------------------------- /Logger-Velocity/dependency-reduced-pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Logger 5 | me.prism3 6 | 1.8.0.15 7 | 8 | 4.0.0 9 | Logger-Velocity 10 | Logger-Velocity 11 | 1.8.0.15 12 | Log all Activities from Players or Server Side! 13 | 14 | 15 | 16 | true 17 | ${project.basedir}/src/main/resources 18 | 19 | 20 | 21 | 22 | maven-compiler-plugin 23 | 3.8.1 24 | 25 | ${java.version} 26 | ${java.version} 27 | 28 | 29 | 30 | org.codehaus.mojo 31 | templating-maven-plugin 32 | 1.0.0 33 | 34 | 35 | filter-src 36 | 37 | filter-sources 38 | 39 | 40 | 41 | 42 | 43 | maven-site-plugin 44 | 3.9.1 45 | 46 | 47 | net.trajano.wagon 48 | wagon-git 49 | 2.0.4 50 | 51 | 52 | org.apache.maven.doxia 53 | doxia-module-markdown 54 | 1.9.1 55 | 56 | 57 | 58 | 59 | maven-release-plugin 60 | 3.0.0-M1 61 | 62 | true 63 | @{project.version} 64 | [RELEASE] 65 | install deploy site-deploy 66 | release 67 | 68 | 69 | 70 | maven-shade-plugin 71 | 3.2.4 72 | 73 | 74 | package 75 | 76 | shade 77 | 78 | 79 | 80 | 81 | 82 | 83 | org.bstats 84 | me.prism3.org.bstats 85 | 86 | 87 | com.zaxxer 88 | me.prism3.com.zaxxer 89 | 90 | 91 | org.mariadb 92 | me.prism3.org.mariadb 93 | 94 | 95 | com.mysql 96 | me.prism3.com.mysql 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | velocitypowered-repo 106 | https://nexus.velocitypowered.com/repository/maven-public/ 107 | 108 | 109 | jitpack.io 110 | https://jitpack.io 111 | 112 | 113 | 114 | 115 | com.velocitypowered 116 | velocity-api 117 | 3.1.1 118 | provided 119 | 120 | 121 | com.gitlab.ruany 122 | LiteBansAPI 123 | 0.3.5 124 | provided 125 | 126 | 127 | 128 | 1.8 129 | UTF-8 130 | 131 | 132 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/api/LiteBansUtil.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.api; 2 | 3 | import com.velocitypowered.api.plugin.PluginContainer; 4 | import me.prism3.loggervelocity.Logger; 5 | 6 | import java.util.Optional; 7 | 8 | public class LiteBansUtil { 9 | 10 | private LiteBansUtil() {} 11 | 12 | public static Optional getLiteBansAPI() { 13 | 14 | return Logger.getServer().getPluginManager().getPlugin("LiteBans"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/commands/DiscordCMD.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.commands; 2 | 3 | import com.velocitypowered.api.command.CommandSource; 4 | import com.velocitypowered.api.command.SimpleCommand; 5 | import me.prism3.loggervelocity.Logger; 6 | import net.kyori.adventure.identity.Identity; 7 | import net.kyori.adventure.text.Component; 8 | 9 | import static me.prism3.loggervelocity.utils.Data.*; 10 | 11 | public class DiscordCMD implements SimpleCommand{ 12 | 13 | private final Logger main = Logger.getInstance(); 14 | 15 | @Override 16 | public void execute(Invocation invocation) { 17 | 18 | final CommandSource sender = invocation.source(); 19 | final String[] args = invocation.arguments(); 20 | 21 | if (sender.hasPermission(loggerReload)) { 22 | 23 | if (args.length == 0) { 24 | 25 | sender.sendMessage(Identity.nil(), Component.text("Thank you for using the Logger Plugin!")); 26 | 27 | } else if (args.length == 1 && args[0].equalsIgnoreCase("discord")) { 28 | 29 | sender.sendMessage(Identity.nil(), Component.text(discordSupportServer)); 30 | 31 | } else { 32 | 33 | sender.sendMessage(Identity.nil(), Component.text(this.main.getMessages().getString("General.Invalid-Syntax").replace("%prefix%", pluginPrefix))); 34 | 35 | } 36 | } else { 37 | 38 | sender.sendMessage(Identity.nil(), Component.text(this.main.getMessages().getString("General.No-Permission").replace("%prefix%", pluginPrefix))); 39 | 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/commands/Reload.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.commands; 2 | 3 | import com.velocitypowered.api.command.CommandSource; 4 | import com.velocitypowered.api.command.SimpleCommand; 5 | import me.prism3.loggervelocity.Logger; 6 | import net.kyori.adventure.identity.Identity; 7 | import net.kyori.adventure.text.Component; 8 | 9 | import static me.prism3.loggervelocity.utils.Data.loggerReload; 10 | import static me.prism3.loggervelocity.utils.Data.pluginPrefix; 11 | 12 | public class Reload implements SimpleCommand { 13 | 14 | private final Logger main = Logger.getInstance(); 15 | 16 | @Override 17 | public void execute(Invocation invocation) { 18 | 19 | final CommandSource sender = invocation.source(); 20 | final String[] args = invocation.arguments(); 21 | 22 | if (sender.hasPermission(loggerReload)) { 23 | 24 | if (args.length == 0) { 25 | 26 | sender.sendMessage(Identity.nil(), Component.text("Thank you for using the Logger Plugin!")); 27 | 28 | } else if (args.length == 1 && args[0].equalsIgnoreCase("reload")) { 29 | 30 | this.main.getMessages().reload(); 31 | 32 | sender.sendMessage(Identity.nil(), Component.text(this.main.getMessages().getString("General.Reload").replace("%prefix%", pluginPrefix))); 33 | 34 | } else { 35 | 36 | sender.sendMessage(Identity.nil(), Component.text(this.main.getMessages().getString("General.Invalid-Syntax").replace("%prefix%", pluginPrefix))); 37 | 38 | } 39 | } else { 40 | 41 | sender.sendMessage(Identity.nil(), Component.text(this.main.getMessages().getString("General.No-Permission").replace("%prefix%", pluginPrefix))); 42 | 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/database/external/External.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.database.external; 2 | 3 | import com.zaxxer.hikari.HikariDataSource; 4 | import me.prism3.loggervelocity.Logger; 5 | import me.prism3.loggervelocity.utils.Data; 6 | 7 | public class External { 8 | 9 | private final Logger main = Logger.getInstance(); 10 | 11 | private String jdbc; 12 | private static final String DATATYPE = Data.dbType.toLowerCase(); 13 | private static final String HOST = Data.dbHost; 14 | private static final int PORT = Data.dbPort; 15 | private static final String USERNAME = Data.dbUserName; 16 | private static final String PASSWORD = Data.dbPassword; 17 | private static final String DATABASE = Data.dbName; 18 | private HikariDataSource hikari; 19 | 20 | public boolean isConnected() { 21 | return this.hikari != null; 22 | } 23 | 24 | public void connect() { 25 | 26 | String jdbcDriver; 27 | final String mySQL = "MySQL"; 28 | final String mySQLDriver = "com.mysql.cj.jdbc.Driver"; 29 | final String mariaDB = "mariadb"; 30 | final String mariaDBDriver = "org.mariadb.jdbc.Driver"; 31 | 32 | switch (DATATYPE) { 33 | 34 | case "mysql": 35 | this.jdbc = mySQL; 36 | jdbcDriver = mySQLDriver; 37 | break; 38 | 39 | case "mariadb": 40 | this.jdbc = mariaDB; 41 | jdbcDriver = mariaDBDriver; 42 | break; 43 | 44 | default: 45 | this.main.getLogger().error("Unknown Database Type. Available ones are: MySQL and MariaDB."); 46 | return; 47 | 48 | } 49 | 50 | if (!isConnected()) { 51 | 52 | hikari = new HikariDataSource(); 53 | hikari.setDriverClassName(jdbcDriver); 54 | hikari.setJdbcUrl(this.getJdbcUrl()); 55 | hikari.addDataSourceProperty("user", USERNAME); 56 | hikari.addDataSourceProperty("password", PASSWORD); 57 | this.main.getLogger().info(this.jdbc + " Connection has been established!"); 58 | 59 | } 60 | } 61 | 62 | public void disconnect() { 63 | 64 | if (isConnected()) { 65 | 66 | this.hikari.close(); 67 | this.main.getLogger().info(this.jdbc + " Connection has been closed!"); 68 | 69 | } 70 | } 71 | 72 | private String getJdbcUrl() { 73 | return "jdbc:" + this.jdbc + "://" + External.HOST + ":" + External.PORT + "/" + External.DATABASE 74 | + "?AllowPublicKeyRetrieval=true?useSSL=false&jdbcCompliantTruncation=false"; 75 | 76 | } 77 | 78 | public HikariDataSource getHikari() { 79 | return this.hikari; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/database/external/ExternalUpdater.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.database.external; 2 | 3 | import me.prism3.loggervelocity.Logger; 4 | import me.prism3.loggervelocity.utils.Data; 5 | 6 | import java.sql.Connection; 7 | import java.sql.DatabaseMetaData; 8 | import java.sql.PreparedStatement; 9 | import java.sql.ResultSet; 10 | import java.util.List; 11 | 12 | public class ExternalUpdater { 13 | 14 | private ExternalUpdater() {} 15 | 16 | public static void updater() { 17 | 18 | final Logger main = Logger.getInstance(); 19 | 20 | int i = 0; 21 | boolean keys = false; 22 | boolean playerName = false; 23 | 24 | if (Data.isExternal && main.getExternal().isConnected()) { 25 | 26 | final List index = ExternalData.getTablesNames(); 27 | 28 | // Primary Key removal Method 29 | try { 30 | 31 | for (String ignored : index) { 32 | 33 | final Connection connection = main.getExternal().getHikari().getConnection(); 34 | final DatabaseMetaData databaseMetaData = connection.getMetaData(); 35 | 36 | final ResultSet resultSet = databaseMetaData.getPrimaryKeys(null, null, index.get(i)); 37 | 38 | while (resultSet.next()) { 39 | 40 | final String primaryKeys = resultSet.getString(4); 41 | 42 | if (primaryKeys.contains("Date")) { 43 | 44 | final PreparedStatement ps1 = connection.prepareStatement("ALTER TABLE " + index.get(i) + " DROP PRIMARY KEY"); 45 | ps1.executeUpdate(); 46 | ps1.close(); 47 | 48 | keys = true; 49 | } 50 | } 51 | 52 | // Playername Renaming method 53 | 54 | final PreparedStatement desc = connection.prepareStatement("DESC " + index.get(i)); 55 | final ResultSet query = desc.executeQuery(); 56 | 57 | while (query.next()) { 58 | 59 | final String field = query.getString("Field"); 60 | 61 | if (field.contains("Playername")) { 62 | 63 | final PreparedStatement pS2 = connection.prepareStatement("ALTER TABLE " + index.get(i) + " CHANGE Playername Player_Name Varchar(30)"); 64 | pS2.executeUpdate(); 65 | pS2.close(); 66 | 67 | playerName = true; 68 | } 69 | } 70 | i++; 71 | } 72 | } catch (Exception e) { 73 | 74 | main.getLogger().error("Unable to update the tables. If the issue persists contact the Author!"); 75 | e.printStackTrace(); 76 | 77 | } 78 | } 79 | if (keys && playerName) main.getLogger().info("All Tables have been Updated!"); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/database/sqlite/SQLite.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.database.sqlite; 2 | 3 | import me.prism3.loggervelocity.Logger; 4 | 5 | import java.io.File; 6 | import java.sql.Connection; 7 | import java.sql.DriverManager; 8 | import java.sql.SQLException; 9 | 10 | public class SQLite { 11 | 12 | private final org.slf4j.Logger logger = Logger.getInstance().getLogger(); 13 | 14 | private Connection connection; 15 | 16 | private final File databaseFile = new File(Logger.getInstance().getFolder().toFile(), "LoggerData - Velocity.db"); 17 | 18 | public void connect() { 19 | 20 | if (!isConnected()) { 21 | 22 | try { 23 | 24 | Class.forName("org.sqlite.JDBC"); 25 | this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.databaseFile.getAbsolutePath()); 26 | this.logger.info("SQLite Connection has been established!"); 27 | 28 | } catch (ClassNotFoundException | SQLException e) { 29 | 30 | this.logger.error("Couldn't load SQLite Database, if the issue persists contact the Authors!"); 31 | e.printStackTrace(); 32 | 33 | } 34 | } 35 | } 36 | 37 | public void disconnect() { 38 | 39 | if (isConnected()) { 40 | 41 | try { 42 | 43 | this.connection.close(); 44 | this.logger.info("SQLite Database has been closed!"); 45 | 46 | } catch (SQLException e) { 47 | 48 | this.logger.error("SQLite Database couldn't be closed safely, if the issue persists contact the Authors!"); 49 | e.printStackTrace(); 50 | 51 | } 52 | } 53 | } 54 | 55 | public Connection getConnection() { return this.connection; } 56 | 57 | public boolean isConnected() { return (this.connection != null); } 58 | } 59 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/discord/DiscordFile.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.discord; 2 | 3 | import com.google.common.io.ByteStreams; 4 | import me.prism3.loggervelocity.Logger; 5 | import me.prism3.loggervelocity.utils.ConfigManager; 6 | import me.prism3.loggervelocity.utils.config.Configuration; 7 | import me.prism3.loggervelocity.utils.config.ConfigurationProvider; 8 | import me.prism3.loggervelocity.utils.config.StringUtils; 9 | import me.prism3.loggervelocity.utils.config.YamlConfiguration; 10 | 11 | import java.io.*; 12 | 13 | public class DiscordFile { 14 | 15 | private final File file; 16 | private Configuration configuration; 17 | 18 | public DiscordFile() { 19 | 20 | final File dataFolder = Logger.getInstance().getFolder().toFile(); 21 | this.file = new File(dataFolder, "discord - Velocity.yml"); 22 | 23 | try { 24 | 25 | if (!this.file.exists()) { 26 | 27 | if (!dataFolder.exists()) { dataFolder.mkdir(); } 28 | 29 | this.file.createNewFile(); 30 | 31 | try (final InputStream is = ConfigManager.class.getResourceAsStream("/discord - Velocity.yml"); 32 | final OutputStream os = new FileOutputStream(this.file)) { 33 | assert is != null; 34 | ByteStreams.copy(is, os); 35 | } 36 | } 37 | this.configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file); 38 | } 39 | catch (IOException e) { e.printStackTrace(); } 40 | } 41 | 42 | public File getFile() { return this.file; } 43 | 44 | public Configuration get() { return this.configuration; } 45 | 46 | public boolean getBoolean(final String path) { 47 | 48 | return this.configuration.get(path) != null && this.configuration.getBoolean(path); 49 | 50 | } 51 | 52 | public String getString(final String path) { 53 | 54 | if (this.configuration.get(path) != null) { 55 | 56 | return StringUtils.translateAlternateColorCodes('&', this.configuration.getString(path)); 57 | 58 | } return "String at path: " + path + " not found!"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/discord/DiscordStatus.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.discord; 2 | 3 | import me.prism3.loggervelocity.Logger; 4 | import net.dv8tion.jda.api.JDA; 5 | import net.dv8tion.jda.api.entities.Activity; 6 | 7 | import java.util.Collections; 8 | import java.util.List; 9 | import java.util.concurrent.Executors; 10 | import java.util.concurrent.ScheduledExecutorService; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | public class DiscordStatus { 14 | 15 | private final Logger main = Logger.getInstance(); 16 | private final JDA jda = new Discord().getJda(); 17 | 18 | private int currentIndex = 0; 19 | private final List> activities = (List>) this.main.getDiscordFile().get().get("ActivityCycling.Activities"); 20 | 21 | private static final ScheduledExecutorService threadPool = Executors.newSingleThreadScheduledExecutor(); 22 | 23 | public DiscordStatus() { 24 | 25 | try { 26 | 27 | assert this.activities != null; 28 | this.activities.forEach((list -> Activity.ActivityType.valueOf(list. 29 | get(0).replace("playing", "streaming").toUpperCase()))); 30 | 31 | } catch (Exception exception) { 32 | 33 | Logger.getInstance().getLogger().error("Discord Status Activity is invalid. It has been disabled."); 34 | return; 35 | 36 | } 37 | 38 | if (this.main.getDiscordFile().get().getBoolean("ActivityCycling.Random")) { 39 | 40 | Collections.shuffle(this.activities); 41 | 42 | } 43 | 44 | threadPool.scheduleWithFixedDelay(() -> { 45 | 46 | this.jda.getPresence().setActivity(Activity.of(Activity.ActivityType.valueOf( 47 | this.activities.get(this.currentIndex).get(0).replace("playing", "streaming") 48 | .toUpperCase()), this.activities.get(this.currentIndex).get(1))); 49 | 50 | this.currentIndex = (this.currentIndex + 1) % this.activities.size(); 51 | 52 | }, 0, this.main.getDiscordFile().get().getInt("ActivityCycling.Time"), TimeUnit.SECONDS); 53 | } 54 | public static ScheduledExecutorService getThreadPool() { return threadPool; } 55 | } 56 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/serverside/Console.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.serverside; 2 | 3 | import com.velocitypowered.api.event.Subscribe; 4 | import com.velocitypowered.api.event.command.CommandExecuteEvent; 5 | import me.prism3.loggervelocity.Logger; 6 | import me.prism3.loggervelocity.database.external.ExternalData; 7 | import me.prism3.loggervelocity.database.sqlite.SQLiteData; 8 | import me.prism3.loggervelocity.utils.FileHandler; 9 | 10 | import java.io.BufferedWriter; 11 | import java.io.FileWriter; 12 | import java.io.IOException; 13 | import java.time.ZonedDateTime; 14 | 15 | import static me.prism3.loggervelocity.utils.Data.*; 16 | 17 | public class Console { 18 | 19 | @Subscribe 20 | public void onConsole(final CommandExecuteEvent event) { 21 | 22 | final Logger main = Logger.getInstance(); 23 | 24 | if (main.getConfig().getBoolean("Log-Server.Console-Commands")) { 25 | 26 | final String command = event.getCommand().replace("\\", "\\\\"); 27 | 28 | // Log To Files 29 | if (isLogToFiles) { 30 | 31 | try { 32 | 33 | final BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getConsoleCommandLogFile(), true)); 34 | out.write(main.getMessages().getString("Files.Server-Side.Console-Commands").replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())).replace("%command%", command) + "\n"); 35 | out.close(); 36 | 37 | } catch (IOException e) { 38 | 39 | main.getLogger().error("An error occurred while logging into the appropriate file."); 40 | e.printStackTrace(); 41 | 42 | } 43 | } 44 | 45 | // Discord 46 | if (!main.getMessages().getString("Discord.Server-Side.Console-Commands").isEmpty()) { 47 | 48 | main.getDiscord().console(main.getMessages().getString("Discord.Server-Side.Console-Commands").replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())).replace("%command%", command), false); 49 | } 50 | 51 | // External 52 | if (isExternal && main.getExternal().isConnected()) { 53 | 54 | try { 55 | 56 | ExternalData.consoleCommands(serverName, command); 57 | 58 | } catch (Exception e) { e.printStackTrace(); } 59 | } 60 | 61 | // SQLite 62 | if (isSqlite && main.getSqLite().isConnected()) { 63 | 64 | try { 65 | 66 | SQLiteData.insertConsoleCommands(serverName, command); 67 | 68 | } catch (Exception e) { e.printStackTrace(); } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/serverside/RAM.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.serverside; 2 | 3 | import me.prism3.loggervelocity.Logger; 4 | import me.prism3.loggervelocity.database.external.ExternalData; 5 | import me.prism3.loggervelocity.database.sqlite.SQLiteData; 6 | import me.prism3.loggervelocity.utils.FileHandler; 7 | 8 | import java.io.BufferedWriter; 9 | import java.io.FileWriter; 10 | import java.io.IOException; 11 | import java.time.ZonedDateTime; 12 | 13 | import static me.prism3.loggervelocity.utils.Data.*; 14 | 15 | public class RAM implements Runnable { 16 | 17 | final Logger main = Logger.getInstance(); 18 | 19 | public void run() { 20 | 21 | if (main.getConfig().getBoolean("Log-Server.RAM")) { 22 | 23 | if (ramPercent <= 0 || ramPercent >= 100) return; 24 | 25 | final long maxMemory = Runtime.getRuntime().maxMemory() / 1048576L; 26 | final long freeMemory = Runtime.getRuntime().freeMemory() / 1048576L; 27 | final long usedMemory = maxMemory - freeMemory; 28 | final double percentUsed = usedMemory * 100.0D / maxMemory; 29 | 30 | if (ramPercent <= percentUsed) { 31 | 32 | // Log To Files 33 | if (isLogToFiles) { 34 | 35 | try { 36 | 37 | final BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getRamLogFile(), true)); 38 | out.write(main.getMessages().getString("Files.Server-Side.RAM").replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())).replace("%max%", String.valueOf(maxMemory)).replace("%used%", String.valueOf(usedMemory)).replace("%free%", String.valueOf(freeMemory)) + "\n"); 39 | out.close(); 40 | 41 | } catch (IOException e) { 42 | 43 | main.getLogger().error("An error occurred while logging into the appropriate file."); 44 | e.printStackTrace(); 45 | 46 | } 47 | } 48 | 49 | // Discord 50 | if (!main.getMessages().getString("Discord.Server-Side.RAM").isEmpty()) { 51 | 52 | main.getDiscord().ram(main.getMessages().getString("Discord.Server-Side.RAM").replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())).replace("%max%", String.valueOf(maxMemory)).replace("%used%", String.valueOf(usedMemory)).replace("%free%", String.valueOf(freeMemory)), false); 53 | 54 | } 55 | 56 | // External 57 | if (isExternal && main.getExternal().isConnected()) { 58 | 59 | try { 60 | 61 | ExternalData.ram(serverName, maxMemory, usedMemory, freeMemory); 62 | 63 | } catch (Exception e) { e.printStackTrace(); } 64 | } 65 | 66 | // SQLite 67 | if (isSqlite && main.getSqLite().isConnected()) { 68 | 69 | try { 70 | 71 | SQLiteData.insertRAM(serverName, maxMemory, usedMemory, freeMemory); 72 | 73 | } catch (Exception e) { e.printStackTrace(); } 74 | } 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/serverside/Start.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.serverside; 2 | 3 | import me.prism3.loggervelocity.Logger; 4 | import me.prism3.loggervelocity.database.external.ExternalData; 5 | import me.prism3.loggervelocity.database.sqlite.SQLiteData; 6 | import me.prism3.loggervelocity.utils.FileHandler; 7 | 8 | import java.io.BufferedWriter; 9 | import java.io.FileWriter; 10 | import java.io.IOException; 11 | import java.time.ZonedDateTime; 12 | 13 | import static me.prism3.loggervelocity.utils.Data.*; 14 | 15 | public class Start { 16 | 17 | public void run() { 18 | 19 | final Logger main = Logger.getInstance(); 20 | 21 | if (main.getConfig().getBoolean("Log-Server.Start")) { 22 | 23 | // Log to Files 24 | if (isLogToFiles) { 25 | 26 | try { 27 | 28 | final BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getServerStartLogFile(), true)); 29 | out.write(main.getMessages().getString("Files.Server-Side.Start").replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())) + "\n"); 30 | out.close(); 31 | 32 | } catch (IOException e) { 33 | 34 | main.getLogger().error("An error occurred while logging into the appropriate file."); 35 | e.printStackTrace(); 36 | 37 | } 38 | } 39 | 40 | // Discord 41 | if (!main.getMessages().getString("Discord.Server-Side.Start").isEmpty()) { 42 | 43 | main.getDiscord().serverStart(main.getMessages().getString("Discord.Server-Side.Start").replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())), false); 44 | 45 | } 46 | 47 | // External 48 | if (isExternal && main.getExternal().isConnected()) { 49 | 50 | try { 51 | 52 | ExternalData.serverStart(serverName); 53 | 54 | } catch (Exception e) { e.printStackTrace(); } 55 | } 56 | 57 | // SQLite 58 | if (isSqlite && main.getSqLite().isConnected()) { 59 | 60 | try { 61 | 62 | SQLiteData.insertServerStart(serverName); 63 | 64 | } catch (Exception e) { e.printStackTrace(); } 65 | } 66 | } 67 | 68 | if (isWhitelisted && isBlacklisted) { 69 | 70 | main.getLogger().error("Enabling both Whitelist and Blacklist isn't supported. " + 71 | "Please disable one of them to continue logging Player Commands"); 72 | 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/serverside/Stop.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.serverside; 2 | 3 | import me.prism3.loggervelocity.Logger; 4 | import me.prism3.loggervelocity.database.external.ExternalData; 5 | import me.prism3.loggervelocity.database.sqlite.SQLiteData; 6 | import me.prism3.loggervelocity.utils.FileHandler; 7 | 8 | import java.io.BufferedWriter; 9 | import java.io.FileWriter; 10 | import java.io.IOException; 11 | import java.time.ZonedDateTime; 12 | 13 | import static me.prism3.loggervelocity.utils.Data.*; 14 | 15 | public class Stop { 16 | 17 | public void run() { 18 | 19 | final Logger main = Logger.getInstance(); 20 | 21 | if (main.getConfig().getBoolean("Log-Server.Stop")) { 22 | 23 | // Log to Files 24 | if (isLogToFiles) { 25 | 26 | try { 27 | 28 | final BufferedWriter out = new BufferedWriter(new FileWriter(FileHandler.getServerStopLogFile(), true)); 29 | out.write(main.getMessages().getString("Files.Server-Side.Stop").replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())) + "\n"); 30 | out.close(); 31 | 32 | } catch (IOException e) { 33 | 34 | main.getLogger().error("An error occurred while logging into the appropriate file."); 35 | e.printStackTrace(); 36 | 37 | } 38 | } 39 | 40 | // Discord 41 | if (!main.getMessages().getString("Discord.Server-Side.Stop").isEmpty()) { 42 | 43 | main.getDiscord().serverStop(main.getMessages().getString("Discord.Server-Side.Stop").replace("%time%", dateTimeFormatter.format(ZonedDateTime.now())), false); 44 | 45 | } 46 | 47 | // External 48 | if (isExternal && main.getExternal().isConnected()) { 49 | 50 | try { 51 | 52 | ExternalData.serverStop(serverName); 53 | 54 | } catch (Exception e) { e.printStackTrace(); } 55 | } 56 | 57 | // SQLite 58 | if (isSqlite && main.getSqLite().isConnected()) { 59 | 60 | try { 61 | 62 | SQLiteData.insertServerStop(serverName); 63 | 64 | } catch (Exception e) { e.printStackTrace(); } 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/utils/ConfigManager.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.utils; 2 | 3 | import com.google.common.io.ByteStreams; 4 | import me.prism3.loggervelocity.Logger; 5 | import me.prism3.loggervelocity.utils.config.Configuration; 6 | import me.prism3.loggervelocity.utils.config.ConfigurationProvider; 7 | import me.prism3.loggervelocity.utils.config.StringUtils; 8 | import me.prism3.loggervelocity.utils.config.YamlConfiguration; 9 | 10 | import java.io.*; 11 | import java.util.ArrayList; 12 | import java.util.Collections; 13 | import java.util.List; 14 | 15 | public class ConfigManager { 16 | 17 | private File file; 18 | private Configuration configuration; 19 | private final File dataFolder = Logger.getInstance().getFolder().toFile(); 20 | 21 | public ConfigManager() { 22 | 23 | this.file = new File(this.dataFolder, "config - Velocity.yml"); 24 | 25 | try { 26 | 27 | if (!this.file.exists()) { 28 | 29 | if (!this.dataFolder.exists()) { this.dataFolder.mkdir(); } 30 | 31 | this.file.createNewFile(); 32 | 33 | try (final InputStream is = ConfigManager.class.getResourceAsStream("/config - Velocity.yml"); 34 | final OutputStream os = new FileOutputStream(this.file)) { 35 | assert is != null; 36 | ByteStreams.copy(is, os); 37 | } 38 | } 39 | this.configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file); 40 | } 41 | catch (IOException e) { e.printStackTrace(); } 42 | } 43 | 44 | public File getFile() { 45 | return this.file; 46 | } 47 | 48 | public int getInt(final String path) { 49 | 50 | if (this.configuration.get(path) != null) { 51 | 52 | return this.configuration.getInt(path); 53 | 54 | } return 0; 55 | } 56 | 57 | public int getLong(final String path) { 58 | 59 | if (this.configuration.get(path) != null) { 60 | 61 | return (int) this.configuration.getLong(path); 62 | 63 | } return 0; 64 | } 65 | 66 | public Object get(final String path) { 67 | return this.configuration.get(path); 68 | } 69 | 70 | public boolean getBoolean(final String path) { 71 | 72 | return this.configuration.get(path) != null && this.configuration.getBoolean(path); 73 | 74 | } 75 | 76 | public String getString(final String path) { 77 | 78 | if (this.configuration.get(path) != null) { 79 | 80 | return StringUtils.translateAlternateColorCodes('&', this.configuration.getString(path)); 81 | 82 | } return "String at path: " + path + " not found!"; 83 | } 84 | 85 | public List getStringList(final String path) { 86 | 87 | if (this.configuration.get(path) != null) { 88 | 89 | final ArrayList strings = new ArrayList<>(); 90 | 91 | for (final String string : this.configuration.getStringList(path)) { 92 | 93 | strings.add(StringUtils.translateAlternateColorCodes('&', string)); 94 | 95 | } return strings; 96 | } return Collections.singletonList("String List at path: " + path + " not found!"); 97 | } 98 | 99 | public void reload() { load(); } 100 | 101 | private void load() { 102 | 103 | this.file = new File(this.dataFolder, "config - Velocity.yml"); 104 | 105 | try { 106 | 107 | this.configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file); 108 | } 109 | 110 | catch (IOException e) { e.printStackTrace(); } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/utils/Messages.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.utils; 2 | 3 | import com.google.common.io.ByteStreams; 4 | import me.prism3.loggervelocity.Logger; 5 | import me.prism3.loggervelocity.utils.config.Configuration; 6 | import me.prism3.loggervelocity.utils.config.ConfigurationProvider; 7 | import me.prism3.loggervelocity.utils.config.StringUtils; 8 | import me.prism3.loggervelocity.utils.config.YamlConfiguration; 9 | 10 | import java.io.*; 11 | 12 | public class Messages { 13 | 14 | private File file; 15 | private Configuration configuration; 16 | 17 | private final File dataFolder = Logger.getInstance().getFolder().toFile(); 18 | 19 | public Messages() { 20 | 21 | this.file = new File(dataFolder, "/messages - Velocity.yml"); 22 | 23 | try { 24 | 25 | if (!this.file.exists()) { 26 | 27 | if (!dataFolder.exists()) { dataFolder.mkdir(); } 28 | 29 | this.file.createNewFile(); 30 | 31 | try (final InputStream is = ConfigManager.class.getResourceAsStream("/messages - Velocity.yml"); 32 | final OutputStream os = new FileOutputStream(this.file)) { 33 | assert is != null; 34 | ByteStreams.copy(is, os); 35 | } 36 | } 37 | this.configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file); 38 | } 39 | catch (IOException e) { e.printStackTrace(); } 40 | } 41 | 42 | public void reload() { load(); } 43 | 44 | private void load() { 45 | 46 | this.file = new File(dataFolder, "/messages - Velocity.yml"); 47 | 48 | try { 49 | 50 | this.configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file); 51 | } 52 | 53 | catch (IOException e) { e.printStackTrace(); } 54 | } 55 | 56 | public File getFile() { 57 | return this.file; 58 | } 59 | 60 | public String getString(final String path) { 61 | 62 | if (this.configuration.get(path) != null) { 63 | 64 | return StringUtils.translateAlternateColorCodes('&', this.configuration.getString(path)); 65 | 66 | } return "String at path: " + path + " not found!"; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/utils/config/ConfigurationProvider.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.utils.config; 2 | 3 | import java.io.*; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public abstract class ConfigurationProvider { 8 | 9 | private static final Map, ConfigurationProvider> providers = new HashMap<>(); 10 | 11 | static { 12 | try { 13 | providers.put( YamlConfiguration.class, new YamlConfiguration() ); 14 | } catch ( NoClassDefFoundError ex ) { 15 | // Ignore, no SnakeYAML 16 | } 17 | } 18 | 19 | public static ConfigurationProvider getProvider(Class provider) 20 | { 21 | return providers.get( provider ); 22 | } 23 | 24 | /*------------------------------------------------------------------------*/ 25 | 26 | public abstract void save(Configuration config, File file) throws IOException; 27 | 28 | public abstract void save(Configuration config, Writer writer); 29 | 30 | public abstract Configuration load(File file) throws IOException; 31 | 32 | public abstract Configuration load(File file, Configuration defaults) throws IOException; 33 | 34 | public abstract Configuration load(Reader reader); 35 | 36 | public abstract Configuration load(Reader reader, Configuration defaults); 37 | 38 | public abstract Configuration load(InputStream is); 39 | 40 | public abstract Configuration load(InputStream is, Configuration defaults); 41 | 42 | public abstract Configuration load(String string); 43 | 44 | public abstract Configuration load(String string, Configuration defaults); 45 | } -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/utils/config/StringUtils.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.utils.config; 2 | 3 | public class StringUtils { 4 | 5 | private StringUtils() {} 6 | 7 | public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) { 8 | 9 | final char[] b = textToTranslate.toCharArray(); 10 | 11 | for(int i = 0; i < b.length - 1; ++i) { 12 | if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) { 13 | b[i] = 167; 14 | b[i + 1] = Character.toLowerCase(b[i + 1]); 15 | } 16 | } return new String(b); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/utils/config/YamlConfiguration.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.utils.config; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.NoArgsConstructor; 5 | import org.yaml.snakeyaml.DumperOptions; 6 | import org.yaml.snakeyaml.Yaml; 7 | import org.yaml.snakeyaml.constructor.Constructor; 8 | import org.yaml.snakeyaml.representer.Representer; 9 | 10 | import java.io.*; 11 | import java.nio.charset.StandardCharsets; 12 | import java.util.LinkedHashMap; 13 | import java.util.Map; 14 | 15 | @NoArgsConstructor(access = AccessLevel.PACKAGE) 16 | public class YamlConfiguration extends ConfigurationProvider { 17 | 18 | private final ThreadLocal yaml = ThreadLocal.withInitial(() -> { 19 | Representer representer = new Representer() 20 | { 21 | { 22 | representers.put( Configuration.class, data -> represent( ( (Configuration) data ).self )); 23 | } 24 | }; 25 | 26 | DumperOptions options = new DumperOptions(); 27 | options.setDefaultFlowStyle( DumperOptions.FlowStyle.BLOCK ); 28 | 29 | return new Yaml( new Constructor(), representer, options ); 30 | }); 31 | 32 | @Override 33 | public void save(Configuration config, File file) throws IOException 34 | { 35 | try ( Writer writer = new OutputStreamWriter( new FileOutputStream( file ), StandardCharsets.UTF_8 ) ) 36 | { 37 | save( config, writer ); 38 | } 39 | } 40 | 41 | @Override 42 | public void save(Configuration config, Writer writer) 43 | { 44 | yaml.get().dump( config.self, writer ); 45 | } 46 | 47 | @Override 48 | public Configuration load(File file) throws IOException 49 | { 50 | return load( file, null ); 51 | } 52 | 53 | @Override 54 | public Configuration load(File file, Configuration defaults) throws IOException 55 | { 56 | try ( FileInputStream is = new FileInputStream( file ) ) 57 | { 58 | return load( is, defaults ); 59 | } 60 | } 61 | 62 | @Override 63 | public Configuration load(Reader reader) 64 | { 65 | return load( reader, null ); 66 | } 67 | 68 | @Override 69 | @SuppressWarnings("unchecked") 70 | public Configuration load(Reader reader, Configuration defaults) 71 | { 72 | Map map = yaml.get().loadAs( reader, LinkedHashMap.class ); 73 | if ( map == null ) 74 | { 75 | map = new LinkedHashMap<>(); 76 | } 77 | return new Configuration( map, defaults ); 78 | } 79 | 80 | @Override 81 | public Configuration load(InputStream is) 82 | { 83 | return load( is, null ); 84 | } 85 | 86 | @Override 87 | @SuppressWarnings("unchecked") 88 | public Configuration load(InputStream is, Configuration defaults) 89 | { 90 | Map map = yaml.get().loadAs( is, LinkedHashMap.class ); 91 | if ( map == null ) 92 | { 93 | map = new LinkedHashMap<>(); 94 | } 95 | return new Configuration( map, defaults ); 96 | } 97 | 98 | @Override 99 | public Configuration load(String string) 100 | { 101 | return load( string, null ); 102 | } 103 | 104 | @Override 105 | @SuppressWarnings("unchecked") 106 | public Configuration load(String string, Configuration defaults) 107 | { 108 | Map map = yaml.get().loadAs( string, LinkedHashMap.class ); 109 | if ( map == null ) 110 | { 111 | map = new LinkedHashMap<>(); 112 | } 113 | return new Configuration( map, defaults ); 114 | } 115 | } -------------------------------------------------------------------------------- /Logger-Velocity/src/main/java/me/prism3/loggervelocity/utils/litebansutil/UsernameFetcher.java: -------------------------------------------------------------------------------- 1 | package me.prism3.loggervelocity.utils.litebansutil; 2 | 3 | import litebans.api.Database; 4 | 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | 9 | public class UsernameFetcher { 10 | 11 | private UsernameFetcher() {} 12 | 13 | public static String playerNameFetcher(String uuid) { 14 | 15 | String name = ""; 16 | final String query = "SELECT name from {history} WHERE uuid=? ORDER BY date DESC LIMIT 1"; 17 | 18 | try (PreparedStatement st = Database.get().prepareStatement(query)) { 19 | 20 | st.setString(1, uuid); 21 | 22 | try (ResultSet rs = st.executeQuery()) { 23 | 24 | if (rs.next()) { 25 | 26 | name = rs.getString("name"); 27 | 28 | } 29 | } 30 | 31 | } catch (SQLException e) { e.printStackTrace(); } 32 | return name; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Logger-Velocity/src/main/resources/config - Velocity.yml: -------------------------------------------------------------------------------- 1 | # ///////////////////////////////////////////////////////////// 2 | # / / 3 | # / Logger Plugin / 4 | # / / 5 | # / [ Velocity Version ] / 6 | # / / 7 | # ///////////////////////////////////////////////////////////// 8 | # 9 | # Thank you for using Logger Plugin! If you are experiencing any issues 10 | # or have any suggestions / features you want to be implemented into the plugin 11 | # feel free to join the support Discord Server! 12 | # 13 | # Spigot: Prism3 14 | # Discord: Prism3#9371 | ID: 403667971089760257 15 | # Discord Server: https://discord.gg/MfR5mcpVfX 16 | # 17 | # Config: 1.8.0.15 18 | 19 | 20 | # Server Name 21 | Server-Name: "Server_Name" 22 | 23 | # Date & Time Formatter 24 | Time-Formatter: "yyyy-MM-dd HH:mm:ss" 25 | 26 | Plugin-Prefix: "&bLogger&fVelocity &8&l| &r " 27 | 28 | # How many days for the logs to be deleted 29 | # Set it to -1 to cancel the Deletion 30 | File-Deletion: 7 31 | 32 | # Log to Files 33 | Log-to-Files: true 34 | 35 | # This will log players with the "loggerproxy.staff.log" permission node in their own folder / file 36 | Staff: 37 | Enabled: false 38 | 39 | # Logging features 40 | Log-Player: 41 | Chat: true 42 | Commands: true 43 | Login: true 44 | Leave: true 45 | 46 | Log-Server: 47 | Console-Commands: true 48 | Start: true 49 | Stop: true 50 | RAM: true 51 | 52 | Log-Extra: 53 | LiteBans: true 54 | 55 | # Player-Commands features 56 | # Do not add / at first 57 | Player-Commands: 58 | Whitelist-Commands: false 59 | Commands-to-Log: 60 | - velocity 61 | - server 62 | Blacklist-Commands: true 63 | Commands-to-Block: 64 | - login 65 | - register 66 | - msg 67 | 68 | # Enable to show player's IPs 69 | Player-Login: 70 | Player-IP: false 71 | 72 | # Server RAM Log 73 | # How often should we check for the Proxy's RAM 74 | # It's better to have it above 1 min to avoid any complications 75 | # Value in Seconds 76 | # Percent goes from 0 -> 100 77 | RAM: 78 | Checker: 300 79 | Percent: 80 80 | 81 | # LiteBans Features to Log 82 | # It does not log revoked actions! 83 | # example: unban 84 | LiteBans: 85 | IP-Ban: true 86 | Temp-IP-Ban: true 87 | Ban: true 88 | Temp-Ban: true 89 | Mute: true 90 | Temp-Mute: true 91 | Kick: true 92 | 93 | # External Database Feature 94 | # Available Types are MySQL and MariaDB 95 | # Data-Deletion Value in Days, Set it -1 to cancel 96 | Database: 97 | Enable: false 98 | Type: MySQL 99 | Host: localhost 100 | Port: 3306 101 | Username: username 102 | Password: PassworD 103 | Database: database 104 | Data-Deletion: 7 105 | 106 | # SQLite Feature 107 | # Data-Deletion value in days, set it -1 to cancel 108 | SQLite: 109 | Enable: false 110 | Data-Deletion: 7 -------------------------------------------------------------------------------- /Logger-Velocity/src/main/resources/discord - Velocity.yml: -------------------------------------------------------------------------------- 1 | # Discord Bridge Configuration for Logger Plugin [ Velocity Version ] 2 | # Need Support? Join the Discord Server: https://discord.gg/MfR5mcpVfX 3 | # Config 1.8.0.15 4 | # Leaving Channel-ID empty will disable the Channel 5 | Discord: 6 | Enable: false 7 | Bot-Token: BOT_KEY 8 | Staff: 9 | Channel-ID: 'CHANNEL_ID' 10 | Player-Chat: 11 | Channel-ID: 'CHANNEL_ID' 12 | Player-Commands: 13 | Channel-ID: 'CHANNEL_ID' 14 | Player-Login: 15 | Channel-ID: 'CHANNEL_ID' 16 | Player-Leave: 17 | Channel-ID: 'CHANNEL_ID' 18 | # Server Side 19 | Server-Side: 20 | Console-Commands: 21 | Channel-ID: 'CHANNEL_ID' 22 | Start: 23 | Channel-ID: 'CHANNEL_ID' 24 | Stop: 25 | Channel-ID: 'CHANNEL_ID' 26 | RAM: 27 | Channel-ID: 'CHANNEL_ID' 28 | # Extra Side 29 | Extra: 30 | LiteBans: 31 | Channel-ID: 'CHANNEL_ID' 32 | # Bot Activity Status 33 | # Randomize the shown status 34 | # First Part must not be different from 35 | # Playing, Watching, Listening, Streaming, Competing 36 | # Otherwise it will not work 37 | # Time in Seconds 38 | ActivityCycling: 39 | Enabled: true 40 | Random: false 41 | Activities: 42 | - ["watching", "Minecraft Movie"] 43 | - ["playing", "Minecraft 1.7"] 44 | - ["listening", "Dragon's Heart Beats"] 45 | - ["streaming", "Minecraft Gameplay"] 46 | Time: 30 -------------------------------------------------------------------------------- /Logger-Velocity/src/main/resources/messages - Velocity.yml: -------------------------------------------------------------------------------- 1 | # Messages for Logger Plugin [ Velocity Version ] 2 | # Need Support? Join the Discord Server: https://discord.gg/MfR5mcpVfX 3 | # Config 1.8.0.15 4 | # Plugin Messages 5 | General: 6 | No-Permission: "%prefix% &cYou do not have permission to run this command." 7 | Reload: "%prefix% &aConfigs Reloaded." 8 | Invalid-Syntax: "%prefix% &cInvalid Syntax." 9 | # Files Instance 10 | Files: 11 | Player-Chat-Staff: "[%time%] [%server%] The Staff <%player%> has said => %msg%" 12 | Player-Chat: "[%time%] [%server%] The Player <%player%> has said => %msg%" 13 | Player-Commands-Staff: "[%time%] [%server%] The Staff <%player%> has executed => %command%" 14 | Player-Commands: "[%time%] [%server%] The Player <%player%> has executed => %command%" 15 | Player-Login-Staff: "[%time%] [%server%] The Staff <%player%> has joined with the current IP -> %IP%" 16 | Player-Login: "[%time%] [%server%] The Player <%player%> has joined with the current IP -> %IP%" 17 | Player-Leave-Staff: "[%time%] [%server%] The Staff <%player%> has left the server" 18 | Player-Leave: "[%time%] [%server%] The Player <%player%> has left the server" 19 | # Server Side Part 20 | Server-Side: 21 | Console-Commands: "[%time%] %command%" 22 | Start: "[%time%] The server has started" 23 | Stop: "[%time%] The server has stopped" 24 | RAM: "[%time%] The Server has exceeded the set amount of percentage of RAM Usage! Total Memory: %max% | Used Memory: %used% | Free Memory: %free%" 25 | # Extra Side Part 26 | Extra: 27 | LiteBans: "[%time%] The command '%command%' has been executed on %on% by %executor% for '%duration%' for the reason %reason% | %silent%" 28 | # Discord Instance 29 | # Emojis can be found here https://emojipedia.org/ or elsewhere. Emojis may not work on >1.12 Servers. 30 | Discord: 31 | Player-Chat-Staff: "**[%time%]** **[%server%]** **%msg%**" 32 | Player-Chat: "**[%time%]** **[%server%]** **%msg%**" 33 | Player-Commands-Staff: "**[%time%]** **[%server%]** **%command%**" 34 | Player-Commands: "**[%time%]** **[%server%]** **%command%**" 35 | Player-Login-Staff: "**[%time%]** ||**%IP%**||" 36 | Player-Login: "**[%time%]** ||**%IP%**||" 37 | Player-Leave-Staff: "**[%time%]** **[%server%]** Left the server" 38 | Player-Leave: "**[%time%]** **[%server%]** Left the server" 39 | # Server Side Part 40 | Server-Side: 41 | Console-Commands: "**[%time%]** %command%" 42 | Start: "**[%time%]**" 43 | Stop: "**[%time%]**" 44 | RAM: "**[%time%]** The Server has exceeded the set amount of percentage of RAM Usage! Total Memory: **%max%** `|` Used Memory: **%used%** `|` Free Memory: **%free%**" 45 | # Extra Side Part 46 | Extra: 47 | LiteBans: "**[%time%]** The command **%command%** has been executed on **%on%** by **%executor%** for **%duration%** for the reason **%reason%** | **%silent%**" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Logger 2 | 3 | ![Updated Badge](https://badges.pufler.dev/updated/ExceptedPrism3/Logger) 4 | [![CodeFactor](https://www.codefactor.io/repository/github/exceptedprism3/logger/badge)](https://www.codefactor.io/repository/github/exceptedprism3/logger) 5 | ![Version](https://img.shields.io/github/v/release/ExceptedPrism3/Logger) 6 | ![Servers](https://img.shields.io/bstats/servers/12036?color=brightgreen) 7 | ![Downloads](https://img.shields.io/github/downloads/ExceptedPrism3/Logger/total) 8 | ![Issues](https://img.shields.io/github/issues/ExceptedPrism3/Logger) 9 | [![Discord](https://img.shields.io/discord/850407951629287424?color=%235865F2&label=Join%20Our%20Discord)](https://discord.gg/MfR5mcpVfX) 10 | 11 | An All-in-One plugin that logs all Activities from Commands, Chat, Player Join, Player Leave, Player Death and even Server's RAM, TPS and Much More for both Proxy and Bukkit Servers! 12 | 13 | This plugin can be found on [Spigot](https://www.spigotmc.org/resources/logger.94236) & [MC-Market](https://www.mc-market.org/resources/20657/) & [Hyatlas](https://hyatlas.com/shop/logger-1-7-1-18.23/). 14 | 15 | If support is needed or a suggesting that needs to be implemented, feel free to ask on the [Discord](https://discord.gg/MfR5mcpVfX), also do not forget to check out the plugin's **[Wiki](https://prism3.gitbook.io/logger-or-wiki/)**. 16 | 17 | # About the Plugin 18 | Someone Destroyed your favorite painting, Toasted your precious diamond chestplate into the lava, Turned off your server through the console or a Staff abusing his powers? 19 | 20 | With more than **20 Features** Checkers, nothing is left without monitoring. 21 | 22 | **This is what The Logger Plugin can do:** 23 | 24 | **Bukkit Side** 25 | - **Player Side** 26 | * **Player Chat** 27 | * **Player Commands** 28 | * **Player Sign Text** 29 | * **Player Join** 30 | * **Player Leave** 31 | * **Player Kick** 32 | * **Player Death** 33 | * **Player Teleport** 34 | * **Player Level** 35 | * **Block Place** 36 | * **Block Break** 37 | * **Bucket Fill** 38 | * **...** 39 | 40 | ## **More Features and Information can be found in the [Wiki](https://prism3.gitbook.io/logger-or-wiki/)** 41 | 42 | ## Info 43 | If you use MySQL, the IP that gets stored in the Database when a Player joins 44 | isn't storing a clear IP, but a number representation of the IP. 45 | To convert it back, just execute the following SQL Command: 46 | 47 | ```mysql 48 | SELECT INET_NTOA("value"); 49 | ``` 50 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | me.prism3 8 | Logger 9 | 1.8.0.15 10 | 11 | 12 | Logger-Spigot 13 | Logger-BungeeCord 14 | Logger-Shaded 15 | Logger-Velocity 16 | 17 | 18 | pom 19 | 20 | Logger 21 | 22 | Log all Activities from Players or Server Side! 23 | 24 | 25 | 1.8 26 | UTF-8 27 | 28 | 29 | 30 | 31 | spigot-repo 32 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/ 33 | 34 | 35 | sonatype 36 | https://oss.sonatype.org/content/groups/public/ 37 | 38 | 39 | dv8tion 40 | m2-dv8tion 41 | https://m2.dv8tion.net/releases 42 | 43 | 44 | 45 | --------------------------------------------------------------------------------