Author SHA1 Message Date
NotAlexNoyle 57cb71abc0 Point submodules at canonical Gitea repositories 2026-11-01 12:50:28 -05:00
NotAlexNoyle f51218e67c Exclude CODEOWNERS from language statistics 2026-10-31 09:54:52 -04:00
NotAlexNoyle cac88a4b67 Add CODEOWNERS (one staff approval) 2026-10-31 09:54:52 -04:00
NotAlexNoyle 0d0c0a24fc Update Utilities-OG API 2026-09-14 01:58:58 -04:00
NotAlexNoyle 7afb98e35c v4.6.5-OG release 2026-09-14 01:34:27 -04:00
NotAlexNoyle c51fd2bd97 Update DiamondBank-OG API 2026-07-29 11:38:08 -04:00
NotAlexNoyle 184cf9d3ee Bundle particles.yml 2026-07-27 09:08:39 -04:00
NotAlexNoyle ec1cfbf964 Update DiamondBank-OG 2026-07-27 07:58:34 -04:00
NotAlexNoyle fa8e8f6ca7 Update DiamondBank-OG API 2026-07-22 07:08:46 -04:00
NotAlexNoyle d519ea97f2 Update Utilities-OG API 2026-07-20 00:47:18 -04:00
NotAlexNoyle 7d97bc71b0 Update Utilities-OG 2026-05-20 11:08:47 -04:00
NotAlexNoyle c9ffe75123 Add rainbow halo by NotAlexNoyle 2026-05-13 07:43:15 -04:00
NotAlexNoyle ba438fe96d Update Utilities-OG 2026-05-11 00:40:09 -04:00
NotAlexNoyle 6f38551ab8 Vault -> DiamondBank-OG API 2026-04-29 14:06:45 -04:00
NotAlexNoyle 1f684943b3 Fix /cosmetics command 2026-04-01 05:37:27 -04:00
NotAlexNoyle a4f8bf1612 Remove /h alias 2026-04-01 04:36:00 -04:00
NotAlexNoyle 9b4f19c702 Merge pull request #4 from true-og/codex/fix-apiversion-expansion-in-plugin.yml
Include processed resources in shadowJar to enable plugin.yml expansion
2026-01-03 08:04:13 -05:00
115 changed files with 2399 additions and 1172 deletions

No files matched your search

