Initial Release
This commit is contained in:
1 parent
c62f5c6c19
commit
b5f912198f
26 files changed
+390
-466
No files matched your search
@@ -47,8 +47,11 @@ dependencies {
|
||||
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare purpur API version to be packaged.
|
||||
compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.2.3") // Import MiniPlaceholders API.
|
||||
compileOnly("com.github.decentsoftware-eu:decentholograms:2.8.9") // Import DecentHolograms API.
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") // Import Vault API.
|
||||
implementation(project(":libs:MCShared-OG")) // Import source-based MCShared-OG API.
|
||||
implementation(project(":libs:Utilities-OG")) // Import source-based Utilities-OG API.
|
||||
implementation("net.kyori:adventure-text-minimessage:4.17.0") // Adventure Minimessage API.
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.3.2") // Adventure Minimessage API.
|
||||
}
|
||||
|
||||
tasks.withType<AbstractArchiveTask>().configureEach {
|
||||
|
||||
+1
-1
Submodule libs/Utilities-OG updated: a204510516...dd12b76d43.
@@ -5,13 +5,11 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -36,8 +34,9 @@ import com.hm.petmaster.listener.PlayerQuitListener;
|
||||
import com.hm.petmaster.listener.PlayerTameListener;
|
||||
import com.hm.petmaster.utils.MessageSender;
|
||||
|
||||
import eu.decentsoftware.holograms.api.utils.UpdateChecker;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
|
||||
/**
|
||||
* Manage pets and display useful information via holograms, action bar or chat messages!
|
||||
@@ -58,8 +57,7 @@ import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
public class PetMaster extends JavaPlugin {
|
||||
|
||||
// Plugin options and various parameters.
|
||||
private String chatHeader;
|
||||
private boolean updatePerformed;
|
||||
private TextComponent chatHeader;
|
||||
private int serverVersion;
|
||||
|
||||
// Fields related to file handling.
|
||||
@@ -74,9 +72,6 @@ public class PetMaster extends JavaPlugin {
|
||||
private PlayerTameListener playerTameListener;
|
||||
private PlayerBreedListener playerBreedListener;
|
||||
|
||||
// Used to check for plugin updates.
|
||||
private UpdateChecker updateChecker;
|
||||
|
||||
// Additional classes related to plugin commands.
|
||||
private HelpCommand helpCommand;
|
||||
private InfoCommand infoCommand;
|
||||
@@ -89,7 +84,7 @@ public class PetMaster extends JavaPlugin {
|
||||
private PetInvincibleCommand petInvincibleCommand;
|
||||
private PetSkillCommand petSkillCommand;
|
||||
|
||||
//Messageing System
|
||||
// Messaging System.
|
||||
private BukkitAudiences adventure;
|
||||
private MessageSender messageSender;
|
||||
|
||||
@@ -141,7 +136,7 @@ public class PetMaster extends JavaPlugin {
|
||||
PetAbilityFile.getPetAbilities().options().copyDefaults(true);
|
||||
PetAbilityFile.petAbilitySave();
|
||||
|
||||
chatHeader = ChatColor.GRAY + "[" + ChatColor.GOLD + "\u265E" + ChatColor.GRAY + "] ";
|
||||
chatHeader = Component.text("<gray>[<gold>\u25b2<gray>]");
|
||||
|
||||
File playerColorConfig = new File(getDataFolder() + File.separator + "playersettings.yml");
|
||||
|
||||
@@ -181,27 +176,9 @@ public class PetMaster extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update configurations from previous versions of the plugin if server reloads or restarts.
|
||||
if (attemptUpdate) {
|
||||
updateOldConfiguration();
|
||||
updateOldLanguage();
|
||||
}
|
||||
|
||||
playerInteractListener.extractParameters();
|
||||
playerLeashListener.extractParameters();
|
||||
|
||||
if (config.getBoolean("checkForUpdate", true)) {
|
||||
if (updateChecker == null) {
|
||||
updateChecker = new UpdateChecker(this, "https://raw.githubusercontent.com/PyvesB/PetMaster/master/pom.xml",
|
||||
"petmaster.admin", chatHeader, "spigotmc.org/resources/pet-master.15904");
|
||||
getServer().getPluginManager().registerEvents(updateChecker, this);
|
||||
updateChecker.launchUpdateCheckerTask();
|
||||
}
|
||||
} else {
|
||||
PlayerJoinEvent.getHandlerList().unregister(updateChecker);
|
||||
updateChecker = null;
|
||||
}
|
||||
|
||||
if (config.getBoolean("disablePlayerDamage", false)) {
|
||||
if (playerAttackListener == null) {
|
||||
playerAttackListener = new PlayerAttackListener(this);
|
||||
@@ -242,67 +219,6 @@ public class PetMaster extends JavaPlugin {
|
||||
return yamlConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates configuration file from older plugin versions by adding missing parameters. Upgrades from versions prior
|
||||
* to 1.2 are not supported.
|
||||
*/
|
||||
private void updateOldConfiguration() {
|
||||
updatePerformed = false;
|
||||
|
||||
updateSetting(config, "languageFileName", "lang.yml", "Name of the language file.");
|
||||
updateSetting(config, "checkForUpdate", true,
|
||||
"Check for update on plugin launch and notify when an OP joins the game.");
|
||||
updateSetting(config, "changeOwnerPrice", 0, "Price of the /petm setowner command (requires Vault).");
|
||||
updateSetting(config, "displayDog", true, "Take dogs into account.");
|
||||
updateSetting(config, "displayCat", true, "Take cats into account.");
|
||||
updateSetting(config, "displayHorse", true, "Take horses into account.");
|
||||
updateSetting(config, "displayLlama", true, "Take llamas into account.");
|
||||
updateSetting(config, "displayParrot", true, "Take parrots into account.");
|
||||
updateSetting(config, "actionBarMessage", false,
|
||||
"Enable or disable action bar messages when right-clicking on a pet.");
|
||||
updateSetting(config, "displayToOwner", false,
|
||||
"Enable or disable showing ownership information for a player's own pets.");
|
||||
updateSetting(config, "freePetPrice", 0, "Price of the /petm free command (requires Vault).");
|
||||
updateSetting(config, "showHealth", true,
|
||||
"Show health next to owner in chat and action bar messages (not holograms).");
|
||||
updateSetting(config, "disablePlayerDamage", false, "Protect pets to avoid being hurt by other player.");
|
||||
updateSetting(config, "enableAngryMobPlayerDamage", true,
|
||||
"Allows players to defend themselves against angry tamed mobs (e.g. dogs) even if disablePlayerDamage is true.");
|
||||
updateSetting(config, "disableLeash", false, "Prevent others from using leash on pet.");
|
||||
updateSetting(config, "disableRiding", false, "Prevent others from mounting pet (horse/donkey).");
|
||||
|
||||
if (updatePerformed) {
|
||||
// Changes in the configuration: save and do a fresh load.
|
||||
try {
|
||||
config.saveConfiguration();
|
||||
config.loadConfiguration();
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
getLogger().log(Level.SEVERE, "Error while saving changes to the configuration file: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates language file from older plugin versions by adding missing parameters. Upgrades from versions prior to
|
||||
* 1.2 are not supported.
|
||||
*/
|
||||
private void updateOldLanguage() {
|
||||
updatePerformed = false;
|
||||
|
||||
updateSetting(lang, "petmaster-help-header", "<prefix> <gold>------------------ ♞<bold>PetMaster</bold>♞ ------------------");
|
||||
updateSetting(lang, "petmaster-prefix", "<gray>[<gold>♞<gray>] ");
|
||||
|
||||
if (updatePerformed) {
|
||||
// Changes in the language file: save and do a fresh load.
|
||||
try {
|
||||
lang.saveConfiguration();
|
||||
lang.loadConfiguration();
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
getLogger().log(Level.SEVERE, "Error while saving changes to the language file: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when server is stopped or reloaded.
|
||||
*/
|
||||
@@ -353,27 +269,11 @@ public class PetMaster extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the configuration file to include a new setting with its default value and its comments.
|
||||
*
|
||||
* @param file
|
||||
* @param name
|
||||
* @param value
|
||||
* @param comments
|
||||
*/
|
||||
private void updateSetting(CommentedYamlConfiguration file, String name, Object value, String... comments) {
|
||||
if (!file.getKeys(false).contains(name)) {
|
||||
file.set(name, value, comments);
|
||||
updatePerformed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getServerVersion() {
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getChatHeader() {
|
||||
public TextComponent getChatHeader() {
|
||||
return chatHeader;
|
||||
}
|
||||
|
||||
@@ -404,4 +304,5 @@ public class PetMaster extends JavaPlugin {
|
||||
public MessageSender getMessageSender(){
|
||||
return messageSender;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,25 +6,27 @@ import org.bukkit.entity.Tameable;
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
public class PetAbilities {
|
||||
|
||||
PetMaster plugin = PetMaster.getPlugin(PetMaster.class);
|
||||
|
||||
//General Variables
|
||||
|
||||
// General Variables.
|
||||
Tameable pet;
|
||||
boolean isPetOwned;
|
||||
Player player;
|
||||
|
||||
//Health Bonus Variables
|
||||
|
||||
// Health Bonus Variables.
|
||||
int healthBonusAmount = plugin.getConfig().getInt("Health-Bonus-Amount");
|
||||
boolean isHealthBonusEnabled = plugin.getConfig().getBoolean("Health-Bonus-Enabled");
|
||||
|
||||
|
||||
|
||||
|
||||
public PetAbilities(PetMaster petmaster) {
|
||||
this.plugin = petmaster;
|
||||
}
|
||||
|
||||
|
||||
public void petHealthBonus() {
|
||||
if(isHealthBonusEnabled == true) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,4 +36,5 @@ public class EnableDisableCommand {
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,4 +45,5 @@ public class FreeCommand {
|
||||
public boolean collectPendingFreeRequest(Player player) {
|
||||
return freePetSet.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.hm.petmaster.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.hm.mcshared.particle.FancyMessageSender;
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
/**
|
||||
@@ -43,7 +40,7 @@ public class HelpCommand {
|
||||
if (sender.hasPermission("petmaster.setowner")) {
|
||||
plugin.getMessageSender().sendMessage(sender, "petmaster-command-setowner");
|
||||
}
|
||||
|
||||
|
||||
if (sender.hasPermission("petmaster.setcolor")) {
|
||||
plugin.getMessageSender().sendMessage(sender, "petmaster-command-setcolor");
|
||||
}
|
||||
@@ -54,4 +51,5 @@ public class HelpCommand {
|
||||
// Tip message.
|
||||
plugin.getMessageSender().sendMessage(sender, "petmaster-tip");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.hm.petmaster.command;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
|
||||
/**
|
||||
* Class in charge of displaying the plugin's extra information (/petm info).
|
||||
*
|
||||
@@ -30,21 +32,21 @@ public class InfoCommand {
|
||||
*/
|
||||
public void getInfo(CommandSender sender) {
|
||||
List<TagResolver> templates = new ArrayList<>();
|
||||
templates.add(Placeholder.component("name", Component.text(plugin.getDescription().getName())));
|
||||
templates.add(Placeholder.component("version", Component.text(plugin.getDescription().getVersion())));
|
||||
templates.add(Placeholder.component("name", Component.text(plugin.getPluginMeta().getName())));
|
||||
templates.add(Placeholder.component("version", Component.text(plugin.getPluginMeta().getVersion())));
|
||||
templates.add(Placeholder.component("website", Component.text(
|
||||
plugin.getDescription().getWebsite() != null ? plugin.getDescription().getWebsite() : ""
|
||||
)));
|
||||
templates.add(Placeholder.component("author", Component.text(plugin.getDescription().getAuthors().get(0))));
|
||||
plugin.getPluginMeta().getWebsite() != null ? plugin.getPluginMeta().getWebsite() : ""
|
||||
)));
|
||||
templates.add(Placeholder.component("author", Component.text(plugin.getPluginMeta().getAuthors().get(0))));
|
||||
templates.add(Placeholder.component("description-details", Component.text(
|
||||
plugin.getPluginLang().getString(
|
||||
"version-command-description-details",
|
||||
"Manage pets and display useful information via holograms, action bar or chat messages!"
|
||||
)
|
||||
)));
|
||||
)
|
||||
)));
|
||||
templates.add(Placeholder.component("state", Component.text(
|
||||
plugin.getEnableDisableCommand().isDisabled() ? "NO" : "YES")
|
||||
));
|
||||
));
|
||||
plugin.getMessageSender().sendMessage(sender, "version-command-name", templates.toArray(new TagResolver[]{}));
|
||||
plugin.getMessageSender().sendMessage(sender, "version-command-version", templates.toArray(new TagResolver[]{}));
|
||||
plugin.getMessageSender().sendMessage(sender, "version-command-website", templates.toArray(new TagResolver[]{}));
|
||||
@@ -52,4 +54,5 @@ public class InfoCommand {
|
||||
plugin.getMessageSender().sendMessage(sender, "version-command-description", templates.toArray(new TagResolver[]{}));
|
||||
plugin.getMessageSender().sendMessage(sender, "version-command-enabled", templates.toArray(new TagResolver[]{}));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,26 +5,26 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import me.barny1094875.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class PetInvincibleCommand {
|
||||
PetMaster plugin = PetMaster.getPlugin(PetMaster.class);
|
||||
|
||||
|
||||
public PetInvincibleCommand(PetMaster petMaster) {
|
||||
this.plugin = petMaster;
|
||||
}
|
||||
|
||||
|
||||
public void godPetCommand(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,45 +5,48 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
import me.barny1094875.utilitiesog.UtilitiesOG;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class PetSkillCommand {
|
||||
|
||||
PetMaster plugin = PetMaster.getPlugin(PetMaster.class);
|
||||
|
||||
|
||||
public PetSkillCommand(PetMaster petMaster) {
|
||||
this.plugin = petMaster;
|
||||
}
|
||||
|
||||
|
||||
public void petSkillCommand(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
player.sendMessage(" ");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
|
||||
if(player.hasPermission("petmaster.admin") || player.isOp()) {
|
||||
player.sendMessage("Pet Boosts Info");
|
||||
player.sendMessage("#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" Pet Boost(Enabled): " + ChatColor.GREEN +plugin.getConfig().getBoolean("Pet-Boost-Enabled"));
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" Health Boost(Enabled): " + ChatColor.GREEN + plugin.getConfig().getBoolean("Health-Boost-Enabled"));
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" Damage Boost(Enabled): " + ChatColor.GREEN + plugin.getConfig().getBoolean("Damage-Boost-Enabled"));
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" Speed Boost(Enabled): " + ChatColor.GREEN + plugin.getConfig().getBoolean("Speed-Boost-Enabled"));
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" Defense Boost(Enabled): " + ChatColor.GREEN + plugin.getConfig().getBoolean("Defense-Boost-Enabled"));
|
||||
player.sendMessage(" ");
|
||||
UtilitiesOG.trueogSendMessage(player, "Pet Boosts Info");
|
||||
UtilitiesOG.trueogSendMessage(player, "#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" Pet Boost(Enabled): " + ChatColor.GREEN +plugin.getConfig().getBoolean("Pet-Boost-Enabled"));
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" Health Boost(Enabled): " + ChatColor.GREEN + plugin.getConfig().getBoolean("Health-Boost-Enabled"));
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" Damage Boost(Enabled): " + ChatColor.GREEN + plugin.getConfig().getBoolean("Damage-Boost-Enabled"));
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" Speed Boost(Enabled): " + ChatColor.GREEN + plugin.getConfig().getBoolean("Speed-Boost-Enabled"));
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" Defense Boost(Enabled): " + ChatColor.GREEN + plugin.getConfig().getBoolean("Defense-Boost-Enabled"));
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
}
|
||||
|
||||
//Stats of boosts current pet is giving them
|
||||
player.sendMessage("Pet Boosts");
|
||||
player.sendMessage("#---------------------#");
|
||||
player.sendMessage(plugin.getChatHeader()+ ChatColor.LIGHT_PURPLE +" Health Boost: "+ ChatColor.GREEN + plugin.getConfig().getDouble("Health-Boost-Amount")+ ChatColor.LIGHT_PURPLE+ " %");
|
||||
player.sendMessage(plugin.getChatHeader()+ ChatColor.LIGHT_PURPLE +" Damage Boost: "+ ChatColor.GREEN + plugin.getConfig().getDouble("Damage-Boost-Amount")+ ChatColor.LIGHT_PURPLE+ " %");
|
||||
player.sendMessage(plugin.getChatHeader()+ ChatColor.LIGHT_PURPLE +" Speed Boost: "+ ChatColor.GREEN + plugin.getConfig().getDouble("Speed-Boost-Amount")+ ChatColor.LIGHT_PURPLE+ " %");
|
||||
player.sendMessage(plugin.getChatHeader()+ ChatColor.LIGHT_PURPLE +" Defense Boost: "+ ChatColor.GREEN + plugin.getConfig().getDouble("Defense-Boost-Amount")+ ChatColor.LIGHT_PURPLE+ " %");
|
||||
|
||||
|
||||
// Stats of boosts current pet is giving them
|
||||
UtilitiesOG.trueogSendMessage(player, "Pet Boosts");
|
||||
UtilitiesOG.trueogSendMessage(player, "#---------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader()+ "&d" +" Health Boost: "+ ChatColor.GREEN + plugin.getConfig().getDouble("Health-Boost-Amount")+ "&d"+ " %");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader()+ "&d" +" Damage Boost: "+ ChatColor.GREEN + plugin.getConfig().getDouble("Damage-Boost-Amount")+ "&d"+ " %");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader()+ "&d" +" Speed Boost: "+ ChatColor.GREEN + plugin.getConfig().getDouble("Speed-Boost-Amount")+ "&d"+ " %");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader()+ "&d" +" Defense Boost: "+ ChatColor.GREEN + plugin.getConfig().getDouble("Defense-Boost-Amount")+ "&d"+ " %");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class ReloadCommand {
|
||||
} else {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
plugin.getMessageSender().sendMessage(sender, "configuration-reload-failed");
|
||||
plugin.getMessageSender().sendMessage(player, "configuration-reload-failed");
|
||||
}
|
||||
plugin.getLogger().severe("Errors while reloading configuration. Please view logs for more details.");
|
||||
}
|
||||
@@ -41,4 +41,4 @@ public class ReloadCommand {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,20 @@
|
||||
package com.hm.petmaster.command;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
|
||||
/**
|
||||
* Class in charge of handling player requests to change default color of a pets
|
||||
@@ -74,7 +76,7 @@ public class SetColorCommand {
|
||||
player,
|
||||
"available-colors",
|
||||
Placeholder.component("colors", Component.text(colors.toString()))
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +91,5 @@ public class SetColorCommand {
|
||||
}
|
||||
return DyeColor.RED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,113 +1,111 @@
|
||||
package com.hm.petmaster.command;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
import com.hm.petmaster.files.PetAbilityFile;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import me.barny1094875.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class SetConfigCommand {
|
||||
PetMaster plugin = PetMaster.getPlugin(PetMaster.class);
|
||||
|
||||
|
||||
public SetConfigCommand(PetMaster plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
public void setConfigCommand(Player player, String[] args) {
|
||||
if(player.hasPermission("petmaster.admin")) {
|
||||
if(args[0].equalsIgnoreCase("set")) {
|
||||
if(args[1].equalsIgnoreCase("config")) {
|
||||
if(args[2].equalsIgnoreCase("set")) {
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("pet-abilities")) {
|
||||
if(args[2].equalsIgnoreCase("enabled")) {
|
||||
if(args[3].equalsIgnoreCase("true")) {
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
|
||||
player.sendMessage("You have enabled Pet Abilities!");
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, "You have enabled Pet Abilities!");
|
||||
PetAbilityFile.getPetAbilities().set("Is-Pet-Abilities-Enabled", true);
|
||||
}
|
||||
if(args[3].equalsIgnoreCase("false")) {
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
|
||||
player.sendMessage("You have disabled Pet Abilities!");
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, "You have disabled Pet Abilities!");
|
||||
PetAbilityFile.getPetAbilities().set("Is-Pet-Abilities-Enabled", false);
|
||||
}
|
||||
}
|
||||
if(args[2].equalsIgnoreCase("set")) {
|
||||
if(args[3].equalsIgnoreCase("health")) {
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
|
||||
player.sendMessage("You have enabled Pet Abilities!");
|
||||
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, "You have enabled Pet Abilities!");
|
||||
|
||||
|
||||
}
|
||||
if(args[3].equalsIgnoreCase("damage")) {
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
|
||||
player.sendMessage("You have enabled Pet Abilities!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, "You have enabled Pet Abilities!");
|
||||
|
||||
}
|
||||
if(args[3].equalsIgnoreCase("speed")) {
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
|
||||
player.sendMessage("You have enabled Pet Abilities!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, "You have enabled Pet Abilities!");
|
||||
|
||||
}
|
||||
if(args[3].equalsIgnoreCase("protection")) {
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
|
||||
player.sendMessage("You have enabled Pet Abilities!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, "You have enabled Pet Abilities!");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,4 +113,4 @@ public class SetConfigCommand {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -37,11 +37,11 @@ public class SetOwnerCommand {
|
||||
}
|
||||
if (newOwner == null) {
|
||||
plugin.getMessageSender().sendMessage(player, "player-offline");
|
||||
} else if (!player.hasPermission("petmaster.setowner")) {
|
||||
} else if (! player.hasPermission("petmaster.setowner")) {
|
||||
plugin.getMessageSender().sendMessage(player, "no-permissions");
|
||||
} else if (plugin.getEnableDisableCommand().isDisabled()) {
|
||||
plugin.getMessageSender().sendMessage(player, "currently-disabled");
|
||||
} else if (!player.hasPermission("petmaster.admin") && newOwner.getUniqueId().equals(player.getUniqueId())) {
|
||||
} else if (! player.hasPermission("petmaster.admin") && newOwner.getUniqueId().equals(player.getUniqueId())) {
|
||||
plugin.getMessageSender().sendMessage(player, "cannot-change-to-yourself");
|
||||
} else {
|
||||
changeOwnershipMap.put(player.getUniqueId(), newOwner);
|
||||
@@ -57,4 +57,5 @@ public class SetOwnerCommand {
|
||||
public Player collectPendingSetOwnershipRequest(Player player) {
|
||||
return changeOwnershipMap.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +1,30 @@
|
||||
package com.hm.petmaster.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import me.barny1094875.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class ShareCommand {
|
||||
|
||||
PetMaster plugin = PetMaster.getPlugin(PetMaster.class);
|
||||
|
||||
|
||||
public ShareCommand(PetMaster petMaster) {
|
||||
this.plugin = petMaster;
|
||||
}
|
||||
|
||||
|
||||
public void sharePetCommand(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"# PetMaster Dev Note #");
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"#-------------------------#");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE +" This is a test feature!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " It will be available soon!");
|
||||
player.sendMessage(plugin.getChatHeader() + ChatColor.LIGHT_PURPLE + " Enjoy!");
|
||||
|
||||
|
||||
|
||||
|
||||
UtilitiesOG.trueogSendMessage(player, " ");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"# PetMaster Dev Note #");
|
||||
UtilitiesOG.trueogSendMessage(player, "&d" +"#-------------------------#");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" +" This is a test feature!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " It will be available soon!");
|
||||
UtilitiesOG.trueogSendMessage(player, plugin.getChatHeader() + "&d" + " Enjoy!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,93 +8,93 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class PetAbilityFile {
|
||||
|
||||
|
||||
private static File petAbilityFile;
|
||||
private static FileConfiguration petAbility;
|
||||
|
||||
|
||||
private static int wolfHealth = 0;
|
||||
private static int wolfDamage = 0;
|
||||
private static int wolfSpeed = 0;
|
||||
private static int wolfProtection = 0;
|
||||
|
||||
|
||||
private static int catHealth = 0;
|
||||
private static int catDamage = 0;
|
||||
private static int catSpeed = 0;
|
||||
private static int catProtection = 0;
|
||||
|
||||
|
||||
private static int donkeyHealth = 0;
|
||||
private static int donkeyDamage = 0;
|
||||
private static int donkeySpeed = 0;
|
||||
private static int donkeyProtection = 0;
|
||||
|
||||
|
||||
private static int llamaHealth = 0;
|
||||
private static int llamaDamage = 0;
|
||||
private static int llamaSpeed = 0;
|
||||
private static int llamaProtection = 0;
|
||||
|
||||
|
||||
private static int parrotHealth = 0;
|
||||
private static int parrotDamage = 0;
|
||||
private static int parrotSpeed = 0;
|
||||
private static int parrotProtection = 0;
|
||||
|
||||
|
||||
public static void petAbilitySetup() {
|
||||
petAbilityFile = new File(Bukkit.getServer().getPluginManager().getPlugin("PetMaster").getDataFolder(),"petability.yml" );
|
||||
|
||||
|
||||
if(!petAbilityFile.exists()) {
|
||||
try {
|
||||
petAbilityFile.createNewFile();
|
||||
}catch(IOException e) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
petAbility = YamlConfiguration.loadConfiguration(petAbilityFile);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static FileConfiguration getPetAbilities() {
|
||||
return petAbility;
|
||||
}
|
||||
|
||||
|
||||
public static void petAbilitySave() {
|
||||
try {
|
||||
petAbility.save(petAbilityFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void petAbilityReload() {
|
||||
petAbility = YamlConfiguration.loadConfiguration(petAbilityFile);
|
||||
}
|
||||
|
||||
|
||||
public static void petAbilityAddDefaults() {
|
||||
petAbility.set("Is-Pet-Abilities-Enabled", true);
|
||||
|
||||
|
||||
petAbility.set("Wolf-Health", wolfHealth);
|
||||
petAbility.set("Wolf-Damage", wolfDamage);
|
||||
petAbility.set("Wolf-Speed", wolfSpeed);
|
||||
petAbility.set("Wolf-Protection", wolfProtection);
|
||||
|
||||
|
||||
petAbility.set("Cat-Health", catHealth);
|
||||
petAbility.set("Cat-Damage", catDamage);
|
||||
petAbility.set("Cat-Speed", catSpeed);
|
||||
petAbility.set("Cat-Protection", catProtection);
|
||||
|
||||
|
||||
petAbility.set("Donkey-Health", donkeyHealth);
|
||||
petAbility.set("Donkey-Damage", donkeyDamage);
|
||||
petAbility.set("Donkey-Speed", donkeySpeed);
|
||||
petAbility.set("Donkey-Protection", donkeyProtection);
|
||||
|
||||
|
||||
petAbility.set("Llama-Health", llamaHealth);
|
||||
petAbility.set("Llama-Damage", llamaDamage);
|
||||
petAbility.set("Llama-Speed", llamaSpeed);
|
||||
petAbility.set("Llama-Protection", llamaProtection);
|
||||
|
||||
|
||||
petAbility.set("Parrot-Health", parrotHealth);
|
||||
petAbility.set("Parrot-Damage", parrotDamage);
|
||||
petAbility.set("Parrot-Speed", parrotSpeed);
|
||||
petAbility.set("Parrot-Protection", parrotProtection);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,20 @@
|
||||
package com.hm.petmaster.listener;
|
||||
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
public class PetDeathListener implements Listener{
|
||||
PetMaster plugin;
|
||||
|
||||
|
||||
|
||||
/*Tameable tameable;
|
||||
public PetDeathListener(PetMaster petMaster) {
|
||||
this.plugin = petMaster;
|
||||
}
|
||||
|
||||
|
||||
boolean isTamed = tameable.isTamed();
|
||||
boolean isDead = tameable.isDead();
|
||||
|
||||
|
||||
public void onPetDeath (EntityDeathEvent event) {
|
||||
if(event.getEntity() instanceof org.bukkit.entity.Tameable && isTamed == true && isDead == true) {
|
||||
tameable.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
||||
@@ -27,11 +23,10 @@ public class PetDeathListener implements Listener{
|
||||
}
|
||||
else if(tameable == null) {
|
||||
return;
|
||||
|
||||
|
||||
}else {
|
||||
isDead = false;
|
||||
isTamed =false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,14 +39,14 @@ public class PlayerAttackListener implements Listener {
|
||||
|
||||
Entity damager = event.getDamager();
|
||||
Entity damaged = event.getEntity();
|
||||
if (!isDamagerProjectileOrPlayer(damager) || !isDamagedOwned(damaged)) {
|
||||
if (! isDamagerProjectileOrPlayer(damager) || ! isDamagedOwned(damaged)) {
|
||||
return;
|
||||
}
|
||||
if (damager instanceof Projectile) {
|
||||
damager = (Entity) ((Projectile) damager).getShooter();
|
||||
}
|
||||
if (isDamagerPlayerDifferentFromDamagedOwner(damager, damaged)) {
|
||||
event.setCancelled(!enableAngryMobPlayerDamage || !isDamagedTargettingDamager(damager, damaged));
|
||||
event.setCancelled(! enableAngryMobPlayerDamage || ! isDamagedTargettingDamager(damager, damaged));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class PlayerAttackListener implements Listener {
|
||||
}
|
||||
|
||||
private boolean isDamagerPlayerDifferentFromDamagedOwner(Entity damager, Entity damaged) {
|
||||
return damager instanceof Player && !((Tameable) damaged).getOwner().getUniqueId().equals(damager.getUniqueId());
|
||||
return damager instanceof Player && ! ((Tameable) damaged).getOwner().getUniqueId().equals(damager.getUniqueId());
|
||||
}
|
||||
|
||||
private boolean isDamagedTargettingDamager(Entity damager, Entity damaged) {
|
||||
@@ -69,4 +69,5 @@ public class PlayerAttackListener implements Listener {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.hm.petmaster.listener;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -10,10 +9,12 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityBreedEvent;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
public class PlayerBreedListener implements Listener {
|
||||
|
||||
|
||||
private final PetMaster plugin;
|
||||
|
||||
|
||||
public PlayerBreedListener(PetMaster plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@@ -30,4 +31,5 @@ public class PlayerBreedListener implements Listener {
|
||||
wolf.setCollarColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,23 @@
|
||||
package com.hm.petmaster.listener;
|
||||
|
||||
import com.hm.mcshared.event.PlayerChangeAnimalOwnershipEvent;
|
||||
import com.hm.petmaster.PetMaster;
|
||||
import eu.decentsoftware.holograms.api.DHAPI;
|
||||
import eu.decentsoftware.holograms.api.holograms.Hologram;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.Llama;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Parrot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Sittable;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -19,9 +26,13 @@ import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import com.hm.mcshared.event.PlayerChangeAnimalOwnershipEvent;
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
import eu.decentsoftware.holograms.api.DHAPI;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
/**
|
||||
* Class used to display holograms, change the owner of a pet or free a pet.
|
||||
@@ -111,14 +122,14 @@ public class PlayerInteractListener implements Listener {
|
||||
// Has the player requested to free one of his pets?
|
||||
boolean freePet = plugin.getFreeCommand().collectPendingFreeRequest(player);
|
||||
|
||||
if (disableRiding && !isOwner && !player.hasPermission("petmaster.admin") && tameable instanceof Vehicle) {
|
||||
if (disableRiding && ! isOwner && !player.hasPermission("petmaster.admin") && tameable instanceof Vehicle) {
|
||||
plugin.getMessageSender().sendMessage(player, "not-owner");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Cannot change ownership or free pet if not owner and no bypass permission.
|
||||
if ((newOwner != null || freePet) && !isOwner && !player.hasPermission("petmaster.admin")) {
|
||||
if ((newOwner != null || freePet) && ! isOwner && !player.hasPermission("petmaster.admin")) {
|
||||
plugin.getMessageSender().sendMessage(player, "not-owner");
|
||||
return;
|
||||
}
|
||||
@@ -127,7 +138,7 @@ public class PlayerInteractListener implements Listener {
|
||||
changeOwner(player, currentOwner, newOwner, tameable);
|
||||
} else if (freePet) {
|
||||
freePet(player, currentOwner, tameable);
|
||||
} else if ((displayToOwner || !isOwner) && player.hasPermission("petmaster.showowner.*")) {
|
||||
} else if ((displayToOwner || ! isOwner) && player.hasPermission("petmaster.showowner.*")) {
|
||||
displayHologramAndMessage(player, currentOwner, tameable);
|
||||
}
|
||||
}
|
||||
@@ -218,27 +229,27 @@ public class PlayerInteractListener implements Listener {
|
||||
int version = plugin.getServerVersion();
|
||||
double offset = HORSE_OFFSET;
|
||||
if (tameable instanceof Ocelot || version >= 14 && tameable instanceof Cat) {
|
||||
if (!displayCat || !player.hasPermission("petmaster.showowner.cat")) {
|
||||
if (! displayCat || !player.hasPermission("petmaster.showowner.cat")) {
|
||||
return;
|
||||
}
|
||||
offset = CAT_OFFSET;
|
||||
} else if (tameable instanceof Wolf) {
|
||||
if (!displayDog || !player.hasPermission("petmaster.showowner.dog")) {
|
||||
if (! displayDog || !player.hasPermission("petmaster.showowner.dog")) {
|
||||
return;
|
||||
}
|
||||
offset = DOG_OFFSET;
|
||||
} else if (version >= 11 && tameable instanceof Llama) {
|
||||
if (!displayLlama || !player.hasPermission("petmaster.showowner.llama")) {
|
||||
if (! displayLlama || !player.hasPermission("petmaster.showowner.llama")) {
|
||||
return;
|
||||
}
|
||||
offset = LLAMA_OFFSET;
|
||||
} else if (version >= 12 && tameable instanceof Parrot) {
|
||||
if (!displayParrot || !player.hasPermission("petmaster.showowner.parrot")) {
|
||||
if (! displayParrot || !player.hasPermission("petmaster.showowner.parrot")) {
|
||||
return;
|
||||
}
|
||||
offset = PARROT_OFFSET;
|
||||
} else if (tameable instanceof Vehicle) {
|
||||
if (!displayHorse || !player.hasPermission("petmaster.showowner.horse")) {
|
||||
if (! displayHorse || !player.hasPermission("petmaster.showowner.horse")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -254,10 +265,10 @@ public class PlayerInteractListener implements Listener {
|
||||
List<String> lines = Collections.singletonList(plugin.getMessageSender().parseMessageToString(
|
||||
"petmaster-hologram",
|
||||
Placeholder.component("owner", Component.text(owner.getName() != null ? owner.getName() : "null"))
|
||||
));
|
||||
));
|
||||
|
||||
if (DHAPI.getHologram(hologramname) == null) {
|
||||
Hologram hologram = DHAPI.createHologram(hologramname, hologramLocation, lines);
|
||||
DHAPI.createHologram(hologramname, hologramLocation, lines);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -277,22 +288,19 @@ public class PlayerInteractListener implements Listener {
|
||||
|
||||
Component healthInfo = null;
|
||||
if (showHealth) {
|
||||
@SuppressWarnings("cast") // Tameable did not extend Animals in older versions of Bukkit.
|
||||
Animals animal = (Animals) tameable;
|
||||
healthInfo = plugin.getMessageSender().parseMessage(
|
||||
plugin.getPluginLang().getString("petmaster-health"),
|
||||
Placeholder.component("current-health", Component.text(String.format("%.1f", animal.getHealth()))),
|
||||
Placeholder.component("max-health", Component.text(
|
||||
plugin.getServerVersion() < 9 ? String.format("%.1f", animal.getMaxHealth())
|
||||
: String.format("%.1f", animal.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())))
|
||||
);
|
||||
: String.format("%.1f", animal.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()))));
|
||||
}
|
||||
|
||||
if (chatMessage) {
|
||||
Component parsedComponent = plugin.getMessageSender().parseMessage(
|
||||
plugin.getPluginLang().getString("petmaster-chat"),
|
||||
Placeholder.component("owner", Component.text(owner.getName() != null ? owner.getName() : "null"))
|
||||
);
|
||||
Placeholder.component("owner", Component.text(owner.getName() != null ? owner.getName() : "null")));
|
||||
if (healthInfo != null){
|
||||
parsedComponent = parsedComponent.append(healthInfo);
|
||||
}
|
||||
@@ -302,8 +310,7 @@ public class PlayerInteractListener implements Listener {
|
||||
if (actionBarMessage) {
|
||||
Component parsedComponent = plugin.getMessageSender().parseMessage(
|
||||
plugin.getPluginLang().getString("petmaster-action-bar"),
|
||||
Placeholder.component("owner", Component.text(owner.getName() != null ? owner.getName() : "null"))
|
||||
);
|
||||
Placeholder.component("owner", Component.text(owner.getName() != null ? owner.getName() : "null")));
|
||||
if (healthInfo != null){
|
||||
parsedComponent = parsedComponent.append(healthInfo);
|
||||
}
|
||||
@@ -329,7 +336,7 @@ public class PlayerInteractListener implements Listener {
|
||||
player,
|
||||
"not-enough-money",
|
||||
Placeholder.component("amount", Component.text(priceWithCurrency))
|
||||
);
|
||||
);
|
||||
return false;
|
||||
}
|
||||
economy.withdrawPlayer(player, price);
|
||||
@@ -337,8 +344,9 @@ public class PlayerInteractListener implements Listener {
|
||||
player,
|
||||
"change-owner-price",
|
||||
Placeholder.component("amount", Component.text(priceWithCurrency))
|
||||
);
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.hm.petmaster.listener;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -10,35 +9,39 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerLeashEntityEvent;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
public class PlayerLeashListener implements Listener {
|
||||
private final PetMaster plugin;
|
||||
|
||||
// Configuration parameters.
|
||||
private boolean disableLeash;
|
||||
private final PetMaster plugin;
|
||||
|
||||
public PlayerLeashListener(PetMaster petMaster) {
|
||||
this.plugin = petMaster;
|
||||
// Configuration parameters.
|
||||
private boolean disableLeash;
|
||||
|
||||
public PlayerLeashListener(PetMaster petMaster) {
|
||||
this.plugin = petMaster;
|
||||
}
|
||||
|
||||
public void extractParameters() {
|
||||
disableLeash = plugin.getPluginConfig().getBoolean("disableLeash", false);
|
||||
}
|
||||
public void extractParameters() {
|
||||
disableLeash = plugin.getPluginConfig().getBoolean("disableLeash", false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerLeashEntityEvent(PlayerLeashEntityEvent event) {
|
||||
if (plugin.getEnableDisableCommand().isDisabled() || !disableLeash)
|
||||
return;
|
||||
Entity entity = event.getEntity();
|
||||
if (!(entity instanceof Tameable))
|
||||
return;
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerLeashEntityEvent(PlayerLeashEntityEvent event) {
|
||||
if (plugin.getEnableDisableCommand().isDisabled() || ! disableLeash)
|
||||
return;
|
||||
Entity entity = event.getEntity();
|
||||
if (! (entity instanceof Tameable))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Tameable tameable = (Tameable) entity;
|
||||
AnimalTamer currentOwner = tameable.getOwner();
|
||||
if (currentOwner == null || currentOwner.getUniqueId().equals(player.getUniqueId()) || player.hasPermission("petmaster.admin"))
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
Tameable tameable = (Tameable) entity;
|
||||
AnimalTamer currentOwner = tameable.getOwner();
|
||||
if (currentOwner == null || currentOwner.getUniqueId().equals(player.getUniqueId()) || player.hasPermission("petmaster.admin"))
|
||||
return;
|
||||
|
||||
plugin.getMessageSender().sendMessage(player, "not-owner");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
plugin.getMessageSender().sendMessage(player, "not-owner");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,4 +27,5 @@ public class PlayerQuitListener implements Listener {
|
||||
plugin.getSetOwnerCommand().collectPendingSetOwnershipRequest(event.getPlayer());
|
||||
plugin.getFreeCommand().collectPendingFreeRequest(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.hm.petmaster.listener;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -10,6 +9,8 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityTameEvent;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
public class PlayerTameListener implements Listener {
|
||||
|
||||
private final PetMaster plugin;
|
||||
@@ -29,4 +30,4 @@ public class PlayerTameListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,86 @@
|
||||
package com.hm.petmaster.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.hm.petmaster.PetMaster;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MessageSender {
|
||||
private final PetMaster plugin;
|
||||
private final MiniMessage miniMessage;
|
||||
|
||||
public MessageSender(PetMaster plugin) {
|
||||
this.plugin = plugin;
|
||||
miniMessage = MiniMessage.miniMessage();
|
||||
}
|
||||
|
||||
private final PetMaster plugin;
|
||||
private final MiniMessage miniMessage;
|
||||
|
||||
public String parseMessageToString(String key, TagResolver... tagResolvers) {
|
||||
return LegacyComponentSerializer.builder().useUnusualXRepeatedCharacterHexFormat().build().serialize(
|
||||
parseMessage(plugin.getPluginLang().getString(key), tagResolvers)
|
||||
);
|
||||
}
|
||||
public MessageSender(PetMaster plugin) {
|
||||
this.plugin = plugin;
|
||||
miniMessage = MiniMessage.miniMessage();
|
||||
}
|
||||
|
||||
public Component parseMessage(String message, TagResolver... tagResolvers) {
|
||||
List<TagResolver> allTagResolvers = new ArrayList<>(Arrays.stream(tagResolvers).toList());
|
||||
allTagResolvers.add(Placeholder.parsed(
|
||||
"prefix",
|
||||
plugin.getPluginLang().getString("petmaster-prefix", "<gray>[<gold>♞<gray>] ")
|
||||
));
|
||||
return miniMessage.deserialize(message, allTagResolvers.toArray(new TagResolver[]{}));
|
||||
}
|
||||
|
||||
public void sendComponent(Player player, Component component){
|
||||
Audience audience = plugin.adventure().player(player);
|
||||
audience.sendMessage(component);
|
||||
}
|
||||
public String parseMessageToString(String key, TagResolver... tagResolvers) {
|
||||
return LegacyComponentSerializer.builder().useUnusualXRepeatedCharacterHexFormat().build().serialize(
|
||||
parseMessage(plugin.getPluginLang().getString(key), tagResolvers));
|
||||
}
|
||||
|
||||
public void sendComponentToActionBar(Player player, Component component){
|
||||
Audience audience = plugin.adventure().player(player);
|
||||
audience.sendActionBar(component);
|
||||
}
|
||||
public Component parseMessage(String message, TagResolver... tagResolvers) {
|
||||
List<TagResolver> allTagResolvers = new ArrayList<>(Arrays.stream(tagResolvers).toList());
|
||||
allTagResolvers.add(Placeholder.parsed(
|
||||
"prefix",
|
||||
plugin.getPluginLang().getString("petmaster-prefix", "<gray>[<gold>♞<gray>] ")));
|
||||
return miniMessage.deserialize(message, allTagResolvers.toArray(new TagResolver[]{}));
|
||||
}
|
||||
|
||||
public void sendMessage(Audience audience, String key, TagResolver... tagResolvers) {
|
||||
audience.sendMessage(parseMessage(plugin.getPluginLang().getString(key), tagResolvers));
|
||||
}
|
||||
public void sendComponent(Player player, Component component){
|
||||
Audience audience = plugin.adventure().player(player);
|
||||
audience.sendMessage(component);
|
||||
}
|
||||
|
||||
public void sendMessage(Player player, String key, TagResolver... tagResolvers) {
|
||||
Audience audience = plugin.adventure().player(player);
|
||||
sendMessage(audience, key, tagResolvers);
|
||||
}
|
||||
public void sendComponentToActionBar(Player player, Component component){
|
||||
Audience audience = plugin.adventure().player(player);
|
||||
audience.sendActionBar(component);
|
||||
}
|
||||
|
||||
public void sendMessage(CommandSender sender, String key, TagResolver... tagResolvers) {
|
||||
Audience audience = plugin.adventure().sender(sender);
|
||||
sendMessage(audience, key, tagResolvers);
|
||||
}
|
||||
public void sendMessage(Audience audience, String key, TagResolver... tagResolvers) {
|
||||
audience.sendMessage(parseMessage(plugin.getPluginLang().getString(key), tagResolvers));
|
||||
}
|
||||
|
||||
public void sendActionBar(Audience audience, String key, TagResolver... tagResolvers) {
|
||||
audience.sendActionBar(parseMessage(plugin.getPluginLang().getString(key), tagResolvers));
|
||||
}
|
||||
public void sendMessage(Player player, String key, TagResolver... tagResolvers) {
|
||||
Audience audience = plugin.adventure().player(player);
|
||||
sendMessage(audience, key, tagResolvers);
|
||||
}
|
||||
|
||||
public void sendActionBar(Player player, String key, TagResolver... tagResolvers) {
|
||||
Audience audience = plugin.adventure().player(player);
|
||||
sendActionBar(audience, key, tagResolvers);
|
||||
}
|
||||
public void sendMessage(CommandSender sender, String key, TagResolver... tagResolvers) {
|
||||
Audience audience = plugin.adventure().sender(sender);
|
||||
sendMessage(audience, key, tagResolvers);
|
||||
}
|
||||
|
||||
public void sendNewLine(CommandSender sender, boolean sendPrefix){
|
||||
Audience audience = plugin.adventure().sender(sender);
|
||||
public void sendActionBar(Audience audience, String key, TagResolver... tagResolvers) {
|
||||
audience.sendActionBar(parseMessage(plugin.getPluginLang().getString(key), tagResolvers));
|
||||
}
|
||||
|
||||
if (sendPrefix){
|
||||
sendMessage(audience, "petmaster-prefix");
|
||||
} else {
|
||||
audience.sendMessage(Component.newline());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void sendActionBar(Player player, String key, TagResolver... tagResolvers) {
|
||||
Audience audience = plugin.adventure().player(player);
|
||||
sendActionBar(audience, key, tagResolvers);
|
||||
}
|
||||
|
||||
public void sendNewLine(CommandSender sender, boolean sendPrefix){
|
||||
Audience audience = plugin.adventure().sender(sender);
|
||||
|
||||
if (sendPrefix){
|
||||
sendMessage(audience, "petmaster-prefix");
|
||||
} else {
|
||||
audience.sendMessage(Component.newline());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package utils;
|
||||
package com.hm.petmaster.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -10,26 +10,26 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
public class TabCompleterPetm implements TabCompleter{
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
List<String> list = Arrays.asList("help", "info" ,"reload", "disable", "enable", " setowner", "free", "setcolor", "sharepet", "godpet", "petskill");
|
||||
String input = args[0].toLowerCase();
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
List<String> list = Arrays.asList("help", "info" ,"reload", "disable", "enable", " setowner", "free", "setcolor", "sharepet", "godpet", "petskill");
|
||||
String input = args[0].toLowerCase();
|
||||
|
||||
List<String> completions = null;
|
||||
for (String s : list) {
|
||||
if (s.startsWith(input)) {
|
||||
if (completions == null) {
|
||||
completions = new ArrayList<>();
|
||||
}
|
||||
completions.add(s);
|
||||
}
|
||||
}
|
||||
if (completions != null) {
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
return completions;
|
||||
}
|
||||
List<String> completions = null;
|
||||
for (String s : list) {
|
||||
if (s.startsWith(input)) {
|
||||
if (completions == null) {
|
||||
completions = new ArrayList<>();
|
||||
}
|
||||
completions.add(s);
|
||||
}
|
||||
}
|
||||
if (completions != null) {
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
return completions;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
name: PetMaster
|
||||
main: com.hm.petmaster.PetMaster
|
||||
version: ${project.version}
|
||||
version: '${version}'
|
||||
author: DarkPyves
|
||||
softdepend: [HolographicDisplays,Vault]
|
||||
description: Manage pets and display useful information via holograms, action bar or chat messages!
|
||||
website: https://github.com/PyvesB/PetMaster
|
||||
api-version: 1.20
|
||||
api-version: '${apiVersion}'
|
||||
commands:
|
||||
petm:
|
||||
description: Main Pet Master command, use it to list sub-commands.
|
||||
|
||||
Reference in new issue
Block a user