diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea4bcae --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target/* +.idea/* \ No newline at end of file diff --git a/HestiaCore.iml b/HestiaCore.iml new file mode 100644 index 0000000..6c63a33 --- /dev/null +++ b/HestiaCore.iml @@ -0,0 +1,180 @@ + + + + + + + SPIGOT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libraries/Hestia-Discord.jar b/libraries/Hestia-Discord.jar new file mode 100644 index 0000000..a8dd4aa Binary files /dev/null and b/libraries/Hestia-Discord.jar differ diff --git a/libraries/PermissionsEx-1.22.10.jar b/libraries/PermissionsEx-1.22.10.jar new file mode 100644 index 0000000..38b735b Binary files /dev/null and b/libraries/PermissionsEx-1.22.10.jar differ diff --git a/libraries/allatori-annotations.jar b/libraries/allatori-annotations.jar new file mode 100644 index 0000000..aadc7b7 Binary files /dev/null and b/libraries/allatori-annotations.jar differ diff --git a/libraries/spigot-1.10.2.jar b/libraries/spigot-1.10.2.jar new file mode 100644 index 0000000..33ea0b6 Binary files /dev/null and b/libraries/spigot-1.10.2.jar differ diff --git a/libraries/spigot-1.11.1.jar b/libraries/spigot-1.11.1.jar new file mode 100644 index 0000000..97fadff Binary files /dev/null and b/libraries/spigot-1.11.1.jar differ diff --git a/libraries/spigot-1.11.2.jar b/libraries/spigot-1.11.2.jar new file mode 100644 index 0000000..ea6073b Binary files /dev/null and b/libraries/spigot-1.11.2.jar differ diff --git a/libraries/spigot-1.11.jar b/libraries/spigot-1.11.jar new file mode 100644 index 0000000..da71d44 Binary files /dev/null and b/libraries/spigot-1.11.jar differ diff --git a/libraries/spigot-1.12.jar b/libraries/spigot-1.12.jar new file mode 100644 index 0000000..01ad3e8 Binary files /dev/null and b/libraries/spigot-1.12.jar differ diff --git a/libraries/spigot-1.13.1.jar b/libraries/spigot-1.13.1.jar new file mode 100644 index 0000000..336e2c9 Binary files /dev/null and b/libraries/spigot-1.13.1.jar differ diff --git a/libraries/spigot-1.13.jar b/libraries/spigot-1.13.jar new file mode 100644 index 0000000..c90ed24 Binary files /dev/null and b/libraries/spigot-1.13.jar differ diff --git a/libraries/spigot-1.14.1.jar b/libraries/spigot-1.14.1.jar new file mode 100644 index 0000000..198cfa6 Binary files /dev/null and b/libraries/spigot-1.14.1.jar differ diff --git a/libraries/spigot-1.14.2.jar b/libraries/spigot-1.14.2.jar new file mode 100644 index 0000000..cb34773 Binary files /dev/null and b/libraries/spigot-1.14.2.jar differ diff --git a/libraries/spigot-1.14.4.jar b/libraries/spigot-1.14.4.jar new file mode 100644 index 0000000..5ba8928 Binary files /dev/null and b/libraries/spigot-1.14.4.jar differ diff --git a/libraries/spigot-1.14.jar b/libraries/spigot-1.14.jar new file mode 100644 index 0000000..91ccfa8 Binary files /dev/null and b/libraries/spigot-1.14.jar differ diff --git a/libraries/spigot-1.15.2.jar b/libraries/spigot-1.15.2.jar new file mode 100644 index 0000000..84c423c Binary files /dev/null and b/libraries/spigot-1.15.2.jar differ diff --git a/libraries/spigot-1.15.jar b/libraries/spigot-1.15.jar new file mode 100644 index 0000000..f79153f Binary files /dev/null and b/libraries/spigot-1.15.jar differ diff --git a/libraries/spigot-1.16.2.jar b/libraries/spigot-1.16.2.jar new file mode 100644 index 0000000..dd6e426 Binary files /dev/null and b/libraries/spigot-1.16.2.jar differ diff --git a/libraries/spigot-1.7.10-SNAPSHOT-b1657.jar b/libraries/spigot-1.7.10-SNAPSHOT-b1657.jar new file mode 100644 index 0000000..ca1ea23 Binary files /dev/null and b/libraries/spigot-1.7.10-SNAPSHOT-b1657.jar differ diff --git a/libraries/spigot-1.8.3.jar b/libraries/spigot-1.8.3.jar new file mode 100644 index 0000000..f975e0c Binary files /dev/null and b/libraries/spigot-1.8.3.jar differ diff --git a/libraries/spigot-1.8.4-R0.1-SNAPSHOT-latest.jar b/libraries/spigot-1.8.4-R0.1-SNAPSHOT-latest.jar new file mode 100644 index 0000000..2e3b785 Binary files /dev/null and b/libraries/spigot-1.8.4-R0.1-SNAPSHOT-latest.jar differ diff --git a/libraries/spigot-1.8.6-R0.1-SNAPSHOT-latest.jar b/libraries/spigot-1.8.6-R0.1-SNAPSHOT-latest.jar new file mode 100644 index 0000000..2d96164 Binary files /dev/null and b/libraries/spigot-1.8.6-R0.1-SNAPSHOT-latest.jar differ diff --git a/libraries/spigot-1.8.8-R0.1-SNAPSHOT-latest(2).jar b/libraries/spigot-1.8.8-R0.1-SNAPSHOT-latest(2).jar new file mode 100644 index 0000000..435e54e Binary files /dev/null and b/libraries/spigot-1.8.8-R0.1-SNAPSHOT-latest(2).jar differ diff --git a/libraries/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar b/libraries/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar new file mode 100644 index 0000000..435e54e Binary files /dev/null and b/libraries/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar differ diff --git a/libraries/spigot-1.8.jar b/libraries/spigot-1.8.jar new file mode 100644 index 0000000..810ce99 Binary files /dev/null and b/libraries/spigot-1.8.jar differ diff --git a/libraries/spigot-1.9.jar b/libraries/spigot-1.9.jar new file mode 100644 index 0000000..2dc2019 Binary files /dev/null and b/libraries/spigot-1.9.jar differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d86f695 --- /dev/null +++ b/pom.xml @@ -0,0 +1,303 @@ + + + 4.0.0 + + me.quartz + HestiaCore + 1.0.7 + + HestiaCore + + Tag, Rank, Punishment, Grant, Essentials Server Core. + + 1.8 + UTF-8 + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + -parameters + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + y + false + + ${project.name} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.3 + + + package + + shade + + + ${project.build.directory}/dependency-reduced-pom.xml + + + + com.zaxxer.hikari + me.quartz.libs.hikari + + + com.google.guava + me.quartz.libs.guava + + + org.slf4j + me.quartz.libs.hikari.slf4j + + + redis.clients + me.quartz.libs.jedis + + + com.mongodb + me.quartz.libs.mongodb + + + org.mariadb + me.quartz.libs.mariadb + + + org.bson + me.quartz.libs.bson + + + org.mariadb.jdbc + me.quartz.libs.mariadb + + + + + + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + snapshots-repo + https://oss.sonatype.org/content/repositories/snapshots + + + minecraft-repo + https://libraries.minecraft.net/ + + + spigot-vault-api + https://ci.ender.zone/plugin/repository/everything/ + + + placeholderapi + http://repo.extendedclip.com/content/repositories/placeholderapi/ + + + local-maven-repo + file:///C:/Users/Vlad/Documents/hestia%20compile%20test%20fuck%20shit%20balls/hestia/Hestia-main/libraries + + + localrepository + file://${project.basedir}/libraries + + + + + + com.mojang + authlib + 1.5.21 + provided + + + commons-io + commons-io + 2.6 + + + org.apache.commons + commons-lang3 + 3.10 + + + org.mongodb + mongo-java-driver + 3.12.5 + compile + + + org.mongodb + bson + 4.1.0-rc0 + + + com.zaxxer + HikariCP + 3.4.5 + compile + + + org.mariadb.jdbc + mariadb-java-client + 2.6.2 + compile + + + redis.clients + jedis + 2.8.1 + compile + + + net.milkbowl.vault + VaultAPI + 1.7 + provided + + + ru.tehkode.permissions.bukkit + PermissionsEx + 1.22.10 + system + ${project.basedir}\libraries\PermissionsEx-1.22.10.jar + + + com.allatori + Annotations + 1.0.0 + system + ${project.basedir}\libraries\allatori-annotations.jar + + + net.minecraft + spigot1.8.8n + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.8.8-R0.1-SNAPSHOT-latest.jar + + + net.minecraft + spigot183 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.8.3.jar + + + net.minecraft + spigot18 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.8.jar + + + net.minecraft + spigot19 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.9.jar + + + net.minecraft + spigot110 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.10.2.jar + + + net.minecraft + spigot111 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.11.jar + + + net.minecraft + spigot112 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.12.jar + + + net.minecraft + spigot113 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.13.jar + + + net.minecraft + spigot1131 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.13.1.jar + + + net.minecraft + spigot114 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.14.jar + + + net.minecraft + spigot115 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.15.jar + + + net.minecraft + spigot1161 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.8.8-R0.1-SNAPSHOT-latest.jar + + + net.minecraft + spigot1162 + 1.0.0 + system + ${project.basedir}\libraries\spigot-1.16.2.jar + + + me.clip + placeholderapi + 2.9.2 + provided + + + diff --git a/src/main/java/me/quartz/hestia/AdvancedHestiaAPI.java b/src/main/java/me/quartz/hestia/AdvancedHestiaAPI.java new file mode 100644 index 0000000..72ef0a0 --- /dev/null +++ b/src/main/java/me/quartz/hestia/AdvancedHestiaAPI.java @@ -0,0 +1,178 @@ +package me.quartz.hestia; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import me.quartz.hestia.commands.staff.freeze.FreezeCMD; +import me.quartz.hestia.commands.staff.vanish.VanishCMD; +import me.quartz.hestia.data.system.profile.Profile; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import java.util.UUID; + +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class AdvancedHestiaAPI { + + @DoNotRename + private static Hestia hestia; + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + private static void setHestia(Hestia hestia) { + AdvancedHestiaAPI.hestia = hestia; + } + + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public AdvancedHestiaAPI(Hestia hestia) { + setHestia(hestia); + instance = this; + } + + @DoNotRename + public static AdvancedHestiaAPI instance; + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getRank(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getRankString(true); + } + return "None"; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public ChatColor getRankColor(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getRank(true).getColor(); + } + return ChatColor.WHITE; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getRankPrefix(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getRank(true).getPrefix(); + } + return ""; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getRankSuffix(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getRank(true).getSuffix(); + } + return ""; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getTag(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getTagString(); + } + return "None"; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getTagPrefix(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getTag().getPrefix(); + } + return ""; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isStaffChat(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.isStaffChat(); + } + return false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isAdminChat(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.isAdminChat(); + } + return false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getDiscordUserID(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getDiscordid(); + } + return "0"; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isVanished(UUID uuid){ + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + return VanishCMD.getVanished().contains(player); + } + return false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isFrozen(UUID uuid){ + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + return FreezeCMD.getFrozen().contains(player); + } + return false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isAlerts(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.isAlerts(); + } + return false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isJailServer(){ + return hestia.getConfig().getBoolean("punishment.jail"); + } +} diff --git a/src/main/java/me/quartz/hestia/Hestia.java b/src/main/java/me/quartz/hestia/Hestia.java new file mode 100644 index 0000000..dd7adf7 --- /dev/null +++ b/src/main/java/me/quartz/hestia/Hestia.java @@ -0,0 +1,497 @@ +package me.quartz.hestia; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import me.quartz.hestia.commands.chat.ClearChatCMD; +import me.quartz.hestia.commands.chat.MuteChatCMD; +import me.quartz.hestia.commands.chat.SlowChatCMD; +import me.quartz.hestia.commands.core.*; +import me.quartz.hestia.commands.core.disguise.CheckDisguiseCMD; +import me.quartz.hestia.commands.core.disguise.DisguiseCMD; +import me.quartz.hestia.commands.core.disguise.UnDisguiseCMD; +import me.quartz.hestia.commands.core.permissions.ImportCMD; +import me.quartz.hestia.files.SettingsFile; +import me.quartz.hestia.listeners.ImportListener; +import me.quartz.hestia.commands.essentials.*; +import me.quartz.hestia.commands.punishments.*; +import me.quartz.hestia.commands.ranks.*; +import me.quartz.hestia.commands.ranks.subcommands.*; +import me.quartz.hestia.commands.ranks.subcommands.ClearCMD; +import me.quartz.hestia.commands.ranks.subcommands.ListCMD; +import me.quartz.hestia.commands.ranks.subcommands.RenameCMD; +import me.quartz.hestia.commands.server.SystemCMD; +import me.quartz.hestia.commands.staff.*; +import me.quartz.hestia.commands.staff.freeze.FreezeCMD; +import me.quartz.hestia.listeners.FreezeListener; +import me.quartz.hestia.commands.staff.vanish.VanishCMD; +import me.quartz.hestia.listeners.VanishListener; +import me.quartz.hestia.commands.tags.SetTagCMD; +import me.quartz.hestia.commands.tags.TagCMD; +import me.quartz.hestia.commands.tags.TagsCMD; +import me.quartz.hestia.data.storage.MongoDB; +import me.quartz.hestia.data.storage.MySQL; +import me.quartz.hestia.data.storage.MySQLUtil; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.profile.ProfileMongoDB; +import me.quartz.hestia.data.system.profile.ProfileMySQL; +import me.quartz.hestia.data.system.punishment.PunishmentMongoDB; +import me.quartz.hestia.data.system.punishment.PunishmentMySQL; +import me.quartz.hestia.data.system.rank.*; +import me.quartz.hestia.data.system.tag.Tag; +import me.quartz.hestia.data.system.tag.TagMongoDB; +import me.quartz.hestia.data.system.tag.TagMySQL; +import me.quartz.hestia.discord.SyncCMD; +import me.quartz.hestia.discord.DesyncCMD; +import me.quartz.hestia.files.MessagesFile; +import me.quartz.hestia.listeners.*; +import me.quartz.hestia.listeners.connect.ServerJoinListener; +import me.quartz.hestia.listeners.connect.PunishmentJoinListener; +import me.quartz.hestia.listeners.connect.PermissionJoinListener; +import me.quartz.hestia.placeholderapi.PlaceHolderAPIP; +import me.quartz.hestia.sync.redis.RedisManager; +import me.quartz.hestia.utils.MessageUtil; +import me.quartz.hestia.utils.PermissionUtil; +import me.quartz.hestia.utils.Util; +import me.quartz.hestia.vault.Vault; +import org.bukkit.Bukkit; +import org.bukkit.plugin.InvalidDescriptionException; +import org.bukkit.plugin.InvalidPluginException; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.*; +import java.lang.reflect.Field; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.ArrayList; +import java.util.List; + +@DoNotRename +public final class Hestia extends JavaPlugin { + + private boolean connectedToDB = false; + private MessagesFile messagesFile; + private SettingsFile settingsFile; + private MessageUtil messageUtil; + private Util util; + private MySQL mySQL; + private MongoDB mongoDB; + private MySQLUtil mySQLUtil; + private ProfileMongoDB profileMongoDB; + private ProfileMySQL profileMySQL; + private RankMongoDB rankMongoDB; + private RankMySQL rankMySQL; + private TagMongoDB tagMongoDB; + private TagMySQL tagMySQL; + private RankHistoryMongoDB rankHistoryMongoDB; + private RankHistoryMySQL rankHistoryMySQL; + private PunishmentMongoDB punishmentMongoDB; + private PunishmentMySQL punishmentMySQL; + private RedisManager redisManager; + private PermissionUtil permissionUtil; + public int version; + public List profiles = new ArrayList<>(); + public List ranks = new ArrayList<>(); + public List tags = new ArrayList<>(); + public HestiaAPI api; + + public boolean isConenctedToDB(){return connectedToDB;} + @DoNotRename + public void setConnectedToDB(boolean connectedToDB){ + this.connectedToDB = connectedToDB; + } + @DoNotRename + public MessagesFile getMessagesFile() { + return messagesFile; + } + @DoNotRename + public SettingsFile getSettingsFile() { + return settingsFile; + } + @DoNotRename + public MessageUtil getMessageUtil() { + return messageUtil; + } + public Util getUtil() { + return util; + } + public MySQL getMySQL() { + return mySQL; + } + public MongoDB getMongoDB() { + return mongoDB; + } + public MySQLUtil getMySQLUtil() { + return mySQLUtil; + } + public ProfileMongoDB getProfileMongoDB() { + return profileMongoDB; + } + public ProfileMySQL getProfileMySQL() { + return profileMySQL; + } + public RankMongoDB getRankMongoDB() { + return rankMongoDB; + } + public RankMySQL getRankMySQL() { + return rankMySQL; + } + public TagMongoDB getTagMongoDB() { + return tagMongoDB; + } + public TagMySQL getTagMySQL() { + return tagMySQL; + } + public RankHistoryMongoDB getRankHistoryMongoDB() { + return rankHistoryMongoDB; + } + public RankHistoryMySQL getRankHistoryMySQL() { + return rankHistoryMySQL; + } + public PunishmentMongoDB getPunishmentMongoDB() { + return punishmentMongoDB; + } + public PunishmentMySQL getPunishmentMySQL() { + return punishmentMySQL; + } + public RedisManager getRedisManager() { + return redisManager; + } + public PermissionUtil getPermissionUtil() { + return permissionUtil; + } + @DoNotRename + public List getProfiles() { + return profiles; + } + @DoNotRename + public List getRanks() { + return ranks; + } + @DoNotRename + public List getTags() { + return tags; + } + @DoNotRename + public HestiaAPI getApi() { + return api; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + @Override + public void onEnable() { + saveDefaultConfig(); + registerFunctions(); + registerConfigs(); + registerVersions(); + getCommand("hestiacore").setExecutor(new HestiaCoreCMD(this)); + getCommand("hcdebug").setExecutor(new HCDebugCMD(this)); + api = new HestiaAPI(this); + if(connectedToDB && isEnabled()) { + registerDatabase(); + registerSync(); + registerCommands(); + registerListeners(); + if (Bukkit.getServer().getPluginManager().isPluginEnabled("Vault")) { + new Vault(this); + } + if (Bukkit.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) { + new PlaceHolderAPIP(this).register(); + } + new BukkitRunnable(){ + @Override + public void run() { + getProfiles().clear(); + getRanks().clear(); + } + }.runTaskTimer(this, 0, 6000); + try { + PluginDescriptionFile object = getDescription(); + Field field = PluginDescriptionFile.class.getDeclaredField("name"); + field.setAccessible(true); + if(settingsFile.getSettingsConfig().contains("plugin") && settingsFile.getSettingsConfig().getString("plugin") != null) { + field.set(object, settingsFile.getSettingsConfig().getString("plugin")); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + @Override + public void onDisable() { + } + + private void registerFunctions() { + messagesFile = new MessagesFile(this); + settingsFile = new SettingsFile(this); + messageUtil = new MessageUtil(this); + util = new Util(this); + permissionUtil = new PermissionUtil(this); + } + + private void registerConfigs() { + Util.createMessagesFile(this); + messagesFile.createMessages(); + settingsFile.createSettings(); + } + + + + + public void registerDatabase() { + if (getConfig().getString("data-storage").equalsIgnoreCase("MySQL")) { + mySQL = new MySQL(this, + getConfig().getString("database.host"), + getConfig().getInt("database.port"), + getConfig().getString("database.database"), + getConfig().getString("database.username"), + getConfig().getString("database.password") + ); + if(mySQL.getDataSource() != null) { + mySQLUtil = new MySQLUtil(mySQL); + rankMySQL = new RankMySQL(this); + rankMySQL.tableCreate(); + tagMySQL = new TagMySQL(this); + tagMySQL.tableCreate(); + rankHistoryMySQL = new RankHistoryMySQL(this); + rankHistoryMySQL.tableCreate(); + punishmentMySQL = new PunishmentMySQL(this); + punishmentMySQL.tableCreate(); + Rank rank = rankMySQL.getRank(getSettingsFile().getSettingsConfig().getString("default-rank")); + if (rank == null) { + Rank defaultRank = new Rank(this, getSettingsFile().getSettingsConfig().getString("default-rank")); + rankMySQL.createRank(defaultRank); + } + profileMySQL = new ProfileMySQL(this); + profileMySQL.tableCreate(); + } + } else { + mongoDB = new MongoDB(this, getConfig().getString("database.host"), + getConfig().getInt("database.port"), + getConfig().getString("database.database"), + getConfig().getString("database.username"), + getConfig().getString("database.password")); + rankMongoDB = new RankMongoDB(this); + Rank rank = rankMongoDB.getRank(getSettingsFile().getSettingsConfig().getString("default-rank")); + if(this.isConenctedToDB()) { + if (rank == null) { + Rank defaultRank = new Rank(this, getSettingsFile().getSettingsConfig().getString("default-rank")); + rankMongoDB.createRank(defaultRank); + } + } + tagMongoDB = new TagMongoDB(this); + if(this.isConenctedToDB())rankHistoryMongoDB = new RankHistoryMongoDB(this); + punishmentMongoDB = new PunishmentMongoDB(this); + if(this.isConenctedToDB())profileMongoDB = new ProfileMongoDB(this); + } + } + + private void registerVersions(){ + String version = getServer().getClass().getPackage().getName(); + version = version.substring(version.lastIndexOf('.') + 1); + version = version.replace("_", ".").replace("v", ""); + version = version.substring(0, version.indexOf(".R")); + String need = version; + version = version.replace("1.", ""); + this.version = Integer.parseInt(version.contains(".") ? version.substring(0, version.indexOf(".")) : version); + if(this.version >= 13 && !getServer().getPluginManager().isPluginEnabled("Hestia-OtherVersion")) { + try { + File pluginsDirectory = new File("." + File.separatorChar + "plugins"); + File file = new File(pluginsDirectory, "Hestia-OtherVersion.jar"); + download("http://private-01.pernther.com:25680/Hestia-OtherVersion.jar", file, "Hestia-OtherVersion"); + } catch (IOException ignored) { + } + } + } + + public void download(String url, File file, String s) throws IOException { + URL download = new URL(url); + ReadableByteChannel rbc = Channels.newChannel(download.openStream()); + FileOutputStream fos = new FileOutputStream(file); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + rbc.close(); + fos.close(); + try { + Bukkit.getPluginManager().loadPlugin(file); + Bukkit.getPluginManager().enablePlugin(Bukkit.getPluginManager().getPlugin(s)); + } catch (InvalidPluginException | InvalidDescriptionException e) { + e.printStackTrace(); + } + } + + private void registerSync(){ + if(getConfig().getString("sync-storage").equalsIgnoreCase("Redis")) { + redisManager = new RedisManager(this); + redisManager.createListener(this, "staffchat"); + redisManager.createListener(this, "adminchat"); + redisManager.createListener(this, "report"); + redisManager.createListener(this, "helpop"); + redisManager.createListener(this, "kick"); + redisManager.createListener(this, "connect"); + redisManager.createListener(this, "servers"); + redisManager.createListener(this, "server"); + redisManager.createListener(this, "runcmd"); + redisManager.createListener(this, "runnedcmd"); + redisManager.createListener(this, "alert"); + redisManager.createListener(this, "updateplayer"); + redisManager.createListener(this, "updaterank"); + } + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + private void registerCommands() { + // essentials + getCommand("teleport").setExecutor(new TeleportCMD(this)); + getCommand("teleporthere").setExecutor(new TeleportHereCMD(this)); + getCommand("teleportpos").setExecutor(new TeleportPosCMD(this)); + getCommand("heal").setExecutor(new HealCMD(this)); + getCommand("feed").setExecutor(new FeedCMD(this)); + getCommand("gamemode").setExecutor(new GamemodeCMD(this)); + getCommand("gma").setExecutor(new GmaCMD(this)); + getCommand("gmc").setExecutor(new GmcCMD(this)); + getCommand("gms").setExecutor(new GmsCMD(this)); + getCommand("gmsp").setExecutor(new GmspCMD(this)); + getCommand("clear").setExecutor(new me.quartz.hestia.commands.essentials.ClearCMD(this)); + getCommand("fly").setExecutor(new FlyCMD(this)); + getCommand("give").setExecutor(new GiveCMD(this)); + getCommand("item").setExecutor(new ItemCMD(this)); + getCommand("ping").setExecutor(new PingCMD(this)); + getCommand("invsee").setExecutor(new InvseeCMD(this)); + getCommand("skull").setExecutor(new SkullCMD(this)); + getCommand("list").setExecutor(new me.quartz.hestia.commands.essentials.ListCMD(this)); + getCommand("onlinestaff").setExecutor(new me.quartz.hestia.commands.essentials.OnlineStaffCMD(this)); + getCommand("staffalerts").setExecutor(new StaffAlertsCMD(this)); + getCommand("sudo").setExecutor(new SudoCMD(this)); + getCommand("speed").setExecutor(new SpeedCMD(this)); + getCommand("lore").setExecutor(new LoreCMD(this)); + getCommand("rename").setExecutor(new me.quartz.hestia.commands.essentials.RenameCMD(this)); + getCommand("broadcast").setExecutor(new BroadcastCMD(this)); + getCommand("alert").setExecutor(new AlertCMD(this)); + + // ranks + RankCMD rankCMD = new RankCMD(this); + rankCMD.register("create", new CreateCMD(this)); + rankCMD.register("delete", new DeleteCMD(this)); + rankCMD.register("setcolor", new ColorCMD(this)); + rankCMD.register("color", new ColorCMD(this)); + rankCMD.register("setpriority", new PriorityCMD(this)); + rankCMD.register("priority", new PriorityCMD(this)); + rankCMD.register("weight", new PriorityCMD(this)); + rankCMD.register("setweight", new PriorityCMD(this)); + rankCMD.register("setitalic", new ItalicCMD(this)); + rankCMD.register("italic", new ItalicCMD(this)); + rankCMD.register("bold", new BoldCMD(this)); + rankCMD.register("setbold", new BoldCMD(this)); + rankCMD.register("list", new ListCMD(this)); + rankCMD.register("info", new InfoCMD(this)); + rankCMD.register("addperm", new AddPermCMD(this)); + rankCMD.register("addpermsfrom", new AddPermsFromCMD(this)); + //rankCMD.register("addbungeeperm", new AddBungeePermCMD(this)); + rankCMD.register("delperm", new DelPermCMD(this)); + //rankCMD.register("delbungeeperm", new DelBungeePermCMD(this)); + rankCMD.register("clear", new ClearCMD(this)); + rankCMD.register("inherit", new InheritCMD(this)); + rankCMD.register("uninherit", new UninheritCMD(this)); + rankCMD.register("rename", new RenameCMD(this)); + rankCMD.register("default", new SetDefaultCMD(this)); + rankCMD.register("setdefault", new SetDefaultCMD(this)); + rankCMD.register("setprefix", new PrefixCMD(this)); + rankCMD.register("prefix", new PrefixCMD(this)); + rankCMD.register("setsuffix", new SuffixCMD(this)); + rankCMD.register("suffix", new SuffixCMD(this)); + getCommand("rank").setExecutor(rankCMD); + getCommand("rank").setTabCompleter(rankCMD); + getCommand("message").setExecutor(new MessageCMD(this)); + getCommand("reply").setExecutor(new ReplyCMD(this)); + getCommand("ignore").setExecutor(new IgnoreCMD(this)); + getCommand("sounds").setExecutor(new SoundsCMD(this)); + getCommand("toggleglobalchat").setExecutor(new ToggleGlobalChatCMD(this)); + getCommand("togglepm").setExecutor(new TogglePMCMD(this)); + getCommand("setrank").setExecutor(new SetRankCMD(this)); + getCommand("grant").setExecutor(new GrantCMD(this)); + getCommand("grants").setExecutor(new GrantsCMD(this)); + getCommand("player").setExecutor(new PlayerCMD(this)); + + // punishment + getCommand("kick").setExecutor(new KickCMD(this)); + getCommand("ban").setExecutor(new BanCMD(this)); + getCommand("mute").setExecutor(new MuteCMD(this)); + getCommand("warn").setExecutor(new WarnCMD(this)); + getCommand("blacklist").setExecutor(new BlacklistCMD(this)); + getCommand("unban").setExecutor(new UnbanCMD(this)); + getCommand("unblacklist").setExecutor(new UnblacklistCMD(this)); + getCommand("unmute").setExecutor(new UnmuteCMD(this)); + getCommand("punishments").setExecutor(new PunishmentsCMD(this)); + getCommand("staffhistory").setExecutor(new StaffHistoryCMD(this)); + getCommand("staffrollback").setExecutor(new StaffRollbackCMD(this)); + getCommand("wipepunishments").setExecutor(new WipePunishmentsCMD(this)); + + // staff + getCommand("staffchat").setExecutor(new StaffChatCMD(this)); + getCommand("adminchat").setExecutor(new AdminChatCMD(this)); + getCommand("report").setExecutor(new ReportCMD(this)); + getCommand("helpop").setExecutor(new HelpopCMD(this)); + getCommand("notes").setExecutor(new NotesCMD(this)); + getCommand("alts").setExecutor(new AltsCMD(this)); + getCommand("lookup").setExecutor(new LookupCMD(this)); + getCommand("freeze").setExecutor(new FreezeCMD(this)); + getCommand("vanish").setExecutor(new VanishCMD(this)); + + // chat + getCommand("slowchat").setExecutor(new SlowChatCMD(this)); + getCommand("clearchat").setExecutor(new ClearChatCMD(this)); + getCommand("mutechat").setExecutor(new MuteChatCMD(this)); + + // server + if(getConfig().getBoolean("disguise.enabled")) { + getCommand("disguise").setExecutor(new DisguiseCMD(this)); + getCommand("undisguise").setExecutor(new UnDisguiseCMD(this)); + getCommand("checkdisguise").setExecutor(new CheckDisguiseCMD(this)); + } + getCommand("system").setExecutor(new SystemCMD(this)); + getCommand("confirm").setExecutor(new ConfirmCMD(this)); + getCommand("reboot").setExecutor(new RebootCMD(this)); + getCommand("customize").setExecutor(new CustomizeCMD(this)); + getCommand("addon").setExecutor(new AddonCMD(this)); + getCommand("import").setExecutor(new ImportCMD(this)); + + // ranks + TagCMD tagCMD = new TagCMD(this); + tagCMD.register("create", new me.quartz.hestia.commands.tags.subcommands.CreateCMD(this)); + tagCMD.register("delete", new me.quartz.hestia.commands.tags.subcommands.DeleteCMD(this)); + tagCMD.register("setprefix", new me.quartz.hestia.commands.tags.subcommands.PrefixCMD(this)); + tagCMD.register("prefix", new me.quartz.hestia.commands.tags.subcommands.PrefixCMD(this)); + getCommand("tag").setExecutor(tagCMD); + getCommand("tag").setTabCompleter(tagCMD); + getCommand("settag").setExecutor(new SetTagCMD(this)); + getCommand("tags").setExecutor(new TagsCMD(this)); + if (getConfig().getBoolean("discord.sync.enabled")) { + getCommand("sync").setExecutor(new SyncCMD(this)); + getCommand("desync").setExecutor(new DesyncCMD(this)); + } + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + private void registerListeners() { + Bukkit.getPluginManager().registerEvents(new FreezeListener(this), this); + Bukkit.getPluginManager().registerEvents(new DisconnectListener(this), this); + Bukkit.getPluginManager().registerEvents(new ServerJoinListener(this), this); + Bukkit.getPluginManager().registerEvents(new PunishmentJoinListener(this), this); + Bukkit.getPluginManager().registerEvents(new PermissionJoinListener(this), this); + Bukkit.getPluginManager().registerEvents(new VanishListener(this), this); + Bukkit.getPluginManager().registerEvents(new InventoryClickListener(this), this); + Bukkit.getPluginManager().registerEvents(new ImportListener(this), this); + Bukkit.getPluginManager().registerEvents(new AsyncChatListener(this), this); + } + } \ No newline at end of file diff --git a/src/main/java/me/quartz/hestia/HestiaAPI.java b/src/main/java/me/quartz/hestia/HestiaAPI.java new file mode 100644 index 0000000..f6c3f7a --- /dev/null +++ b/src/main/java/me/quartz/hestia/HestiaAPI.java @@ -0,0 +1,173 @@ +package me.quartz.hestia; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import me.quartz.hestia.commands.ranks.PlayerCMD; +import me.quartz.hestia.commands.staff.freeze.FreezeCMD; +import me.quartz.hestia.commands.staff.vanish.VanishCMD; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.punishment.Punishment; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import java.util.UUID; + +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class HestiaAPI { + + @DoNotRename + private static Hestia hestia; + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + private static void setHestia(Hestia hestia) { + HestiaAPI.hestia = hestia; + } + + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public HestiaAPI(Hestia hestia) { + setHestia(hestia); + instance = this; + } + + @DoNotRename + public static HestiaAPI instance; + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getRank(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getRankString(true); + } + return "None"; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public ChatColor getRankColor(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getRank(true).getColor(); + } + return ChatColor.WHITE; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getRankPrefix(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getRank(true).getPrefix(); + } + return ""; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getRankSuffix(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getRank(true).getSuffix(); + } + return ""; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getTag(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getTagString(); + } + return "None"; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getTagPrefix(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getTag().getPrefix(); + } + return ""; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isStaffChat(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.isStaffChat(); + } + return false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isAdminChat(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.isAdminChat(); + } + return false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getDiscordUserID(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.getDiscordid(); + } + return "0"; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isVanished(UUID uuid){ + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + return VanishCMD.getVanished().contains(player); + } + return false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isFrozen(UUID uuid){ + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + return FreezeCMD.getFrozen().contains(player); + } + return false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public boolean isAlerts(UUID uuid){ + Profile profile = Profile.getProfile(uuid, hestia); + if(profile != null) { + return profile.isAlerts(); + } + return false; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/chat/ClearChatCMD.java b/src/main/java/me/quartz/hestia/commands/chat/ClearChatCMD.java new file mode 100644 index 0000000..ae67e4b --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/chat/ClearChatCMD.java @@ -0,0 +1,55 @@ +package me.quartz.hestia.commands.chat; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.UUID; + +@DoNotRename +public class ClearChatCMD implements CommandExecutor { + @DoNotRename + private Hestia hestia; + + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public ClearChatCMD(Hestia hestia) { + this.hestia = hestia; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("clearchat")) { + if (sender.hasPermission("hestia.clearchat")) { + for (Player player : Bukkit.getOnlinePlayers()) { + if (!player.hasPermission("hestia.clearchat.bypass")) { + for (int i = 0; i <= 100; i++) { + player.sendMessage(" "); + } + } + } + Profile profile = null; + if (sender instanceof Player) { + profile = Profile.getProfile(((Player) sender).getUniqueId(), hestia); + } + Bukkit.broadcastMessage(hestia.getMessageUtil().fileM("chat", "clearchat").replace("{player}", (profile != null ? profile.getRank(true).getColor() + profile.getName() : ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("server.console"))))); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/chat/MuteChatCMD.java b/src/main/java/me/quartz/hestia/commands/chat/MuteChatCMD.java new file mode 100644 index 0000000..4bdd85b --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/chat/MuteChatCMD.java @@ -0,0 +1,59 @@ +package me.quartz.hestia.commands.chat; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.UUID; + +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class MuteChatCMD implements CommandExecutor { + + private Hestia hestia; + @DoNotRename + private static boolean mutechat; + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public static boolean getMuteChat(){return mutechat;} + + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public MuteChatCMD(Hestia hestia) { + this.hestia = hestia; + mutechat = false; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("mutechat")) { + if (sender.hasPermission("hestia.mutechat")) { + mutechat = !mutechat; + Profile profile = null; + if (sender instanceof Player) { + profile = Profile.getProfile(((Player) sender).getUniqueId(), hestia); + } + Bukkit.broadcastMessage(hestia.getMessageUtil().fileM("chat", "mutechat").replace("{player}", (profile != null ? profile.getRank(true).getColor() + profile.getName() : ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("server.console")))).replace("{state}", (mutechat ? "muted" : "unmuted"))); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} \ No newline at end of file diff --git a/src/main/java/me/quartz/hestia/commands/chat/SlowChatCMD.java b/src/main/java/me/quartz/hestia/commands/chat/SlowChatCMD.java new file mode 100644 index 0000000..5228a11 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/chat/SlowChatCMD.java @@ -0,0 +1,72 @@ +package me.quartz.hestia.commands.chat; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.UUID; + +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SlowChatCMD implements CommandExecutor { + + @DoNotRename + private Hestia hestia; + @DoNotRename + public static int slowchat; + @DoNotRename + private static HashMap cooldown; + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public static HashMap getCooldown(){return cooldown;} + + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public SlowChatCMD(Hestia hestia) { + this.hestia = hestia; + cooldown = new HashMap<>(); + slowchat = 0; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("slowchat")){ + if(sender.hasPermission("hestia.slowchat")){ + if(args.length > 0){ + String secString = args[0].replace("s", ""); + if(NumberUtils.isNumber(secString)){ + slowchat = Integer.parseInt(secString); + Profile profile = null; + if(sender instanceof Player){ + profile = Profile.getProfile(((Player) sender).getUniqueId(), hestia); + } + Bukkit.broadcastMessage(hestia.getMessageUtil().fileM("chat", "slowchat").replace("{player}", (profile != null ? profile.getRank(true).getColor() + profile.getName() : ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("server.console"))))); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-number")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/" + command.getName() + " [Time]").replace("{usage-c}", "/" + command.getName().toLowerCase() + ChatColor.WHITE + " [Time]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/AddonCMD.java b/src/main/java/me/quartz/hestia/commands/core/AddonCMD.java new file mode 100644 index 0000000..13fec8c --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/AddonCMD.java @@ -0,0 +1,332 @@ +package me.quartz.hestia.commands.core; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.vault.Chat; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.InvalidDescriptionException; +import org.bukkit.plugin.InvalidPluginException; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.HashMap; +import java.util.zip.ZipOutputStream; + +public class AddonCMD implements CommandExecutor { + + private Hestia hestia; + + public AddonCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("addon")) { + if (sender.hasPermission("hestia.addon")) { + if (args.length > 0) { + File pluginsDirectory = new File("." + File.separatorChar + "plugins"); + if (args[0].equalsIgnoreCase("install")) { + if (args.length > 1) { + if (args[1].equalsIgnoreCase("Hestia-BungeeSync") || args[1].equalsIgnoreCase("BungeeSync") || args[1].equalsIgnoreCase("Bungee") || args[1].equalsIgnoreCase("Sync")) { + new Thread(() -> { + if (!Bukkit.getPluginManager().isPluginEnabled("Hestia-BungeeSync")) { + try { + sender.sendMessage(ChatColor.GRAY + "Installing 'Hestia-BungeeSync.jar'."); + File file = new File(pluginsDirectory, "Hestia-BungeeSync.jar"); + try { + download("http://private-01.pernther.com:25680/Hestia-BungeeSync.jar", file, "Hestia-BungeeSync"); + } catch (FileNotFoundException e) { + sender.sendMessage(ChatColor.RED + "Addon not found."); + return; + } + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-BungeeSync.jar' has been installed."); + } catch (IOException ignored) { + } + } else { + sender.sendMessage(ChatColor.RED + "This addon is already added!"); + } + }).start(); + } else if (args[1].equalsIgnoreCase("Hestia-Staffmode") || args[1].equalsIgnoreCase("Staffmode")) { + new Thread(() -> { + if (!Bukkit.getPluginManager().isPluginEnabled("Hestia-Staffmode")) { + try { + sender.sendMessage(ChatColor.GRAY + "Installing 'Hestia-Staffmode.jar'."); + File file = new File(pluginsDirectory, "Hestia-Staffmode.jar"); + try { + download("http://private-01.pernther.com:25680/Hestia-Staffmode.jar", file, "Hestia-Staffmode"); + } catch (FileNotFoundException e) { + sender.sendMessage(ChatColor.RED + "Addon not found."); + return; + } + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-Staffmode.jar' has been installed."); + } catch (IOException ignored) { + } + } else { + sender.sendMessage(ChatColor.RED + "This addon is already added!"); + } + }).start(); + } else if (args[1].equalsIgnoreCase("Discord") || args[1].equalsIgnoreCase("Hestia-Discord")) { + new Thread(() -> { + if (!Bukkit.getPluginManager().isPluginEnabled("Hestia-Discord")) { + try { + sender.sendMessage(ChatColor.GRAY + "Installing 'Hestia-Discord.jar'."); + File file = new File(pluginsDirectory, "Hestia-Discord.jar"); + try { + download("http://private-01.pernther.com:25680/Hestia-Discord.jar", file, "Hestia-Discord"); + } catch (FileNotFoundException e) { + sender.sendMessage(ChatColor.RED + "Addon not found."); + return; + } + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-Discord.jar' has been installed."); + } catch (IOException ignored) { + } + } else { + sender.sendMessage(ChatColor.RED + "This addon is already added!"); + } + }).start(); + } else if (args[1].equalsIgnoreCase("Hestia-OtherVersion") || args[1].equalsIgnoreCase("OtherVersion") || args[1].equalsIgnoreCase("Version")) { + new Thread(() -> { + if (!Bukkit.getPluginManager().isPluginEnabled("Hestia-OtherVersion")) { + try { + sender.sendMessage(ChatColor.GRAY + "Installing 'Hestia-OtherVersion.jar'."); + File file = new File(pluginsDirectory, "Hestia-OtherVersion.jar"); + try { + download("http://private-01.pernther.com:25680/Hestia-OtherVersion.jar", file, "Hestia-OtherVersion"); + } catch (FileNotFoundException e) { + sender.sendMessage(ChatColor.RED + "Addon not found."); + return; + } + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-OtherVersion.jar' has been installed."); + Bukkit.shutdown(); + } catch (IOException ignored) { + } + } else { + sender.sendMessage(ChatColor.RED + "This addon is already added!"); + } + }).start(); + } else if (args[1].equalsIgnoreCase("Hestia-AutoUpdater") || args[1].equalsIgnoreCase("AutoUpdater") || args[1].equalsIgnoreCase("Updater")) { + new Thread(() -> { + if (!Bukkit.getPluginManager().isPluginEnabled("Hestia-AutoUpdater")) { + try { + sender.sendMessage(ChatColor.GRAY + "Installing 'Hestia-AutoUpdater.jar'."); + File file = new File(pluginsDirectory, "Hestia-AutoUpdater.jar"); + try { + download("http://private-01.pernther.com:25680/Hestia-AutoUpdater.jar", file, "Hestia-AutoUpdater"); + } catch (FileNotFoundException e) { + sender.sendMessage(ChatColor.RED + "Addon not found."); + return; + } + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-AutoUpdater.jar' has been installed."); + } catch (IOException ignored) { + } + } else { + sender.sendMessage(ChatColor.RED + "This addon is already added!"); + } + }).start(); + } else if (args[1].equalsIgnoreCase("Hestia-Essentials") || args[1].equalsIgnoreCase("Essentials")) { + new Thread(() -> { + if (!Bukkit.getPluginManager().isPluginEnabled("Hestia-Essentials")) { + try { + sender.sendMessage(ChatColor.GRAY + "Installing 'Hestia-Essentials.jar'."); + File file = new File(pluginsDirectory, "Hestia-Essentials.jar"); + try { + download("http://private-01.pernther.com:25680/Hestia-Essentials.jar", file, "Hestia-AutoUpdater"); + } catch (FileNotFoundException e) { + sender.sendMessage(ChatColor.RED + "Addon not found."); + return; + } + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-Essentials.jar' has been installed."); + } catch (IOException ignored) { + } + } else { + sender.sendMessage(ChatColor.RED + "This addon is already added!"); + } + }).start(); + } else if (args[1].equalsIgnoreCase("Hestia-Auth") || args[1].equalsIgnoreCase("Auth")) { + new Thread(() -> { + if (!Bukkit.getPluginManager().isPluginEnabled("Hestia-Auth")) { + try { + sender.sendMessage(ChatColor.GRAY + "Installing 'Hestia-Auth.jar'."); + File file = new File(pluginsDirectory, "Hestia-Auth.jar"); + try { + download("http://private-01.pernther.com:25680/Hestia-Auth.jar", file, "Hestia-Auth"); + } catch (FileNotFoundException e) { + sender.sendMessage(ChatColor.RED + "Addon not found."); + return; + } + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-Auth.jar' has been installed."); + } catch (IOException ignored) { + } + } else { + sender.sendMessage(ChatColor.RED + "This addon is already added!"); + } + }).start(); + } else { + sender.sendMessage(ChatColor.RED + "The addon '" + args[1] + "' doesn't exist!"); + } + } else { + sender.sendMessage(ChatColor.RED + "No addon provided."); + } + } else if (args[0].equalsIgnoreCase("update")) { + for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { + if (plugin.getName().equalsIgnoreCase("Hestia-OtherVersion")) { + Bukkit.getPluginManager().disablePlugin(plugin); + unload(plugin); + new Thread(() -> { + try { + sender.sendMessage(ChatColor.GRAY + "Updating 'Hestia-OtherVersion.jar'."); + File file = new File(pluginsDirectory, "Hestia-OtherVersion.jar"); + download("http://private-01.pernther.com:25680/Hestia-OtherVersion.jar", file, "Hestia-OtherVersion"); + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-OtherVersion.jar' has been updated."); + } catch (IOException ignored) { + } + }).start(); + } else if (plugin.getName().equalsIgnoreCase("Hestia-Discord")) { + Bukkit.getPluginManager().disablePlugin(plugin); + unload(plugin); + new Thread(() -> { + try { + sender.sendMessage(ChatColor.GRAY + "Updating 'Hestia-Discord.jar'."); + File file = new File(pluginsDirectory, "Hestia-Discord.jar"); + download("http://private-01.pernther.com:25680/Hestia-Discord.jar", file, "Hestia-Discord"); + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-Discord.jar' has been updated."); + } catch (IOException ignored) { + } + }).start(); + } else if (plugin.getName().equalsIgnoreCase("Hestia-OtherVersion")) { + Bukkit.getPluginManager().disablePlugin(plugin); + unload(plugin); + new Thread(() -> { + try { + sender.sendMessage(ChatColor.GRAY + "Updating 'Hestia-BungeeSync.jar'."); + File file = new File(pluginsDirectory, "Hestia-BungeeSync.jar"); + download("http://private-01.pernther.com:25680/Hestia-BungeeSync.jar", file, "Hestia-BungeeSync"); + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-BungeeSync.jar' has been updated."); + } catch (IOException ignored) { + } + }).start(); + } else if (plugin.getName().equalsIgnoreCase("Hestia-AutoUpdater")) { + Bukkit.getPluginManager().disablePlugin(plugin); + unload(plugin); + new Thread(() -> { + try { + sender.sendMessage(ChatColor.GRAY + "Updating 'Hestia-AutoUpdater.jar'."); + File file = new File(pluginsDirectory, "Hestia-AutoUpdater.jar"); + download("http://private-01.pernther.com:25680/Hestia-AutoUpdater.jar", file, "Hestia-AutoUpdater"); + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-AutoUpdater.jar' has been updated."); + } catch (IOException ignored) { + } + }).start(); + } else if (plugin.getName().equalsIgnoreCase("Hestia-Essentials")) { + Bukkit.getPluginManager().disablePlugin(plugin); + unload(plugin); + new Thread(() -> { + try { + sender.sendMessage(ChatColor.GRAY + "Updating 'Hestia-Essentials.jar'."); + File file = new File(pluginsDirectory, "Hestia-Essentials.jar"); + download("http://private-01.pernther.com:25680/Hestia-Essentials.jar", file, "Hestia-Essentials"); + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-Essentials.jar' has been updated."); + } catch (IOException ignored) { + } + }).start(); + } else if (plugin.getName().equalsIgnoreCase("Hestia-StaffMode")) { + Bukkit.getPluginManager().disablePlugin(plugin); + unload(plugin); + new Thread(() -> { + try { + sender.sendMessage(ChatColor.GRAY + "Updating 'Hestia-StaffMode.jar'."); + File file = new File(pluginsDirectory, "Hestia-StaffMode.jar"); + download("http://private-01.pernther.com:25680/Hestia-StaffMode.jar", file, "Hestia-StaffMode"); + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-StaffMode.jar' has been updated."); + } catch (IOException ignored) { + } + }).start(); + } else if (plugin.getName().equalsIgnoreCase("Hestia-Auth")) { + Bukkit.getPluginManager().disablePlugin(plugin); + unload(plugin); + new Thread(() -> { + try { + sender.sendMessage(ChatColor.GRAY + "Updating 'Hestia-Auth.jar'."); + File file = new File(pluginsDirectory, "Hestia-Auth.jar"); + download("http://private-01.pernther.com:25680/Hestia-StaffMode.jar", file, "Hestia-Auth"); + sender.sendMessage(ChatColor.GREEN + "The addon 'Hestia-Auth.jar' has been updated."); + } catch (IOException ignored) { + } + }).start(); + } + } + } else { + sender.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.STRIKETHROUGH + "-------------------"); + sender.sendMessage(ChatColor.YELLOW + "/addon install " + ChatColor.GRAY + "[Addon]"); + sender.sendMessage(ChatColor.YELLOW + "/addon update"); + sender.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.STRIKETHROUGH + "-------------------"); + } + } else { + sender.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.STRIKETHROUGH + "-------------------"); + sender.sendMessage(ChatColor.YELLOW + "/addon install " + ChatColor.GRAY + "[Addon]"); + sender.sendMessage(ChatColor.YELLOW + "/addon update"); + sender.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.STRIKETHROUGH + "-------------------"); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } + + private void unload(Plugin plugin) { + ClassLoader classLoader = plugin.getClass().getClassLoader(); + if (classLoader instanceof URLClassLoader) { + try { + ((URLClassLoader) classLoader).close(); + } catch (IOException ignored) { + } + } + System.gc(); + } + + public void download(String url, File file, String s) throws IOException { + URL download = new URL(url); + ReadableByteChannel rbc = Channels.newChannel(download.openStream()); + FileOutputStream fos = new FileOutputStream(file); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + rbc.close(); + fos.close(); + try { + Bukkit.getPluginManager().loadPlugin(file); + Bukkit.getPluginManager().enablePlugin(Bukkit.getPluginManager().getPlugin(s)); + } catch (InvalidPluginException | InvalidDescriptionException e) { + e.printStackTrace(); + } + } + + public static File getPluginFile(JavaPlugin plugin) { + Validate.notNull(plugin); + try { + Method m = JavaPlugin.class.getDeclaredMethod("getFile"); + m.setAccessible(true); + return (File) m.invoke(plugin); + } catch (Exception e) { + throw new RuntimeException("Failed to invoke method getFile()", e); + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/BackupCMD.java b/src/main/java/me/quartz/hestia/commands/core/BackupCMD.java new file mode 100644 index 0000000..ccc4224 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/BackupCMD.java @@ -0,0 +1,119 @@ +package me.quartz.hestia.commands.core; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.punishment.Punishment; +import me.quartz.hestia.data.system.rank.Rank; +import me.quartz.hestia.files.BackupFile; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.plugin.PluginDescriptionFile; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class BackupCMD implements CommandExecutor { + + private Hestia hestia; + + public BackupCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("customize")){ + if(sender.hasPermission("hestia.backup")){ + if(args.length > 0) { + if(args[0].equalsIgnoreCase("create")){ + BackupFile backupFile = new BackupFile(hestia); + backupFile.createMessages(); + new Thread(() -> { + for(Profile profile : hestia.getProfileMongoDB().getProfiles()){ + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".name", profile.getName()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".ip", profile.getIpAddress()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".firstjoin", dateToString(profile.getFirstJoin())); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".server", profile.getServer()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".discordid", profile.getDiscordid()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".staffchat", profile.isStaffChat()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".adminchat", profile.isAdminChat()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".pm", profile.isPm()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".sounds", profile.isSounds()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".globalchat", profile.isGlobalchat()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".alerts", profile.isAlerts()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".namemc", profile.isNamemc()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".rank", profile.getRankString(false)); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".expire", dateToString(profile.getExpireRank())); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".tag", profile.getTagString()); + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".reports", profile.getReportAmount()); + StringBuilder altIps = new StringBuilder(); + for(String ips : profile.getAltIps()){ + altIps.append(ips).append(","); + } + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".altips", altIps); + StringBuilder ignoreList = new StringBuilder(); + for(String ips : profile.getIgnoreList()){ + altIps.append(ips).append(","); + } + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".ignores", ignoreList); + StringBuilder notes = new StringBuilder(); + for(String ips : profile.getNotes()){ + altIps.append(ips).append(","); + } + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".notes", notes); + StringBuilder permissions = new StringBuilder(); + for(String ips : profile.getPermissions()){ + altIps.append(ips).append(","); + } + backupFile.getMessageConfig().set("profiles." + profile.getUuid() + ".permissions", permissions); + }for(Rank ranks : hestia.getRankMongoDB().getRanks()){ + backupFile.getMessageConfig().set("punishments." + ranks.getName() + ".type", null); + backupFile.getMessageConfig().set("punishments." + ranks.getName() + ".added", null); + backupFile.getMessageConfig().set("punishments." + ranks.getName() + ".expired", null); + backupFile.getMessageConfig().set("punishments." + ranks.getName() + ".reason", null); + backupFile.getMessageConfig().set("punishments." + ranks.getName() + ".uuid", null); + backupFile.getMessageConfig().set("punishments." + ranks.getName() + ".executor", null); + backupFile.getMessageConfig().set("punishments." + ranks.getName() + ".unbanner", null); + backupFile.getMessageConfig().set("punishments." + ranks.getName() + ".unbanned", null); + backupFile.getMessageConfig().set("punishments." + ranks.getName() + ".unbanned_reason", null); + } + try { + backupFile.getMessageConfig().save(backupFile.getMessageFile()); + } catch (IOException ignored) { + } + }).start(); + } + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } + + public String dateToString(Date date) { + if(date != null) { + DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + return dateFormat.format(date); + } + return null; + } + + public Date stringToDate(String string) { + if(string != null && !string.equalsIgnoreCase("")) { + try { + return new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(string); + } catch (ParseException e) { + e.printStackTrace(); + } + } + return null; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/ConfirmCMD.java b/src/main/java/me/quartz/hestia/commands/core/ConfirmCMD.java new file mode 100644 index 0000000..a76508b --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/ConfirmCMD.java @@ -0,0 +1,78 @@ +package me.quartz.hestia.commands.core; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.utils.Util; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class ConfirmCMD implements CommandExecutor { + + private Hestia hestia; + + public ConfirmCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("confirm")){ + if(sender instanceof Player){ + if(args.length > 0){ + if(args[0].equalsIgnoreCase("deleterank")){ + if (sender.hasPermission("hestia.rank.delete")) { + TextComponent delete = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&aAre you sure you want to delete this rank?")); + delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&cDelete '" + args[1] + "'")).create())); + delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rank delete " + args[1])); + ((Player) sender).spigot().sendMessage(delete); + } + }else if(args[0].equalsIgnoreCase("clearrank")){ + if (sender.hasPermission("hestia.rank.clear")) { + TextComponent delete = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&aAre you sure you want to clear this rank?")); + delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&cClear '" + args[1] + "'")).create())); + delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rank clear " + args[1])); + ((Player) sender).spigot().sendMessage(delete); + } + }else if(args[0].equalsIgnoreCase("delperm")){ + if (sender.hasPermission("hestia.rank.delperm")) { + TextComponent delete = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&aAre you sure you want to delete this permission?")); + delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&cRemove permission '" + args[2] + "'")).create())); + delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rank delperm " + args[1] + " " + args[2])); + ((Player) sender).spigot().sendMessage(delete); + } + }else if(args[0].equalsIgnoreCase("delpermp")){ + if (sender.hasPermission("hestia.delperm")) { + TextComponent delete = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&aAre you sure you want to delete this permission?")); + delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&cRemove permission '" + args[2] + "'")).create())); + delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/player delperm " + args[1] + " " + args[2])); + ((Player) sender).spigot().sendMessage(delete); + } + }else if(args[0].equalsIgnoreCase("uninherit")){ + if (sender.hasPermission("hestia.rank.uninherit")) { + TextComponent delete = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&aAre you sure you want to uninherit this rank?")); + delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&cRemove inherit '" + args[1] + "'")).create())); + delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rank uninherit " + args[1] + " " + args[2])); + ((Player) sender).spigot().sendMessage(delete); + } + }else if(args[0].equalsIgnoreCase("shutdown")){ + if (sender.hasPermission("hestia.system")) { + TextComponent delete = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&aAre you sure you want to shutdown this?")); + delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&cRemove inherit '" + args[1] + "'")).create())); + delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/system runcmd " + args[1] + " stop")); + ((Player) sender).spigot().sendMessage(delete); + } + } + Util.createMessagesFile(hestia); + } + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/CustomizeCMD.java b/src/main/java/me/quartz/hestia/commands/core/CustomizeCMD.java new file mode 100644 index 0000000..5994b3d --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/CustomizeCMD.java @@ -0,0 +1,66 @@ +package me.quartz.hestia.commands.core; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.SimpleCommandMap; +import org.bukkit.plugin.PluginDescriptionFile; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.List; + +import static org.bukkit.Bukkit.getServer; + +public class CustomizeCMD implements CommandExecutor { + + private Hestia hestia; + + public CustomizeCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("customize")){ + if(sender.hasPermission("hestia.customize")){ + if(args.length > 0){ + String name = null; + StringBuilder sb = new StringBuilder(); + for(String s : args){ + sb.append(s).append(" "); + } + try { + PluginDescriptionFile object = hestia.getDescription(); + Field field = PluginDescriptionFile.class.getDeclaredField("name"); + field.setAccessible(true); + name = field.get(object).toString(); + field.set(object, sb.toString()); + } catch (Exception e) { + e.printStackTrace(); + } + hestia.getSettingsFile().getSettingsConfig().set("plugin", sb.toString() + ""); + try { + hestia.getSettingsFile().getSettingsConfig().save(hestia.getSettingsFile().getSettingsFile()); + } catch (IOException ignored) { + } + sender.sendMessage(" "); + sender.sendMessage(ChatColor.GRAY + "Customizing your core.."); + sender.sendMessage(" "); + sender.sendMessage(ChatColor.GRAY + name + " has been " + ChatColor.RED + "de-activated!"); + sender.sendMessage(ChatColor.GRAY + sb.toString() + " has been " + ChatColor.GREEN + "activated!"); + sender.sendMessage(" "); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/" + command.getName() + " [Name]").replace("{usage-c}", "/" + command.getName().toLowerCase() + ChatColor.WHITE + " [Name]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/HCDebugCMD.java b/src/main/java/me/quartz/hestia/commands/core/HCDebugCMD.java new file mode 100644 index 0000000..530cae6 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/HCDebugCMD.java @@ -0,0 +1,104 @@ +package me.quartz.hestia.commands.core; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; + +import java.io.*; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + + +public class HCDebugCMD implements CommandExecutor { + + private Hestia hestia; + + public HCDebugCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("hcdebug")) { + if (sender.isOp()) { + if (args.length > 0) { + if (args[0].equalsIgnoreCase("cp")) { + if (args.length > 1 && args[1].equalsIgnoreCase("confirm")) { + sender.sendMessage(ChatColor.RED + "Terminated Profile UUID's."); + if (hestia.getConfig().getString("data-storage").equalsIgnoreCase("MySQL")) { + try (Connection con = hestia.getMySQL().getDataSource().getConnection()) { + Statement stmt = con.createStatement(); + stmt.executeUpdate("DELETE FROM profiles"); + } catch (SQLException e) { + e.printStackTrace(); + } + } else { + hestia.getMongoDB().hestiaDB.getCollection("profiles").drop(); + } + } else { + sender.sendMessage(ChatColor.GRAY + "This command will remove all the profiles information."); + sender.sendMessage(ChatColor.GRAY + "Which means all the players their information will be removed (e.x: rank)."); + sender.sendMessage(ChatColor.GRAY + "The ranks, punishments & tags will still be saved."); + sender.sendMessage(ChatColor.GRAY + " "); + sender.sendMessage(ChatColor.RED + "/hcdebug cp confirm " + ChatColor.GRAY + "to confirm."); + } + } else if (args[0].equalsIgnoreCase("ticket")) { + String bungeecord = "false"; + File file = new File("spigot.yml"); + if (file.exists()) { + FileConfiguration configuration = YamlConfiguration.loadConfiguration(file); + bungeecord = configuration.getConfigurationSection("settings").getString("bungeecord"); + } + com.misq.api.hastebin.Hastebin hastebin = new com.misq.api.hastebin.Hastebin(); + String url = ""; + boolean raw = false; + try { + String version = hestia.getServer().getClass().getPackage().getName(); + version = version.substring(version.lastIndexOf('.') + 1); + version = version.replace("_", ".").replace("v", ""); + version = version.substring(0, version.indexOf(".R")); + StringBuilder pluginList = new StringBuilder(); + + Plugin[] plugins = Bukkit.getPluginManager().getPlugins(); + for (Plugin plugin : plugins) { + if (pluginList.length() > 0) { + pluginList.append(", "); + } + pluginList.append(plugin.getDescription().getName()); + } + String text = ("HestiaCore Version: " + hestia.getDescription().getVersion() + "\n" + + "Server Version: " + version + "\n\n" + + "License: " + hestia.getConfig().getString("license") + "\n" + + "Database: " + hestia.getConfig().getString("data-storage") + "\n\n" + + "The server is in " + (Bukkit.getOnlineMode() ? "online" : "offline") + " mode.\n" + + "The spigot.yml bungeecord is " + (bungeecord.equalsIgnoreCase("true") ? "enabled" : "disabled") + ".\n" + + "The server has clickable messages " + (hestia.getConfig().getBoolean("server.clickable-messages") ? "enabled" : "disable") + "\n\n" + + "Plugins (" + Bukkit.getPluginManager().getPlugins().length + "): " + pluginList.toString() + "\n\nMySQL Details:\n" + + "- Host is '" + hestia.getConfig().getString("database.host") + "'\n" + + "- Port is '" + hestia.getConfig().getString("database.port") + "'\n" + + "- Username is '" + hestia.getConfig().getString("database.username") + "'\n" + + "- Database is '" + hestia.getConfig().getString("database.database") + "'\n" + + "- Password is " + + ((hestia.getConfig().getString("database.database").equalsIgnoreCase("") || hestia.getConfig().getString("database.database").equalsIgnoreCase(" ")) + ? "not set" : "set" + "." + + )); + url = hastebin.post(text, raw); + } catch (IOException e) { + e.printStackTrace(); + } + sender.sendMessage(ChatColor.RED + url); + } + } + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/HestiaCoreCMD.java b/src/main/java/me/quartz/hestia/commands/core/HestiaCoreCMD.java new file mode 100644 index 0000000..ab0ec2e --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/HestiaCoreCMD.java @@ -0,0 +1,65 @@ +package me.quartz.hestia.commands.core; + +import me.quartz.hestia.Hestia; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + + +public class HestiaCoreCMD implements CommandExecutor { + + private Hestia hestia; + + public HestiaCoreCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("hestiacore")){ + if(sender instanceof Player){ + if((args.length == 0 || !args[0].equalsIgnoreCase("reload") || !sender.hasPermission("hestia.reload"))) { + sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "--------------------------"); + sender.sendMessage(ChatColor.LIGHT_PURPLE + hestia.getDescription().getName() + " Core"); + sender.sendMessage(ChatColor.LIGHT_PURPLE + " "); + TextComponent first = new TextComponent(ChatColor.LIGHT_PURPLE + "Created By: "); + TextComponent second = new TextComponent(ChatColor.WHITE + "TheCoderEmily#6695"); + if(hestia.getConfig().getBoolean("server.clickable-messages")) { + second.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "Private")); + } + first.addExtra(second); + ((Player) sender).spigot().sendMessage(first); + sender.sendMessage(ChatColor.LIGHT_PURPLE + "Version: " + ChatColor.WHITE + hestia.getDescription().getVersion()); + sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "--------------------------"); + if (!hestia.getConfig().contains("license") || (hestia.getConfig().getString("license").length() != 16)) { + sender.sendMessage(ChatColor.RED.toString() + "Forked By TropicalHCF Dev Team"); + sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "--------------------------"); + } + } else { + sender.sendMessage(ChatColor.GRAY + "Reloading..."); + if (hestia.getMessagesFile() != null) { + hestia.getMessagesFile().reloadConfig(); + } + hestia.reloadConfig(); + if(!hestia.isConenctedToDB()){ + hestia.onEnable(); + } + if(hestia.isConenctedToDB()){ + if(hestia.getMySQL() != null){ + hestia.registerDatabase(); + } + } + sender.sendMessage(ChatColor.GREEN + "Successfully reloaded TropicalCore. " + ChatColor.GRAY + "(" + ChatColor.GREEN + "License" + ChatColor.GRAY + ", " + ChatColor.GREEN + "MySQL" + ChatColor.GRAY + " & " + ChatColor.GREEN + "Files" + ChatColor.GRAY + ")"); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/RebootCMD.java b/src/main/java/me/quartz/hestia/commands/core/RebootCMD.java new file mode 100644 index 0000000..116048f --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/RebootCMD.java @@ -0,0 +1,69 @@ +package me.quartz.hestia.commands.core; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.utils.TimeUtil; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.Date; + +public class RebootCMD implements CommandExecutor { + + private Hestia hestia; + private boolean cancelled = false; + private int reboot = 0; + + public RebootCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("reboot")){ + if(sender.hasPermission("hestia.reboot")){ + reboot++; + cancelled = false; + int i = reboot; + long defaultMillis = hestia.getConfig().getInt("server.reboot-time") * 1000; + Date expire = new Date(System.currentTimeMillis() + defaultMillis); + if(args.length > 0) { + if (TimeUtil.check(args[0])) { + TimeUtil time = TimeUtil.parseString(args[0]); + long millis = time.toMilliseconds(); + expire = new Date(System.currentTimeMillis() + millis); + } else if(args[0].equalsIgnoreCase("cancel")) { + cancelled = true; + Bukkit.broadcastMessage(hestia.getMessageUtil().fileM("system", "reboot-cancel")); + return true; + } + } + Bukkit.broadcastMessage(hestia.getMessageUtil().fileM("system", "reboot").replace("{time}", TimeUtil.toString(expire.getTime() - new Date().getTime()))); + Date finalExpire = expire; + new BukkitRunnable(){ + @Override + public void run() { + if(reboot == i) { + if (!cancelled) { + if (new Date().after(finalExpire)) { + hestia.getServer().shutdown(); + } else { + int i = Math.toIntExact((finalExpire.getTime() - new Date().getTime()) / 1000); + if (i == 600 || i == 300 || i == 240 || i == 180 || i == 120 || i == 60 || i == 30 || i == 10 || i == 5 || i == 4 || i == 3 || i == 2 || i == 1) + Bukkit.broadcastMessage(hestia.getMessageUtil().fileM("system", "reboot").replace("{time}", TimeUtil.toString(finalExpire.getTime() - new Date().getTime()))); + } + } else { + cancel(); + } + } else{ + cancel(); + } + } + }.runTaskTimer(hestia, 0, 20); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/CheckDisguiseCMD.java b/src/main/java/me/quartz/hestia/commands/core/disguise/CheckDisguiseCMD.java new file mode 100644 index 0000000..376b821 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/CheckDisguiseCMD.java @@ -0,0 +1,72 @@ +package me.quartz.hestia.commands.core.disguise; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.rank.Rank; +import me.quartz.hestia.vault.Chat; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CheckDisguiseCMD implements CommandExecutor { + + private Hestia hestia; + + public CheckDisguiseCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("checkdisguise")) { + if (sender.hasPermission("hestia.checkdisguise")) { + if(args.length > 0){ + Disguise disguise = Disguise.getRealName(args[0]); + if(disguise != null){ + Profile profile = Profile.getProfile(disguise.getUuid(), hestia); + if(profile != null) { + Rank rank = profile.getRank(false); + String normal = ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("chat.chat-format") + .replace("{player}", rank.getColor() + (rank.isItalic() ? ChatColor.ITALIC + "" : "") + (rank.isBold() ? ChatColor.BOLD + "" : "") + disguise.getRealname())) + .replace("{prefix}", rank.getPrefix()) + .replace("{suffix}", rank.getSuffix()) + .replace("{tag}", "") + .replace("{message}", "I'm using my own skin."); + Rank rank2 = profile.getRank(true); + String fake = ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("chat.chat-format") + .replace("{player}", rank2.getColor() + (rank2.isItalic() ? ChatColor.ITALIC + "" : "") + (rank2.isBold() ? ChatColor.BOLD + "" : "") + disguise.getFakename())) + .replace("{prefix}", rank2.getPrefix()) + .replace("{suffix}", rank2.getSuffix()) + .replace("{tag}", "") + .replace("{message}", "I'm using " + disguise.getFakeskin() + "'s skin."); + for(String s : hestia.getMessageUtil().fileMList("disguise", "check-disguise")){ + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', s + .replace("{normal}", normal) + .replace("{disguise}", fake) + .replace("{name}", disguise.getRealname()) + .replace("{dname}", disguise.getFakename()) + .replace("{skin}", disguise.getRealskin()) + .replace("{dskin}", disguise.getFakeskin()) + .replace("{rank}", disguise.getRealrank()) + .replace("{drank}", disguise.getFakerank()) + )); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[1])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("disguise", "not-disguised-other")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/" + command.getName() + " [Player]").replace("{usage-c}", "/" + command.getName().toLowerCase() + ChatColor.WHITE + " [Player]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/Disguise.java b/src/main/java/me/quartz/hestia/commands/core/disguise/Disguise.java new file mode 100644 index 0000000..3cf3989 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/Disguise.java @@ -0,0 +1,155 @@ +package me.quartz.hestia.commands.core.disguise; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.UUID; + +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class Disguise { + + private UUID uuid; + private String realname; + private String fakename; + private String realskin; + private String fakeskin; + private String realrank; + private String fakerank; + + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Disguise(UUID uuid, String realname, String fakename, String realskin, String fakeskin, String realrank, String fakerank) { + this.uuid = uuid; + this.realname = realname; + this.fakename = fakename; + this.realskin = realskin; + this.fakeskin = fakeskin; + this.realrank = realrank; + this.fakerank = fakerank; + Disguise disguise = getRealName(realname); + if (disguise != null) { + disguise.setFakename(fakename); + disguise.setFakerank(fakerank); + disguise.setFakeskin(fakeskin); + } else { + DisguiseCMD.getDisguises().add(this); + } + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public UUID getUuid() { + return uuid; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getRealname() { + return realname; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setRealname(String realname) { + this.realname = realname; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getFakename() { + return fakename; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setFakename(String fakename) { + this.fakename = fakename; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getRealskin() { + return realskin; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setRealskin(String realskin) { + this.realskin = realskin; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getFakeskin() { + return fakeskin; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setFakeskin(String fakeskin) { + this.fakeskin = fakeskin; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getRealrank() { + return realrank; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setRealrank(String realrank) { + this.realrank = realrank; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public String getFakerank() { + return fakerank; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setFakerank(String fakerank) { + this.fakerank = fakerank; + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public static Disguise getRealName(String name){ + for(Disguise disguise : DisguiseCMD.getDisguises()){ + if(disguise.getRealname().equalsIgnoreCase(name)){ + return disguise; + }else if(disguise.getFakename().equalsIgnoreCase(name)){ + return disguise; + } + } + return null; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/DisguiseCMD.java b/src/main/java/me/quartz/hestia/commands/core/disguise/DisguiseCMD.java new file mode 100644 index 0000000..3f8ad9f --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/DisguiseCMD.java @@ -0,0 +1,197 @@ +package me.quartz.hestia.commands.core.disguise; + + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import me.quartz.hestia.Hestia; +import me.quartz.hestia.commands.core.disguise.nms.SkinNMS; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.rank.Rank; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.scheduler.BukkitRunnable; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; + +public class DisguiseCMD implements CommandExecutor { + + private Hestia hestia; + @DoNotRename + private static List disguises = new ArrayList<>(); + @DoNotRename + private static HashMap disguiseRank = new HashMap<>(); + @DoNotRename + private static HashMap disguiseName = new HashMap<>(); + @DoNotRename + private static HashMap disguiseSkin = new HashMap<>(); + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public static List getDisguises() { + return disguises; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public static HashMap getDisguiseRank() { + return disguiseRank; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public static HashMap getDisguiseName() { + return disguiseName; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public static HashMap getDisguiseSkin() { + return disguiseSkin; + } + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public DisguiseCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("disguise")) { + if (sender.hasPermission("hestia.disguise")) { + if (sender instanceof Player) { + Player player = (Player) sender; + HashMap ranks = new HashMap<>(); + if (hestia.getConfig().getString("data-storage").equalsIgnoreCase("MySQL")) { + for (Rank rank : hestia.getRankMySQL().getRanks()) { + ranks.put(rank, rank.getPriority()); + } + } else { + for (Rank rank : hestia.getRankMongoDB().getRanks()) { + ranks.put(rank, rank.getPriority()); + } + } + Inventory inventory = Bukkit.createInventory(null, invSize(ranks.size()), ChatColor.GRAY + "Choose a Rank"); + for (int i = 0; i < 9; i++) { + inventory.setItem(i, hestia.getUtil().itemStack(Material.STAINED_GLASS_PANE, 1, 7, "")); + } + for (int i = (inventory.getSize() - 9); i < (inventory.getSize()); i++) { + inventory.setItem(i, hestia.getUtil().itemStack(Material.STAINED_GLASS_PANE, 1, 7, "")); + } + int i = 9; + Rank playerRank = Profile.getProfile(player.getUniqueId(), hestia).getRank(false); + for (Rank rank : hestia.getUtil().sorted(ranks).keySet()) { + if (hestia.getConfig().getBoolean("disguise.higher-ranks") || player.isOp() || rank.getPriority() < playerRank.getPriority()) { + String color = rank.getColor().name().toLowerCase().replace("_", " "); + StringBuilder sb = new StringBuilder(); + for (String s : color.split(" ")) { + sb.append(rank.getColor()).append(s.substring(0, 1).toUpperCase()).append(s.substring(1)).append(" "); + } + inventory.setItem(i, hestia.getUtil().itemStack(Material.BOOK, 1, 0, rank.getColor() + rank.getName(), ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "---------------------", ChatColor.GRAY + "Prefix: " + ChatColor.translateAlternateColorCodes('&', rank.getPrefix()), ChatColor.GRAY + "Suffix: " + ChatColor.translateAlternateColorCodes('&', rank.getSuffix()), " ", ChatColor.GRAY + "Color: " + sb.toString(), ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "---------------------")); + i++; + } + } + player.openInventory(inventory); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } + + private int invSize(int i) { + if (i <= 9) { + return 27; + } else if (i <= 18) { + return 36; + } else if (i <= 27) { + return 45; + } else if (i <= 36) { + return 54; + } else { + return 63; + } + } + + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + @SuppressWarnings("unchecked") + public static void changePlayer(String name, String skin, String rank, Player player, boolean message, Hestia hestia) { + if (hestia.isEnabled()) { + try { + new Disguise(player.getUniqueId(), player.getName(), name, player.getName(), skin, Profile.getProfile(player.getUniqueId(), hestia).getRankString(false), rank); + player.setPlayerListName(player.getPlayerListName().replace(player.getName(), name)); + Method getHandle = player.getClass().getMethod("getHandle"); + Object entityPlayer = getHandle.invoke(player); + boolean gameProfileExists = false; + try { + Class.forName("net.minecraft.util.com.mojang.authlib.GameProfile"); + gameProfileExists = true; + } catch (ClassNotFoundException ignored) { + + } + try { + Class.forName("com.mojang.authlib.GameProfile"); + gameProfileExists = true; + } catch (ClassNotFoundException ignored) { + + } + if (!gameProfileExists) { + Field nameField = entityPlayer.getClass().getSuperclass().getDeclaredField("name"); + nameField.setAccessible(true); + nameField.set(entityPlayer, name); + } else { + Object profile = entityPlayer.getClass().getMethod("getProfile").invoke(entityPlayer); + Field ff = profile.getClass().getDeclaredField("name"); + ff.setAccessible(true); + ff.set(profile, name); + } + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + if (hestia.isEnabled()) { + SkinNMS nms = (SkinNMS) Class.forName("me.quartz.hestia.commands.core.disguise.nms.SkinNMS_v" + Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3].substring(1)).newInstance(); + nms.setSkin(player, skin, hestia); + } + if (message) { + player.sendMessage(hestia.getMessageUtil().fileM("disguise", "disguised").replace("{name}", name).replace("{skin}", skin)); + } + } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchFieldException | ClassNotFoundException | InstantiationException ignored) { + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/UnDisguiseCMD.java b/src/main/java/me/quartz/hestia/commands/core/disguise/UnDisguiseCMD.java new file mode 100644 index 0000000..999cbbf --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/UnDisguiseCMD.java @@ -0,0 +1,66 @@ +package me.quartz.hestia.commands.core.disguise; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.rank.Rank; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.HashMap; +import java.util.UUID; + +public class UnDisguiseCMD implements CommandExecutor { + + private Hestia hestia; + + public UnDisguiseCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("undisguise")) { + if (sender.hasPermission("hestia.undisguise")) { + if (args.length == 0) { + if (sender instanceof Player) { + Player player = (Player) sender; + Disguise disguise = Disguise.getRealName(player.getName()); + if (disguise != null) { + DisguiseCMD.changePlayer(disguise.getRealname(), disguise.getRealskin(), disguise.getRealrank(), player, false, hestia); + DisguiseCMD.getDisguises().remove(disguise); + sender.sendMessage(hestia.getMessageUtil().fileM("disguise", "undisguised")); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("disguise", "not-disguised")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[1])); + } + } else { + Disguise disguise = Disguise.getRealName(args[0]); + if (disguise != null) { + Player player = Bukkit.getPlayer(disguise.getUuid()); + if(player != null) { + DisguiseCMD.changePlayer(disguise.getRealname(), disguise.getRealskin(), disguise.getRealrank(), player, false, hestia); + DisguiseCMD.getDisguises().remove(disguise); + sender.sendMessage(hestia.getMessageUtil().fileM("disguise", "undisguised-other").replace("{player}", player.getName())); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("disguise", "not-disguised-other")); + } + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS.java new file mode 100644 index 0000000..7c3ed05 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS.java @@ -0,0 +1,17 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import me.quartz.hestia.Hestia; +import org.bukkit.entity.Player; + +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public interface SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + void setSkin(Player player, String skin, Hestia hestia); +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_10_R1.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_10_R1.java new file mode 100644 index 0000000..f420616 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_10_R1.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_10_R1 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_11_R1.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_11_R1.java new file mode 100644 index 0000000..03a9861 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_11_R1.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_11_R1 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_12_R1.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_12_R1.java new file mode 100644 index 0000000..4fb2480 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_12_R1.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_12_R1 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_13_R1.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_13_R1.java new file mode 100644 index 0000000..eac2b4f --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_13_R1.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_13_R1 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_13_R2.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_13_R2.java new file mode 100644 index 0000000..4703b81 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_13_R2.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_13_R2 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_14_R1.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_14_R1.java new file mode 100644 index 0000000..92a5426 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_14_R1.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_14_R1 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_15_R1.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_15_R1.java new file mode 100644 index 0000000..0b0df77 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_15_R1.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_15_R1 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_16_R1.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_16_R1.java new file mode 100644 index 0000000..8a04768 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_16_R1.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_16_R1 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_16_R2.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_16_R2.java new file mode 100644 index 0000000..94d617a --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_16_R2.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_16_R2 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_8_R1.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_8_R1.java new file mode 100644 index 0000000..5781ccb --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_8_R1.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_8_R1 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_8_R2.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_8_R2.java new file mode 100644 index 0000000..e24df21 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_8_R2.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_8_R2 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_8_R3.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_8_R3.java new file mode 100644 index 0000000..5767db7 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_8_R3.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_8_R3 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_9_R1.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_9_R1.java new file mode 100644 index 0000000..364c2b5 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_9_R1.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_9_R1 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_9_R2.java b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_9_R2.java new file mode 100644 index 0000000..bea1d82 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/disguise/nms/SkinNMS_v1_9_R2.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.core.disguise.nms; + +import com.allatori.annotations.ControlFlowObfuscation; +import com.allatori.annotations.DoNotRename; +import com.allatori.annotations.ExtensiveFlowObfuscation; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.Collection; +@DoNotRename +@ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) +@ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) +public class SkinNMS_v1_9_R2 implements SkinNMS { + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public Property getProp(String skin) { + try { + URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + skin); + InputStreamReader reader_0 = new InputStreamReader(url_0.openStream()); + String uuid = new JsonParser().parse(reader_0).getAsJsonObject().get("id").getAsString(); + URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false"); + InputStreamReader reader_1 = new InputStreamReader(url_1.openStream()); + JsonObject textureProperty = new JsonParser().parse(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject(); + String texture = textureProperty.get("value").getAsString(); + + String signature = textureProperty.get("signature").getAsString(); + + return new Property("textures", + texture, + signature); + + } catch (IOException | IllegalStateException ignored) { + } + return null; + } + @DoNotRename + @ControlFlowObfuscation(ControlFlowObfuscation.DISABLE) + @ExtensiveFlowObfuscation(ControlFlowObfuscation.DISABLE) + public void setSkin(Player player, String skin, Hestia hestia) { + GameProfile profile = ((CraftPlayer) player).getProfile(); + profile.getProperties().clear(); + if(getProp(skin) != null) { + profile.getProperties().put("textures", getProp(skin)); + try { + if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) { + Collection players = (Collection) Bukkit.class.getMethod("getOnlinePlayers").invoke(null); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } else { + Player[] players = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers").invoke(null)); + new BukkitRunnable() { + @Override + public void run() { + for (Player p : players) { + p.hidePlayer(player); + p.showPlayer(player); + + } + } + }.runTask(hestia); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/me/quartz/hestia/commands/core/permissions/ImportCMD.java b/src/main/java/me/quartz/hestia/commands/core/permissions/ImportCMD.java new file mode 100644 index 0000000..4a1330a --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/core/permissions/ImportCMD.java @@ -0,0 +1,52 @@ +package me.quartz.hestia.commands.core.permissions; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +public class ImportCMD implements CommandExecutor { + + private Hestia hestia; + + public ImportCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("import")){ + if(sender.hasPermission("hestia.import")){ + if(sender instanceof Player){ + Player player = (Player) sender; + Inventory inventory = Bukkit.createInventory(null, 27, "Import Data"); + for(int i = 0; i < inventory.getSize(); i++){ + inventory.setItem(i, hestia.getUtil().itemStack(Material.STAINED_GLASS_PANE, 1, 15, " ")); + } + inventory.setItem(10, hestia.getUtil().itemStack(Material.STAINED_GLASS_PANE, 1, hestia.getServer().getPluginManager().isPluginEnabled("PermissionsEx") ? 13 : 14, hestia.getServer().getPluginManager().isPluginEnabled("PermissionsEx") ? ChatColor.DARK_GREEN + "PermissionsEx" : ChatColor.RED + "PermissionsEx", ChatColor.GRAY + "Import data of PermissionsEx", "", + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "✔" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Remove all current ranks.", + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "✔" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Create all PEX ranks.", + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "✔" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Add all PEX permissions.", + ChatColor.DARK_GRAY + "[" + ChatColor.RED + "✘" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Add players to group." + )); + inventory.setItem(13, hestia.getUtil().itemStack(Material.STAINED_GLASS_PANE, 1, hestia.getServer().getPluginManager().isPluginEnabled("NCore") ? 13 : 14, hestia.getServer().getPluginManager().isPluginEnabled("NCore") ? ChatColor.DARK_GREEN + "nCore" : ChatColor.RED + "nCore", ChatColor.GRAY + "Import data of nCore", "", + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "✔" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Remove all current ranks.", + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "✔" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Remove all current tags.", + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "✔" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Create all nCore ranks.", + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "✔" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Create all nCore tags.", + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "✔" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Add all nCore permissions.", + ChatColor.DARK_GRAY + "[" + ChatColor.RED + "✘" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY + "Add players to group." + )); + inventory.setItem(16, hestia.getUtil().itemStack(Material.STAINED_GLASS_PANE, 1, 14, ChatColor.RED + "???")); + player.openInventory(inventory); + } + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/AlertCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/AlertCMD.java new file mode 100644 index 0000000..8a56417 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/AlertCMD.java @@ -0,0 +1,45 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class AlertCMD implements CommandExecutor { + + private Hestia hestia; + + public AlertCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("alert")){ + if(sender.hasPermission("hestia.alert")){ + if(args.length > 0){ + StringBuilder sb = new StringBuilder(); + for(String s : args){ + sb.append(s).append(" "); + } + String bc = hestia.getMessageUtil().fileM("essentials", "alert").replace("{message}", ChatColor.translateAlternateColorCodes('&', sb.toString())); + if(hestia.getConfig().getString("sync-storage").equalsIgnoreCase("Redis")) { + hestia.getRedisManager().getRedisPublish().pub("alert", bc); + }else if(hestia.getConfig().getString("sync-storage").equalsIgnoreCase("BungeeCord")) { + if(hestia.getServer().getPluginManager().isPluginEnabled("Hestia-BungeeSync")) { + //HestiaBungeeSync.postInfo("alert", bc); + } + Bukkit.broadcastMessage(bc); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/" + command.getName().toLowerCase() + " [Message]").replace("{usage-c}", "/" + command.getName().toLowerCase() + "" + ChatColor.WHITE + " [Message]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/BroadcastCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/BroadcastCMD.java new file mode 100644 index 0000000..5b9820e --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/BroadcastCMD.java @@ -0,0 +1,37 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class BroadcastCMD implements CommandExecutor { + + private Hestia hestia; + + public BroadcastCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("broadcast")){ + if(sender.hasPermission("hestia.broadcast")){ + if(args.length > 0){ + StringBuilder sb = new StringBuilder(); + for(String s : args){ + sb.append(s).append(" "); + } + Bukkit.broadcastMessage(hestia.getMessageUtil().fileM("essentials", "broadcast").replace("{message}", ChatColor.translateAlternateColorCodes('&', sb.toString()))); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/" + command.getName().toLowerCase() + " [Message]").replace("{usage-c}", "/" + command.getName().toLowerCase() + "" + ChatColor.WHITE + " [Message]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/ClearCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/ClearCMD.java new file mode 100644 index 0000000..5e7179c --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/ClearCMD.java @@ -0,0 +1,58 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class ClearCMD implements CommandExecutor { + + private Hestia hestia; + + public ClearCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("clear")){ + if(sender.hasPermission("hestia.clear")){ + if(args.length > 0){ + if(sender.hasPermission("hestia.clear.other")) { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { + player.getInventory().clear(); + player.getInventory().setBoots(null); + player.getInventory().setLeggings(null); + player.getInventory().setChestplate(null); + player.getInventory().setHelmet(null); + player.sendMessage(hestia.getMessageUtil().fileM("essentials", "clear")); + if (player != sender) { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "clear-other").replace("{player}", player.getName())); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } else if(sender instanceof Player){ + Player player = (Player) sender; + player.getInventory().clear(); + player.getInventory().setBoots(null); + player.getInventory().setLeggings(null); + player.getInventory().setChestplate(null); + player.getInventory().setHelmet(null); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "clear").replace("{player}", player.getName())); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/FeedCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/FeedCMD.java new file mode 100644 index 0000000..51a7fd6 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/FeedCMD.java @@ -0,0 +1,50 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class FeedCMD implements CommandExecutor { + + private Hestia hestia; + + public FeedCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("feed")){ + if(sender.hasPermission("hestia.feed")){ + if(args.length > 0){ + if(sender.hasPermission("hestia.feed.other")) { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { + player.setFoodLevel(20); + player.sendMessage(hestia.getMessageUtil().fileM("essentials", "feed")); + if (player != sender) { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "feed-other").replace("{player}", player.getName())); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } else if(sender instanceof Player){ + Player player = (Player) sender; + player.setFoodLevel(20); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "feed").replace("{player}", player.getName())); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/FlyCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/FlyCMD.java new file mode 100644 index 0000000..b1863c6 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/FlyCMD.java @@ -0,0 +1,51 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class FlyCMD implements CommandExecutor { + + private Hestia hestia; + + public FlyCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("fly")){ + if(sender.hasPermission("hestia.fly")){ + if(args.length > 0){ + if(sender.hasPermission("hestia.fly.other")) { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { + player.setAllowFlight(!player.getAllowFlight()); + player.sendMessage(hestia.getMessageUtil().fileM("essentials", "fly").replace("{toggle}", player.getAllowFlight() ? "enabled" : "disabled")); + if (player != sender) { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "fly-other").replace("{player}", player.getName()).replace("{toggle}", player.getAllowFlight() ? "enabled" : "disabled")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } else if(sender instanceof Player){ + Player player = (Player) sender; + player.setAllowFlight(!player.getAllowFlight()); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "fly").replace("{player}", player.getName()).replace("{toggle}", player.getAllowFlight() ? "enabled" : "disabled")); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/GamemodeCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/GamemodeCMD.java new file mode 100644 index 0000000..5d20b4b --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/GamemodeCMD.java @@ -0,0 +1,59 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class GamemodeCMD implements CommandExecutor { + + private Hestia hestia; + + public GamemodeCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("gamemode")){ + if( + sender.hasPermission("hestia.gamemode") || + sender.hasPermission("hestia.gamemode.other") || + sender.hasPermission("hestia.gamemode.creative") || + sender.hasPermission("hestia.gamemode.survival") || + sender.hasPermission("hestia.gamemode.adventure") || + sender.hasPermission("hestia.gamemode.creative.other") || + sender.hasPermission("hestia.gamemode.survival.other") || + sender.hasPermission("hestia.gamemode.adventure.other") + ){ + if(args.length > 0) { + if(args.length > 1) { + Player player = Bukkit.getPlayer(args[1]); + if (player != null) { + GameMode gameMode = hestia.getUtil().getGameMode(player, args[0]); + hestia.getUtil().setGamemode(sender, player, gameMode, hestia); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[1])); + } + } else if(sender instanceof Player) { + Player player = (Player) sender; + GameMode gameMode = hestia.getUtil().getGameMode(player, args[0]); + hestia.getUtil().setGamemodePersonal(sender, player, gameMode, hestia); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/gamemode [GameMode] ").replace("{usage-c}", "/gamemode" + ChatColor.WHITE + " [GameMode] ")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } + +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/GiveCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/GiveCMD.java new file mode 100644 index 0000000..31c7adb --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/GiveCMD.java @@ -0,0 +1,52 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class GiveCMD implements CommandExecutor { + + private Hestia hestia; + + public GiveCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("give")){ + if(sender.hasPermission("hestia.give")){ + if(args.length > 1) { + Player player = Bukkit.getPlayer(args[0]); + if(player != null){ + if(Material.getMaterial(args[1].toUpperCase()) != null){ + Material material = Material.valueOf(args[1].toUpperCase()); + int amount = 1; + if(args.length > 2 && NumberUtils.isNumber(args[2])){ + amount = Integer.parseInt(args[2]); + } + player.getInventory().addItem(new ItemStack(material, amount)); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "give").replace("{material}", material.name()).replace("{amount}", amount + "").replace("{player}", player.getName())); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "material-not-found").replace("{material}", args[1])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/give [Player] [Material] ").replace("{usage-c}", "/give" + ChatColor.WHITE + " [Player] [Material] ")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/GmaCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/GmaCMD.java new file mode 100644 index 0000000..0454b31 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/GmaCMD.java @@ -0,0 +1,47 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class GmaCMD implements CommandExecutor { + + private Hestia hestia; + + public GmaCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("gma")) { + if ( + sender.hasPermission("hestia.gamemode") || + sender.hasPermission("hestia.gamemode.other") || + sender.hasPermission("hestia.gamemode.adventure") || + sender.hasPermission("hestia.gamemode.adventure.other") + ) { + if (args.length > 0) { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { + GameMode gameMode = GameMode.ADVENTURE; + hestia.getUtil().setGamemode(sender, player, gameMode, hestia); + } + } else if (sender instanceof Player) { + Player player = (Player) sender; + GameMode gameMode = GameMode.ADVENTURE; + hestia.getUtil().setGamemodePersonal(sender, player, gameMode, hestia); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} \ No newline at end of file diff --git a/src/main/java/me/quartz/hestia/commands/essentials/GmcCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/GmcCMD.java new file mode 100644 index 0000000..474cd2a --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/GmcCMD.java @@ -0,0 +1,48 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class GmcCMD implements CommandExecutor { + + private Hestia hestia; + + public GmcCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("gmc")) { + if ( + sender.hasPermission("hestia.gamemode") || + sender.hasPermission("hestia.gamemode.other") || + sender.hasPermission("hestia.gamemode.creative") || + sender.hasPermission("hestia.gamemode.creative.other") + ) { + if (args.length > 0) { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { + GameMode gameMode = GameMode.CREATIVE; + hestia.getUtil().setGamemode(sender, player, gameMode, hestia); + } + } else if (sender instanceof Player) { + Player player = (Player) sender; + GameMode gameMode = GameMode.CREATIVE; + hestia.getUtil().setGamemodePersonal(sender, player, gameMode, hestia); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/GmsCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/GmsCMD.java new file mode 100644 index 0000000..5846d6e --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/GmsCMD.java @@ -0,0 +1,47 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class GmsCMD implements CommandExecutor { + + private Hestia hestia; + + public GmsCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("gms")) { + if ( + sender.hasPermission("hestia.gamemode") || + sender.hasPermission("hestia.gamemode.other") || + sender.hasPermission("hestia.gamemode.survival") || + sender.hasPermission("hestia.gamemode.survival.other") + ) { + if (args.length > 0) { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { + GameMode gameMode = GameMode.SURVIVAL; + hestia.getUtil().setGamemode(sender, player, gameMode, hestia); + } + } else if (sender instanceof Player) { + Player player = (Player) sender; + GameMode gameMode = GameMode.SURVIVAL; + hestia.getUtil().setGamemodePersonal(sender, player, gameMode, hestia); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/GmspCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/GmspCMD.java new file mode 100644 index 0000000..a1e1d13 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/GmspCMD.java @@ -0,0 +1,49 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class GmspCMD implements CommandExecutor { + + private Hestia hestia; + + public GmspCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("gmsp")) { + if(hestia.version >= 8) { + if ( + sender.hasPermission("hestia.gamemode") || + sender.hasPermission("hestia.gamemode.other") || + sender.hasPermission("hestia.gamemode.spectator") || + sender.hasPermission("hestia.gamemode.spectator.other") + ) { + if (args.length > 0) { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { + GameMode gameMode = GameMode.SPECTATOR; + hestia.getUtil().setGamemode(sender, player, gameMode, hestia); + } + } else if (sender instanceof Player) { + Player player = (Player) sender; + GameMode gameMode = GameMode.SPECTATOR; + hestia.getUtil().setGamemodePersonal(sender, player, gameMode, hestia); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/HealCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/HealCMD.java new file mode 100644 index 0000000..568edac --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/HealCMD.java @@ -0,0 +1,58 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; + +public class HealCMD implements CommandExecutor { + + private Hestia hestia; + + public HealCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("heal")){ + if(sender.hasPermission("hestia.heal")){ + if(args.length > 0){ + if(sender.hasPermission("hestia.heal.other")) { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { + player.setHealth(20); + player.setFoodLevel(20); + player.getActivePotionEffects().clear(); + player.sendMessage(hestia.getMessageUtil().fileM("essentials", "heal")); + for (PotionEffect effect :player.getActivePotionEffects ()){ + player.removePotionEffect(effect.getType()); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } else if(sender instanceof Player){ + Player player = (Player) sender; + player.setHealth(20); + player.setFoodLevel(20); + for (PotionEffect effect :player.getActivePotionEffects ()){ + player.removePotionEffect(effect.getType()); + } + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "heal").replace("{player}", player.getName())); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/IgnoreCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/IgnoreCMD.java new file mode 100644 index 0000000..4891a22 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/IgnoreCMD.java @@ -0,0 +1,88 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +public class IgnoreCMD implements CommandExecutor { + + private Hestia hestia; + + public IgnoreCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("ignore")){ + if(sender.hasPermission("hestia.ignore")) { + if(sender instanceof Player) { + Player player = (Player) sender; + if (args.length > 0) { + Player target = Bukkit.getPlayer(args[0]); + Profile profile; + profile = Profile.getProfile(player.getUniqueId(), hestia); + if (profile != null) { + if (target != null) { + List ignores = profile.getIgnoreList(); + if (ignores.contains(target.getName())) { + ignores.remove(target.getName()); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "unignored").replace("{player}", target.getName())); + } else { + ignores.add(target.getName()); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "ignored").replace("{player}", target.getName())); + } + profile.setIgnoreList(ignores); + } else if (args[0].equalsIgnoreCase("list")) { + TextComponent ignores = new TextComponent(""); + int ignoretime = profile.getIgnoreList().size(); + for (String ignore : profile.getIgnoreList()) { + ignoretime--; + TextComponent delete = new TextComponent(ChatColor.DARK_GRAY + "(" + ChatColor.DARK_RED + "✘" + ChatColor.DARK_GRAY + ") "); + TextComponent extra; + if (ignoretime == 0) { + extra = new TextComponent(ignore); + } else { + extra = new TextComponent(ignore + ", "); + } + delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&cRemove '" + ignore + "' from ignore list.")).create())); + delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ignore " + ignore)); + ignores.addExtra(delete); + ignores.addExtra(extra); + } + for(String string : hestia.getMessageUtil().fileMList("essentials", "ignore-list")) { + if(string.contains("{ignores}")){ + ((Player) sender).spigot().sendMessage(ignores); + } else { + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', string).replace("{amount}", profile.getIgnoreList().size() + "")); + } + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/ignore [Player]").replace("{usage-c}", "/ignore" + ChatColor.WHITE + " [Player]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} \ No newline at end of file diff --git a/src/main/java/me/quartz/hestia/commands/essentials/InvseeCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/InvseeCMD.java new file mode 100644 index 0000000..70bc393 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/InvseeCMD.java @@ -0,0 +1,70 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.scheduler.BukkitRunnable; + +public class InvseeCMD implements CommandExecutor { + + private Hestia hestia; + + public InvseeCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("invsee")){ + if(sender.hasPermission("hestia.invsee")){ + if(sender instanceof Player) { + Player player = (Player) sender; + if (args.length > 0) { + Player target = Bukkit.getPlayer(args[0]); + if (target != null) { + Inventory inventory = Bukkit.createInventory(null, 54, ChatColor.GRAY + "Inventory of " + target.getName()); + player.openInventory(inventory); + new BukkitRunnable(){ + @Override + public void run() { + if(target.isOnline()) { + if (player.getOpenInventory() != null + && player.getOpenInventory().getTopInventory() != null + && player.getOpenInventory().getTopInventory().getTitle() != null + && player.getOpenInventory().getTopInventory().getTitle().startsWith(ChatColor.GRAY + "Inventory of") + ) { + player.getOpenInventory().getTopInventory().setContents(target.getInventory().getContents()); + player.getOpenInventory().getTopInventory().setItem(53, target.getInventory().getHelmet()); + player.getOpenInventory().getTopInventory().setItem(52, target.getInventory().getChestplate()); + player.getOpenInventory().getTopInventory().setItem(51, target.getInventory().getLeggings()); + player.getOpenInventory().getTopInventory().setItem(50, target.getInventory().getBoots()); + } else { + cancel(); + } + } else { + player.closeInventory(); + cancel(); + } + } + }.runTaskTimer(hestia, 0, 1); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[1])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/invsee [Player]").replace("{usage-c}", "/invsee" + ChatColor.WHITE + " [Player]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/ItemCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/ItemCMD.java new file mode 100644 index 0000000..f039cbc --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/ItemCMD.java @@ -0,0 +1,52 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class ItemCMD implements CommandExecutor { + + private Hestia hestia; + + public ItemCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("item")){ + if(sender.hasPermission("hestia.item")){ + if(args.length > 0) { + if(sender instanceof Player){ + Player player = (Player) sender; + if(Material.getMaterial(args[0].toUpperCase()) != null){ + Material material = Material.valueOf(args[0].toUpperCase()); + int amount = 1; + if(args.length > 1 && NumberUtils.isNumber(args[1])){ + amount = Integer.parseInt(args[1]); + } + player.getInventory().addItem(new ItemStack(material, amount)); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "item").replace("{material}", material.name()).replace("{amount}", amount + "")); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "material-not-found").replace("{material}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/item [Material] ").replace("{usage-c}", "/item" + ChatColor.WHITE + " [Material] ")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/ListCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/ListCMD.java new file mode 100644 index 0000000..b9f0f33 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/ListCMD.java @@ -0,0 +1,84 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.commands.staff.vanish.VanishCMD; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.rank.Rank; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.List; + +public class ListCMD implements CommandExecutor { + + private Hestia hestia; + + public ListCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("list")){ + if(sender.hasPermission("hestia.list")){ + List ranks; + if (hestia.getConfig().getString("data-storage").equalsIgnoreCase("MySQL")) { + ranks = hestia.getRankMySQL().getRanks(); + } else { + ranks = hestia.getRankMongoDB().getRanks(); + } + StringBuilder rankSB = new StringBuilder(); + HashMap ranksHashmap = new HashMap<>(); + for (Rank rank : ranks) { + ranksHashmap.put(rank, rank.getPriority()); + } + for(Rank rank : hestia.getUtil().sorted(ranksHashmap).keySet()){ + rankSB.append(rank.getColor()).append((rank.isBold() ? ChatColor.BOLD + "" : "")).append((rank.isItalic() ? ChatColor.ITALIC + "" : "")).append(rank.getName()).append(ChatColor.WHITE).append(", "); + } + StringBuilder playerSB = new StringBuilder(); + HashMap playerHashmap = new HashMap<>(); + for(Player player : Bukkit.getOnlinePlayers()) { + Profile profile = Profile.getProfile(player.getUniqueId(), hestia); + if (profile != null) { + Rank rank = null; + for (Rank rankies : ranks) { + if (rankies.getName().equalsIgnoreCase(profile.getRankString(true))) { + rank = rankies; + } + } + if (rank != null) { + playerHashmap.put(player, rank); + } + } + } + for(Rank rank : hestia.getUtil().sorted(ranksHashmap).keySet()) { + for (Player player : playerHashmap.keySet()) { + if (playerHashmap.get(player) == rank) { + if (!VanishCMD.getVanished().contains(player)) { + playerSB.append(rank.getColor()).append((rank.isBold() ? ChatColor.BOLD + "" : "")).append((rank.isItalic() ? ChatColor.ITALIC + "" : "")).append(player.getName()).append(ChatColor.WHITE).append(", "); + }else if (sender.hasPermission("hestia.notify")) { + playerSB.append(ChatColor.AQUA).append("[S] ").append(rank.getColor()).append((rank.isBold() ? ChatColor.BOLD + "" : "")).append((rank.isItalic() ? ChatColor.ITALIC + "" : "")).append(player.getName()).append(ChatColor.WHITE).append(", "); + } + } + } + } + for(String string : hestia.getMessageUtil().fileMList("essentials", "list")){ + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', string. + replace("{ranks}", rankSB.toString().length() > 1 ? rankSB.toString().substring(0, rankSB.toString().length() - 2) : ""). + replace("{players}", playerSB.toString().length() > 1 ? playerSB.toString().substring(0, playerSB.toString().length() - 2) : ""). + replace("{max}", Bukkit.getMaxPlayers() + ""). + replace("{online}", (Bukkit.getOnlinePlayers().size() - VanishCMD.getVanished().size()) + "") + )); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/LoreCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/LoreCMD.java new file mode 100644 index 0000000..45320bf --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/LoreCMD.java @@ -0,0 +1,95 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.ArrayList; +import java.util.List; + +public class LoreCMD implements CommandExecutor { + + private Hestia hestia; + + public LoreCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("lore")){ + if(sender.hasPermission("hestia.lore")){ + if(sender instanceof Player) { + Player player = (Player) sender; + if (args.length > 0) { + if (args[0].equalsIgnoreCase("add")) { + if (args.length > 1) { + ItemStack itemStack = player.getInventory().getItemInHand(); + if (itemStack != null && itemStack.getType() != Material.AIR) { + StringBuilder line = new StringBuilder(); + for (int i = 1; i < args.length; i++) { + line.append(args[i]).append(" "); + } + ItemMeta itemMeta = itemStack.getItemMeta(); + List lore = new ArrayList<>(); + if(itemMeta.getLore() != null){ + lore.addAll(itemMeta.getLore()); + } + lore.add(ChatColor.translateAlternateColorCodes('&', line.toString())); + itemMeta.setLore(lore); + player.getInventory().getItemInHand().setItemMeta(itemMeta); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "added-lore").replace("{number}", lore.size() + "")); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "no-item")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/lore add [Text]").replace("{usage-c}", "/lore add" + ChatColor.WHITE + " [Text]")); + } + }else if (args[0].equalsIgnoreCase("delete")) { + if (args.length > 1) { + ItemStack itemStack = player.getInventory().getItemInHand(); + if (itemStack != null && itemStack.getType() != Material.AIR) { + if (NumberUtils.isNumber(args[1])) { + int i = Integer.parseInt(args[1]) - 1; + ItemMeta itemMeta = itemStack.getItemMeta(); + if (itemMeta.getLore() != null && itemMeta.getLore().size() >= i) { + List lore = itemMeta.getLore(); + lore.remove(i); + itemMeta.setLore(lore); + player.getInventory().getItemInHand().setItemMeta(itemMeta); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "deleted-lore").replace("{number}", (i + 1) + "")); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "no-lore")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-number")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "no-item")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/lore delete [Line]").replace("{usage-c}", "/lore delete" + ChatColor.WHITE + " [Line]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/lore add/delete").replace("{usage-c}", "/lore add/delete" + ChatColor.WHITE + "")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/lore add/delete").replace("{usage-c}", "/lore add/delete" + ChatColor.WHITE + "")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/MessageCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/MessageCMD.java new file mode 100644 index 0000000..c6732f2 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/MessageCMD.java @@ -0,0 +1,89 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.commands.staff.vanish.VanishCMD; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.rank.Rank; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Sound; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class MessageCMD implements CommandExecutor { + + private Hestia hestia; + private static HashMap recents = new HashMap<>(); + + public static HashMap getRecents() { + return recents; + } + + public MessageCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("message")) { + if (sender.hasPermission("hestia.message")) { + if (sender instanceof Player) { + Player player = (Player) sender; + if (args.length > 1) { + Player target = Bukkit.getPlayer(args[0]); + if (target != null && (!VanishCMD.getVanished().contains(target) || sender.hasPermission("hestia.vanish"))) { + StringBuilder sb = new StringBuilder(); + for (int i = 1; i < args.length; i++) { + sb.append(args[i]).append(" "); + } + Profile profileTarget = Profile.getProfile(target.getUniqueId(), hestia); + if (profileTarget != null && !profileTarget.getIgnoreList().contains(player.getName())) { + if(profileTarget.isPm()) { + Profile profilePlayer = Profile.getProfile(player.getUniqueId(), hestia); + if (profilePlayer != null && !profilePlayer.getIgnoreList().contains(target.getName())) { + if(profilePlayer.isPm()) { + new Thread(() -> { + Rank targetRank = profileTarget.getRank(true); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("chat.to-format").replace("{player}", targetRank.getColor() + (targetRank.isBold() ? ChatColor.BOLD + "" : "") + (targetRank.isItalic() ? ChatColor.ITALIC + "" : "") + target.getName()).replace("{message}", sb.toString()))); + }).start(); + new Thread(() -> { + Rank playerRank = profilePlayer.getRank(true); + target.sendMessage(ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("chat.from-format").replace("{player}", playerRank.getColor() + (playerRank.isBold() ? ChatColor.BOLD + "" : "") + (playerRank.isItalic() ? ChatColor.ITALIC + "" : "") + player.getName()).replace("{message}", sb.toString()))); + MessageCMD.getRecents().put(player, target); + MessageCMD.getRecents().put(target, player); + if(profileTarget.isSounds()) { + target.playSound(player.getLocation(), "SUCCESSFUL_HIT", 10, 1); + } + }).start(); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "player-togglepm")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "player-ignored")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "target-togglepm")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "target-ignored")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/message [Player] [Message]").replace("{usage-c}", "/message" + ChatColor.WHITE + " [Player] [Message]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/me/quartz/hestia/commands/essentials/OnlineStaffCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/OnlineStaffCMD.java new file mode 100644 index 0000000..93c068c --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/OnlineStaffCMD.java @@ -0,0 +1,79 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.commands.core.disguise.Disguise; +import me.quartz.hestia.commands.staff.vanish.VanishCMD; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.rank.Rank; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class OnlineStaffCMD implements CommandExecutor { + + private Hestia hestia; + + public OnlineStaffCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("onlinestaff")){ + if(sender.hasPermission("hestia.onlinestaff")){ + List ranks; + if (hestia.getConfig().getString("data-storage").equalsIgnoreCase("MySQL")) { + ranks = hestia.getRankMySQL().getRanks(); + } else { + ranks = hestia.getRankMongoDB().getRanks(); + } + HashMap ranksHashmap = new HashMap<>(); + for (Rank rank : ranks) { + ranksHashmap.put(rank, rank.getPriority()); + } + StringBuilder playerSB = new StringBuilder(); + HashMap playerHashmap = new HashMap<>(); + for(Player player : Bukkit.getOnlinePlayers()) { + if (player.hasPermission("hestia.staff") && !VanishCMD.getVanished().contains(player) && (Disguise.getRealName(player.getName()) == null)) { + Profile profile = Profile.getProfile(player.getUniqueId(), hestia); + if (profile != null) { + Rank rank = null; + for (Rank rankies : ranks) { + if (rankies.getName().equalsIgnoreCase(profile.getRankString(true))) { + rank = rankies; + } + } + if (rank != null) { + playerHashmap.put(player, rank); + } + } + } + } + for(Rank rank : hestia.getUtil().sorted(ranksHashmap).keySet()) { + for (Player player : playerHashmap.keySet()) { + if (playerHashmap.get(player) == rank) { + playerSB.append(rank.getPrefix()).append(rank.getColor()).append((rank.isBold() ? ChatColor.BOLD + "" : "")).append((rank.isItalic() ? ChatColor.ITALIC + "" : "")).append(player.getName()).append(ChatColor.WHITE).append("\n"); + } + } + } + for(String string : hestia.getMessageUtil().fileMList("essentials", "onlinestaff")){ + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', string. + replace("{players}", playerSB.toString()). + replace("{max}", Bukkit.getMaxPlayers() + ""). + replace("{online}", Bukkit.getOnlinePlayers().size() + "") + )); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/PingCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/PingCMD.java new file mode 100644 index 0000000..90f8a35 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/PingCMD.java @@ -0,0 +1,60 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.lang.reflect.InvocationTargetException; + +public class PingCMD implements CommandExecutor { + + private Hestia hestia; + + public PingCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("ping")){ + if(sender.hasPermission("hestia.ping")){ + if(args.length > 0){ + if(sender.hasPermission("hestia.ping.other")) { + Player player = Bukkit.getPlayer(args[0]); + if (player != null) { + try { + Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player); + int ping = (int) entityPlayer.getClass().getField("ping").get(entityPlayer); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "ping-other").replace("{ping}", ping + "").replace("{player}", player.getName())); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | NoSuchFieldException e) { + sender.sendMessage(ChatColor.RED + "Error."); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } else if(sender instanceof Player){ + Player player = (Player) sender; + try { + Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player); + int ping = (int) entityPlayer.getClass().getField("ping").get(entityPlayer); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "ping").replace("{ping}", ping + "")); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | NoSuchFieldException e) { + sender.sendMessage(ChatColor.RED + "Error."); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/RenameCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/RenameCMD.java new file mode 100644 index 0000000..3140d1c --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/RenameCMD.java @@ -0,0 +1,57 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.ArrayList; +import java.util.List; + +public class RenameCMD implements CommandExecutor { + + private Hestia hestia; + + public RenameCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("rename")){ + if(sender.hasPermission("hestia.rename")){ + if(sender instanceof Player) { + Player player = (Player) sender; + if (args.length > 0) { + ItemStack itemStack = player.getInventory().getItemInHand(); + if (itemStack != null && itemStack.getType() != Material.AIR) { + StringBuilder line = new StringBuilder(); + for (String arg : args) { + line.append(arg).append(" "); + } + ItemMeta itemMeta = itemStack.getItemMeta(); + itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', line.toString())); + player.getInventory().getItemInHand().setItemMeta(itemMeta); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "renamed")); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "no-item")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/lore add/delete").replace("{usage-c}", "/lore add/delete" + ChatColor.WHITE + "")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/ReplyCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/ReplyCMD.java new file mode 100644 index 0000000..1ede38d --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/ReplyCMD.java @@ -0,0 +1,84 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.commands.staff.vanish.VanishCMD; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.rank.Rank; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Sound; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.HashMap; + +public class ReplyCMD implements CommandExecutor { + + private Hestia hestia; + + public ReplyCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("reply")) { + if (sender.hasPermission("hestia.reply")) { + if (sender instanceof Player) { + Player player = (Player) sender; + if (args.length > 0) { + Player target = MessageCMD.getRecents().getOrDefault(player, null); + if (target != null && (!VanishCMD.getVanished().contains(target) || sender.hasPermission("hestia.vanish"))) { + StringBuilder sb = new StringBuilder(); + for (String arg : args) { + sb.append(arg).append(" "); + } + Profile profileTarget = Profile.getProfile(target.getUniqueId(), hestia); + if (profileTarget != null && !profileTarget.getIgnoreList().contains(player.getName())) { + if(profileTarget.isPm()) { + Profile profilePlayer = Profile.getProfile(player.getUniqueId(), hestia); + if (profilePlayer != null && !profilePlayer.getIgnoreList().contains(target.getName())) { + if(profilePlayer.isPm()) { + new Thread(() -> { + Rank targetRank = profileTarget.getRank(true); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("chat.to-format").replace("{player}", target.getName()).replace("{player-color}", targetRank.getColor() + (targetRank.isBold() ? ChatColor.BOLD + "" : "") + (targetRank.isItalic() ? ChatColor.ITALIC + "" : "") + target.getName()).replace("{message}", sb.toString()))); + }).start(); + new Thread(() -> { + Rank playerRank = profilePlayer.getRank(true); + target.sendMessage(ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("chat.from-format").replace("{player}", player.getName()).replace("{player-color}", playerRank.getColor() + (playerRank.isBold() ? ChatColor.BOLD + "" : "") + (playerRank.isItalic() ? ChatColor.ITALIC + "" : "") + player.getName()).replace("{message}", sb.toString()))); + MessageCMD.getRecents().put(player, target); + MessageCMD.getRecents().put(target, player); + if(profileTarget.isSounds()) { + target.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 10, 1); + } + }).start(); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "player-togglepm")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "player-ignored")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "target-togglepm")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "target-ignored")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "no-reply").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/reply [Message]").replace("{usage-c}", "/reply" + ChatColor.WHITE + " [Message]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return false; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/SkullCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/SkullCMD.java new file mode 100644 index 0000000..0fbdef2 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/SkullCMD.java @@ -0,0 +1,55 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public class SkullCMD implements CommandExecutor { + + private Hestia hestia; + + public SkullCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("skull")){ + if(sender.hasPermission("hestia.skull")){ + if(sender instanceof Player) { + Player player = (Player) sender; + if (args.length > 0) { + if (sender.hasPermission("hestia.skull.other")) { + ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1); + SkullMeta skullMeta = (SkullMeta) skull.getItemMeta(); + skullMeta.setOwner((args[0])); + skull.setItemMeta(skullMeta); + player.getInventory().addItem(skull); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "skull").replace("{player}", args[0])); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } else { + ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1); + SkullMeta skullMeta = (SkullMeta) skull.getItemMeta(); + skullMeta.setOwner(player.getName()); + skull.setItemMeta(skullMeta); + player.getInventory().addItem(skull); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "skull").replace("{player}", player.getName())); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/SoundsCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/SoundsCMD.java new file mode 100644 index 0000000..9ae6553 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/SoundsCMD.java @@ -0,0 +1,41 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class SoundsCMD implements CommandExecutor { + + private Hestia hestia; + + public SoundsCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("sounds")){ + if(sender.hasPermission("hestia.sounds")){ + if(sender instanceof Player){ + Player player = (Player) sender; + Profile profile = Profile.getProfile(player.getUniqueId(), hestia); + if(profile != null){ + profile.toggleSounds(); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "sounds").replace("{player}", sender.getName()).replace("{toggle}", (profile.isSounds() ? "enabled" : "disabled"))); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return false; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/SpeedCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/SpeedCMD.java new file mode 100644 index 0000000..457ce5b --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/SpeedCMD.java @@ -0,0 +1,55 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class SpeedCMD implements CommandExecutor { + + private Hestia hestia; + + public SpeedCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("speed")){ + if(sender.hasPermission("hestia.speed")){ + if(sender instanceof Player) { + if (args.length > 0) { + Player player = (Player) sender; + if(NumberUtils.isNumber(args[0]) && !args[0].contains("f")){ + double speed = Double.parseDouble(args[0]); + if(speed <= 10 && speed >= 0) { + if (player.isFlying()) { + player.setFlySpeed((float) (speed / 10)); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "flyspeed").replace("{speed}", speed + "")); + } else { + player.setWalkSpeed((float) (speed / 10)); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "walkspeed").replace("{speed}", speed + "")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "maxspeed")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-number")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/speed [Speed]").replace("{usage-c}", "/speed" + ChatColor.WHITE + " [Speed]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/StaffAlertsCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/StaffAlertsCMD.java new file mode 100644 index 0000000..df2c0c0 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/StaffAlertsCMD.java @@ -0,0 +1,40 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class StaffAlertsCMD implements CommandExecutor { + + private Hestia hestia; + + public StaffAlertsCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("staffalerts")){ + if(sender.hasPermission("hestia.staffalerts")){ + if(sender instanceof Player){ + Player player = (Player) sender; + Profile profile = Profile.getProfile(player.getUniqueId(), hestia); + if(profile != null){ + profile.toggleAlerts(); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "staffalert").replace("{player}", sender.getName()).replace("{toggle}", (profile.isAlerts() ? "enabled" : "disabled"))); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return false; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/SudoCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/SudoCMD.java new file mode 100644 index 0000000..8403f1c --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/SudoCMD.java @@ -0,0 +1,49 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class SudoCMD implements CommandExecutor { + + private Hestia hestia; + + public SudoCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("sudo")){ + if(sender.hasPermission("hestia.sudo")){ + if(args.length > 1){ + Player player = Bukkit.getPlayer(args[0]); + if(player != null){ + StringBuilder commandS = new StringBuilder(); + for(int i = 1; i < args.length; i++){ + commandS.append(args[i]).append(" "); + } + String execute = commandS.toString(); + if(execute.startsWith("/")){ + player.performCommand(execute.replaceFirst("/", "")); + } else { + player.chat(execute); + } + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "sudo").replace("{player}", player.getName()).replace("{execute}", execute.substring(0, execute.length() - 1))); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/sudo [Player] [Execute]").replace("{usage-c}", "/sudo" + ChatColor.WHITE + " [Player] [Execute]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/TeleportCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/TeleportCMD.java new file mode 100644 index 0000000..44e9eb6 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/TeleportCMD.java @@ -0,0 +1,67 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class TeleportCMD implements CommandExecutor { + + private Hestia hestia; + + public TeleportCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("teleport")){ + if(sender.hasPermission("hestia.teleport")){ + Player target = null; + Player teleporter = null; + if(args.length == 1){ + if(sender instanceof Player){ + teleporter = (Player) sender; + target = Bukkit.getPlayer(args[0]); + if(target != null){ + teleporter.teleport(target); + teleporter.sendMessage(hestia.getMessageUtil().fileM("essentials", "teleport").replace("{player}", target.getName())); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else if(args.length > 1) { + if (sender.hasPermission("hestia.teleporthere")) { + teleporter = Bukkit.getPlayer(args[0]); + target = Bukkit.getPlayer(args[1]); + if (teleporter != null) { + if (target != null) { + teleporter.teleport(target); + teleporter.sendMessage(hestia.getMessageUtil().fileM("essentials", "teleport").replace("{player}", target.getName())); + if(teleporter != sender){ + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "teleport-other").replace("{player}", teleporter.getName()).replace("{target}", target.getName())); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[1])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/teleport [Player] ").replace("{usage-c}", "/teleport" + ChatColor.WHITE + " [Player] ")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/TeleportHereCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/TeleportHereCMD.java new file mode 100644 index 0000000..5e4f5b1 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/TeleportHereCMD.java @@ -0,0 +1,48 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class TeleportHereCMD implements CommandExecutor { + + private Hestia hestia; + + public TeleportHereCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("teleporthere")) { + if (sender.hasPermission("hestia.teleporthere")) { + if (args.length > 0) { + if (sender instanceof Player) { + Player player = (Player) sender; + Player target = Bukkit.getPlayer(args[0]); + if(target != null){ + target.teleport(player); + target.sendMessage(hestia.getMessageUtil().fileM("essentials", "teleport").replace("{player}", player.getName())); + if(target != player) { + player.sendMessage(hestia.getMessageUtil().fileM("essentials", "teleport-here").replace("{player}", target.getName())); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "player-not-found").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/teleporthere [Player]").replace("{usage-c}", "/teleporthere" + ChatColor.WHITE + " [Player]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/TeleportPosCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/TeleportPosCMD.java new file mode 100644 index 0000000..d8ac81b --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/TeleportPosCMD.java @@ -0,0 +1,47 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class TeleportPosCMD implements CommandExecutor { + + private Hestia hestia; + + public TeleportPosCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (command.getName().equalsIgnoreCase("teleportpos")) { + if (sender.hasPermission("hestia.teleportpos")) { + if (args.length > 2) { + if (sender instanceof Player) { + Player player = (Player) sender; + if (NumberUtils.isNumber(args[0]) && NumberUtils.isNumber(args[1]) && NumberUtils.isNumber(args[2])) { + Location location = new Location(player.getWorld(), ((Integer.parseInt(args[0]) > 0) ? Integer.parseInt(args[0]) + 0.5 : Integer.parseInt(args[0]) - 0.5), Integer.parseInt(args[1]), ((Integer.parseInt(args[2]) > 0) ? Integer.parseInt(args[2]) + 0.5 : Integer.parseInt(args[2]) - 0.5)); + player.teleport(location); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "teleport-pos").replace("{location}", args[0] + ", " + args[1] + ", " + args[2])); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-number").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/teleportpos [x] [y] [z]").replace("{usage-c}", "/teleportpos" + ChatColor.WHITE + " [x] [y] [z]")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return true; + } +} \ No newline at end of file diff --git a/src/main/java/me/quartz/hestia/commands/essentials/ToggleGlobalChatCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/ToggleGlobalChatCMD.java new file mode 100644 index 0000000..d5e54c7 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/ToggleGlobalChatCMD.java @@ -0,0 +1,40 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class ToggleGlobalChatCMD implements CommandExecutor { + + private Hestia hestia; + + public ToggleGlobalChatCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("toggleglobalchat")){ + if(sender.hasPermission("hestia.toggleglobalchat")){ + if(sender instanceof Player){ + Player player = (Player) sender; + Profile profile = Profile.getProfile(player.getUniqueId(), hestia); + if(profile != null){ + profile.toggleGlobalchat(); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "toggleglobalchat").replace("{player}", sender.getName()).replace("{toggle}", (profile.isGlobalchat() ? "enabled" : "disabled"))); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return false; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/essentials/TogglePMCMD.java b/src/main/java/me/quartz/hestia/commands/essentials/TogglePMCMD.java new file mode 100644 index 0000000..11dc109 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/essentials/TogglePMCMD.java @@ -0,0 +1,40 @@ +package me.quartz.hestia.commands.essentials; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class TogglePMCMD implements CommandExecutor { + + private Hestia hestia; + + public TogglePMCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("togglepm")){ + if(sender.hasPermission("hestia.togglepm")){ + if(sender instanceof Player){ + Player player = (Player) sender; + Profile profile = Profile.getProfile(player.getUniqueId(), hestia); + if(profile != null){ + profile.togglePm(); + sender.sendMessage(hestia.getMessageUtil().fileM("essentials", "pms").replace("{player}", sender.getName()).replace("{toggle}", (profile.isPm() ? "enabled" : "disabled"))); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "only-players")); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "no-perms")); + } + } + return false; + } +} diff --git a/src/main/java/me/quartz/hestia/commands/punishments/BanCMD.java b/src/main/java/me/quartz/hestia/commands/punishments/BanCMD.java new file mode 100644 index 0000000..0bd1606 --- /dev/null +++ b/src/main/java/me/quartz/hestia/commands/punishments/BanCMD.java @@ -0,0 +1,142 @@ +package me.quartz.hestia.commands.punishments; + +import me.quartz.hestia.Hestia; +import me.quartz.hestia.data.system.profile.Profile; +import me.quartz.hestia.data.system.punishment.Punishment; +import me.quartz.hestia.data.system.punishment.Type; +import me.quartz.hestia.data.system.rank.Rank; +import me.quartz.hestia.utils.TimeUtil; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.Date; + +public class BanCMD implements CommandExecutor { + + private Hestia hestia; + + public BanCMD(Hestia hestia) { + this.hestia = hestia; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(command.getName().equalsIgnoreCase("ban")) { + if (sender.hasPermission("hestia.ban") || sender.hasPermission("hestia.tempban")) { + if (args.length > 0) { + Profile target = Profile.getProfile(args[0], hestia); + if (target != null) { + String reason = hestia.getConfig().getString("punishment.ban-reason"); + boolean silent = false; + Date expire = null; + if (args.length > 1) { + int argI = 1; + if(TimeUtil.check(args[1])){ + TimeUtil time = TimeUtil.parseString(args[1]); + long millis = time.toMilliseconds(); + expire = new Date(System.currentTimeMillis() + millis); + argI++; + } + if((argI == 1 && sender.hasPermission("hestia.ban")) || (argI == 2)) { + StringBuilder sb = new StringBuilder(); + for (int i = argI; i < args.length; i++) { + if (args[i].equalsIgnoreCase("-s") || hestia.getConfig().getBoolean("punishment.auto-silent")) { + silent = true; + } + sb.append(args[i].replace("-s", "")).append(" "); + } + if (sb.toString().equalsIgnoreCase(" ") || sb.toString().equalsIgnoreCase("")) { + reason = hestia.getConfig().getString("punishment.ban-reason"); + } else { + reason = sb.toString(); + } + } + } + boolean finalSilent = silent; + String finalReason = reason; + Date finalExpire = expire; + Date finalExpire1 = expire; + String finalReason1 = reason; + Date finalExpire2 = expire; + String finalReason2 = reason; + new Thread(() -> { + Profile playerP = null; + if(sender instanceof Player){ + playerP = Profile.getProfile(((Player) sender).getUniqueId(), hestia); + } + Rank targetR = target.getRank(false); + Rank playerR = null; + if (playerP != null) { + playerR = playerP.getRank(false); + } + if(playerR != null && targetR != null){ + if(playerR.getPriority() <= targetR.getPriority() && !sender.isOp()){ + sender.sendMessage(hestia.getMessageUtil().fileM("punishment", "no-higher")); + return; + } + } + for (Player player : Bukkit.getOnlinePlayers()) { + Rank finalPlayerR = playerR; + new Thread(() -> { + Profile profile = Profile.getProfile(player.getUniqueId(), hestia); + if (player.hasPermission("hestia.notify") && profile != null && profile.isAlerts() && hestia.getConfig().getBoolean("server.clickable-messages")) { + TextComponent message = new TextComponent((hestia.getMessageUtil().fileM("punishment", (finalSilent ? "silent-" : "") + (finalExpire != null ? "temp-" : "") + "ban").replace("{player}", (finalPlayerR != null ? finalPlayerR.getColor() + (finalPlayerR.isBold() ? ChatColor.BOLD + "" : "") + (finalPlayerR.isItalic() ? ChatColor.ITALIC + "" : "") + sender.getName() : ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("server.console")))).replace("{target}", (targetR != null ? targetR.getColor() + (targetR.isBold() ? ChatColor.BOLD + "" : "") + (targetR.isItalic() ? ChatColor.ITALIC + "" : "") + target.getName() : ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("server.console")))).replace("{reason}", finalReason))); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( + ChatColor.YELLOW + "Reason: " + ChatColor.RED + finalReason + "\n" + + ChatColor.YELLOW + "Duration: " + ChatColor.RED + (finalExpire != null ? TimeUtil.toString((finalExpire.getTime() + 1000) - new Date().getTime()) : "Perm")).create())); + player.spigot().sendMessage(message); + } else if (!finalSilent) { + TextComponent message = new TextComponent(hestia.getMessageUtil().fileM("punishment", (finalExpire != null ? "temp-" : "") + "ban").replace("{player}", (finalPlayerR != null ? finalPlayerR.getColor() + (finalPlayerR.isBold() ? ChatColor.BOLD + "" : "") + (finalPlayerR.isItalic() ? ChatColor.ITALIC + "" : "") + sender.getName() : ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("server.console")))).replace("{target}", (targetR != null ? targetR.getColor() + (targetR.isBold() ? ChatColor.BOLD + "" : "") + (targetR.isItalic() ? ChatColor.ITALIC + "" : "") + target.getName() : ChatColor.translateAlternateColorCodes('&', hestia.getConfig().getString("server.console")))).replace("{reason}", finalReason)); + player.spigot().sendMessage(message); + } + }).start(); + } + Punishment punishment = new Punishment(Type.BAN, new Date(), finalExpire1, finalReason1, target.getUuid(), (sender instanceof Player ? ((Player) sender).getUniqueId() : null)); + if (hestia.getConfig().getString("data-storage").equalsIgnoreCase("MySQL")) { + hestia.getPunishmentMySQL().createHistory(punishment); + } else { + hestia.getPunishmentMongoDB().createHistory(punishment); + } + StringBuilder sb = new StringBuilder(); + for (String r : hestia.getMessageUtil().fileMList("punishment", (punishment.getExpired() == null ? "" : "temp-") + "ban-screen")) { + sb.append(ChatColor.translateAlternateColorCodes('&', r.replace("{reason}", punishment.getReason()).replace("{expire}", + (punishment.getExpired() == null ? "Never" : TimeUtil.toString(punishment.getExpired().getTime() - new Date().getTime()))))).append("\n"); + } + Bukkit.getScheduler().runTask(hestia, () -> { + String post = target.getName() + "/-/" + sb.toString(); + if(hestia.getConfig().getString("sync-storage").equalsIgnoreCase("Redis")) { + hestia.getRedisManager().getRedisPublish().pub("kick", post); + }else if(hestia.getConfig().getString("sync-storage").equalsIgnoreCase("BungeeCord")) { + if(hestia.getServer().getPluginManager().isPluginEnabled("Hestia-BungeeSync")) { + //HestiaBungeeSync.postInfo("kick", post); + } + Player player = Bukkit.getPlayer(target.getName()); + if(player != null){ + player.kickPlayer(ChatColor.translateAlternateColorCodes('&', post.split("/-/")[1])); + } + } + }); + if(hestia.getServer().getPluginManager().isPluginEnabled("Hestia-Discord") && hestia.getConfig().getBoolean("discord.punishments-log.enabled")) { + //API.sendPunishment("banned", "BAN", target.getName(), playerP == null ? "Console" : playerP.getName(), finalReason2, finalExpire2 == null ? "Permanent" : TimeUtil.toString(finalExpire2.getTime() - new Date().getTime())); + } + }).start(); + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "never-joined").replace("{player}", args[0])); + } + } else { + sender.sendMessage(hestia.getMessageUtil().fileM("general", "usage").replace("{usage}", "/ban [Player]