View File
Whitespace-only changes.
+1
View File
@@ -0,0 +1 @@
.gitea/CODEOWNERS linguist-detectable=false
+3
View File
@@ -0,0 +1,3 @@
# Pull requests request review from the eligible staff team(s).
# One approval from either an Admin or Developer satisfies branch protection.
* @trueog/Admins @trueog/Developers
+6
View File
@@ -0,0 +1,6 @@
[submodule "libs/Utilities-OG"]
path = libs/Utilities-OG
url = https://git.trueog.net/trueog/Utilities-OG
[submodule "libs/DiamondBank-OG"]
path = libs/DiamondBank-OG
url = https://git.trueog.net/trueog/DiamondBank-OG
+5
View File
@@ -1,3 +1,8 @@
4.6.5-OG:
- Hide cosmetics while a player is in a Duels-OG match and restore them when it ends
- Hide cosmetics while a player is combat tagged by EternalCombat-OG and restore them on untag
- Add enabled-worlds whitelist, defaulting to world, world_nether and world_the_end
4.6.2-OG:
- Use TrueOG Network live config files
- Bundle default particles.yml into .jar
Executable
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/bash
# Fetch all submodule content.
git submodule update --force --recursive --init
+27 -3
View File
@@ -9,6 +9,10 @@ plugins {
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
}
extra["kotlinAttribute"] = Attribute.of("kotlin-tag", Boolean::class.javaObjectType)
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
/* --------------------------- JDK / Kotlin ---------------------------- */
java {
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
@@ -23,7 +27,7 @@ kotlin { jvmToolchain(17) }
/* ----------------------------- Metadata ------------------------------ */
group = "net.trueog.cosmetics-og" // Declare bundle identifier.
version = "4.6.2" // Declare plugin version (will be in .jar).
version = "4.6.5" // Declare plugin version (will be in .jar).
val apiVersion = "1.19" // Declare minecraft server target version.
@@ -48,10 +52,14 @@ dependencies {
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare Purpur API version to be packaged.
implementation("com.zaxxer:HikariCP:3.3.1") // Import HikariCP API.
implementation("org.slf4j:slf4j-nop:1.7.25") // Import SLF4J API.
compileOnly("com.github.Realizedd:TokenManager:3.2.4") { exclude(group = "*", module = "*") } // TokenManager API.
compileOnly("com.github.MilkBowl:VaultAPI:1.7") { exclude(group = "org.bukkit", module = "bukkit") } // Vault API.
compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG Java API (from source).
compileOnlyApi(project(":libs:DiamondBank-OG")) {
attributes { attribute(kotlinAttribute, true) }
} // Import TrueOG network DiamondBank-OG Kotlin API (from source).
}
apply(from = "eclipse.gradle.kts") // Import eclipse classpath support script.
/* ---------------------- Reproducible jars ---------------------------- */
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
isPreserveFileTimestamps = false
@@ -67,6 +75,12 @@ tasks.shadowJar {
relocationPrefix = "${project.group}.shadow"
archiveClassifier.set("") // Use empty string instead of null.
minimize()
doLast {
val particlesMenu = zipTree(archiveFile.get().asFile).matching { include("menus/particles.yml") }
if (particlesMenu.isEmpty) {
throw GradleException("The shaded jar is missing menus/particles.yml")
}
}
}
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
@@ -108,3 +122,13 @@ tasks.named("compileJava") {
tasks.named("spotlessCheck") {
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
}
/* ------------------------------ Eclipse SHIM ------------------------- */
// This can't be put in eclipse.gradle.kts because Gradle is weird.
subprojects {
apply(plugin = "java-library")
apply(plugin = "eclipse")
eclipse.project.name = "${project.name}-${rootProject.name}"
tasks.withType<Jar>().configureEach { archiveBaseName.set("${project.name}-${rootProject.name}") }
}
+158
View File
@@ -0,0 +1,158 @@
/* This is free and unencumbered software released into the public domain */
import org.gradle.api.tasks.bundling.Jar
import org.gradle.plugins.ide.eclipse.model.EclipseModel
import java.nio.file.Files
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.OutputKeys
import javax.xml.transform.TransformerFactory
import javax.xml.transform.dom.DOMSource
import javax.xml.transform.stream.StreamResult
val sourcePluginProjects =
configurations
.getByName("compileClasspath")
.allDependencies
.filterIsInstance<ProjectDependency>()
.map { it.path }
.filter { it.startsWith(":libs:") }
.distinct()
val sourcePluginProjectNames = sourcePluginProjects.map { it.substringAfterLast(":") }.toSet()
sourcePluginProjects.forEach { evaluationDependsOn(it) }
val ideLibs: Configuration by
configurations.creating {
isCanBeResolved = true
isCanBeConsumed = false
}
configure<EclipseModel> {
project {
name = "${rootProject.name}-Plugin"
}
classpath {
plusConfigurations.add(ideLibs)
}
}
val ideLibDir = layout.buildDirectory.dir("ide-libs")
val hashRegex = Regex("-[0-9a-fA-F]{10}(?=\\.jar$)") // Black magic.
val copyTasks = mutableListOf<TaskProvider<Copy>>()
sourcePluginProjects.forEach { path ->
val sub = project(path)
val archiveTaskName = if ("shadowJar" in sub.tasks.names) "shadowJar" else "jar"
val archiveTask = sub.tasks.named<Jar>(archiveTaskName)
val copyTask =
tasks.register<Copy>("ideCopy${sub.name.replaceFirstChar(Char::titlecase)}") {
dependsOn(archiveTask)
from(archiveTask.flatMap { it.archiveFile })
into(ideLibDir)
rename { it.replace(hashRegex, "") } // Remove git commit hash from jarfile.
}
copyTasks += copyTask
}
/* Ensure the jars exist before .classpath is generated */
tasks.named("eclipseClasspath").configure { dependsOn(copyTasks) }
/* Supply those jars to the ideLibs configuration (after evaluation) */
afterEvaluate { dependencies { add("ideLibs", fileTree(ideLibDir) { include("*.jar") }) } }
val injectIdeLibs =
tasks.register("injectIdeLibs") {
dependsOn("eclipse") // run after all eclipse files are generated
doLast {
val cpFile = file(".classpath")
if (!cpFile.exists()) return@doLast
val jars = fileTree(ideLibDir.get()) { include("*.jar") }.files.sortedBy { it.name }
if (jars.isEmpty()) return@doLast
// Parse DOM
val dbf = DocumentBuilderFactory.newInstance()
val doc = dbf.newDocumentBuilder().parse(cpFile)
val root = doc.documentElement
// Helper to see if an entry already exists
fun exists(path: String): Boolean =
root.getElementsByTagName("classpathentry").let { list ->
(0 until list.length).any { i ->
val n = list.item(i)
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
val p = n.attributes?.getNamedItem("path")?.nodeValue
kind == "lib" && p == path
}
}
// Remove any entry that points to ide-libs dir or unresolved :libs: project refs.
val toRemove = mutableListOf<org.w3c.dom.Node>()
val list = root.getElementsByTagName("classpathentry")
val dirPath = ideLibDir.get().asFile.absolutePath
for (i in 0 until list.length) {
val n = list.item(i)
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
val p = n.attributes?.getNamedItem("path")?.nodeValue ?: ""
val isIdeLibEntry = kind == "lib" && (p == dirPath || p.startsWith("$dirPath/"))
val sourceProjectPath = p.removePrefix("/")
val isHalfImportedSourceModule = kind == "src" && p.startsWith("/libs:")
val isSourcePluginModule = kind == "src" && sourceProjectPath in sourcePluginProjectNames
if (isIdeLibEntry || isHalfImportedSourceModule || isSourcePluginModule) {
toRemove += n
}
}
toRemove.forEach { root.removeChild(it) }
// Append our jar entries LAST
jars.forEach { f ->
val abs = f.absolutePath
if (!exists(abs)) {
val entry = doc.createElement("classpathentry")
entry.setAttribute("kind", "lib")
entry.setAttribute("path", abs)
root.appendChild(entry)
}
}
// Write back pretty
val tf =
TransformerFactory.newInstance().newTransformer().apply {
setOutputProperty(OutputKeys.INDENT, "yes")
setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1")
setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no")
setOutputProperty(OutputKeys.ENCODING, "UTF-8")
}
Files.newBufferedWriter(cpFile.toPath()).use { w -> tf.transform(DOMSource(doc), StreamResult(w)) }
}
}
tasks.named("eclipse").configure { finalizedBy(injectIdeLibs) }
val eclipseModel = extensions.getByType<EclipseModel>()
fun Project.addResolvableEclipseConfigs() {
val jarAttr =
objects.named(org.gradle.api.attributes.LibraryElements::class, org.gradle.api.attributes.LibraryElements.JAR)
val apiAttr = objects.named(org.gradle.api.attributes.Usage::class, org.gradle.api.attributes.Usage.JAVA_API)
val compileOnlyRes =
configurations.create("eclipseCompileOnly") {
extendsFrom(configurations.getByName("compileOnly"))
isCanBeResolved = true
isCanBeConsumed = false
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
}
val compileOnlyApiRes =
configurations.create("eclipseCompileOnlyApi") {
extendsFrom(configurations.getByName("compileOnlyApi"))
isCanBeResolved = true
isCanBeConsumed = false
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
}
eclipseModel.classpath.plusConfigurations.addAll(listOf(compileOnlyRes, compileOnlyApiRes))
}
addResolvableEclipseConfigs()
Submodule libs/DiamondBank-OG added at 39d5a2b936.
+1
Submodule libs/Utilities-OG added at 8b5c86cc9c.
+12
View File
@@ -1 +1,13 @@
rootProject.name = "Cosmetics-OG"
ProcessBuilder("sh", "bootstrap.sh").directory(rootDir).inheritIO().start().let {
if (it.waitFor() != 0) throw GradleException("bootstrap.sh failed")
}
file("libs")
.listFiles()
?.filter { it.isDirectory && !it.name.startsWith(".") }
?.forEach { dir ->
include(":libs:${dir.name}")
project(":libs:${dir.name}").projectDir = dir
}
+2 -1
View File
@@ -55,7 +55,8 @@ public class HatAPI extends ParticleHatsAPI {
if (tellPlayer) {
player.sendMessage(Message.COMMAND_SET_SUCCESS.getValue().replace("{1}", hat.getDisplayName()));
CosmeticsOG.chatMessage(player,
Message.COMMAND_SET_SUCCESS.getValue().replace("{1}", hat.getDisplayName()));
}
+1 -1
View File
@@ -2,4 +2,4 @@ package cosmeticsOG;
public enum BuildType {
RELEASE, RELEASE_CANDIDATE, SNAPSHOT;
}
}
+216 -108
View File
@@ -1,5 +1,24 @@
package cosmeticsOG;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import cosmeticsOG.API.HatAPI;
import cosmeticsOG.API.ParticleHatsAPI;
import cosmeticsOG.database.Database;
@@ -25,25 +44,13 @@ import cosmeticsOG.tasks.MenuTask;
import cosmeticsOG.tasks.PromptTask;
import cosmeticsOG.ui.MenuManagerFactory;
import cosmeticsOG.util.YamlUtil;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
import net.trueog.utilitiesog.UtilitiesOG;
@SuppressWarnings("unused")
public class CosmeticsOG extends JavaPlugin {
private static final String DEFAULT_PARTICLES_MENU = "menus/particles.yml";
// [Future] Are features that i plan on adding.
// [?] Are ideas that may or may not get added.
@@ -53,7 +60,6 @@ public class CosmeticsOG extends JavaPlugin {
// groups as well.
// TODO: [?] Enjin economy support?
// TODO: [?] Custom Player Head support? (Head Database, Heads Plugin)
// TODO: [?] Type texture support? Lets built-in types display custom images
// (eg. capes)
// TODO: [?] More flexible mode support?
@@ -62,9 +68,8 @@ public class CosmeticsOG extends JavaPlugin {
// Display when: (running, walking, flying, etc)
// Disable when: (pvp, swimming, etc)
// TODO: [Future] Add update notifier
// TODO: [Future] Allow adding custom types images as frames to an animation
// TODO: [Future] Re-implement text particle type
// TODO: [Future] Allow adding custom types images as frames to an animation.
// TODO: [Future] Re-implement text particle type.
// TODO: [Future] Let particles be attached to blocks...
// Have a separate block menu that shows nearby particles for the player to
// edit.
@@ -81,14 +86,16 @@ public class CosmeticsOG extends JavaPlugin {
private ParticleRenderer particleRenderer;
// Managers
private static DiamondBankAPIJava diamondBankAPI;
// Managers.
private ResourceManager resourceManager;
private EventManager eventManager;
private CommandManager commandManager;
private ParticleManager particleManager;
private HookManager hookManager;
// Lang
// Lang.
private File langFile;
private YamlConfiguration lang;
@@ -97,18 +104,18 @@ public class CosmeticsOG extends JavaPlugin {
private ConcurrentHashMap<UUID, EntityState> entityState;
// Lets us know we can use the BaseComponent class from the bungee api
// Lets us know we can use the BaseComponent class from the bungee api.
private boolean supportsBaseComponent = true;
private Prompt prompt;
// Tasks
// Tasks.
private MenuTask menuTask;
private PromptTask promptTask;
private EntityTask entityTask;
private boolean enabled = false;
// Debugging
// Debugging.
public static final boolean debugging = false;
@Override
@@ -119,17 +126,38 @@ public class CosmeticsOG extends JavaPlugin {
logger = instance.getLogger();
hatAPI = new HatAPI(this);
// Make sure we're running on a supported version
// Initialize the DiamondBank-OG API.
final RegisteredServiceProvider<DiamondBankAPIJava> provider = getServer().getServicesManager()
.getRegistration(DiamondBankAPIJava.class);
// If the DiamondBank-OG API failed to initialize, do this...
if (provider == null) {
// Tell Bukkit to disable this plugin, and inform the console.
disableSelf("DiamondBank-OG API is null – disabling " + getPluginMeta().getName() + "!");
return;
}
// Assign the active instance of DiamondBank-OG to the API handler.
diamondBankAPI = provider.getProvider();
// Make sure we're running on a supported version.
if (serverVersion < 13) {
particleRenderer = new LegacyParticleRenderer();
if (serverVersion < 8) {
Utils.logToConsole("-----------------------------------------------------------------------");
Utils.logToConsole("This version of ParticleHats is not compatible with your server version");
Utils.logToConsole("Download version 3.7.5 if your server is on a version older than 1.8");
Utils.logToConsole("-----------------------------------------------------------------------");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"-----------------------------------------------------------------------");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"This version of ParticleHats is not compatible with your server version");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"Download version 3.7.5 if your server is on a version older than 1.8");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"-----------------------------------------------------------------------");
getServer().getPluginManager().disablePlugin(this);
return;
@@ -142,56 +170,62 @@ public class CosmeticsOG extends JavaPlugin {
}
// Check to see if we're running on Spigot
// Check to see if we're running on Spigot.
try {
Class.forName("net.md_5.bungee.api.chat.BaseComponent");
} catch (ClassNotFoundException e) {
} catch (ClassNotFoundException classNotFoundException) {
supportsBaseComponent = false;
}
// Save default config
// Save default config.
saveDefaultConfig();
Utils.logToConsole("Loading ParticleHats v" + getPluginMeta().getVersion());
Utils.logToConsole("");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Loading ParticleHats v" + getPluginMeta().getVersion());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "");
{
// Create our menu manager factory
// Create our menu manager factory.
menuManagerFactory = new MenuManagerFactory(this);
if (YamlUtil.checkConfigForUpdates(getConfig())) {
if (SettingsManager.CONFIG_AUTO_UPDATE.getBoolean()) {
Utils.logToConsole("Updating config.yml");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Updating config.yml");
YamlUtil.updateConfig(this, getConfig());
} else {
Utils.logToConsole("There is an update for config.yml, auto updates are disabled.");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"There is an update for config.yml, auto updates are disabled.");
}
}
// Load our database
saveDefaultParticlesMenu();
// Load our database.
databaseType = DatabaseType.fromAlias(SettingsManager.DATABASE_TYPE.getString());
database = databaseType.getDatabase(this);
// yaml always returns true, mysql will return false if the connection could not
// be made
// be made.
if (!database.isEnabled()) {
Utils.logToConsole("---------------------------------------------------");
Utils.logToConsole("There was an error connecting to the MySQL database");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"---------------------------------------------------");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"There was an error connecting to the MySQL database");
if (database.getException() != null) {
Utils.logToConsole("Error: " + database.getException().getClass().getSimpleName());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"Error: " + database.getException().getClass().getSimpleName());
if (debugging) {
database.getException().printStackTrace();
@@ -200,26 +234,27 @@ public class CosmeticsOG extends JavaPlugin {
}
Utils.logToConsole("Switching to yaml");
Utils.logToConsole("---------------------------------------------------");
Utils.logToConsole("");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Switching to yaml");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"---------------------------------------------------");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "");
databaseType = DatabaseType.YAML;
database = databaseType.getDatabase(this);
}
// Initialize our player state map
entityState = new ConcurrentHashMap<UUID, EntityState>();
// Initialize our player state map.
entityState = new ConcurrentHashMap<>();
// log("");
checkDefaultLang();
loadLang();
// Create our managers
// Create our managers.
resourceManager = new ResourceManager(this);
eventManager = new EventManager(this);
commandManager = new CommandManager(this, "h");
commandManager = new CommandManager(this, "cosmetics");
particleManager = new ParticleManager(this);
hookManager = new HookManager(this);
@@ -233,46 +268,76 @@ public class CosmeticsOG extends JavaPlugin {
}
// Handles menu updates
// Handles menu updates.
menuTask = new MenuTask(this);
menuTask.runTaskTimer(this, 0, SettingsManager.LIVE_MENU_UPDATE_FREQUENCY.getInt());
// Handles meta editing prompts
// Handles meta editing prompts.
promptTask = new PromptTask(this);
promptTask.runTaskTimer(this, 0, 40);
// Handles displaying particles
// Handles displaying particles.
entityTask = new EntityTask(this);
entityTask.runTaskTimer(this, 0, 4);
}
Utils.logToConsole("");
Utils.logToConsole("Done :)");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Done :)");
enabled = true;
}
private void saveDefaultParticlesMenu() {
if (!SettingsManager.LOAD_INCLUDED_MENUS.getBoolean()) {
return;
}
File particlesMenu = new File(getDataFolder(), DEFAULT_PARTICLES_MENU);
if (!particlesMenu.exists()) {
saveResource(DEFAULT_PARTICLES_MENU, false);
}
}
public static CosmeticsOG getInstance() {
return instance;
}
public static String getPrefix() {
return "&7[&aCosmetics-OG&f-&4OG&7]";
}
public static void chatMessage(Player player, String message) {
UtilitiesOG.trueogMessage(player, getPrefix() + " " + message);
}
@Override
public void onDisable() {
if (enabled) {
if (!enabled) {
database.onDisable();
menuTask.cancel();
promptTask.cancel();
entityTask.cancel();
return;
}
database.onDisable();
menuTask.cancel();
promptTask.cancel();
entityTask.cancel();
}
public void onReload() {
@@ -308,14 +373,14 @@ public class CosmeticsOG extends JavaPlugin {
resourceManager.onReload();
hookManager.onReload();
// Reload each equipped hats async task
// Reload each equipped hats async task.
entityState.values().forEach(EntityState::reload);
}
/**
* Get the ParticleHats Hat API
*
*
* @return
*/
public ParticleHatsAPI getAPI() {
@@ -326,7 +391,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Returns the Database this plugin is using
*
*
* @return
*/
public Database getDatabase() {
@@ -337,7 +402,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Returns the type of database this server is using
*
*
* @return
*/
public DatabaseType getDatabaseType() {
@@ -348,7 +413,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Returns the MenuManagerFactory class
*
*
* @return
*/
public MenuManagerFactory getMenuManagerFactory() {
@@ -359,7 +424,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Get the ParticleRenderer for this server version
*
*
* @return
*/
public ParticleRenderer getParticleRenderer() {
@@ -370,7 +435,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Get the ResourceManager class
*
*
* @return
*/
public ResourceManager getResourceManager() {
@@ -381,7 +446,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Get the ParticleManager class
*
*
* @return
*/
public ParticleManager getParticleManager() {
@@ -392,7 +457,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Get the HookManager class
*
*
* @return
*/
public HookManager getHookManager() {
@@ -403,7 +468,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Returns the PlayerState object that belongs to this player
*
*
* @return
*/
public PlayerState getPlayerState(Player player) {
@@ -414,7 +479,7 @@ public class CosmeticsOG extends JavaPlugin {
public PlayerState getNewPlayerState(Player player) {
UUID id = player.getUniqueId();
final UUID id = player.getUniqueId();
removePlayerState(id);
return (PlayerState) getEntityState(player);
@@ -423,8 +488,7 @@ public class CosmeticsOG extends JavaPlugin {
public EntityState getEntityState(Entity entity, int entityID) {
UUID id = entity.getUniqueId();
final UUID id = entity.getUniqueId();
if (entityState.containsKey(id)) {
return entityState.get(id);
@@ -433,7 +497,7 @@ public class CosmeticsOG extends JavaPlugin {
if (entity instanceof Player) {
EntityState eState;
final EntityState eState;
if (entity.hasMetadata("NPC")) {
@@ -446,13 +510,15 @@ public class CosmeticsOG extends JavaPlugin {
}
entityState.put(id, eState);
return eState;
}
EntityState eState = new EntityState(entity, entityID);
final EntityState eState = new EntityState(entity, entityID);
entityState.put(id, eState);
return eState;
}
@@ -465,7 +531,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Checks to see if this entity has an EntityState object loaded
*
*
* @param entity
* @return
*/
@@ -477,7 +543,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Returns all currently active player states
*
*
* @return
*/
public Collection<EntityState> getEntityStates() {
@@ -488,7 +554,7 @@ public class CosmeticsOG extends JavaPlugin {
public void removePlayerState(UUID id) {
EntityState es = entityState.remove(id);
final EntityState es = entityState.remove(id);
if (es != null) {
es.clearActiveHats();
@@ -499,7 +565,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Check to see if we can use the bungee BaseComponent class
*
*
* @return
*/
public Boolean canUseBungee() {
@@ -510,19 +576,19 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Gets the current server version
*
*
* @return
*/
public double getServerVersion() {
String version = Bukkit.getBukkitVersion().split("-")[0].substring(2);
final String version = StringUtils.substring(Bukkit.getBukkitVersion().split("-")[0], 2);
return Double.parseDouble(version);
}
/**
* Get this plugins CommandManager
*
*
* @return
*/
public CommandManager getCommandManager() {
@@ -539,7 +605,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Sends the player a message using their Action Bar
*
*
* @param player
* @param message
*/
@@ -557,15 +623,15 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Checks to see if a file exists with this name in the given folder
*
*
* @param folderName
* @param fileName
* @return
*/
public boolean fileExists(String folderName, String fileName) {
String directory = getDataFolder() + File.separator + folderName + File.separator + fileName;
File file = new File(directory);
final String directory = getDataFolder() + File.separator + folderName + File.separator + fileName;
final File file = new File(directory);
return file.exists();
@@ -573,7 +639,7 @@ public class CosmeticsOG extends JavaPlugin {
/**
* Logs a debug message to the server console if debugging is enabled
*
*
* @param obj
*/
public static void debug(Object obj) {
@@ -590,26 +656,28 @@ public class CosmeticsOG extends JavaPlugin {
String targetLang = SettingsManager.LANG.getString();
File langFile = new File(getDataFolder() + File.separator + "lang" + File.separator + targetLang);
final File langFile = new File(getDataFolder() + File.separator + "lang" + File.separator + targetLang);
if (!langFile.exists()) {
if (targetLang.equals("en_US.lang")) {
if ("en_US.lang".equals(targetLang)) {
Utils.logToConsole("Creating en_US.lang");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Creating en_US.lang");
} else {
Utils.logToConsole("Could not find locale " + targetLang + ", switching to en_US.lang");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"Could not find locale " + targetLang + ", switching to en_US.lang");
}
// Create our default .lang file since the specified one doesn't exist
// Create our default .lang file since the specified one doesn't exist.
createDefaultLang();
targetLang = "en_US.lang";
}
Utils.logToConsole("Loaded locale " + targetLang);
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Loaded locale " + targetLang);
this.langFile = new File(getDataFolder() + File.separator + "lang" + File.separator + targetLang);
this.lang = YamlConfiguration.loadConfiguration(this.langFile);
@@ -617,31 +685,35 @@ public class CosmeticsOG extends JavaPlugin {
private void createDefaultLang() {
File langFolder = new File(getDataFolder() + File.separator + "lang");
final File langFolder = new File(getDataFolder() + File.separator + "lang");
if (!langFolder.exists()) {
langFolder.mkdirs();
}
InputStream langStream = getResource("lang/en_US.lang");
if (langStream != null) {
final InputStream langStream = getResource("lang/en_US.lang");
if (langStream == null) {
File langFile = new File(getDataFolder() + File.separator + "lang" + File.separator + "en_US.lang");
return;
if (langFile.exists()) {
}
langFile.delete();
final File langFile = new File(getDataFolder() + File.separator + "lang" + File.separator + "en_US.lang");
if (langFile.exists()) {
}
langFile.delete();
try {
}
Files.copy(langStream, Paths.get(langFile.getPath()));
try {
} catch (IOException e) {
Files.copy(langStream, Paths.get(langFile.getPath()));
}
} catch (IOException ioException) {
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Error creating en_US.lang");
ioException.printStackTrace();
}
@@ -649,17 +721,18 @@ public class CosmeticsOG extends JavaPlugin {
private void checkDefaultLang() {
File langFile = new File(getDataFolder() + File.separator + "lang" + File.separator + "en_US.lang");
final File langFile = new File(getDataFolder() + File.separator + "lang" + File.separator + "en_US.lang");
if (!langFile.exists()) {
createDefaultLang();
} else {
YamlConfiguration tempLangConfig = YamlConfiguration.loadConfiguration(langFile);
final YamlConfiguration tempLangConfig = YamlConfiguration.loadConfiguration(langFile);
if (tempLangConfig.getDouble("version", 1.0) != LANG_VERSION) {
Utils.logToConsole("Updating en_US.lang");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Updating en_US.lang");
createDefaultLang();
}
@@ -668,4 +741,39 @@ public class CosmeticsOG extends JavaPlugin {
}
// Helps this plugin kill itself gracefully (in minecraft).
public static void disableSelf(String reason) {
final CosmeticsOG pluginInstance = getInstance();
if (pluginInstance == null) {
return;
}
Bukkit.getScheduler().runTask(pluginInstance, () -> {
// If this plugin is already disabled, do this...
if (!pluginInstance.isEnabled()) {
// Do nothing, task already completed.
return;
}
// Inform console of this plugin being disabled.
UtilitiesOG.logToConsole(getPrefix(), reason);
Bukkit.getPluginManager().disablePlugin(pluginInstance);
});
}
public static DiamondBankAPIJava getDiamondBankAPI() {
return diamondBankAPI;
}
}
-132
View File
@@ -1,132 +0,0 @@
package cosmeticsOG;
import java.util.regex.Pattern;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.entity.Player;
public class Utils {
// Regular expressions to match color codes starting with § or & in Strings.
private static final Pattern LEGACY_COLOR_PATTERN = Pattern.compile("(?i)[§&][0-9A-FK-OR]");
private static final Pattern MINIMESSAGE_TAG_PATTERN = Pattern.compile("<[^>]*>");
// Sends a formatted message to the player (including name replacement).
public static void cosmeticsOGPlaceholderMessage(Player p, String message) {
p.sendMessage(legacySerializerAnyCase((message)));
}
public static void logToConsole(Component component) {
String serialized = MiniMessage.miniMessage().serialize(component);
String stripped = stripColors(serialized);
CosmeticsOG.getInstance().getLogger().info("Cosmetics-OG " + stripped);
}
public static void logToConsole(String message) {
TextComponent component = LegacyComponentSerializer.legacyAmpersand().deserialize(message);
String serialized = MiniMessage.miniMessage().serialize(component);
String stripped = stripColors(serialized);
CosmeticsOG.getInstance().getLogger().info("Cosmetics-OG " + stripped);
}
public static TextComponent legacySerializerAnyCase(String subject) {
int count = 0;
// Count the number of '&' characters to determine the size of the array
for (char c : subject.toCharArray()) {
if (c == '&') {
count++;
}
}
// Create an array to store the positions of '&' characters
int[] positions = new int[count];
int index = 0;
// Find the positions of '&' characters and store in the array
for (int i = 0; i < subject.length(); i++) {
if (subject.charAt(i) == '&') {
if (isUpperBukkitCode(subject.charAt(i + 1))) {
subject = replaceCharAtIndex(subject, (i + 1), Character.toLowerCase(subject.charAt(i + 1)));
}
positions[index++] = i;
}
}
return LegacyComponentSerializer.legacyAmpersand().deserialize(subject);
}
private static boolean isUpperBukkitCode(char input) {
char[] bukkitColorCodes = { 'A', 'B', 'C', 'D', 'E', 'F', 'K', 'L', 'M', 'N', 'O', 'R' };
boolean match = false;
// Loop through each character in the array.
for (char c : bukkitColorCodes) {
// Check if the current character in the array is equal to the input character.
if (c == input) {
match = true;
}
}
return match;
}
private static String replaceCharAtIndex(String original, int index, char newChar) {
// Check if the index is valid
if (index >= 0 && index < original.length()) {
// Create a new string with the replaced character
return original.substring(0, index) + newChar + original.substring(index + 1);
}
// If the index is invalid, return the original string
return original;
}
public static String stripColors(String input) {
if (input == null)
return null;
// Remove MiniMessage tags
String stripped = MINIMESSAGE_TAG_PATTERN.matcher(input).replaceAll("");
// Remove legacy color codes
stripped = LEGACY_COLOR_PATTERN.matcher(stripped).replaceAll("");
return stripped;
}
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.locale.Message;
import cosmeticsOG.permission.Permission;
import java.util.ArrayList;
@@ -62,7 +62,7 @@ public abstract class Command {
if (!sender.isPlayer() && isPlayerOnly()) {
Utils.logToConsole(Message.COMMAND_ERROR_PLAYER_ONLY.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_PLAYER_ONLY.getValue());
return false;
}
@@ -78,11 +78,11 @@ public abstract class Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage(sender.getPlayer(), Message.COMMAND_ERROR_NO_PERMISSION.getValue());
CosmeticsOG.chatMessage(sender.getPlayer(), Message.COMMAND_ERROR_NO_PERMISSION.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_NO_PERMISSION.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_NO_PERMISSION.getValue());
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.database.Database;
import cosmeticsOG.database.properties.Group;
import cosmeticsOG.locale.Message;
@@ -26,7 +26,7 @@ public class MainCommand extends Command {
if (!sender.isPlayer()) {
Utils.logToConsole(Message.COMMAND_ERROR_PLAYER_ONLY.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_PLAYER_ONLY.getValue());
return false;
}
@@ -63,16 +63,16 @@ public class MainCommand extends Command {
if (usingGroupMenu) {
Utils.cosmeticsOGPlaceholderMessage(sender.getPlayer(),
CosmeticsOG.chatMessage(sender.getPlayer(),
Message.COMMAND_ERROR_UNKNOWN_GROUP_MENU.getValue().replace("{1}", menuName));
} else {
// TODO: Figure out why the menu isn't in the database.
Player player = sender.getPlayer();
Utils.cosmeticsOGPlaceholderMessage(player,
CosmeticsOG.chatMessage(player,
"Does the menu exist in the database?: " + String.valueOf(database.menuExists(menuName)));
Utils.cosmeticsOGPlaceholderMessage(player,
CosmeticsOG.chatMessage(player,
Message.COMMAND_ERROR_UNKNOWN_MENU.getValue().replace("{1}", menuName));
}
@@ -98,11 +98,11 @@ public class MainCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage(sender.getPlayer(), Message.COMMAND_ERROR_UNKNOWN.getValue());
CosmeticsOG.chatMessage(sender.getPlayer(), Message.COMMAND_ERROR_UNKNOWN.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_UNKNOWN.getValue());
}
@@ -127,7 +127,7 @@ public class MainCommand extends Command {
@Override
public String getArgumentName() {
return "h";
return "cosmetics";
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.properties.Group;
@@ -23,13 +23,13 @@ public class AddGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, getUsage().getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, getUsage().getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(getUsage().getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), getUsage().getValue());
}
@@ -66,12 +66,12 @@ public class AddGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_GROUP_EXISTS.replace("{1}", groupName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_GROUP_EXISTS.replace("{1}", groupName));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_GROUP_EXISTS.replace("{1}", groupName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_GROUP_EXISTS.replace("{1}", groupName));
}
@@ -83,12 +83,12 @@ public class AddGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ADD_GROUP_SUCCESS.replace("{1}", groupName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ADD_GROUP_SUCCESS.replace("{1}", groupName));
} else {
Utils.logToConsole(Message.COMMAND_ADD_GROUP_SUCCESS.replace("{1}", groupName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ADD_GROUP_SUCCESS.replace("{1}", groupName));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.type.DatabaseType;
@@ -26,13 +26,13 @@ public class AddTypeCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, getUsage().getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, getUsage().getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(getUsage().getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), getUsage().getValue());
}
@@ -44,11 +44,11 @@ public class AddTypeCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ADD_TYPE_ERROR.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ADD_TYPE_ERROR.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ADD_TYPE_ERROR.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ADD_TYPE_ERROR.getValue());
}
@@ -61,12 +61,12 @@ public class AddTypeCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_TYPE_EXISTS.replace("{1}", imageName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_TYPE_EXISTS.replace("{1}", imageName));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_TYPE_EXISTS.replace("{1}", imageName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_TYPE_EXISTS.replace("{1}", imageName));
}
@@ -80,12 +80,12 @@ public class AddTypeCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ADD_TYPE_SUCCESS.replace("{1}", imageName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ADD_TYPE_SUCCESS.replace("{1}", imageName));
} else {
Utils.logToConsole(Message.COMMAND_ADD_TYPE_SUCCESS.replace("{1}", imageName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ADD_TYPE_SUCCESS.replace("{1}", imageName));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -62,14 +62,15 @@ public class BukkitHelpCommand extends Command {
Player player = sender.getPlayer();
Utils.cosmeticsOGPlaceholderMessage(player,
CosmeticsOG.chatMessage(player,
"<white>> <light_purple>Cosmetics<red>-OG <yellow>v" + core.getPluginMeta().getVersion());
Utils.cosmeticsOGPlaceholderMessage(player, "<gray>> " + Message.COMMAND_HELP_TIP.getValue());
CosmeticsOG.chatMessage(player, "<gray>> " + Message.COMMAND_HELP_TIP.getValue());
} else {
Utils.logToConsole("&r&2Cosmetics&c-OG &ev" + core.getPluginMeta().getVersion());
Utils.logToConsole("&7 " + Message.COMMAND_HELP_TIP.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"&r&2Cosmetics&c-OG &ev" + core.getPluginMeta().getVersion());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "&7 " + Message.COMMAND_HELP_TIP.getValue());
}
@@ -82,7 +83,7 @@ public class BukkitHelpCommand extends Command {
} else {
Utils.logToConsole(MiniMessage.miniMessage().serialize(component));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), MiniMessage.miniMessage().serialize(component));
}
@@ -114,11 +115,11 @@ public class BukkitHelpCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage(sender.getPlayer(), Message.COMMAND_ERROR_NO_PERMISSION.getValue());
CosmeticsOG.chatMessage(sender.getPlayer(), Message.COMMAND_ERROR_NO_PERMISSION.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_NO_PERMISSION.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_NO_PERMISSION.getValue());
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -33,8 +33,8 @@ public class ClearCommand extends Command {
if (!sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_CLEAR_PLAYER_USAGE.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_CLEAR_PLAYER_USAGE.getValue());
return false;
@@ -44,11 +44,11 @@ public class ClearCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_CLEAR_SUCCESS.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_CLEAR_SUCCESS.getValue());
} else {
Utils.logToConsole(Message.COMMAND_CLEAR_SUCCESS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_CLEAR_SUCCESS.getValue());
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -20,12 +20,13 @@ public class ClearPlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(0)));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(0)));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(0)));
}
@@ -37,12 +38,13 @@ public class ClearPlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
}
@@ -54,12 +56,13 @@ public class ClearPlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_CLEAR_PLAYER_SUCCESS.getValue().replace("{1}", player.getName()));
} else {
Utils.logToConsole(Message.COMMAND_CLEAR_PLAYER_SUCCESS.getValue().replace("{1}", player.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_CLEAR_PLAYER_SUCCESS.getValue().replace("{1}", player.getName()));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.Database;
@@ -27,8 +27,7 @@ public class CreateCommand extends Command {
PlayerState playerState = core.getPlayerState(sender.getPlayer());
if (playerState.hasEditorOpen()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
return false;
@@ -42,11 +41,11 @@ public class CreateCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_CREATE_INVALID.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_CREATE_INVALID.getValue());
} else {
Utils.logToConsole(Message.COMMAND_CREATE_INVALID.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_CREATE_INVALID.getValue());
}
@@ -61,12 +60,13 @@ public class CreateCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_MENU_EXISTS.getValue().replace("{1}", menuName));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_MENU_EXISTS.getValue().replace("{1}", menuName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_MENU_EXISTS.getValue().replace("{1}", menuName));
}
@@ -78,18 +78,18 @@ public class CreateCommand extends Command {
if (!sender.isPlayer()) {
Utils.logToConsole(Message.COMMAND_CREATE_SUCCESS.replace("{1}", menuName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_CREATE_SUCCESS.replace("{1}", menuName));
return true;
} else {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_CREATE_SUCCESS.replace("{1}", menuName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_CREATE_SUCCESS.replace("{1}", menuName));
PlayerState playerState = core.getPlayerState(sender.getPlayer());
EditorMenuManager editorManager = core.getMenuManagerFactory().getEditorMenuManager(playerState);
MenuInventory inventory = new MenuInventory(menuName, Utils.legacySerializerAnyCase(menuName), 6, null);
MenuInventory inventory = new MenuInventory(menuName, UtilitiesOG.trueogColorize(menuName), 6, null);
editorManager.setEditingMenu(inventory);
editorManager.open();
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.properties.Group;
@@ -22,13 +22,13 @@ public class DeleteGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, getUsage().getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, getUsage().getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(getUsage().getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), getUsage().getValue());
}
@@ -56,12 +56,12 @@ public class DeleteGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_GROUP.replace("{1}", groupName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_UNKNOWN_GROUP.replace("{1}", groupName));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_GROUP.replace("{1}", groupName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_GROUP.replace("{1}", groupName));
}
@@ -73,12 +73,12 @@ public class DeleteGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_REMOVE_GROUP_SUCCESS.replace("{1}", groupName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_REMOVE_GROUP_SUCCESS.replace("{1}", groupName));
} else {
Utils.logToConsole(Message.COMMAND_REMOVE_GROUP_SUCCESS.replace("{1}", groupName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_REMOVE_GROUP_SUCCESS.replace("{1}", groupName));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.Database;
@@ -62,13 +62,13 @@ public class EditCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_EDIT_USAGE.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_EDIT_USAGE.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(Message.COMMAND_EDIT_USAGE.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_EDIT_USAGE.getValue());
}
@@ -80,7 +80,7 @@ public class EditCommand extends Command {
Database database = core.getDatabase();
if (playerState.hasEditorOpen()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
return false;
@@ -105,8 +105,7 @@ public class EditCommand extends Command {
if (!database.menuExists(menuName)) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
return false;
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.Database;
@@ -24,13 +24,13 @@ public class EditGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, getUsage().getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, getUsage().getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(getUsage().getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), getUsage().getValue());
}
@@ -65,12 +65,12 @@ public class EditGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_GROUP.replace("{1}", groupName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_UNKNOWN_GROUP.replace("{1}", groupName));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_GROUP.replace("{1}", groupName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_GROUP.replace("{1}", groupName));
}
@@ -82,12 +82,12 @@ public class EditGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
}
@@ -105,12 +105,12 @@ public class EditGroupCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_EDIT_GROUP_SUCCESS.replace("{1}", groupName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_EDIT_GROUP_SUCCESS.replace("{1}", groupName));
} else {
Utils.logToConsole(Message.COMMAND_EDIT_GROUP_SUCCESS.replace("{1}", groupName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_EDIT_GROUP_SUCCESS.replace("{1}", groupName));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.properties.Group;
@@ -22,11 +22,11 @@ public class GroupInfoCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_GROUP_INFO_TIP.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_GROUP_INFO_TIP.getValue());
} else {
Utils.logToConsole(Message.COMMAND_GROUP_INFO_TIP.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_GROUP_INFO_TIP.getValue());
}
@@ -37,11 +37,11 @@ public class GroupInfoCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, ("&f> " + info));
CosmeticsOG.chatMessage((Player) sender, ("&f> " + info));
} else {
Utils.logToConsole("> " + info);
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "> " + info);
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.configuration.CustomConfig;
@@ -24,13 +24,13 @@ public class ImportCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_IMPORT_USAGE.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_IMPORT_USAGE.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(Message.COMMAND_IMPORT_USAGE.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_IMPORT_USAGE.getValue());
}
@@ -42,11 +42,11 @@ public class ImportCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ADD_TYPE_ERROR.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ADD_TYPE_ERROR.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ADD_TYPE_ERROR.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ADD_TYPE_ERROR.getValue());
}
@@ -59,12 +59,12 @@ public class ImportCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_MENU_EXISTS.replace("{1}", menuName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_MENU_EXISTS.replace("{1}", menuName));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_MENU_EXISTS.replace("{1}", menuName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_MENU_EXISTS.replace("{1}", menuName));
}
@@ -79,12 +79,12 @@ public class ImportCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
}
@@ -96,12 +96,11 @@ public class ImportCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_IMPORT_SUCCESS.replace("{1}", menuName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_IMPORT_SUCCESS.replace("{1}", menuName));
} else {
Utils.logToConsole(Message.COMMAND_IMPORT_SUCCESS.replace("{1}", menuName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_IMPORT_SUCCESS.replace("{1}", menuName));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.editor.EditorMenuManager;
import cosmeticsOG.editor.MetaState;
@@ -30,7 +30,7 @@ public class MetaCommand extends EditCommand {
PlayerState playerState = core.getPlayerState(player);
if (!playerState.hasEditorOpen()) {
Utils.cosmeticsOGPlaceholderMessage(player, Message.META_ERROR.getValue());
CosmeticsOG.chatMessage(player, Message.META_ERROR.getValue());
return false;
@@ -38,8 +38,8 @@ public class MetaCommand extends EditCommand {
if (args.size() == 0) {
Utils.cosmeticsOGPlaceholderMessage(player, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage(player,
CosmeticsOG.chatMessage(player, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage(player,
Message.COMMAND_META_USAGE.replace("{1}", playerState.getMetaState().getSuggestion()));
return false;
@@ -61,7 +61,7 @@ public class MetaCommand extends EditCommand {
} else {
Utils.logToConsole(Message.COMMAND_ERROR_PLAYER_ONLY.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_PLAYER_ONLY.getValue());
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.Database;
@@ -72,13 +72,13 @@ public class OpenCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_OPEN_USAGE.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_OPEN_USAGE.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(Message.COMMAND_OPEN_USAGE.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_OPEN_USAGE.getValue());
}
@@ -90,7 +90,7 @@ public class OpenCommand extends Command {
if (!sender.isPlayer()) {
Utils.logToConsole(Message.COMMAND_ERROR_PLAYER_ONLY.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_PLAYER_ONLY.getValue());
return false;
@@ -99,8 +99,7 @@ public class OpenCommand extends Command {
PlayerState playerState = core.getPlayerState(sender.getPlayer());
if (playerState.hasEditorOpen()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
return false;
@@ -285,7 +284,7 @@ public class OpenCommand extends Command {
if (menuName.equals("purchase")) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_OPEN_ERROR.replace("{1}", menuName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_OPEN_ERROR.replace("{1}", menuName));
return null;
@@ -300,8 +299,7 @@ public class OpenCommand extends Command {
if (menuInventory == null) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_UNKNOWN_MENU.replace("{1}", menuName));
return null;
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -33,11 +33,11 @@ public class OpenPlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, getUsage().getValue());
CosmeticsOG.chatMessage((Player) sender, getUsage().getValue());
} else {
Utils.logToConsole(getUsage().getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), getUsage().getValue());
}
@@ -50,12 +50,13 @@ public class OpenPlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(1)));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(1)));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(1)));
}
@@ -67,12 +68,12 @@ public class OpenPlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", targetPlayer.getName()));
} else {
Utils.logToConsole(
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", targetPlayer.getName()));
}
@@ -86,12 +87,13 @@ public class OpenPlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_OPEN_PLAYER_EDITING.replace("{1}", targetPlayer.getName()));
} else {
Utils.logToConsole(Message.COMMAND_OPEN_PLAYER_EDITING.replace("{1}", targetPlayer.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_OPEN_PLAYER_EDITING.replace("{1}", targetPlayer.getName()));
}
@@ -1,7 +1,6 @@
package cosmeticsOG.commands.subcommands;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -23,7 +22,7 @@ public class ParticlesCommand extends Command {
PlayerState playerState = core.getPlayerState(sender.getPlayer());
if (playerState.hasEditorOpen()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
return false;
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -19,11 +19,11 @@ public class ReloadCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_RELOAD_SUCCESS.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_RELOAD_SUCCESS.getValue());
} else {
Utils.logToConsole(Message.COMMAND_RELOAD_SUCCESS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_RELOAD_SUCCESS.getValue());
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -21,13 +21,13 @@ public class RemoveTypeCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, getUsage().getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, getUsage().getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(getUsage().getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), getUsage().getValue());
}
@@ -40,12 +40,12 @@ public class RemoveTypeCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_TYPE.replace("{1}", imageName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_UNKNOWN_TYPE.replace("{1}", imageName));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_TYPE.replace("{1}", imageName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_TYPE.replace("{1}", imageName));
}
@@ -57,12 +57,12 @@ public class RemoveTypeCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
Message.COMMAND_REMOVE_TYPE_SUCCESS.replace("{1}", imageName));
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_REMOVE_TYPE_SUCCESS.replace("{1}", imageName));
} else {
Utils.logToConsole(Message.COMMAND_REMOVE_TYPE_SUCCESS.replace("{1}", imageName));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_REMOVE_TYPE_SUCCESS.replace("{1}", imageName));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.Database;
@@ -26,13 +26,13 @@ public class SetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_SET_USAGE.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_SET_USAGE.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(Message.COMMAND_SET_USAGE.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_SET_USAGE.getValue());
}
@@ -45,12 +45,13 @@ public class SetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(0)));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(0)));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(0)));
}
@@ -62,12 +63,13 @@ public class SetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
}
@@ -112,12 +114,13 @@ public class SetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_SET_ALREADY_SET.getValue().replace("{1}", player.getName()));
} else {
Utils.logToConsole(Message.COMMAND_SET_ALREADY_SET.getValue().replace("{1}", player.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_SET_ALREADY_SET.getValue().replace("{1}", player.getName()));
}
@@ -133,12 +136,13 @@ public class SetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_SET_LABEL_ERROR.getValue().replace("{1}", hatLabel));
} else {
Utils.logToConsole(Message.COMMAND_SET_LABEL_ERROR.getValue().replace("{1}", hatLabel));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_SET_LABEL_ERROR.getValue().replace("{1}", hatLabel));
}
@@ -158,7 +162,8 @@ public class SetCommand extends Command {
if (tellPlayer) {
player.sendMessage(Message.COMMAND_SET_SUCCESS.getValue().replace("{1}", hat.getDisplayName()));
CosmeticsOG.chatMessage(player,
Message.COMMAND_SET_SUCCESS.getValue().replace("{1}", hat.getDisplayName()));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -30,13 +30,13 @@ public class SpigotHelpCommand extends BukkitHelpCommand {
Command command = cmds.getValue();
if (command != null) {
String commandText = "&3Command: &f" + Utils.stripColors(command.getName()) + "\n" + "&3Description: &8"
+ Utils.stripColors(command.getDescription().getValue()) + "\n" + "&3Usage: &8"
+ Utils.stripColors(command.getUsage().getValue()) + "\n" + "&3Permission: &8"
+ Utils.stripColors(command.getPermission().getPermission());
String commandText = "&3Command: &f" + UtilitiesOG.stripFormatting(command.getName()) + "\n"
+ "&3Description: &8" + UtilitiesOG.stripFormatting(command.getDescription().getValue()) + "\n"
+ "&3Usage: &8" + UtilitiesOG.stripFormatting(command.getUsage().getValue()) + "\n"
+ "&3Permission: &8" + UtilitiesOG.stripFormatting(command.getPermission().getPermission());
TextComponent hoverText = Utils.legacySerializerAnyCase(commandText);
TextComponent commandComponent = Utils.legacySerializerAnyCase("&7> &3" + command.getUsage().getValue())
TextComponent hoverText = UtilitiesOG.trueogColorize(commandText);
TextComponent commandComponent = UtilitiesOG.trueogColorize("&7> &3" + command.getUsage().getValue())
.hoverEvent(HoverEvent.showText(hoverText))
.clickEvent(ClickEvent.suggestCommand(command.getUsage().getValue()));
@@ -54,13 +54,14 @@ public class SpigotHelpCommand extends BukkitHelpCommand {
if (sender.isPlayer()) {
Player player = sender.getPlayer();
Utils.cosmeticsOGPlaceholderMessage(player, "&f> &6ParticleHats v" + core.getPluginMeta().getVersion());
Utils.cosmeticsOGPlaceholderMessage(player, "&7> " + Message.COMMAND_HELP_TIP.getValue());
CosmeticsOG.chatMessage(player, "&f> &6ParticleHats v" + core.getPluginMeta().getVersion());
CosmeticsOG.chatMessage(player, "&7> " + Message.COMMAND_HELP_TIP.getValue());
} else {
Utils.logToConsole("&f> &6ParticleHats v" + core.getPluginMeta().getVersion());
Utils.logToConsole("&7> " + Message.COMMAND_HELP_TIP.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"&f> &6ParticleHats v" + core.getPluginMeta().getVersion());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "&7> " + Message.COMMAND_HELP_TIP.getValue());
}
@@ -76,7 +77,7 @@ public class SpigotHelpCommand extends BukkitHelpCommand {
} else {
Utils.logToConsole(component.content());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), component.content());
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -31,13 +31,13 @@ public class ToggleCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, getUsage().getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, getUsage().getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(getUsage().getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), getUsage().getValue());
}
@@ -57,11 +57,11 @@ public class ToggleCommand extends Command {
core.getPlayerState(sender.getPlayer()).toggleHats(!toggleStatus);
if (toggleStatus) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_TOGGLE_ON.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_TOGGLE_ON.getValue());
} else {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_TOGGLE_OFF.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_TOGGLE_OFF.getValue());
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.locale.Message;
@@ -23,13 +23,13 @@ public class TogglePlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, getUsage().getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, getUsage().getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(getUsage().getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), getUsage().getValue());
}
@@ -42,12 +42,13 @@ public class TogglePlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(1)));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(1)));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(1)));
}
@@ -59,12 +60,13 @@ public class TogglePlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
}
@@ -78,12 +80,13 @@ public class TogglePlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_TOGGLE_PLAYER_ON.getValue().replace("{1}", player.getName()));
} else {
Utils.logToConsole(Message.COMMAND_TOGGLE_PLAYER_ON.getValue().replace("{1}", player.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_TOGGLE_PLAYER_ON.getValue().replace("{1}", player.getName()));
}
@@ -91,12 +94,13 @@ public class TogglePlayerCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_TOGGLE_PLAYER_OFF.getValue().replace("{1}", player.getName()));
} else {
Utils.logToConsole(Message.COMMAND_TOGGLE_PLAYER_OFF.getValue().replace("{1}", player.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_TOGGLE_PLAYER_OFF.getValue().replace("{1}", player.getName()));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.commands.subcommands;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Command;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.database.Database;
@@ -26,13 +26,13 @@ public class UnsetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.cosmeticsOGPlaceholderMessage((Player) sender, Message.COMMAND_UNSET_USAGE.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_ERROR_ARGUMENTS.getValue());
CosmeticsOG.chatMessage((Player) sender, Message.COMMAND_UNSET_USAGE.getValue());
} else {
Utils.logToConsole(Message.COMMAND_ERROR_ARGUMENTS.getValue());
Utils.logToConsole(Message.COMMAND_UNSET_USAGE.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_ERROR_ARGUMENTS.getValue());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), Message.COMMAND_UNSET_USAGE.getValue());
}
@@ -45,12 +45,13 @@ public class UnsetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(0)));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(0)));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_UNKNOWN_PLAYER.getValue().replace("{1}", args.get(0)));
}
@@ -62,12 +63,13 @@ public class UnsetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
} else {
Utils.logToConsole(Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_ERROR_OFFLINE_PLAYER.getValue().replace("{1}", player.getName()));
}
@@ -91,12 +93,13 @@ public class UnsetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_UNSET_NOT_WEARING.getValue().replace("{1}", player.getName()));
} else {
Utils.logToConsole(Message.COMMAND_UNSET_NOT_WEARING.getValue().replace("{1}", player.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_UNSET_NOT_WEARING.getValue().replace("{1}", player.getName()));
}
@@ -110,12 +113,13 @@ public class UnsetCommand extends Command {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_UNSET_LABEL_ERROR.getValue().replace("{1}", hatLabel));
} else {
Utils.logToConsole(Message.COMMAND_UNSET_LABEL_ERROR.getValue().replace("{1}", hatLabel));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_UNSET_LABEL_ERROR.getValue().replace("{1}", hatLabel));
}
@@ -126,7 +130,8 @@ public class UnsetCommand extends Command {
core.getPlayerState(player).removeHat(hat);
if (tellPlayer) {
player.sendMessage(Message.COMMAND_UNSET_SUCCESS.getValue().replace("{1}", hat.getDisplayName()));
CosmeticsOG.chatMessage(player,
Message.COMMAND_UNSET_SUCCESS.getValue().replace("{1}", hat.getDisplayName()));
}
@@ -1,7 +1,7 @@
package cosmeticsOG.configuration;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.util.ResourceUtil;
import java.io.File;
import java.io.IOException;
@@ -37,7 +37,7 @@ public class CustomConfig {
} else if (logOutput) {
Utils.logToConsole("Loading " + path + File.separator + fileName);
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Loading " + path + File.separator + fileName);
}
@@ -47,7 +47,8 @@ public class CustomConfig {
} catch (Exception error) {
Utils.logToConsole("There was an error loading " + name + ", error: " + error.getClass().getSimpleName());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"There was an error loading " + name + ", error: " + error.getClass().getSimpleName());
}
@@ -69,7 +70,8 @@ public class CustomConfig {
} catch (Exception error) {
Utils.logToConsole("There was an error loading " + name + ", error: " + error.getClass().getSimpleName());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"There was an error loading " + name + ", error: " + error.getClass().getSimpleName());
}
@@ -86,7 +88,8 @@ public class CustomConfig {
} catch (Exception error) {
Utils.logToConsole("There was an error saving the config file: " + error.getMessage());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"There was an error saving the config file: " + error.getMessage());
}
@@ -103,7 +106,8 @@ public class CustomConfig {
} catch (Exception error) {
Utils.logToConsole("There was an error loading " + name + ", error: " + error.getClass().getSimpleName());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"There was an error loading " + name + ", error: " + error.getClass().getSimpleName());
}
@@ -175,8 +179,8 @@ public class CustomConfig {
} catch (IOException error) {
Utils.logToConsole("ERROR: Failed to copy resource: " + core.getResource(fileName) + "into file: "
+ file.getAbsolutePath());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "ERROR: Failed to copy resource: "
+ core.getResource(fileName) + "into file: " + file.getAbsolutePath());
}
@@ -190,7 +194,8 @@ public class CustomConfig {
} catch (IOException error) {
Utils.logToConsole("ERROR: Failed to create file: " + file.getAbsolutePath());
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"ERROR: Failed to create file: " + file.getAbsolutePath());
}
@@ -200,7 +205,7 @@ public class CustomConfig {
if (logOutput) {
Utils.logToConsole("Creating " + path + File.separator + fileName);
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Creating " + path + File.separator + fileName);
}
@@ -1,9 +1,9 @@
package cosmeticsOG.database.type.mysql;
import net.trueog.utilitiesog.UtilitiesOG;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.commands.Sender;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.configuration.CustomConfig;
@@ -115,7 +115,7 @@ public class MySQLDatabase implements Database {
helper.initDatabase(core);
connected = true;
Utils.logToConsole("Successfully connected to MySQL database");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Successfully connected to MySQL database");
} catch (Exception e) {
@@ -1246,12 +1246,13 @@ public class MySQLDatabase implements Database {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_IMPORT_SUCCESS.replace("{1}", menuConfig.getName()));
} else {
Utils.logToConsole(Message.COMMAND_IMPORT_SUCCESS.replace("{1}", menuConfig.getName()));
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_IMPORT_SUCCESS.replace("{1}", menuConfig.getName()));
}
@@ -1263,12 +1264,12 @@ public class MySQLDatabase implements Database {
if (sender.isPlayer()) {
Utils.cosmeticsOGPlaceholderMessage((Player) sender,
CosmeticsOG.chatMessage((Player) sender,
Message.COMMAND_IMPORT_ERROR.replace("{1}", error.getClass().getSimpleName()));
} else {
Utils.logToConsole(
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
Message.COMMAND_IMPORT_ERROR.replace("{1}", error.getClass().getSimpleName()));
}
@@ -1285,7 +1286,7 @@ public class MySQLDatabase implements Database {
/**
* Adds an exiting .yml menu into the database
*
*
* @param menuConfig
* @return
* @throws SQLException
@@ -1692,7 +1693,7 @@ public class MySQLDatabase implements Database {
/**
* Inserts an image into the database
*
*
* @param imageName
* @param image
* @return
@@ -1736,7 +1737,7 @@ public class MySQLDatabase implements Database {
/**
* Creates an empty menu in the database
*
*
* @param menuName
* @param title
* @param rows
@@ -1815,7 +1816,7 @@ public class MySQLDatabase implements Database {
while (menuResult.next()) {
final TextComponent menuTitle = Utils.legacySerializerAnyCase(menuResult.getString("title"));
final TextComponent menuTitle = UtilitiesOG.trueogColorize(menuResult.getString("title"));
final int menuSize = menuResult.getInt("size");
final String alias = menuResult.getString("alias");
@@ -1971,7 +1972,7 @@ public class MySQLDatabase implements Database {
/**
* Updates the database with any changes
*
*
* @param menuName
* @param slot
* @param sqlQuery
@@ -2013,8 +2014,8 @@ public class MySQLDatabase implements Database {
// Using legacySerializerAnyCase to handle any-case color codes
ItemMeta meta = item.getItemMeta();
meta.displayName(Utils.legacySerializerAnyCase(hat.getDisplayName())); // Convert color-coded string to
// Component
meta.displayName(UtilitiesOG.trueogColorize(hat.getDisplayName())); // Convert color-coded string to
// Component
while (set.next()) {
@@ -2022,16 +2023,16 @@ public class MySQLDatabase implements Database {
switch (type) {
case DESCRIPTION:
descriptionComponents.add(Utils.legacySerializerAnyCase(set.getString("value"))); // Handle
// any-case
// color codes
descriptionComponents.add(UtilitiesOG.trueogColorize(set.getString("value"))); // Handle
// any-case
// color codes
break;
case PERMISSION_DESCRIPTION:
permissionDescriptionComponents.add(Utils.legacySerializerAnyCase(set.getString("value"))); // Handle
// any-case
// color
// codes
permissionDescriptionComponents.add(UtilitiesOG.trueogColorize(set.getString("value"))); // Handle
// any-case
// color
// codes
break;
case ICON:
@@ -2320,7 +2321,7 @@ public class MySQLDatabase implements Database {
/**
* Moves data from one table to another table
*
*
* @param fromMenu
* @param toMenu
* @param fromSlot
@@ -2380,7 +2381,7 @@ public class MySQLDatabase implements Database {
/**
* Moves hat data to a new slot
*
*
* @param menuName
* @param previousSlot
* @param newSlot
@@ -2408,7 +2409,7 @@ public class MySQLDatabase implements Database {
/**
* Swaps hat data with an existing slot
*
*
* @param menuName
* @param previousSlot
* @param newSlot
@@ -2502,7 +2503,7 @@ public class MySQLDatabase implements Database {
/**
* Returns the value stored at the column label, or the default value if null
*
*
* @param set
* @param columnLabel
* @param defaultValue
@@ -2524,7 +2525,7 @@ public class MySQLDatabase implements Database {
/**
* Returns the value stored at the column index, or the default value if 0
*
*
* @param set
* @param columnLabel
* @param defaultValue
@@ -2546,7 +2547,7 @@ public class MySQLDatabase implements Database {
/**
* Returns the value stored at the column index, or the default value if 0
*
*
* @param set
* @param columnLabel
* @param defaultValue
@@ -1,7 +1,7 @@
package cosmeticsOG.database.type.yaml;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.configuration.CustomConfig;
import cosmeticsOG.database.Database;
@@ -36,7 +36,6 @@ import cosmeticsOG.util.YamlUtil;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -73,7 +72,7 @@ public class YamlDatabase implements Database {
public YamlDatabase(CosmeticsOG core) {
Utils.logToConsole("Loaded YAML database.");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Loaded YAML database.");
this.core = core;
@@ -124,31 +123,6 @@ public class YamlDatabase implements Database {
}
if (SettingsManager.LOAD_INCLUDED_MENUS.getBoolean()) {
// Try to load this server versions .yml file.
File particlesFile = new File(
core.getDataFolder() + File.separator + "menus" + File.separator + "particles.yml");
if (!particlesFile.exists()) {
Utils.logToConsole("particlesFile does not exist at path: " + particlesFile.getAbsolutePath());
InputStream particleStream = ResourceUtil.getMostCompatibleParticlesMenu();
if (particleStream != null) {
try {
ResourceUtil.copyFile(particleStream, particlesFile);
} catch (IOException e) {
}
}
}
}
onReload();
}
@@ -914,7 +888,7 @@ public class YamlDatabase implements Database {
File menusFolder = new File(core.getDataFolder() + File.separator + "menus");
if (!menusFolder.isDirectory()) {
Utils.logToConsole("Unable to find menus folder");
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Unable to find menus folder");
return;
}
@@ -1060,7 +1034,7 @@ public class YamlDatabase implements Database {
FileConfiguration config = menuConfig.getConfig();
final String menuName = menuConfig.getName();
final TextComponent menuTitle = Utils.legacySerializerAnyCase(config.getString("settings.title", "New Menu"));
final TextComponent menuTitle = UtilitiesOG.trueogColorize(config.getString("settings.title", "New Menu"));
final int menuSize = config.getInt("settings.size", 6);
final String alias = config.getString("settings.alias");
final MenuInventory inventory = new MenuInventory(menuName, menuTitle, menuSize, alias);
@@ -1,7 +1,7 @@
package cosmeticsOG.editor;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.locale.Message;
import cosmeticsOG.managers.SettingsManager;
import cosmeticsOG.particles.Hat;
@@ -904,7 +904,7 @@ public class EditorLore {
List<Component> footerDescription = StringUtil
.parseDescription(Message.EDITOR_HAT_FOOTER_DESCRIPTION.getValue());
List<String> footerStrings = footerDescription.stream()
.map(component -> Utils.legacySerializerAnyCase(component.toString()).content())
.map(component -> UtilitiesOG.trueogColorize(component.toString()).content())
.collect(Collectors.toList());
description.addAll(footerStrings);
@@ -998,7 +998,7 @@ public class EditorLore {
String formattedTitle = menuTitle.replace(extraInfo[0], title);
// Process color codes.
return Utils.legacySerializerAnyCase(formattedTitle).content();
return UtilitiesOG.trueogColorize(formattedTitle).content();
}
@@ -1,7 +1,7 @@
package cosmeticsOG.editor;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.database.Database;
import cosmeticsOG.locale.Message;
import cosmeticsOG.particles.Hat;
@@ -92,7 +92,7 @@ public enum MetaState {
sb.deleteCharAt(0);
String value = sb.toString();
String rawString = Utils.stripColors(value);
String rawString = UtilitiesOG.stripFormatting(value);
Hat targetHat = editorManager.getBaseHat();
@@ -123,7 +123,7 @@ public enum MetaState {
case MENU_ALIAS: {
editorManager.getEditingMenu().setAlias(Utils.stripColors(args.get(0)));
editorManager.getEditingMenu().setAlias(UtilitiesOG.stripFormatting(args.get(0)));
editorManager.reopen();
}
@@ -137,7 +137,8 @@ public enum MetaState {
if (database.menuExists(menuName)) {
player.sendMessage(Message.COMMAND_ERROR_MENU_EXISTS.getValue().replace("{1}", menuName));
CosmeticsOG.chatMessage(player,
Message.COMMAND_ERROR_MENU_EXISTS.getValue().replace("{1}", menuName));
return;
}
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorMenuManager;
import cosmeticsOG.locale.Message;
@@ -122,8 +122,8 @@ public class EditorActionMenu extends AbstractListMenu {
String titleStr = menuTitle.replace(leftClickInfo[0], leftClick).replace(rightClickInfo[0], rightClick)
.replace("{3}", Integer.toString(i + 1)).replace("{4}", Integer.toString(totalPages));
// Convert the title string to a colorized TextComponent using TrueOG Utils.
Component title = Utils.legacySerializerAnyCase(titleStr);
// Convert the title string to a colorized TextComponent using Utilities-OG.
Component title = UtilitiesOG.trueogColorize(titleStr);
// Pass the colorized title Component to createInventory.
Inventory menu = Bukkit.createInventory(null, 54, title);
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -33,7 +33,7 @@ public class EditorActionMenuOverview extends AbstractStaticMenu {
this.callback = callback;
this.targetHat = menuManager.getBaseHat();
this.inventory = Bukkit.createInventory(null, 27,
Utils.legacySerializerAnyCase(Message.EDITOR_ACTION_OVERVIEW_MENU_TITlE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_ACTION_OVERVIEW_MENU_TITlE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -27,7 +27,7 @@ public class EditorAngleMenu extends AbstractStaticMenu {
this.editorManager = menuManager;
this.callback = callback;
this.inventory = Bukkit.createInventory(null, 27,
Utils.legacySerializerAnyCase(Message.EDITOR_ANGLE_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_ANGLE_MENU_TITLE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -49,7 +49,7 @@ public class EditorBaseMenu extends AbstractStaticMenu {
StringUtil.parseDescription(Message.EDITOR_SLOT_DESCRIPTION.getValue()));
this.editingTitle = EditorLore.getTrimmedMenuTitle(menuInventory.getName(), Message.EDITOR_BASE_MENU_TITLE);
this.inventory = Bukkit.createInventory(null, menuInventory.getSize(),
Utils.legacySerializerAnyCase(editingTitle));
UtilitiesOG.trueogColorize(editingTitle));
this.inventory.setContents(menuInventory.getContents());
emptyParticleAction = (event, slot) -> {
@@ -235,10 +235,10 @@ public class EditorBaseMenu extends AbstractStaticMenu {
*/
public void setTitle(String title) {
menuInventory.setTitle(Utils.legacySerializerAnyCase(title));
menuInventory.setTitle(UtilitiesOG.trueogColorize(title));
Inventory replacementInventory = Bukkit.createInventory(null, inventory.getSize(),
Utils.legacySerializerAnyCase(editingTitle));
UtilitiesOG.trueogColorize(editingTitle));
replacementInventory.setContents(inventory.getContents());
inventory = replacementInventory;
@@ -337,7 +337,7 @@ public class EditorBaseMenu extends AbstractStaticMenu {
if (this.rows != rows) {
Inventory replacementInventory = Bukkit.createInventory(null, (9 * rows),
Utils.legacySerializerAnyCase(editingTitle));
UtilitiesOG.trueogColorize(editingTitle));
// inventory.setContents() only works when resizing the menus to a smaller size.
// So, we need to use a loop
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -40,7 +40,7 @@ public class EditorColorMenu extends AbstractStaticMenu {
this.callback = callback;
this.colors = new HashMap<Integer, Color>();
this.inventory = Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_COLOUR_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_COLOUR_MENU_TITLE.getValue()));
this.setColorAction = (event, slot) -> {
@@ -202,7 +202,7 @@ public class EditorColorMenu extends AbstractStaticMenu {
private String getColorDescription(Color color, String title) {
String description = Message.EDITOR_COLOUR_MENU_PRESET_DESCRIPTION.getValue();
String s = description.replace("{1}", Utils.stripColors(title.toLowerCase()))
String s = description.replace("{1}", UtilitiesOG.stripFormatting(title.toLowerCase()))
.replace("{2}", Integer.toString(color.getRed())).replace("{3}", Integer.toString(color.getGreen()))
.replace("{4}", Integer.toString(color.getBlue()));
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.locale.Message;
import cosmeticsOG.ui.AbstractStaticMenu;
@@ -22,7 +22,7 @@ public class EditorDeleteMenu extends AbstractStaticMenu {
this.editorBaseMenu = editorBaseMenu;
this.inventory = Bukkit.createInventory(null, 27,
Utils.legacySerializerAnyCase(Message.EDITOR_DELETE_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_DELETE_MENU_TITLE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.database.Database;
import cosmeticsOG.database.Database.DataType;
@@ -47,7 +47,7 @@ public class EditorDescriptionMenu extends AbstractListMenu {
this.totalPages = 1;
setMenu(0, Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_DESCRIPTION_MENU_TITLE.getValue())));
UtilitiesOG.trueogColorize(Message.EDITOR_DESCRIPTION_MENU_TITLE.getValue())));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
import cosmeticsOG.locale.Message;
@@ -25,7 +25,7 @@ public class EditorDurationMenu extends AbstractStaticMenu {
this.targetHat = menuManager.getBaseHat();
this.callback = callback;
this.inventory = Bukkit.createInventory(null, 27,
Utils.legacySerializerAnyCase(Message.EDITOR_DURATION_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_DURATION_MENU_TITLE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.database.Database.DataType;
import cosmeticsOG.editor.EditorLore;
@@ -50,7 +50,7 @@ public class EditorIconMenuOverview extends AbstractListMenu {
this.totalPages = 1;
setMenu(0, Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_ICON_OVERVIEW_MENU_TITLE.getValue())));
UtilitiesOG.trueogColorize(Message.EDITOR_ICON_OVERVIEW_MENU_TITLE.getValue())));
build();
@@ -257,8 +257,8 @@ public class EditorIconMenuOverview extends AbstractListMenu {
int index = getNormalIndex(i, 10, 2);
// Convert the display name to TextComponent using TrueOG Utils for color codes.
TextComponent nameComponent = Utils.legacySerializerAnyCase(displayName);
// Convert the display name to TextComponent using Utilities-OG color codes.
TextComponent nameComponent = UtilitiesOG.trueogColorize(displayName);
// Parse and process the description if it's a List<String>, converting it to
// List<TextComponent>.
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorMenuManager;
import cosmeticsOG.editor.MetaState;
@@ -35,7 +35,7 @@ public class EditorItemPromptMenu extends AbstractStaticMenu {
this.callback = callback;
this.itemName = itemName;
this.itemDescription = itemDescription;
this.inventory = Bukkit.createInventory(null, 54, Utils.legacySerializerAnyCase(title.getValue()));
this.inventory = Bukkit.createInventory(null, 54, UtilitiesOG.trueogColorize(title.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.database.Database.DataType;
import cosmeticsOG.editor.EditorLore;
@@ -112,7 +112,7 @@ public class EditorItemStackMenu extends AbstractListMenu {
};
setMenu(0, Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_ITEMSTACK_MENU_TITLE.getValue())));
UtilitiesOG.trueogColorize(Message.EDITOR_ITEMSTACK_MENU_TITLE.getValue())));
build();
@@ -260,7 +260,7 @@ public class EditorItemStackMenu extends AbstractListMenu {
String displayName = Message.EDITOR_ICON_MENU_ITEM_PREFIX.getValue()
+ StringUtil.getMaterialName(item.getType());
ItemUtil.setNameAndDescription(item, Utils.legacySerializerAnyCase(displayName),
ItemUtil.setNameAndDescription(item, UtilitiesOG.trueogColorize(displayName),
StringUtil.parseDescription(Message.EDITOR_ICON_MENU_ICON_DESCRIPTION.getValue()));
setItem(0, getNormalIndex(i, 10, 2), item);
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.compatibility.CompatibleSound;
import cosmeticsOG.database.Database;
@@ -63,7 +63,7 @@ public class EditorMainMenu extends AbstractStaticMenu {
this.targetHat = editorManager.getTargetHat();
this.ownerState = core.getPlayerState(owner);
this.inventory = Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_MAIN_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_MAIN_MENU_TITLE.getValue()));
setParticleAction = (event, slot) -> {
@@ -385,7 +385,7 @@ public class EditorMainMenu extends AbstractStaticMenu {
// Stop if the player has more than the maximum allowed hats.
if (!ownerState.canEquip()) {
owner.sendMessage(Message.HAT_EQUIPPED_OVERFLOW.replace("{1}",
CosmeticsOG.chatMessage(owner, Message.HAT_EQUIPPED_OVERFLOW.replace("{1}",
Integer.toString(SettingsManager.MAXIMUM_HAT_LIMIT.getInt())));
return MenuClickResult.NEGATIVE;
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorMenuManager;
import cosmeticsOG.editor.MetaState;
@@ -183,7 +183,7 @@ public class EditorMenuSelectionMenu extends AbstractListMenu {
String menuTitle = title.replace("{1}", Integer.toString(index + 1)).replace("{2}",
Integer.toString(totalPages));
Inventory menu = Bukkit.createInventory(null, 54, Utils.legacySerializerAnyCase(menuTitle));
Inventory menu = Bukkit.createInventory(null, 54, UtilitiesOG.trueogColorize(menuTitle));
menu.setItem(49, backButtonItem);
// Next Page.
@@ -251,8 +251,8 @@ public class EditorMenuSelectionMenu extends AbstractListMenu {
String name = Message.EDITOR_MENU_SELECTION_MENU_PREFIX.getValue() + key;
ItemStack item = ItemUtil.createItem(Material.BOOK, 1, name);
ItemUtil.setItemDescription(item, Utils.legacySerializerAnyCase(
Message.EDITOR_MENU_SELECTION_MENU_DESCRIPTION.getValue().replace("{1}", value)));
ItemUtil.setItemDescription(item, UtilitiesOG
.trueogColorize(Message.EDITOR_MENU_SELECTION_MENU_DESCRIPTION.getValue().replace("{1}", value)));
setItem(page, getNormalIndex(index++, 10, 2), item);
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.database.Database;
import cosmeticsOG.database.Database.DataType;
@@ -29,7 +29,7 @@ public class EditorMetaMenu extends AbstractStaticMenu {
this.editorManager = menuManager;
this.targetHat = menuManager.getBaseHat();
this.inventory = Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_META_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_META_MENU_TITLE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.editor.EditorMenuManager;
import cosmeticsOG.locale.Message;
import org.bukkit.Bukkit;
@@ -19,7 +19,7 @@ public class EditorNodeMainMenu extends EditorMainMenu {
public void build() {
this.inventory = Bukkit.createInventory(null, 45,
Utils.legacySerializerAnyCase(Message.EDITOR_MAIN_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_MAIN_MENU_TITLE.getValue()));
this.particleButtonSlot = 13;
this.trackingButtonSlot = 19;
this.countButtonSlot = 15;
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -33,7 +33,7 @@ public class EditorNodeMenuOverview extends AbstractListMenu {
this.totalPages = 1;
setMenu(0, Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_NODE_OVERVIEW_MENU_TITLE.getValue())));
UtilitiesOG.trueogColorize(Message.EDITOR_NODE_OVERVIEW_MENU_TITLE.getValue())));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -26,7 +26,7 @@ public class EditorOffsetMenu extends AbstractStaticMenu {
this.editorManager = menuManager;
this.callback = callback;
this.inventory = Bukkit.createInventory(null, 45,
Utils.legacySerializerAnyCase(Message.EDITOR_OFFSET_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_OFFSET_MENU_TITLE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.database.Database;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -39,7 +39,7 @@ public class EditorParticleMenuOverview extends AbstractStaticMenu {
this.particles = new HashMap<Integer, ParticleEffect>();
this.modifiedParticles = new HashMap<Integer, Boolean>();
this.inventory = Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_PARTICLE_OVERVIEW_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_PARTICLE_OVERVIEW_MENU_TITLE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -59,7 +59,7 @@ public class EditorParticleSelectionMenu extends AbstractStaticMenu {
this.colorFilterMenus = new HashMap<Integer, Inventory>();
this.dataFilterMenus = new HashMap<Integer, Inventory>();
this.recentFilterMenu = Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_PARTICLE_MENU_RECENT_FILTER_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_PARTICLE_MENU_RECENT_FILTER_TITLE.getValue()));
this.particles = new HashMap<Integer, ParticleEffect>();
this.colorParticles = new HashMap<Integer, ParticleEffect>();
@@ -395,7 +395,7 @@ public class EditorParticleSelectionMenu extends AbstractStaticMenu {
String menuTitle = title.replace("{1}", Integer.toString(i + 1)).replace("{2}",
Integer.toString(totalPages));
Inventory inventory = Bukkit.createInventory(null, 54, Utils.legacySerializerAnyCase(menuTitle));
Inventory inventory = Bukkit.createInventory(null, 54, UtilitiesOG.trueogColorize(menuTitle));
inventory.setItem(49, backButtonItem);
inventory.setItem(45,
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -91,7 +91,7 @@ public class EditorPotionMenu extends AbstractListMenu {
String title = menuTitle.replace("{1}", Integer.toString(i + 1)).replace("{2}",
Integer.toString(totalPages));
Inventory menu = Bukkit.createInventory(null, 54, Utils.legacySerializerAnyCase(title));
Inventory menu = Bukkit.createInventory(null, 54, UtilitiesOG.trueogColorize(title));
menu.setItem(49, backButtonItem);
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.locale.Message;
import cosmeticsOG.ui.AbstractStaticMenu;
@@ -24,7 +24,7 @@ public class EditorResizeMenu extends AbstractStaticMenu {
this.editorBaseMenu = editorBaseMenu;
this.inventory = Bukkit.createInventory(null, 27,
Utils.legacySerializerAnyCase(Message.EDITOR_RESIZE_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_RESIZE_MENU_TITLE.getValue()));
build();
@@ -60,7 +60,7 @@ public class EditorResizeMenu extends AbstractStaticMenu {
i == 0 ? "" : suffixInfo[1]);
String description = Message.EDITOR_RESIZE_MENU_SET_ROW_DESCRIPTION.getValue();
List<TextComponent> descriptionList = List.of(Utils.legacySerializerAnyCase(description));
List<TextComponent> descriptionList = List.of(UtilitiesOG.trueogColorize(description));
ItemStack row = ItemUtil.createItem(CompatibleMaterial.GRAY_DYE.getMaterial(), 1, t, descriptionList);
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.locale.Message;
@@ -127,7 +127,7 @@ public class EditorSearchMenu extends AbstractListMenu {
for (int i = 0; i < totalPages; i++) {
Inventory inventory = Bukkit.createInventory(null, 54, Utils.legacySerializerAnyCase(menuTitle));
Inventory inventory = Bukkit.createInventory(null, 54, UtilitiesOG.trueogColorize(menuTitle));
inventory.setItem(49, backButtonItem);
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -32,7 +32,7 @@ public class EditorSettingsMenu extends AbstractStaticMenu {
this.editorBaseMenu = editorBaseMenu;
this.menuInventory = editorBaseMenu.getMenuInventory();
this.inventory = Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_SETTINGS_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_SETTINGS_MENU_TITLE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.compatibility.CompatibleSound;
import cosmeticsOG.editor.EditorMenuManager;
@@ -33,7 +33,7 @@ public class EditorSlotMenu extends AbstractStaticMenu {
this.cloning = cloning;
this.size = editorBaseMenu.getMenuInventory().getSize();
this.inventory = Bukkit.createInventory(null, size,
Utils.legacySerializerAnyCase(Message.EDITOR_SLOT_MENU_TITlE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_SLOT_MENU_TITlE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -339,7 +339,7 @@ public class EditorSoundMenu extends AbstractStaticMenu {
String menuTitle = startingTitle.getValue().replace("{1}", Integer.toString(i + 1)).replace("{2}",
Integer.toString(pages));
Inventory menu = Bukkit.createInventory(null, 54, Utils.legacySerializerAnyCase(menuTitle));
Inventory menu = Bukkit.createInventory(null, 54, UtilitiesOG.trueogColorize(menuTitle));
// Filters.
menu.setItem(45, ItemUtil.createItem(Material.BOWL, 1, Message.EDITOR_SOUND_MENU_MISC_FILTER.getValue()));
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.locale.Message;
import cosmeticsOG.particles.properties.ParticleTag;
@@ -67,7 +67,7 @@ public class EditorTagMenu extends AbstractListMenu {
for (int i = 0; i < totalPages; i++) {
Inventory menu = Bukkit.createInventory(null, 54, Utils.legacySerializerAnyCase(title));
Inventory menu = Bukkit.createInventory(null, 54, UtilitiesOG.trueogColorize(title));
menu.setItem(49, backButtonItem);
// Next page.
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.database.Database.DataType;
import cosmeticsOG.editor.EditorMenuManager;
@@ -37,7 +37,7 @@ public class EditorTagMenuOverview extends AbstractListMenu {
this.totalPages = 1;
setMenu(0, Bukkit.createInventory(null, 54,
Utils.legacySerializerAnyCase(Message.EDITOR_TAG_OVERVIEW_MENU_TITLE.getValue())));
UtilitiesOG.trueogColorize(Message.EDITOR_TAG_OVERVIEW_MENU_TITLE.getValue())));
build();
@@ -164,7 +164,7 @@ public class EditorTagMenuOverview extends AbstractListMenu {
for (int i = 0; i < tags.size(); i++) {
ParticleTag tag = tags.get(i);
String titleString = Utils.legacySerializerAnyCase(tagTitle.replace("{1}", tag.getDisplayName())).content();
String titleString = UtilitiesOG.trueogColorize(tagTitle.replace("{1}", tag.getDisplayName())).content();
List<TextComponent> textComponents = StringUtil
.parseDescription(Message.EDITOR_TAG_OVERVIEW_MENU_TAG_DESCRIPTION.getValue()).stream()
.map(component -> (TextComponent) component).collect(Collectors.toList());
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.compatibility.CompatibleSound;
import cosmeticsOG.editor.EditorLore;
@@ -40,7 +40,7 @@ public class EditorTransferMenu extends AbstractStaticMenu {
this.editorManager = menuManager;
this.menuName = menuName;
this.menuInventory = core.getDatabase().loadInventory(menuName, core.getPlayerState(owner));
this.inventory = Bukkit.createInventory(null, menuInventory.getSize(), Utils.legacySerializerAnyCase(
this.inventory = Bukkit.createInventory(null, menuInventory.getSize(), UtilitiesOG.trueogColorize(
EditorLore.getTrimmedMenuTitle(menuInventory.getTitle().content(), Message.EDITOR_MOVE_MENU_TITLE)));
build();
@@ -100,7 +100,7 @@ public class EditorTransferMenu extends AbstractStaticMenu {
} else {
ItemUtil.setNameAndDescription(item,
Utils.legacySerializerAnyCase(Message.EDITOR_MOVE_MENU_OCCUPIED.getValue()),
UtilitiesOG.trueogColorize(Message.EDITOR_MOVE_MENU_OCCUPIED.getValue()),
StringUtil.parseDescription(Message.EDITOR_MOVE_MENU_OCCUPIED_DESCRIPTION.getValue()));
setButton(i, item, cancelAction);
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -373,7 +373,7 @@ public class EditorTypeMenu extends AbstractStaticMenu {
String menuTitle = title.replace("{1}", Integer.toString(i + 1)).replace("{2}", Integer.toString(pages));
Inventory menu = Bukkit.createInventory(null, 54, Utils.legacySerializerAnyCase(menuTitle));
Inventory menu = Bukkit.createInventory(null, 54, UtilitiesOG.trueogColorize(menuTitle));
menu.setItem(49, backButtonItem);
// Next page.
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.EditorMenuManager;
@@ -32,7 +32,7 @@ public class EditorVelocityMenu extends AbstractStaticMenu {
this.particleIndex = particleIndex;
this.callback = callback;
this.inventory = Bukkit.createInventory(null, 27,
Utils.legacySerializerAnyCase(Message.EDITOR_VELOCITY_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_VELOCITY_MENU_TITLE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.purchase.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.database.Database;
import cosmeticsOG.database.Database.DataType;
@@ -40,7 +40,7 @@ public class PurchaseEditorMainMenu extends AbstractStaticMenu {
this.editorBaseMenu = menuManager.getEditingMenu();
this.targetHat = menuManager.getBaseHat();
this.inventory = Bukkit.createInventory(null, 36,
Utils.legacySerializerAnyCase(Message.EDITOR_MAIN_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_MAIN_MENU_TITLE.getValue()));
build();
@@ -1,7 +1,7 @@
package cosmeticsOG.editor.purchase.menus;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.editor.EditorLore;
import cosmeticsOG.editor.MetaState;
@@ -32,7 +32,7 @@ public class PurchaseEditorSettingsMenu extends AbstractStaticMenu {
this.editorBaseMenu = menuManager.getEditingMenu();
this.menuInventory = editorBaseMenu.getMenuInventory();
this.inventory = Bukkit.createInventory(null, 36,
Utils.legacySerializerAnyCase(Message.EDITOR_SETTINGS_MENU_TITLE.getValue()));
UtilitiesOG.trueogColorize(Message.EDITOR_SETTINGS_MENU_TITLE.getValue()));
build();
@@ -1,31 +0,0 @@
package cosmeticsOG.hooks;
import org.bukkit.entity.Player;
public interface CurrencyHook {
/**
* Gets the players current economy balance
*
* @param id
* @return
*/
public int getBalance(Player player);
/**
* Withdraws the provided amount from the players economy balance
*
* @param id
* @param amount
* @return
*/
public boolean withdraw(Player player, int amount);
/**
* Checks to see if this hook has been loaded
*
* @return
*/
public boolean isEnabled();
}
@@ -0,0 +1,181 @@
package cosmeticsOG.hooks;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.player.EntityState;
import cosmeticsOG.player.SuppressionSource;
import java.lang.reflect.Method;
import java.util.Collection;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.Plugin;
// Hides cosmetics while a player is in a Duels-OG match and restores them when it ends.
// Talks to the Duels-OG API through reflection so Duels-OG stays an optional dependency.
public class DuelsHook implements Listener {
private static final String DUELS_API_CLASS = "me.realized.duels.api.Duels";
private static final String MATCH_START_EVENT_CLASS = "me.realized.duels.api.event.match.MatchStartEvent";
private static final String MATCH_END_EVENT_CLASS = "me.realized.duels.api.event.match.MatchEndEvent";
private final CosmeticsOG core;
private final Plugin duelsPlugin;
private final Method getArenaManagerMethod;
private final Method isInMatchMethod;
private final Method getStartPlayersMethod;
private final Method getMatchMethod;
private final Method getStartingPlayersMethod;
public DuelsHook(final CosmeticsOG core, final Plugin duelsPlugin) throws ReflectiveOperationException {
this.core = core;
this.duelsPlugin = duelsPlugin;
final ClassLoader loader = duelsPlugin.getClass().getClassLoader();
final Class<?> duelsApiClass = Class.forName(DUELS_API_CLASS, false, loader);
if (!duelsApiClass.isInstance(duelsPlugin)) {
throw new ClassNotFoundException(duelsPlugin.getName() + " does not implement " + DUELS_API_CLASS);
}
getArenaManagerMethod = duelsApiClass.getMethod("getArenaManager");
isInMatchMethod = getArenaManagerMethod.getReturnType().getMethod("isInMatch", Player.class);
final Class<?> startEventClass = Class.forName(MATCH_START_EVENT_CLASS, false, loader);
getStartPlayersMethod = startEventClass.getMethod("getPlayers");
final Class<?> endEventClass = Class.forName(MATCH_END_EVENT_CLASS, false, loader);
getMatchMethod = endEventClass.getMethod("getMatch");
getStartingPlayersMethod = getMatchMethod.getReturnType().getMethod("getStartingPlayers");
registerMatchEvent(startEventClass.asSubclass(Event.class), true);
registerMatchEvent(endEventClass.asSubclass(Event.class), false);
syncOnlinePlayers();
}
// Returns true if Duels-OG currently has this player in a match.
public boolean isInMatch(Player player) {
if (!duelsPlugin.isEnabled()) {
return false;
}
try {
final Object arenaManager = getArenaManagerMethod.invoke(duelsPlugin);
return arenaManager != null && Boolean.TRUE.equals(isInMatchMethod.invoke(arenaManager, player));
} catch (ReflectiveOperationException | RuntimeException ignored) {
return false;
}
}
// Unregisters the match listeners and restores cosmetics for everyone still
// suppressed.
public void unregister() {
HandlerList.unregisterAll(this);
for (EntityState entityState : core.getEntityStates()) {
entityState.setSuppressed(SuppressionSource.DUEL, false);
}
}
private void registerMatchEvent(Class<? extends Event> eventClass, boolean matchStarted) {
final EventExecutor executor = (listener, event) -> handleMatchEvent(event, matchStarted);
core.getServer().getPluginManager().registerEvent(eventClass, this, EventPriority.MONITOR, executor, core,
false);
}
private void handleMatchEvent(Event event, boolean matchStarted) {
try {
if (matchStarted) {
final Object players = getStartPlayersMethod.invoke(event);
if (players instanceof Player[]) {
for (Player player : (Player[]) players) {
setSuppressed(player, true);
}
}
return;
}
// The end event carries UUIDs only, so read both starting players from the
// match.
final Object match = getMatchMethod.invoke(event);
if (match == null) {
return;
}
final Object players = getStartingPlayersMethod.invoke(match);
if (players instanceof Collection) {
for (Object player : (Collection<?>) players) {
if (player instanceof Player) {
setSuppressed((Player) player, false);
}
}
}
} catch (ReflectiveOperationException | RuntimeException ignored) {
}
}
private void syncOnlinePlayers() {
for (Player player : core.getServer().getOnlinePlayers()) {
setSuppressed(player, isInMatch(player));
}
}
private void setSuppressed(Player player, boolean suppressed) {
if (player == null || !core.hasEntityState(player)) {
return;
}
core.getPlayerState(player).setSuppressed(SuppressionSource.DUEL, suppressed);
}
}
@@ -0,0 +1,166 @@
package cosmeticsOG.hooks;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.player.EntityState;
import cosmeticsOG.player.SuppressionSource;
import java.lang.reflect.Method;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.Plugin;
// Hides cosmetics while EternalCombat-OG has a player combat tagged, restores on untag.
// Talks to the EternalCombat-OG API through reflection so it stays an optional dependency.
public class EternalCombatHook implements Listener {
private static final String API_CLASS = "com.eternalcode.combat.EternalCombatApi";
private static final String TAG_EVENT_CLASS = "com.eternalcode.combat.fight.event.FightTagEvent";
private static final String UNTAG_EVENT_CLASS = "com.eternalcode.combat.fight.event.FightUntagEvent";
private final CosmeticsOG core;
private final Plugin combatPlugin;
private final Method getFightManagerMethod;
private final Method isInCombatMethod;
private final Method getTagPlayerMethod;
private final Method getUntagPlayerMethod;
public EternalCombatHook(final CosmeticsOG core, final Plugin combatPlugin) throws ReflectiveOperationException {
this.core = core;
this.combatPlugin = combatPlugin;
final ClassLoader loader = combatPlugin.getClass().getClassLoader();
final Class<?> apiClass = Class.forName(API_CLASS, false, loader);
if (!apiClass.isInstance(combatPlugin)) {
throw new ClassNotFoundException(combatPlugin.getName() + " does not implement " + API_CLASS);
}
getFightManagerMethod = apiClass.getMethod("getFightManager");
isInCombatMethod = getFightManagerMethod.getReturnType().getMethod("isInCombat", UUID.class);
final Class<?> tagEventClass = Class.forName(TAG_EVENT_CLASS, false, loader);
getTagPlayerMethod = tagEventClass.getMethod("getPlayer");
final Class<?> untagEventClass = Class.forName(UNTAG_EVENT_CLASS, false, loader);
getUntagPlayerMethod = untagEventClass.getMethod("getPlayer");
registerTagEvent(tagEventClass.asSubclass(Event.class), getTagPlayerMethod, true);
registerTagEvent(untagEventClass.asSubclass(Event.class), getUntagPlayerMethod, false);
core.getServer().getPluginManager().registerEvents(this, core);
syncOnlinePlayers();
}
// Returns true if EternalCombat-OG currently has this player combat tagged.
public boolean isInCombat(Player player) {
if (!combatPlugin.isEnabled()) {
return false;
}
try {
final Object fightManager = getFightManagerMethod.invoke(combatPlugin);
return fightManager != null
&& Boolean.TRUE.equals(isInCombatMethod.invoke(fightManager, player.getUniqueId()));
} catch (ReflectiveOperationException | RuntimeException ignored) {
return false;
}
}
// Unregisters the listeners and restores cosmetics for everyone still tagged.
public void unregister() {
HandlerList.unregisterAll(this);
clearAll();
}
// Tags never get released once the plugin is gone, so drop them here.
@EventHandler
public void onPluginDisable(PluginDisableEvent event) {
if (event.getPlugin().equals(combatPlugin)) {
clearAll();
}
}
private void registerTagEvent(Class<? extends Event> eventClass, Method getPlayerMethod, boolean tagged) {
// Cancelled tag or untag events leave the combat state unchanged, so skip them.
final EventExecutor executor = (listener, event) -> handleTagEvent(event, getPlayerMethod, tagged);
core.getServer().getPluginManager().registerEvent(eventClass, this, EventPriority.MONITOR, executor, core,
true);
}
private void handleTagEvent(Event event, Method getPlayerMethod, boolean tagged) {
try {
final Object playerId = getPlayerMethod.invoke(event);
if (playerId instanceof UUID) {
setSuppressed(core.getServer().getPlayer((UUID) playerId), tagged);
}
} catch (ReflectiveOperationException | RuntimeException ignored) {
}
}
private void syncOnlinePlayers() {
for (Player player : core.getServer().getOnlinePlayers()) {
setSuppressed(player, isInCombat(player));
}
}
private void clearAll() {
for (EntityState entityState : core.getEntityStates()) {
entityState.setSuppressed(SuppressionSource.COMBAT, false);
}
}
private void setSuppressed(Player player, boolean suppressed) {
if (player == null || !core.hasEntityState(player)) {
return;
}
core.getPlayerState(player).setSuppressed(SuppressionSource.COMBAT, suppressed);
}
}
@@ -10,11 +10,11 @@ public interface VanishHook {
* @param player
* @return
*/
public boolean isVanished(Player player);
boolean isVanished(Player player);
/**
* Unregisters this hook
*/
public void unregister();
void unregister();
}
}
@@ -1,41 +0,0 @@
package cosmeticsOG.hooks.economy;
import cosmeticsOG.hooks.CurrencyHook;
import java.util.OptionalLong;
import me.realized.tokenmanager.api.TokenManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class TokenManagerHook implements CurrencyHook {
private final TokenManager api;
public TokenManagerHook() {
api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
}
@Override
public int getBalance(Player player) {
OptionalLong balance = api.getTokens(player);
return (int) balance.orElse(0);
}
@Override
public boolean withdraw(Player player, int amount) {
return api.removeTokens(player, amount);
}
@Override
public boolean isEnabled() {
return api != null;
}
}
@@ -1,49 +0,0 @@
package cosmeticsOG.hooks.economy;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.hooks.CurrencyHook;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultHook implements CurrencyHook {
private Economy economy;
private boolean economyEnabled;
public VaultHook(final CosmeticsOG core) {
RegisteredServiceProvider<Economy> econProvider = core.getServer().getServicesManager()
.getRegistration(net.milkbowl.vault.economy.Economy.class);
if (econProvider != null) {
economy = econProvider.getProvider();
}
economyEnabled = economy != null;
}
@Override
public int getBalance(Player player) {
return (int) economy.getBalance(player);
}
@Override
public boolean withdraw(Player player, int amount) {
return economy.withdrawPlayer(player, amount).transactionSuccess();
}
@Override
public boolean isEnabled() {
return economyEnabled;
}
}
@@ -0,0 +1,193 @@
package cosmeticsOG.hooks.vanish;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.hooks.VanishHook;
import cosmeticsOG.particles.Hat;
import cosmeticsOG.player.PlayerState;
import java.lang.reflect.Method;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.Plugin;
public class SuperVanishHook implements VanishHook, Listener {
private static final String VANISH_METADATA_KEY = "vanished";
private static final String VANISH_API_CLASS = "de.myzelyam.api.vanish.VanishAPI";
private static final String[] VANISH_EVENT_CLASSES = { "de.myzelyam.api.vanish.PostPlayerHideEvent",
"de.myzelyam.api.vanish.PostPlayerShowEvent", "de.myzelyam.api.vanish.PlayerHideEvent",
"de.myzelyam.api.vanish.PlayerShowEvent" };
private final CosmeticsOG core;
private final Plugin vanishPlugin;
private Method isVanishedMethod;
private boolean hasLoadedVanishAPI;
public SuperVanishHook(final CosmeticsOG core, final Plugin vanishPlugin) {
this.core = core;
this.vanishPlugin = vanishPlugin;
registerVanishEvents();
syncOnlinePlayers();
}
@Override
public boolean isVanished(Player player) {
Boolean apiVanished = getVanishAPIState(player);
if (apiVanished != null) {
return apiVanished;
}
return hasVanishMetadata(player);
}
@Override
public void unregister() {
HandlerList.unregisterAll(this);
}
private void registerVanishEvents() {
registerVanishEvent(VANISH_EVENT_CLASSES[0], true);
registerVanishEvent(VANISH_EVENT_CLASSES[1], false);
registerVanishEvent(VANISH_EVENT_CLASSES[2], true);
registerVanishEvent(VANISH_EVENT_CLASSES[3], false);
}
@SuppressWarnings("unchecked")
private void registerVanishEvent(String eventClassName, boolean vanished) {
try {
Class<?> eventClass = Class.forName(eventClassName, false, vanishPlugin.getClass().getClassLoader());
if (!Event.class.isAssignableFrom(eventClass)) {
return;
}
EventExecutor executor = (listener, event) -> handleVanishEvent(event, vanished);
core.getServer().getPluginManager().registerEvent((Class<? extends Event>) eventClass, this,
EventPriority.MONITOR, executor, core, true);
} catch (ClassNotFoundException ignored) {
}
}
private void handleVanishEvent(Event event, boolean vanished) {
if (event instanceof PlayerEvent) {
syncPlayer(((PlayerEvent) event).getPlayer(), vanished);
}
}
private void syncOnlinePlayers() {
for (Player player : core.getServer().getOnlinePlayers()) {
syncPlayer(player, isVanished(player));
}
}
private void syncPlayer(Player player, boolean vanished) {
if (!core.hasEntityState(player)) {
return;
}
PlayerState playerState = core.getPlayerState(player);
for (Hat hat : playerState.getActiveHats()) {
hat.setVanished(vanished);
}
}
private Boolean getVanishAPIState(Player player) {
Method method = getIsVanishedMethod();
if (method == null) {
return null;
}
try {
Object result = method.invoke(null, player);
if (result instanceof Boolean) {
return (Boolean) result;
}
} catch (ReflectiveOperationException | RuntimeException ignored) {
}
return null;
}
private Method getIsVanishedMethod() {
if (!hasLoadedVanishAPI) {
hasLoadedVanishAPI = true;
try {
Class<?> vanishAPI = Class.forName(VANISH_API_CLASS, false, vanishPlugin.getClass().getClassLoader());
isVanishedMethod = vanishAPI.getMethod("isVanished", Player.class);
} catch (ReflectiveOperationException | RuntimeException ignored) {
}
}
return isVanishedMethod;
}
private boolean hasVanishMetadata(Player player) {
for (MetadataValue value : player.getMetadata(VANISH_METADATA_KEY)) {
Plugin owningPlugin = value.getOwningPlugin();
if (owningPlugin != null && owningPlugin.equals(vanishPlugin) && value.asBoolean()) {
return true;
}
}
return false;
}
}
@@ -1,7 +1,7 @@
package cosmeticsOG.listeners;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.editor.EditorMenuManager;
import cosmeticsOG.editor.MetaState;
import cosmeticsOG.managers.SettingsManager;
@@ -68,7 +68,7 @@ public class ChatListener implements Listener {
// Convert the Component to a plain string
String messageString = PlainTextComponentSerializer.plainText().serialize(event.message());
if (Utils.stripColors(messageString).equals("cancel")) {
if (UtilitiesOG.stripFormatting(messageString).equals("cancel")) {
editorManager.reopen();
@@ -43,7 +43,7 @@ public class CommandListener implements Listener {
MetaState metaState = playerState.getMetaState();
if (metaState != MetaState.NONE) {
player.sendMessage(Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
CosmeticsOG.chatMessage(player, Message.COMMAND_ERROR_ALREADY_EDITING.getValue());
event.setCancelled(true);
}
@@ -3,11 +3,14 @@ package cosmeticsOG.listeners;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.database.type.DatabaseType;
import cosmeticsOG.database.type.yaml.YamlDatabase;
import cosmeticsOG.hooks.DuelsHook;
import cosmeticsOG.hooks.EternalCombatHook;
import cosmeticsOG.hooks.VanishHook;
import cosmeticsOG.managers.SettingsManager;
import cosmeticsOG.particles.Hat;
import cosmeticsOG.particles.HatReference;
import cosmeticsOG.player.PlayerState;
import cosmeticsOG.player.SuppressionSource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -35,6 +38,14 @@ public class ConnectionListener implements Listener {
Player player = event.getPlayer();
UUID id = event.getPlayer().getUniqueId();
PlayerState playerState = core.getNewPlayerState(player);
VanishHook vanishHook = core.getHookManager().getVanishHook();
boolean isVanished = vanishHook != null && vanishHook.isVanished(player);
// Keep cosmetics hidden if the player is already mid-duel or combat tagged.
DuelsHook duelsHook = core.getHookManager().getDuelsHook();
playerState.setSuppressed(SuppressionSource.DUEL, duelsHook != null && duelsHook.isInMatch(player));
EternalCombatHook combatHook = core.getHookManager().getEternalCombatHook();
playerState.setSuppressed(SuppressionSource.COMBAT, combatHook != null && combatHook.isInCombat(player));
// Load equipped hats
core.getDatabase().loadPlayerEquippedHats(id, (loadedHats) -> {
@@ -45,6 +56,7 @@ public class ConnectionListener implements Listener {
List<Hat> hats = (ArrayList<Hat>) loadedHats;
for (Hat hat : hats) {
hat.setVanished(isVanished);
playerState.addHat(hat);
}
@@ -94,17 +106,6 @@ public class ConnectionListener implements Listener {
}
VanishHook vanishHook = core.getHookManager().getVanishHook();
if (vanishHook != null) {
if (vanishHook.isVanished(player)) {
playerState.getActiveHats().forEach(hat -> hat.setVanished(true));
}
}
}
@EventHandler
@@ -89,7 +89,8 @@ public class InteractListener implements Listener {
if (inventory == null) {
player.sendMessage(Message.COMMAND_ERROR_UNKNOWN_MENU.getValue().replace("{1}", menuName));
CosmeticsOG.chatMessage(player,
Message.COMMAND_ERROR_UNKNOWN_MENU.getValue().replace("{1}", menuName));
return;
}
+62 -48
View File
@@ -27,9 +27,9 @@ public enum Message {
*/
// Miscellaneous.
COMMAND_ERROR_UNKNOWN("&cUnknown command, try &7/h help &cfor a list of commands"),
COMMAND_ERROR_UNKNOWN("&cUnknown command, try &7/cosmetics help &cfor a list of commands"),
COMMAND_ERROR_NO_PERMISSION("&cYou don't have permission to use this command"),
COMMAND_ERROR_PLAYER_ONLY("&cYou must be a player to use this command, try &7/h help"),
COMMAND_ERROR_PLAYER_ONLY("&cYou must be a player to use this command, try &7/cosmetics help"),
COMMAND_ERROR_ARGUMENTS("&cWrong number of arguments"),
COMMAND_ERROR_MENU_EXISTS("&7Menu '&c{1}&7' already exists"),
COMMAND_ERROR_UNKNOWN_MENU("&cUnable to find menu '&7{1}&c'"),
@@ -43,114 +43,117 @@ public enum Message {
COMMAND_ERROR_UNKNOWN_NPC("&cUnable to find a NPC with that id"),
// Main Command.
COMMAND_MAIN_DESCRIPTION("Main Command"), COMMAND_MAIN_USAGE("/h"),
COMMAND_MAIN_DESCRIPTION("Main Command"), COMMAND_MAIN_USAGE("/cosmetics"),
COMMAND_MAIN_DEFAULT_MENU_ERROR("&cThere is no default menu set in config.yml"),
// Help Command.
COMMAND_HELP_DESCRIPTION("Displays all commands and their usage"), COMMAND_HELP_USAGE("/h help"),
COMMAND_HELP_DESCRIPTION("Displays all commands and their usage"), COMMAND_HELP_USAGE("/cosmetics help"),
COMMAND_HELP_TIP("&7&oOnly showing commands you have permission for"),
// Reload Command.
COMMAND_RELOAD_DESCRIPTION("Reloads the plugin"), COMMAND_RELOAD_USAGE("/h reload"),
COMMAND_RELOAD_DESCRIPTION("Reloads the plugin"), COMMAND_RELOAD_USAGE("/cosmetics reload"),
COMMAND_RELOAD_SUCCESS("&aParticleHats reloaded"),
// Clear Command.
COMMAND_CLEAR_DESCRIPTION("Removes all of the players active particles"), COMMAND_CLEAR_USAGE("/h clear"),
COMMAND_CLEAR_DESCRIPTION("Removes all of the players active particles"), COMMAND_CLEAR_USAGE("/cosmetics clear"),
COMMAND_CLEAR_SUCCESS("&aAll particles cleared"),
COMMAND_CLEAR_PLAYER_DESCRIPTION("Removes all particles for the target player"),
COMMAND_CLEAR_PLAYER_USAGE("/h clear <player>"), COMMAND_CLEAR_PLAYER_SUCCESS("&aAll particles cleared for &3{1}"),
COMMAND_CLEAR_PLAYER_USAGE("/cosmetics clear <player>"),
COMMAND_CLEAR_PLAYER_SUCCESS("&aAll particles cleared for &3{1}"),
// Toggle Command.
COMMAND_TOGGLE_DESCRIPTION("Toggles all particles on / off"), COMMAND_TOGGLE_USAGE("/h toggle <on/off>"),
COMMAND_TOGGLE_DESCRIPTION("Toggles all particles on / off"), COMMAND_TOGGLE_USAGE("/cosmetics toggle <on/off>"),
COMMAND_TOGGLE_ON("&aToggled all particles &2On"), COMMAND_TOGGLE_OFF("&aToggled all particles &cOff"),
COMMAND_TOGGLE_PLAYER_DESCRIPTION("Toggles all particles on / off for the given player"),
COMMAND_TOGGLE_PLAYER_USAGE("/h toggle <on/off> <player>"),
COMMAND_TOGGLE_PLAYER_USAGE("/cosmetics toggle <on/off> <player>"),
COMMAND_TOGGLE_PLAYER_ON("&aToggled all particles &2On &afor {1}"),
COMMAND_TOGGLE_PLAYER_OFF("&aToggled all particles &cOff &afor {1}"),
// Create Command.
COMMAND_CREATE_DESCRIPTION("Creates a new menu with the given name"), COMMAND_CREATE_USAGE("/h create <menu name>"),
COMMAND_CREATE_SUCCESS("&aCreated menu {1}"), COMMAND_CREATE_INVALID("&cInvalid menu name"),
COMMAND_CREATE_DESCRIPTION("Creates a new menu with the given name"),
COMMAND_CREATE_USAGE("/cosmetics create <menu name>"), COMMAND_CREATE_SUCCESS("&aCreated menu {1}"),
COMMAND_CREATE_INVALID("&cInvalid menu name"),
// Edit Command.
COMMAND_EDIT_DESCRIPTION("Opens a menu in the editor"), COMMAND_EDIT_USAGE("/h edit <menu name>"),
COMMAND_EDIT_DESCRIPTION("Opens a menu in the editor"), COMMAND_EDIT_USAGE("/cosmetics edit <menu name>"),
// Meta Command.
COMMAND_META_DESCRIPTION("Lets the player edit meta properties while editing a menu"),
COMMAND_META_USAGE("/h meta {1}"),
COMMAND_META_USAGE("/cosmetics meta {1}"),
// Open Command.
COMMAND_OPEN_DESCRIPTION("Opens the selected menu"), COMMAND_OPEN_USAGE("/h open <menu name>"),
COMMAND_OPEN_DESCRIPTION("Opens the selected menu"), COMMAND_OPEN_USAGE("/cosmetics open <menu name>"),
COMMAND_OPEN_ERROR("&cCan't open menu '&7{1}&c' from command"),
// Open Player Command.
COMMAND_OPEN_PLAYER_DESCRIPTION("Opens the selected menu for the target player"),
COMMAND_OPEN_PLAYER_USAGE("/h open <menu name> <player>"),
COMMAND_OPEN_PLAYER_USAGE("/cosmetics open <menu name> <player>"),
COMMAND_OPEN_PLAYER_EDITING("&c{1} can't open menus while editing"),
// Particles Command.
COMMAND_PARTICLE_DESCRIPTION("Lets players manage their equipped particles"),
COMMAND_PARTICLE_USAGE("/h particles"),
COMMAND_PARTICLE_USAGE("/cosmetics particles"),
// Set Command.
COMMAND_SET_DESCRIPTION("Creates a new hat from the given label and equips it to the player"),
COMMAND_SET_USAGE("/h set <player> <label> <demo true|false> <tellPlayer true|false>"),
COMMAND_SET_USAGE("/cosmetics set <player> <label> <demo true|false> <tellPlayer true|false>"),
COMMAND_SET_LABEL_ERROR("&cUnable to find label '&7{1}&c'"),
COMMAND_SET_ALREADY_SET("&c{1} is already wearing this hat"), COMMAND_SET_SUCCESS("&aYou were given the {1} &ahat"),
// Unset Command.
COMMAND_UNSET_DESCRIPTION("Unequips the hat with the given label from player"),
COMMAND_UNSET_USAGE("/h unset <player> <label> <tellPlayer true|false>"),
COMMAND_UNSET_USAGE("/cosmetics unset <player> <label> <tellPlayer true|false>"),
COMMAND_UNSET_LABEL_ERROR("&cUnable to find label '&7{1}&c'"),
COMMAND_UNSET_NOT_WEARING("&c{1} isn't wearing this hat"),
COMMAND_UNSET_SUCCESS("&aThe {1} &ahat was taken from you"),
// Add Group Command.
COMMAND_ADD_GROUP_DESCRIPTION("Add a new group, use weight to determine a groups priority"),
COMMAND_ADD_GROUP_USAGE("/h group add <name> <menu> <weight>"), COMMAND_ADD_GROUP_SUCCESS("&aAdded group &3'{1}'"),
COMMAND_ADD_GROUP_USAGE("/cosmetics group add <name> <menu> <weight>"),
COMMAND_ADD_GROUP_SUCCESS("&aAdded group &3'{1}'"),
// Delete Group Command.
COMMAND_REMOVE_GROUP_DESCRIPTION("Removes a group"), COMMAND_REMOVE_GROUP_USAGE("/h group remove <group>"),
COMMAND_REMOVE_GROUP_DESCRIPTION("Removes a group"), COMMAND_REMOVE_GROUP_USAGE("/cosmetics group remove <group>"),
COMMAND_REMOVE_GROUP_SUCCESS("&aGroup '&3{1}&a' removed"),
// Edit Group Command.
COMMAND_EDIT_GROUP_DESCRIPTION("Edit an existing group"),
COMMAND_EDIT_GROUP_USAGE("/h group edit <group> <menu> <weight>"),
COMMAND_EDIT_GROUP_USAGE("/cosmetics group edit <group> <menu> <weight>"),
COMMAND_EDIT_GROUP_SUCCESS("&aUpdated group '&3{1}&a'"),
// Group Info Command.
COMMAND_GROUP_INFO_DESCRIPTION("Lists all available groups"), COMMAND_GROUP_INFO_USAGE("/h group info"),
COMMAND_GROUP_INFO_DESCRIPTION("Lists all available groups"), COMMAND_GROUP_INFO_USAGE("/cosmetics group info"),
COMMAND_GROUP_INFO_TIP("&3Groups:"), COMMAND_GROUP_INFO("&3name: &f{1} &3menu: &f{2} &3weight: &f{3}"),
// Add Type Command.
COMMAND_ADD_TYPE_DESCRIPTION("Adds a custom type to the MySQL database"),
COMMAND_ADD_TYPE_USAGE("/h type add <type>"), COMMAND_ADD_TYPE_SUCCESS("&aAdded '&3{1}&a' to the database"),
COMMAND_ADD_TYPE_USAGE("/cosmetics type add <type>"), COMMAND_ADD_TYPE_SUCCESS("&aAdded '&3{1}&a' to the database"),
COMMAND_ADD_TYPE_ERROR("&cThis command only works with a MySQL database"),
// Remove Type Command.
COMMAND_REMOVE_TYPE_DESCRIPTION("Removes a custom type from the MySQL database"),
COMMAND_REMOVE_TYPE_USAGE("/h type remove <type>"),
COMMAND_REMOVE_TYPE_USAGE("/cosmetics type remove <type>"),
COMMAND_REMOVE_TYPE_SUCCESS("&aRemoved '&3{1}&a' from the database"),
COMMAND_REMOVE_TYPE_PROMPT("&a'&3{1}&a' is being used currently, use /h type remove {1} again to remove"),
COMMAND_REMOVE_TYPE_PROMPT("&a'&3{1}&a' is being used currently, use /cosmetics type remove {1} again to remove"),
// Import Command.
COMMAND_IMPORT_DESCRIPTION("Adds an existing .yml menu into the MySQL database"),
COMMAND_IMPORT_USAGE("/h import <menu>"), COMMAND_IMPORT_SUCCESS("&aAdded '&3{1}&a' to the MySQL database"),
COMMAND_IMPORT_USAGE("/cosmetics import <menu>"), COMMAND_IMPORT_SUCCESS("&aAdded '&3{1}&a' to the MySQL database"),
COMMAND_IMPORT_ERROR("&cThere was an error importing this menu error: {1}"),
// NPC Command.
COMMAND_NPC_SUPPORT_ERROR("&cUnable to find Citizens plugin"),
// NPC Clear Command.
COMMAND_NPC_CLEAR_DESCRIPTION("Clears all active hats for this NPC"), COMMAND_NPC_CLEAR_USAGE("/h npc clear <id>"),
COMMAND_NPC_CLEAR_SUCCESS("&aCleared all hats for {1}"),
COMMAND_NPC_CLEAR_DESCRIPTION("Clears all active hats for this NPC"),
COMMAND_NPC_CLEAR_USAGE("/cosmetics npc clear <id>"), COMMAND_NPC_CLEAR_SUCCESS("&aCleared all hats for {1}"),
// Manage NPC Command.
COMMAND_MANAGE_NPC_DESCRIPTION("Manage this NPC's hats"), COMMAND_MANAGE_NPC_USAGE("/h npc manage"),
COMMAND_MANAGE_NPC_DESCRIPTION("Manage this NPC's hats"), COMMAND_MANAGE_NPC_USAGE("/cosmetics npc manage"),
// NPC Set Command.
COMMAND_NPC_SET_SUCCESS("&aGave &3{1} &athe &3{2} &r&ahat"), COMMAND_NPC_SET_DESCRIPTION("Equip a hat to a NPC"),
COMMAND_NPC_SET_USAGE("/h npc set <npc id> <label>"),
COMMAND_NPC_SET_USAGE("/cosmetics npc set <npc id> <label>"),
// Purchase menu.
PURCHASE_MENU_TITLE("Confirm Purchase"), PURCHASE_MENU_CONFIRM("&3Accept Purchase"),
@@ -345,9 +348,10 @@ public enum Message {
* Types
*/
TYPE_NONE_NAME("&cNone"), TYPE_NONE_DESCRIPTION("&8Does absolutely nothing"), TYPE_HALO_NAME("&bHalo"),
TYPE_HALO_DESCRIPTION("&8A ring of particles for the/n&8players head"), TYPE_TRAIL_NAME("&bTrail"),
TYPE_TRAIL_DESCRIPTION("&8Displays a small cloud of particles/n&8with random offsets"), TYPE_CAPE_NAME("&bCape"),
TYPE_CAPE_DESCRIPTION("&8A Cape worn on the players back"), TYPE_WINGS_NAME("&bWings"),
TYPE_HALO_DESCRIPTION("&8A ring of particles for the/n&8players head"), TYPE_RAINBOW_HALO_NAME("&dRainbow Halo"),
TYPE_RAINBOW_HALO_DESCRIPTION("&8A spinning rainbow ring of/n&8particles above the players head"),
TYPE_TRAIL_NAME("&bTrail"), TYPE_TRAIL_DESCRIPTION("&8Displays a small cloud of particles/n&8with random offsets"),
TYPE_CAPE_NAME("&bCape"), TYPE_CAPE_DESCRIPTION("&8A Cape worn on the players back"), TYPE_WINGS_NAME("&bWings"),
TYPE_WINGS_DESCRIPTION("&8Default Wings"), TYPE_VORTEX_NAME("&bVortex"),
TYPE_VORTEX_DESCRIPTION("&8A Swirling cone that gets/n&8larger at the bottom"), TYPE_ARCH_NAME("&bArch"),
TYPE_ARCH_DESCRIPTION("&8A half circle that sits/n&8above the players head"), TYPE_ATOM_NAME("&bAtom"),
@@ -368,35 +372,38 @@ public enum Message {
/**
* Meta State
*/
META_ERROR("&cYou are not editing a menu"), META_HAT_NAME_USAGE("&6Use &f/h meta <name> &6to rename"),
META_ERROR("&cYou are not editing a menu"), META_HAT_NAME_USAGE("&6Use &f/cosmetics meta <name> &6to rename"),
META_HAT_NAME_DESCRIPTION("Type the &eName &finto chat, or '&ccancel&f' to return"),
META_HAT_NAME_SUGGESTION("hat name..."), META_HAT_LABEL_USAGE("&6Use &f/h meta <label> &6to rename"),
META_HAT_NAME_SUGGESTION("hat name..."), META_HAT_LABEL_USAGE("&6Use &f/cosmetics meta <label> &6to rename"),
META_HAT_LABEL_DESCRIPTION("Type the &eLabel &finto chat, or '&6cancel&f' to return"),
META_HAT_LABEL_SUGGESTION("label..."), META_HAT_COMMAND_USAGE("&6Use &f/h meta <command> &6to rename"),
META_HAT_LABEL_SUGGESTION("label..."), META_HAT_COMMAND_USAGE("&6Use &f/cosmetics meta <command> &6to rename"),
META_HAT_COMMAND_DESCRIPTION("Type the &eCommand &7(without '/') &finto chat, or '&6cancel&f' to return"),
META_HAT_COMMAND_SUGGESTION("command..."), META_HAT_DESCRIPTION_USAGE("&6Use &f/h meta <description> &6to rename"),
META_HAT_COMMAND_SUGGESTION("command..."),
META_HAT_DESCRIPTION_USAGE("&6Use &f/cosmetics meta <description> &6to rename"),
META_HAT_DESCRIPTION_DESCRIPTION("Type the &eDescription &finto chat, or '&6cancel&f' to return"),
META_HAT_DESCRIPTION_SUGGESTION("description..."),
META_HAT_PERMISSION_USAGE("&6Use &f/h meta <permission> &6to rename"),
META_HAT_PERMISSION_USAGE("&6Use &f/cosmetics meta <permission> &6to rename"),
META_HAT_PERMISSION_DESCRIPTION("Type the &ePermission &finto chat, or '&6cancel&f' to return"),
META_HAT_PERMISSION_SUGGESTION("permission..."),
META_HAT_PERMISSION_DESCRIPTION_USAGE("&6Use &f/h meta <description> &6to rename"),
META_HAT_PERMISSION_DESCRIPTION_USAGE("&6Use &f/cosmetics meta <description> &6to rename"),
META_HAT_PERMISSION_DESCRIPTION_DESCRIPTION("Type the &eDescription &finto chat, or '&6cancel&f' to return"),
META_HAT_PERMISSION_DESCRIPTION_SUGGESTION("description..."),
META_HAT_PERMISSION_MESSAGE_USAGE("&6Use &f/h meta <permission message> &6to rename"),
META_HAT_PERMISSION_MESSAGE_USAGE("&6Use &f/cosmetics meta <permission message> &6to rename"),
META_HAT_PERMISSION_MESSAGE_DESCRIPTION("Type the &eMessage &finto chat, or '&6cancel&f' to return"),
META_HAT_PERMISSION_MESSAGE_SUGGESTION("permission message..."),
META_HAT_EQUIP_MESSAGE_USAGE("&6Use &f/h meta <equip message> &6to rename"),
META_HAT_EQUIP_MESSAGE_USAGE("&6Use &f/cosmetics meta <equip message> &6to rename"),
META_HAT_EQUIP_MESSAGE_DESCRIPTION("Type the &eMessage &finto chat, or '&6cancel&f' to return"),
META_HAT_EQUIP_MESSAGE_SUGGESTION("equip message..."), META_HAT_TAG_USAGE("&6Use &f/h meta <tag> &6to set"),
META_HAT_EQUIP_MESSAGE_SUGGESTION("equip message..."), META_HAT_TAG_USAGE("&6Use &f/cosmetics meta <tag> &6to set"),
META_HAT_TAG_DESCRIPTION("Type the &eTag &finto chat, or '&6cancel&f' to return"),
META_HAT_TAG_SUGGESTION("tag..."), META_MENU_TITLE_USAGE("&6Use &f/h meta <title> &6to rename"),
META_HAT_TAG_SUGGESTION("tag..."), META_MENU_TITLE_USAGE("&6Use &f/cosmetics meta <title> &6to rename"),
META_MENU_TITLE_DESCRIPTION("Type the &eTitle &finto chat, or '&6cancel&f' to return"),
META_MENU_TITLE_SUGGESTION("menu title..."), META_MENU_ALIAS_USAGE("&6Use &f/h meta <alias> &6to assign"),
META_MENU_TITLE_SUGGESTION("menu title..."), META_MENU_ALIAS_USAGE("&6Use &f/cosmetics meta <alias> &6to assign"),
META_MENU_ALIAS_DESCRIPTION("Type the &eAlias &finto chat, or '&6cancel&f' to return"),
META_MENU_ALIAS_SUGGESTION("menu alias"), META_NEW_MENU_USAGE("&6Use &f/h meta <menu name> &6to create a new menu"),
META_MENU_ALIAS_SUGGESTION("menu alias"),
META_NEW_MENU_USAGE("&6Use &f/cosmetics meta <menu name> &6to create a new menu"),
META_NEW_MENU_DESCRIPTION("Type the &eName &finto chat, or '&6cancel&f' to return"),
META_NEW_MENU_SUGGESTION("menu name..."), META_BLOCK_SEARCH_USAGE("&6Use &f/h meta <block name> &6to search"),
META_NEW_MENU_SUGGESTION("menu name..."),
META_BLOCK_SEARCH_USAGE("&6Use &f/cosmetics meta <block name> &6to search"),
META_BLOCK_SEARCH_DESCRIPTION("Type the &eBlock Name &finto chat, or '&6cancel&f' to return"),
META_BLOCK_SEARCH_SUGGESTION("block name..."), META_NPC_MANAGE_USAGE("Right Click on a NPC to manage their hats"),
META_NPC_MANAGE_DESCRIPTION("Right Click on a NPC to manage their hats"),
@@ -677,7 +684,7 @@ public enum Message {
EDITOR_META_MENU_NAME_DESCRIPTION(
"/n&8Current:/n&8� {1}/n/n&3Left Click to Change{2=/n&cShift Right Click to Reset}"),
EDITOR_META_MENU_LABEL_DESCRIPTION(
"/n&8Labels allow you to use this hat/n&8in commands like: &7/h set <player> <label>/n/n&8Current:/n&8� &7{1=&cNot Set}/n/n&3Left Click to Change{2=/n&cShift Right Click to Clear}"),
"/n&8Labels allow you to use this hat/n&8in commands like: &7/cosmetics set <player> <label>/n/n&8Current:/n&8� &7{1=&cNot Set}/n/n&3Left Click to Change{2=/n&cShift Right Click to Clear}"),
EDITOR_META_MENU_DESCRIPTION_DESCRIPTION(
"/n&8Current:/n{1}/n&3Left Click to Change{2=/n&cShift Right Click to Clear}"),
EDITOR_META_MENU_EMPTY_DESCRIPTION("/n&8Current:/n&8� &cNot Set/n/n&3Left Click to Change"),
@@ -845,7 +852,7 @@ public enum Message {
*/
public void sendTo(Player player) {
player.sendMessage(getValue());
CosmeticsOG.chatMessage(player, getValue());
}
@@ -856,6 +863,13 @@ public enum Message {
*/
public void sendTo(CommandSender sender) {
if (sender instanceof Player) {
CosmeticsOG.chatMessage((Player) sender, getValue());
return;
}
sender.sendMessage(getValue());
}
@@ -1,19 +1,27 @@
package cosmeticsOG.managers;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.hooks.CurrencyHook;
import cosmeticsOG.hooks.VanishHook;
import cosmeticsOG.hooks.economy.TokenManagerHook;
import cosmeticsOG.hooks.economy.VaultHook;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.hooks.DuelsHook;
import cosmeticsOG.hooks.EternalCombatHook;
import cosmeticsOG.hooks.VanishHook;
import cosmeticsOG.hooks.vanish.SuperVanishHook;
import net.trueog.utilitiesog.UtilitiesOG;
public class HookManager {
private static final String[] VANISH_PLUGIN_NAMES = { "Vanish-OG", "SuperVanish", "PremiumVanish",
"VanishNoPacket" };
private static final String DUELS_PLUGIN_NAME = "Duels-OG";
private static final String ETERNALCOMBAT_PLUGIN_NAME = "EternalCombat-OG";
private final CosmeticsOG core;
private CurrencyHook currencyHook;
private VanishHook vanishHook;
private DuelsHook duelsHook;
private EternalCombatHook eternalCombatHook;
public HookManager(final CosmeticsOG core) {
@@ -29,17 +37,6 @@ public class HookManager {
}
/**
* Get this plugin's CurrencyHook
*
* @return
*/
public CurrencyHook getCurrencyHook() {
return currencyHook;
}
/**
* Get this plugin's VanishHook
*
@@ -51,68 +48,55 @@ public class HookManager {
}
// Returns the Duels-OG hook, or null when Duels-OG is absent or the flag is
// off.
public DuelsHook getDuelsHook() {
return duelsHook;
}
// Returns the EternalCombat-OG hook, or null when absent or the flag is off.
public EternalCombatHook getEternalCombatHook() {
return eternalCombatHook;
}
private void loadHooks() {
PluginManager pluginManager = core.getServer().getPluginManager();
final PluginManager pluginManager = core.getServer().getPluginManager();
// Vault Hook.
if (SettingsManager.FLAG_VAULT.getBoolean()) {
if (pluginManager.isPluginEnabled("DiamondBank-OG")) {
if (currencyHook != null && currencyHook instanceof VaultHook) {
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Hooking into DiamondBank-OG...");
return;
} else {
}
SettingsManager.FLAG_DIAMONDBANK.addOverride(false);
if (pluginManager.isPluginEnabled("Vault")) {
currencyHook = new VaultHook(core);
Utils.logToConsole("Hooking into Vault...");
} else {
Utils.logToConsole("WARNING: Could not find Vault, disabling economy support!");
SettingsManager.FLAG_VAULT.addOverride(false);
currencyHook = null;
}
}
// TokenManager Hook.
else if (SettingsManager.FLAG_TOKEN_MANAGER.getBoolean()) {
if (currencyHook != null && currencyHook instanceof TokenManagerHook) {
return;
}
if (pluginManager.isPluginEnabled("TokenManager")) {
currencyHook = new TokenManagerHook();
Utils.logToConsole("Hooking into TokenManager...");
} else {
Utils.logToConsole("WARNING: Could not find TokenManager, disabling economy support!");
SettingsManager.FLAG_TOKEN_MANAGER.addOverride(false);
currencyHook = null;
}
CosmeticsOG.disableSelf("Could not find DiamondBank-OG! Disabling Cosmetics-OG...");
}
// Vanish Hooks.
if (vanishHook == null && SettingsManager.FLAG_VANISH.getBoolean()) {
// TODO: TrueOG vanish hook.
final Plugin vanishPlugin = getEnabledVanishPlugin(pluginManager);
if (vanishPlugin != null) {
vanishHook = new SuperVanishHook(core, vanishPlugin);
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Hooking into " + vanishPlugin.getName() + "...");
} else {
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"WARNING: Could not find a supported vanish plugin, disabling vanish support!");
SettingsManager.FLAG_VANISH.addOverride(false);
}
} else {
@@ -125,6 +109,137 @@ public class HookManager {
}
loadDuelsHook(pluginManager);
loadEternalCombatHook(pluginManager);
}
// Hides cosmetics during Duels-OG matches while the flag is on and Duels-OG is
// loaded.
private void loadDuelsHook(PluginManager pluginManager) {
if (!SettingsManager.FLAG_DUELS.getBoolean()) {
if (duelsHook != null) {
duelsHook.unregister();
duelsHook = null;
}
return;
}
if (duelsHook != null) {
return;
}
final Plugin duelsPlugin = getEnabledPlugin(pluginManager, DUELS_PLUGIN_NAME);
if (duelsPlugin == null) {
return;
}
try {
duelsHook = new DuelsHook(core, duelsPlugin);
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Hooking into " + DUELS_PLUGIN_NAME + "...");
} catch (ReflectiveOperationException | RuntimeException exception) {
logUnsupported(DUELS_PLUGIN_NAME, exception);
}
}
// Hides cosmetics while EternalCombat-OG combat tags a player, if the flag is
// on.
private void loadEternalCombatHook(PluginManager pluginManager) {
if (!SettingsManager.FLAG_ETERNALCOMBAT.getBoolean()) {
if (eternalCombatHook != null) {
eternalCombatHook.unregister();
eternalCombatHook = null;
}
return;
}
if (eternalCombatHook != null) {
return;
}
final Plugin combatPlugin = getEnabledPlugin(pluginManager, ETERNALCOMBAT_PLUGIN_NAME);
if (combatPlugin == null) {
return;
}
try {
eternalCombatHook = new EternalCombatHook(core, combatPlugin);
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "Hooking into " + ETERNALCOMBAT_PLUGIN_NAME + "...");
} catch (ReflectiveOperationException | RuntimeException exception) {
logUnsupported(ETERNALCOMBAT_PLUGIN_NAME, exception);
}
}
// Returns the named plugin if it is enabled, otherwise warns and returns null.
private Plugin getEnabledPlugin(PluginManager pluginManager, String pluginName) {
final Plugin plugin = pluginManager.getPlugin(pluginName);
if (plugin == null || !plugin.isEnabled()) {
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"WARNING: Could not find " + pluginName + ", disabling its cosmetics hook!");
return null;
}
return plugin;
}
private void logUnsupported(String pluginName, Exception exception) {
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(), "WARNING: Unsupported " + pluginName + " version ("
+ exception.getMessage() + "), disabling its cosmetics hook!");
}
private Plugin getEnabledVanishPlugin(PluginManager pluginManager) {
for (String pluginName : VANISH_PLUGIN_NAMES) {
if (pluginManager.isPluginEnabled(pluginName)) {
return pluginManager.getPlugin(pluginName);
}
}
return null;
}
}
@@ -1,7 +1,7 @@
package cosmeticsOG.managers;
import cosmeticsOG.util.WorldUtil;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.hooks.VanishHook;
import cosmeticsOG.locale.Message;
import cosmeticsOG.particles.Hat;
@@ -15,7 +15,6 @@ import cosmeticsOG.ui.StaticMenuManager;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
@@ -116,12 +115,11 @@ public class ParticleManager {
PlayerState playerState = core.getPlayerState(player);
String worldName = player.getWorld().getName().toLowerCase();
List<String> disabledWorlds = SettingsManager.DISABLED_WORLDS.getList();
// Disabled World.
if (disabledWorlds.contains(worldName)) {
// World not allowed by the whitelist or blacklist.
if (!WorldUtil.isEnabled(worldName)) {
Utils.cosmeticsOGPlaceholderMessage(player, Message.WORLD_DISABLED.getValue());
CosmeticsOG.chatMessage(player, Message.WORLD_DISABLED.getValue());
return false;
@@ -134,7 +132,7 @@ public class ParticleManager {
&& !player.hasPermission(Permission.WORLD.append(worldName)))
{
Utils.cosmeticsOGPlaceholderMessage(player, Message.WORLD_NO_PERMISSION.getValue());
CosmeticsOG.chatMessage(player, Message.WORLD_NO_PERMISSION.getValue());
return false;
@@ -155,7 +153,7 @@ public class ParticleManager {
} else {
Utils.cosmeticsOGPlaceholderMessage(player, Message.HAT_EQUIPPED_OVERFLOW.replace("{1}",
CosmeticsOG.chatMessage(player, Message.HAT_EQUIPPED_OVERFLOW.replace("{1}",
Integer.toString(SettingsManager.MAXIMUM_HAT_LIMIT.getInt())));
return false;
@@ -187,13 +185,13 @@ public class ParticleManager {
if (!equipMessage.equals("")) {
Utils.cosmeticsOGPlaceholderMessage(player, equipMessage);
CosmeticsOG.chatMessage(player, equipMessage);
} else {
Message defaultMessage = hat.isVanished() ? Message.HAT_EQUIPPED_VANISHED : Message.HAT_EQUIPPED;
Utils.cosmeticsOGPlaceholderMessage(player, defaultMessage.replace("{1}", hat.getDisplayName()));
CosmeticsOG.chatMessage(player, defaultMessage.replace("{1}", hat.getDisplayName()));
}
@@ -6,6 +6,7 @@ import cosmeticsOG.util.ItemUtil;
import cosmeticsOG.util.MathUtil;
import cosmeticsOG.util.ResourceUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Material;
@@ -22,8 +23,10 @@ public enum SettingsManager {
LOAD_INCLUDED_MENUS("load-included-menus", Type.BOOLEAN, true),
LOAD_INCLUDED_CUSTOM_TYPES("load-included-custom-types", Type.BOOLEAN, true),
DISABLED_WORLDS("disabled-worlds", Type.STRING_LIST, new ArrayList<String>()),
ENABLED_WORLDS("enabled-worlds", Type.STRING_LIST,
new ArrayList<String>(Arrays.asList("world", "world_nether", "world_the_end"))),
CHECK_WORLD_PERMISSION("check-world-permission", Type.BOOLEAN, true),
CLOSE_MENU_ON_EQUIP("close-menu-on-equip", Type.BOOLEAN, true), CURRENCY("currency", Type.STRING, "$"),
CLOSE_MENU_ON_EQUIP("close-menu-on-equip", Type.BOOLEAN, true), CURRENCY("currency", Type.STRING, "&bShards"),
LIVE_MENUS("live-menus", Type.BOOLEAN, true), LIVE_MENU_UPDATE_FREQUENCY("live-menu-update-frequency", Type.INT, 5),
MAXIMUM_HAT_LIMIT("max-hats", Type.INT_CLAMPED, 7, 28),
UNEQUIP_OVERFLOW_HATS("unequip-overflow-hats", Type.BOOLEAN, false),
@@ -43,11 +46,11 @@ public enum SettingsManager {
/**
* Flags
*/
FLAG_VAULT("flags.vault", Type.BOOLEAN, false), FLAG_PLAYERPOINTS("flags.playerpoints", Type.BOOLEAN, false),
FLAG_TOKEN_MANAGER("flags.token-manager", Type.BOOLEAN, false),
FLAG_DIAMONDBANK("flags.diamondbank", Type.BOOLEAN, false),
FLAG_EXPERIENCE("flags.experience", Type.BOOLEAN, false), FLAG_PERMISSION("flags.permission", Type.BOOLEAN, true),
FLAG_VANISH("flags.vanish", Type.BOOLEAN, false),
FLAG_ESSENTIALS_VANISH("flags.essentials-vanish", Type.BOOLEAN, false),
FLAG_DUELS("flags.duels", Type.BOOLEAN, true), FLAG_ETERNALCOMBAT("flags.eternalcombat", Type.BOOLEAN, true),
/**
* Afk / Combat cooldown and flags
@@ -157,7 +160,7 @@ public enum SettingsManager {
public static boolean isEconomyEnabled() {
return FLAG_VAULT.getBoolean() || FLAG_PLAYERPOINTS.getBoolean() || FLAG_TOKEN_MANAGER.getBoolean();
return FLAG_DIAMONDBANK.getBoolean();
}
+3 -3
View File
@@ -1,7 +1,7 @@
package cosmeticsOG.particles;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.locale.Message;
import cosmeticsOG.particles.effects.PixelEffect;
@@ -2194,8 +2194,8 @@ public class Hat {
}
menuItem = item.clone();
ItemUtil.setNameAndDescription(menuItem, Utils.legacySerializerAnyCase(name),
normalDescription.stream().map(Utils::legacySerializerAnyCase).collect(Collectors.toList()));
ItemUtil.setNameAndDescription(menuItem, UtilitiesOG.trueogColorize(name),
normalDescription.stream().map(UtilitiesOG::trueogColorize).collect(Collectors.toList()));
return menuItem;
@@ -1,7 +1,7 @@
package cosmeticsOG.particles;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.compatibility.CompatibleMaterial;
import cosmeticsOG.locale.Message;
import cosmeticsOG.util.ItemUtil;
@@ -367,7 +367,7 @@ public enum ParticleEffect {
*/
public String getStrippedName() {
return Utils.stripColors(getDisplayName());
return UtilitiesOG.stripFormatting(getDisplayName());
}
@@ -1,14 +1,14 @@
package cosmeticsOG.particles.effects;
import cosmeticsOG.Utils;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.util.ResourceUtil;
public class ParticleHatsEffect extends CommunityEffect {
public ParticleHatsEffect() {
super(ResourceUtil.getImage("particlehats.png"), "particlehats",
Utils.legacySerializerAnyCase("&6ParticleHats"), Utils.legacySerializerAnyCase("&7Medius_Echo"));
super(ResourceUtil.getImage("particlehats.png"), "particlehats", UtilitiesOG.trueogColorize("&6ParticleHats"),
UtilitiesOG.trueogColorize("&7Medius_Echo"));
}
@@ -0,0 +1,165 @@
package cosmeticsOG.particles.effects;
import cosmeticsOG.locale.Message;
import cosmeticsOG.particles.Effect;
import cosmeticsOG.particles.Hat;
import cosmeticsOG.particles.ParticleEffect;
import cosmeticsOG.particles.properties.ParticleLocation;
import cosmeticsOG.particles.properties.ParticleTracking;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class RainbowHaloEffect extends Effect {
private static final Color[] RAINBOW_COLORS = { Color.fromRGB(255, 82, 82), Color.fromRGB(255, 171, 64),
Color.fromRGB(255, 238, 88), Color.fromRGB(105, 240, 174), Color.fromRGB(64, 196, 255),
Color.fromRGB(124, 77, 255), Color.fromRGB(255, 64, 129) };
private static final int POINT_COUNT = 18;
private static final double RADIUS = 0.8D;
private static final float DUST_SCALE = 0.7F;
private final List<Vector> ringPoints = new ArrayList<>();
@Override
public String getName() {
return "rainbow_halo";
}
@Override
public String getDisplayName() {
return Message.TYPE_RAINBOW_HALO_NAME.getValue();
}
@Override
public String getDescription() {
return Message.TYPE_RAINBOW_HALO_DESCRIPTION.getValue();
}
@Override
public int getParticlesSupported() {
return 1;
}
@Override
public ParticleLocation getDefaultLocation() {
return ParticleLocation.HEAD;
}
@Override
public List<ParticleTracking> getSupportedTrackingMethods() {
return Arrays.asList(ParticleTracking.values());
}
@Override
public ParticleTracking getDefaultTrackingMethod() {
return ParticleTracking.TRACK_NOTHING;
}
@Override
public boolean supportsAnimation() {
return false;
}
@Override
public boolean isCustom() {
return false;
}
@Override
public void build() {
ringPoints.clear();
for (int i = 0; i < POINT_COUNT; i++) {
final double angle = i * Math.PI * 2.0D / POINT_COUNT;
ringPoints.add(new Vector(Math.cos(angle) * RADIUS, 0.0D, Math.sin(angle) * RADIUS));
}
final List<List<Vector>> frames = createEmptyFrames();
frames.add(new ArrayList<>(ringPoints));
setFrames(frames);
}
@Override
public void display(int ticks, Entity entity, Hat hat) {
if (ticks % hat.getUpdateFrequency() != 0) {
return;
}
Location location = entity.getLocation();
if (hat.getTrackingMethod() == ParticleTracking.TRACK_HEAD_MOVEMENT && entity instanceof Player) {
location = ((Player) entity).getEyeLocation();
}
final double yaw = Math.toRadians(location.getYaw());
final double cos = Math.cos(yaw);
final double sin = Math.sin(yaw);
final Vector offset = hat.getOffset();
final double offsetX = ((offset.getX() * cos) - (offset.getZ() * sin));
final double offsetZ = ((offset.getX() * sin) + (offset.getZ() * cos));
final Vector angle = hat.getAngle();
final double angleX = Math.toRadians(angle.getX());
final double angleY = Math.toRadians(angle.getY());
final double angleZ = Math.toRadians(angle.getZ());
final World world = location.getWorld();
final int colorStep = ticks / 4;
final double spin = ticks * 0.05D;
final double spinCos = Math.cos(spin);
final double spinSin = Math.sin(spin);
for (int i = 0; i < ringPoints.size(); i++) {
final Vector base = ringPoints.get(i).clone();
final double rx = (base.getX() * spinCos) - (base.getZ() * spinSin);
final double rz = (base.getX() * spinSin) + (base.getZ() * spinCos);
Vector v = new Vector(rx, 0.0D, rz);
v.multiply(hat.getScale());
v = getAngleVector(angleX, angleY, angleZ, v);
final Location target = location.clone().add(offsetX, 0.0D, offsetZ);
target.add(getTrackingPosition(hat, v, location, cos, sin));
final Color color = RAINBOW_COLORS[Math.floorMod(colorStep + i, RAINBOW_COLORS.length)];
renderer.spawnParticleColor(world, ParticleEffect.REDSTONE, target, 1, 0.0D, 0.0D, 0.0D, 0.0D, color,
DUST_SCALE, true);
}
}
}
@@ -1,9 +1,21 @@
package cosmeticsOG.particles.properties;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.events.HatEquipEvent;
import cosmeticsOG.hooks.CurrencyHook;
import cosmeticsOG.locale.Message;
import cosmeticsOG.managers.SettingsManager;
import cosmeticsOG.particles.Hat;
@@ -16,15 +28,10 @@ import cosmeticsOG.ui.StaticMenu;
import cosmeticsOG.ui.StaticMenuManager;
import cosmeticsOG.util.ItemUtil;
import cosmeticsOG.util.PlayerUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import net.trueog.diamondbankog.DiamondBankException;
import net.trueog.diamondbankog.balance.shard.PlayerShards;
import net.trueog.utilitiesog.UtilitiesOG;
public enum ParticleAction {
@@ -38,7 +45,7 @@ public enum ParticleAction {
private final boolean hasData;
private final boolean isHidden;
private static final Map<Integer, ParticleAction> actionID = new HashMap<Integer, ParticleAction>();
private static final Map<Integer, ParticleAction> actionID = new HashMap<>();
static {
@@ -83,7 +90,7 @@ public enum ParticleAction {
public String getName() {
return this.toString().toLowerCase();
return StringUtils.lowerCase(this.toString());
}
@@ -136,7 +143,7 @@ public enum ParticleAction {
*/
public String getStrippedName() {
return Utils.stripColors(getDisplayName());
return UtilitiesOG.stripFormatting(getDisplayName());
}
@@ -167,26 +174,25 @@ public enum ParticleAction {
@SuppressWarnings("incomplete-switch")
public void onClick(Player player, Hat hat, int slot, Inventory inventory, String argument) {
PlayerState playerState = core.getPlayerState(player);
boolean canClose = SettingsManager.CLOSE_MENU_ON_EQUIP.getBoolean();
final PlayerState playerState = core.getPlayerState(player);
final boolean canClose = SettingsManager.CLOSE_MENU_ON_EQUIP.getBoolean();
switch (this) {
case EQUIP: {
case EQUIP -> {
HatEquipEvent event = new HatEquipEvent(player, hat);
final HatEquipEvent event = new HatEquipEvent(player, hat);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
// Remove an already equipped hat
// Remove an already equipped hat.
if (checkAgainstEquippedHats(hat, slot, playerState, inventory)) {
return;
}
// Check to see if we have already purchased this hat
// Check to see if we have already purchased this hat.
if (playerState.hasPurchased(hat)) {
core.getParticleManager().equipHat(player, hat);
@@ -201,26 +207,27 @@ public enum ParticleAction {
}
boolean canUsePermission = SettingsManager.FLAG_PERMISSION.getBoolean();
boolean canUseCurrency = SettingsManager.isEconomyEnabled();
boolean canUseExp = SettingsManager.FLAG_EXPERIENCE.getBoolean();
final boolean canUsePermission = SettingsManager.FLAG_PERMISSION.getBoolean();
final boolean canUseCurrency = SettingsManager.isEconomyEnabled();
final boolean canUseExp = SettingsManager.FLAG_EXPERIENCE.getBoolean();
if (canUsePermission) {
if (hat.isLocked()) {
// Only show the permission denied message if vault and exp are also disabled.
// Only show the permission denied message if currency and exp are also
// disabled.
if (!canUseCurrency && !canUseExp) {
String deniedMessage = hat.getPermissionDeniedDisplayMessage();
final String deniedMessage = hat.getPermissionDeniedDisplayMessage();
if (!deniedMessage.equals("")) {
if (!"".equals(deniedMessage)) {
Utils.cosmeticsOGPlaceholderMessage(player, deniedMessage);
CosmeticsOG.chatMessage(player, deniedMessage);
} else {
Utils.cosmeticsOGPlaceholderMessage(player, Message.HAT_NO_PERMISSION.getValue());
CosmeticsOG.chatMessage(player, Message.HAT_NO_PERMISSION.getValue());
}
@@ -253,18 +260,15 @@ public enum ParticleAction {
}
double playerBalance = -1;
if (canUseCurrency) {
CurrencyHook currencyHook = core.getHookManager().getCurrencyHook();
if (currencyHook != null && currencyHook.isEnabled()) {
openPurchaseMenuIfAffordable(player, playerState, hat, canClose);
return;
playerBalance = currencyHook.getBalance(player);
}
}
} else if (canUseExp) {
long playerBalance = -1;
if (canUseExp) {
playerBalance = player.getLevel();
@@ -274,9 +278,7 @@ public enum ParticleAction {
if (playerBalance < hat.getPrice()) {
String currency = SettingsManager.CURRENCY.getString();
Utils.cosmeticsOGPlaceholderMessage(player,
Message.INSUFFICIENT_FUNDS.getValue().replace("{1}", currency));
sendInsufficientFunds(player);
if (canClose) {
@@ -288,26 +290,7 @@ public enum ParticleAction {
} else {
StaticMenuManager staticManager = core.getMenuManagerFactory()
.getStaticMenuManager(playerState);
playerState.setPendingPurchase(hat);
MenuInventory purchaseInventory = core.getDatabase().getPurchaseMenu(playerState);
AbstractMenu pendingPurchaseMenu;
if (purchaseInventory != null) {
pendingPurchaseMenu = new StaticMenu(core, staticManager, player, purchaseInventory);
} else {
pendingPurchaseMenu = new StaticMenu(core, staticManager, player,
PendingPurchaseMenu.defaultPendingPurchaseInventory.clone());
}
staticManager.addMenu(pendingPurchaseMenu);
pendingPurchaseMenu.open();
openPendingPurchaseMenu(player, playerState, hat);
}
@@ -329,42 +312,22 @@ public enum ParticleAction {
}
break;
}
case TOGGLE -> {
case TOGGLE: {
List<Hat> hats = playerState.getActiveHats();
// Toggles all active hats based on the first hats toggle state
// Players can toggle individual hats through the hat manager
final List<Hat> hats = playerState.getActiveHats();
if (hats.size() > 0) {
boolean initialToggle = hats.get(0).isHidden();
for (Hat h : hats) {
h.setHidden(!initialToggle);
}
final boolean initialToggle = hats.get(0).isHidden();
hats.forEach(h -> h.setHidden(!initialToggle));
}
break;
}
case CLOSE -> PlayerUtil.closeInventory(player);
case OVERRIDE -> {
case CLOSE: {
PlayerUtil.closeInventory(player);
break;
}
case OVERRIDE: {
// Remove an already equipped hat
// Remove an already equipped hat.
if (checkAgainstEquippedHats(hat, slot, playerState, inventory)) {
return;
@@ -378,21 +341,16 @@ public enum ParticleAction {
}
break;
}
case CLEAR: {
case CLEAR -> {
core.getPlayerState(player).clearActiveHats();
Utils.cosmeticsOGPlaceholderMessage(player, Message.COMMAND_CLEAR_SUCCESS.getValue());
break;
CosmeticsOG.chatMessage(player, Message.COMMAND_CLEAR_SUCCESS.getValue());
}
case COMMAND -> {
case COMMAND: {
if (!argument.equals("")) {
if (!"".equals(argument)) {
PlayerUtil.runNextTick(() -> {
@@ -403,12 +361,8 @@ public enum ParticleAction {
}
break;
}
case OPEN_MENU_PERMISSION:
case OPEN_MENU: {
case OPEN_MENU_PERMISSION, OPEN_MENU -> {
if (this == OPEN_MENU_PERMISSION && !player.hasPermission(hat.getFullPermission())) {
@@ -416,71 +370,60 @@ public enum ParticleAction {
}
StaticMenuManager staticManager = (StaticMenuManager) playerState.getMenuManager();
final StaticMenuManager staticManager = (StaticMenuManager) playerState.getMenuManager();
if (staticManager == null) {
return;
}
AbstractMenu menu = staticManager.getMenuFromCache(argument);
final AbstractMenu menu = staticManager.getMenuFromCache(argument);
if (menu != null) {
menu.open();
} else {
MenuInventory menuInventory = core.getDatabase().loadInventory(argument, playerState);
final MenuInventory menuInventory = core.getDatabase().loadInventory(argument, playerState);
if (menuInventory == null) {
Utils.cosmeticsOGPlaceholderMessage(player,
CosmeticsOG.chatMessage(player,
Message.COMMAND_ERROR_UNKNOWN_MENU.getValue().replace("{1}", argument));
break;
}
StaticMenu staticMenu = new StaticMenu(core, staticManager, player, menuInventory);
final StaticMenu staticMenu = new StaticMenu(core, staticManager, player, menuInventory);
staticManager.addMenu(staticMenu);
staticMenu.open();
}
break;
}
case PURCHASE_CONFIRM -> {
case PURCHASE_CONFIRM: {
Hat pendingHat = playerState.getPendingPurchase();
final Hat pendingHat = playerState.getPendingPurchase();
// Go back to the previous menu if the pending hat is null
if (pendingHat == null) {
gotoPreviousMenu(playerState);
return;
}
int price = pendingHat.getPrice();
final int price = pendingHat.getPrice();
boolean purchased = false;
if (SettingsManager.isEconomyEnabled()) {
CurrencyHook currencyHook = core.getHookManager().getCurrencyHook();
if (currencyHook != null && currencyHook.isEnabled()) {
if (currencyHook.withdraw(player, price)) {
purchased = true;
}
}
playerState.setPendingPurchase(null);
purchaseWithDiamondBank(player, playerState, pendingHat, price);
return;
} else if (SettingsManager.FLAG_EXPERIENCE.getBoolean()) {
double currentBalance = player.getLevel();
double newBalance = currentBalance - price;
final double currentBalance = player.getLevel();
final double newBalance = currentBalance - price;
player.setLevel((int) newBalance);
purchased = true;
@@ -489,39 +432,21 @@ public enum ParticleAction {
if (purchased) {
playerState.addPurchasedHat(pendingHat);
core.getDatabase().savePlayerPurchase(player.getUniqueId(), pendingHat);
core.getParticleManager().equipHat(player, pendingHat);
if (SettingsManager.CLOSE_MENU_ON_EQUIP.getBoolean()) {
PlayerUtil.closeInventory(player);
} else {
gotoPreviousMenu(playerState);
}
finishPurchase(player, playerState, pendingHat);
}
break;
}
case PURCHASE_DENY -> {
case PURCHASE_DENY: {
playerState.setPendingPurchase(null);
gotoPreviousMenu(playerState);
break;
}
case DEMO -> {
case DEMO: {
HatEquipEvent event = new HatEquipEvent(player, hat);
final HatEquipEvent event = new HatEquipEvent(player, hat);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
hat.setPermanent(false);
@@ -529,18 +454,14 @@ public enum ParticleAction {
}
break;
}
case ACTIVE_PARTICLES -> {
case ACTIVE_PARTICLES: {
StaticMenuManager staticManager = core.getMenuManagerFactory().getStaticMenuManager(playerState);
EquippedParticlesMenu particlesMenu = new EquippedParticlesMenu(core, staticManager, player, true);
final StaticMenuManager staticManager = core.getMenuManagerFactory().getStaticMenuManager(playerState);
final EquippedParticlesMenu particlesMenu = new EquippedParticlesMenu(core, staticManager, player,
true);
staticManager.addMenu(particlesMenu);
particlesMenu.open();
break;
}
@@ -582,7 +503,7 @@ public enum ParticleAction {
try {
return ParticleAction.valueOf(name.toUpperCase());
return ParticleAction.valueOf(StringUtils.upperCase(name));
} catch (IllegalArgumentException e) {
@@ -594,9 +515,8 @@ public enum ParticleAction {
private void gotoPreviousMenu(PlayerState playerState) {
StaticMenuManager staticManager = (StaticMenuManager) playerState.getMenuManager();
AbstractMenu menu = staticManager.getPreviousOpenMenu();
final StaticMenuManager staticManager = (StaticMenuManager) playerState.getMenuManager();
final AbstractMenu menu = staticManager.getPreviousOpenMenu();
if (menu == null) {
return;
@@ -609,24 +529,277 @@ public enum ParticleAction {
private boolean checkAgainstEquippedHats(Hat hat, int slot, PlayerState playerState, Inventory inventory) {
if (playerState.isEquipped(hat)) {
if (!playerState.isEquipped(hat)) {
playerState.removeHat(hat);
ItemStack item = inventory.getItem(slot);
return false;
ItemUtil.stripHighlight(item);
}
// Convert List<String> to List<Component>.
List<Component> components = hat.getCachedDescription().stream().map(Component::text)
.collect(Collectors.toList());
playerState.removeHat(hat);
final ItemStack item = inventory.getItem(slot);
ItemUtil.stripHighlight(item);
// Convert List<String> to List<Component>.
final List<Component> components = hat.getCachedDescription().stream().map(Component::text)
.collect(Collectors.toList());
ItemUtil.setItemDescription(item, components);
return true;
}
private void openPurchaseMenuIfAffordable(Player player, PlayerState playerState, Hat hat, boolean canClose) {
if (!isDiamondBankAvailable()) {
return;
}
final UUID uuid = player.getUniqueId();
final long priceShards = hat.getPrice();
getSpendableShardBalance(uuid).whenComplete((playerBalance, throwable) -> {
if (throwable != null) {
handleDiamondBankFailure(player, throwable);
return;
}
runOnMainThread(() -> {
if (!player.isOnline()) {
return;
}
if (playerBalance < priceShards) {
sendInsufficientFunds(player);
if (canClose) {
PlayerUtil.closeInventory(player);
}
return;
}
openPendingPurchaseMenu(player, playerState, hat);
});
});
}
private void openPendingPurchaseMenu(Player player, PlayerState playerState, Hat hat) {
final StaticMenuManager staticManager = core.getMenuManagerFactory().getStaticMenuManager(playerState);
playerState.setPendingPurchase(hat);
final MenuInventory purchaseInventory = core.getDatabase().getPurchaseMenu(playerState);
final AbstractMenu pendingPurchaseMenu;
if (purchaseInventory != null) {
pendingPurchaseMenu = new StaticMenu(core, staticManager, player, purchaseInventory);
} else {
pendingPurchaseMenu = new StaticMenu(core, staticManager, player,
PendingPurchaseMenu.defaultPendingPurchaseInventory.clone());
}
staticManager.addMenu(pendingPurchaseMenu);
pendingPurchaseMenu.open();
}
private void purchaseWithDiamondBank(Player player, PlayerState playerState, Hat pendingHat, long priceShards) {
if (!isDiamondBankAvailable()) {
return;
}
final UUID uuid = player.getUniqueId();
final String notes = "Purchased " + UtilitiesOG.stripFormatting(pendingHat.getDisplayName());
consumePlayerShards(uuid, priceShards, notes).whenComplete((ignored, throwable) -> {
if (throwable != null) {
handleDiamondBankFailure(player, throwable);
return;
}
runOnMainThread(() -> finishPurchase(player, playerState, pendingHat));
});
}
private void finishPurchase(Player player, PlayerState playerState, Hat pendingHat) {
if (!player.isOnline()) {
return;
}
playerState.setPendingPurchase(null);
playerState.addPurchasedHat(pendingHat);
core.getDatabase().savePlayerPurchase(player.getUniqueId(), pendingHat);
core.getParticleManager().equipHat(player, pendingHat);
if (SettingsManager.CLOSE_MENU_ON_EQUIP.getBoolean()) {
PlayerUtil.closeInventory(player);
} else {
gotoPreviousMenu(playerState);
}
}
private CompletableFuture<Long> getSpendableShardBalance(UUID uuid) {
return callDiamondBankAsync(() -> {
final PlayerShards shards = CosmeticsOG.getDiamondBankAPI().getAllShards(uuid);
return shards.getBank() + shards.getInventory();
});
}
private CompletableFuture<Void> consumePlayerShards(UUID uuid, long priceShards, String notes) {
return callDiamondBankAsync(() -> {
CosmeticsOG.getDiamondBankAPI().consumeFromPlayer(uuid, priceShards, "Cosmetics-OG purchase", notes);
return null;
});
}
private <T> CompletableFuture<T> callDiamondBankAsync(DiamondBankCall<T> call) {
final CompletableFuture<T> future = new CompletableFuture<>();
Bukkit.getScheduler().runTaskAsynchronously(CosmeticsOG.getInstance(), () -> {
try {
future.complete(call.execute());
} catch (Throwable t) {
future.completeExceptionally(t);
}
});
return future;
}
private boolean isDiamondBankAvailable() {
if (CosmeticsOG.getDiamondBankAPI() != null) {
ItemUtil.setItemDescription(item, components);
return true;
}
CosmeticsOG.disableSelf("Could not find DiamondBank-OG! Disabling Cosmetics-OG...");
return false;
}
private void handleDiamondBankFailure(Player player, Throwable throwable) {
final Throwable cause = unwrapCompletionException(throwable);
if (cause instanceof DiamondBankException.EconomyDisabledException) {
CosmeticsOG.disableSelf("The DiamondBank-OG economy is disabled - disabling Cosmetics-OG!");
return;
}
if (cause instanceof DiamondBankException.InsufficientFundsException
|| cause instanceof DiamondBankException.InsufficientBalanceException)
{
runOnMainThread(() -> {
if (player.isOnline()) {
sendInsufficientFunds(player);
}
});
return;
}
if (cause instanceof DiamondBankException.PlayerNotOnlineException) {
return;
}
UtilitiesOG.logToConsole(CosmeticsOG.getPrefix(),
"DiamondBank-OG transaction failed: " + cause.getClass().getSimpleName());
if (CosmeticsOG.debugging) {
cause.printStackTrace();
}
}
private Throwable unwrapCompletionException(Throwable throwable) {
if (throwable instanceof CompletionException && throwable.getCause() != null) {
return throwable.getCause();
}
return throwable;
}
private void sendInsufficientFunds(Player player) {
final String currency = SettingsManager.CURRENCY.getString();
CosmeticsOG.chatMessage(player, Message.INSUFFICIENT_FUNDS.getValue().replace("{1}", currency));
}
private void runOnMainThread(Runnable runnable) {
Bukkit.getScheduler().runTask(CosmeticsOG.getInstance(), runnable);
}
@FunctionalInterface
private interface DiamondBankCall<T> {
T execute() throws Exception;
}
}
@@ -1,6 +1,6 @@
package cosmeticsOG.particles.properties;
import cosmeticsOG.Utils;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.locale.Message;
import java.util.HashMap;
import java.util.Map;
@@ -82,7 +82,7 @@ public enum ParticleAnimation {
*/
public String getStrippedName() {
return Utils.stripColors(getDisplayName());
return UtilitiesOG.stripFormatting(getDisplayName());
}
@@ -1,6 +1,6 @@
package cosmeticsOG.particles.properties;
import cosmeticsOG.Utils;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.locale.Message;
import java.util.HashMap;
import java.util.Map;
@@ -98,7 +98,7 @@ public enum ParticleLocation {
*/
public String getStrippedName() {
return Utils.stripColors(getDisplayName());
return UtilitiesOG.stripFormatting(getDisplayName());
}
@@ -1,7 +1,7 @@
package cosmeticsOG.particles.properties;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.CosmeticsOG;
import cosmeticsOG.Utils;
import cosmeticsOG.locale.Message;
import java.util.ArrayList;
import java.util.HashMap;
@@ -86,7 +86,7 @@ public enum ParticleMode {
*/
public String getStrippedName() {
return Utils.stripColors(getDisplayName());
return UtilitiesOG.stripFormatting(getDisplayName());
}
@@ -1,6 +1,6 @@
package cosmeticsOG.particles.properties;
import cosmeticsOG.Utils;
import net.trueog.utilitiesog.UtilitiesOG;
import cosmeticsOG.particles.Effect;
import cosmeticsOG.particles.effects.AngelWingsEffect;
import cosmeticsOG.particles.effects.AnimatedEffect;
@@ -13,6 +13,7 @@ import cosmeticsOG.particles.effects.CrystalEffect;
import cosmeticsOG.particles.effects.Debug5x5Effect;
import cosmeticsOG.particles.effects.Debug6x6Effect;
import cosmeticsOG.particles.effects.HaloEffect;
import cosmeticsOG.particles.effects.RainbowHaloEffect;
import cosmeticsOG.particles.effects.HelixEffect;
import cosmeticsOG.particles.effects.HoopEffect;
import cosmeticsOG.particles.effects.InverseVortexEffect;
@@ -40,7 +41,8 @@ public enum ParticleType {
ANGEL_WINGS(14, new AngelWingsEffect()), CREEPER_HAT(15, new CreeperEffect()),
CLEAN_TRAIL(16, new CleanTrailEffect()), TORNADO(17, new TornadoEffect()), CUSTOM(18, new PixelEffect()),
PARTICLEHATS(19, new ParticleHatsEffect()), ANIMATED(20, new AnimatedEffect(), true),
DEBUG_5X5(-1, new Debug5x5Effect(), true), DEBUG_6X6(-2, new Debug6x6Effect(), true);
RAINBOW_HALO(21, new RainbowHaloEffect()), DEBUG_5X5(-1, new Debug5x5Effect(), true),
DEBUG_6X6(-2, new Debug6x6Effect(), true);
private final int id;
private final Effect effect;
@@ -145,7 +147,7 @@ public enum ParticleType {
*/
public String getStrippedName() {
return Utils.stripColors(effect.getDisplayName());
return UtilitiesOG.stripFormatting(effect.getDisplayName());
}
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff. Show more