mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-31 03:25:28 +02:00
Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into endgame
This commit is contained in:
@@ -21,6 +21,9 @@ import java.util.HashSet;
|
||||
|
||||
public final class BlockUtils {
|
||||
|
||||
public static final String SHORT_GRASS = "SHORT_GRASS";
|
||||
public static final String GRASS = "GRASS";
|
||||
|
||||
private BlockUtils() {
|
||||
}
|
||||
|
||||
@@ -37,6 +40,21 @@ public final class BlockUtils {
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(1, mcMMO.p));
|
||||
}
|
||||
|
||||
/**
|
||||
* Util method for compatibility across Minecraft versions, grabs the {@link Material} enum for short_grass
|
||||
*
|
||||
* @return the {@link Material} enum for short_grass
|
||||
*/
|
||||
public static Material getShortGrass() {
|
||||
if (Material.getMaterial(SHORT_GRASS) != null) {
|
||||
return Material.getMaterial(SHORT_GRASS);
|
||||
} else if (Material.getMaterial(GRASS) != null) {
|
||||
return Material.getMaterial(GRASS);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unable to find short grass material");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the state for a block to be seen as unnatural and cleanup any unwanted metadata from the block
|
||||
* @param block target block
|
||||
|
@@ -0,0 +1,28 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class CancellableRunnable implements Consumer<WrappedTask> {
|
||||
private boolean cancelled = false;
|
||||
|
||||
public void cancel() {
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
public abstract void run();
|
||||
|
||||
@Override
|
||||
public void accept(WrappedTask wrappedTask) {
|
||||
// Run the task if it hasn't been cancelled
|
||||
if (!cancelled) {
|
||||
run();
|
||||
}
|
||||
|
||||
// Cancel the task if it has been cancelled after running
|
||||
if (cancelled) {
|
||||
wrappedTask.cancel();
|
||||
}
|
||||
}
|
||||
}
|
@@ -112,7 +112,7 @@ public final class ChimaeraWing {
|
||||
|
||||
if (warmup > 0) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Teleport.Commencing", String.valueOf(warmup));
|
||||
new ChimaeraWingWarmup(mcMMOPlayer).runTaskLater(mcMMO.p, 20 * warmup);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ChimaeraWingWarmup(mcMMOPlayer), 20 * warmup);
|
||||
}
|
||||
else {
|
||||
chimaeraExecuteTeleport();
|
||||
@@ -123,15 +123,18 @@ public final class ChimaeraWing {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (mcMMO.p.getGeneralConfig().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
|
||||
player.teleport(player.getBedSpawnLocation());
|
||||
// player.teleport(player.getBedSpawnLocation());
|
||||
mcMMO.p.getFoliaLib().getImpl().teleportAsync(player, player.getBedSpawnLocation());
|
||||
}
|
||||
else {
|
||||
Location spawnLocation = player.getWorld().getSpawnLocation();
|
||||
if (spawnLocation.getBlock().getType() == Material.AIR) {
|
||||
player.teleport(spawnLocation);
|
||||
// player.teleport(spawnLocation);
|
||||
mcMMO.p.getFoliaLib().getImpl().teleportAsync(player, spawnLocation);
|
||||
}
|
||||
else {
|
||||
player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
|
||||
// player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
|
||||
mcMMO.p.getFoliaLib().getImpl().teleportAsync(player, player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -366,7 +366,8 @@ public final class EventUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
teleportingPlayer.teleport(targetPlayer);
|
||||
// teleportingPlayer.teleport(targetPlayer);
|
||||
mcMMO.p.getFoliaLib().getImpl().teleportAsync(teleportingPlayer, targetPlayer.getLocation());
|
||||
|
||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
|
||||
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
|
||||
|
@@ -8,7 +8,7 @@ import java.io.*;
|
||||
public class FixSpellingNetheriteUtil {
|
||||
|
||||
public static void processFileCheck(mcMMO pluginRef, String fileName, UpgradeType upgradeType) {
|
||||
pluginRef.getLogger().info("Checking " + fileName + " config material names...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Checking " + fileName + " config material names...");
|
||||
|
||||
File configFile = new File(pluginRef.getDataFolder(), fileName);
|
||||
if(configFile.exists()) {
|
||||
|
@@ -186,14 +186,14 @@
|
||||
//
|
||||
// for (File file : toDelete) {
|
||||
// if (file.delete()) {
|
||||
// mcMMO.p.debug("Deleted: " + file.getName());
|
||||
// LogUtils.debug(mcMMO.p.getLogger(), "Deleted: " + file.getName());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // This gets called onDisable
|
||||
// public void saveAnniversaryFiles() {
|
||||
// mcMMO.p.debug("Saving anniversary files...");
|
||||
// LogUtils.debug(mcMMO.p.getLogger(), "Saving anniversary files...");
|
||||
// String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary." + currentYear + ".yml";
|
||||
//
|
||||
// try {
|
||||
|
@@ -5,6 +5,8 @@ import com.gmail.nossr50.mcMMO;
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import static com.gmail.nossr50.util.LogUtils.DEBUG_STR;
|
||||
|
||||
public class LogFilter implements Filter {
|
||||
private final boolean debug;
|
||||
|
||||
@@ -15,6 +17,6 @@ public class LogFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public boolean isLoggable(LogRecord record) {
|
||||
return !(record.getMessage().contains("[Debug]") && !debug);
|
||||
return !(record.getMessage().contains(DEBUG_STR) && !debug);
|
||||
}
|
||||
}
|
||||
|
14
src/main/java/com/gmail/nossr50/util/LogUtils.java
Normal file
14
src/main/java/com/gmail/nossr50/util/LogUtils.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class LogUtils {
|
||||
|
||||
public static final String DEBUG_STR = "[D] ";
|
||||
|
||||
public static void debug(@NotNull Logger logger, @NotNull String message) {
|
||||
logger.info(DEBUG_STR + message);
|
||||
}
|
||||
}
|
@@ -490,6 +490,7 @@ public class MaterialMapStore {
|
||||
tools.addAll(tridents);
|
||||
tools.addAll(stringTools);
|
||||
tools.addAll(bows);
|
||||
tools.addAll(crossbows);
|
||||
}
|
||||
|
||||
private void fillBows() {
|
||||
@@ -999,8 +1000,8 @@ public class MaterialMapStore {
|
||||
private void fillShroomyWhiteList()
|
||||
{
|
||||
canMakeShroomyWhiteList.add("dirt");
|
||||
canMakeShroomyWhiteList.add("grass");
|
||||
canMakeShroomyWhiteList.add("grass_path");
|
||||
canMakeShroomyWhiteList.add("grass_block");
|
||||
canMakeShroomyWhiteList.add("dirt_path");
|
||||
}
|
||||
|
||||
private void fillBlockCrackerWhiteList()
|
||||
@@ -1013,8 +1014,8 @@ public class MaterialMapStore {
|
||||
private void fillHerbalismAbilityBlackList()
|
||||
{
|
||||
herbalismAbilityBlackList.add("dirt");
|
||||
herbalismAbilityBlackList.add("grass");
|
||||
herbalismAbilityBlackList.add("grass_path");
|
||||
herbalismAbilityBlackList.add("grass_block");
|
||||
herbalismAbilityBlackList.add("dirt_path");
|
||||
herbalismAbilityBlackList.add("farmland");
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -255,7 +254,7 @@ public final class Misc {
|
||||
|
||||
if (player != null) {
|
||||
UserManager.remove(player);
|
||||
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +325,7 @@ public final class Misc {
|
||||
experienceOrb.setExperience(experienceValue);
|
||||
}
|
||||
|
||||
private static class SpawnOrbTask extends BukkitRunnable {
|
||||
private static class SpawnOrbTask implements Runnable {
|
||||
private final Location location;
|
||||
private int orbExpValue;
|
||||
|
||||
|
@@ -81,7 +81,7 @@ public final class MobHealthbarUtils {
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, new FixedMetadataValue(mcMMO.p, false));
|
||||
}
|
||||
|
||||
new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, (long) displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(target, new MobHealthDisplayUpdaterTask(target), (long) displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -268,7 +268,7 @@ public class ModManager {
|
||||
|
||||
try {
|
||||
entitiesFile.save(entityFile);
|
||||
mcMMO.p.debug(entity.getType().toString() + " was added to the custom entities file!");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), entity.getType().toString() + " was added to the custom entities file!");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@@ -2,6 +2,7 @@ package com.gmail.nossr50.util.compat;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.compat.layers.bungee.AbstractBungeeSerializerCompatibilityLayer;
|
||||
import com.gmail.nossr50.util.compat.layers.bungee.BungeeLegacySerializerCompatibilityLayer;
|
||||
import com.gmail.nossr50.util.compat.layers.bungee.BungeeModernSerializerCompatibilityLayer;
|
||||
@@ -34,11 +35,11 @@ public class CompatibilityManager {
|
||||
private AbstractMasterAnglerCompatibility masterAnglerCompatibility;
|
||||
|
||||
public CompatibilityManager(@NotNull MinecraftGameVersion minecraftGameVersion) {
|
||||
mcMMO.p.getLogger().info("Loading compatibility layers...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Loading compatibility layers...");
|
||||
this.minecraftGameVersion = minecraftGameVersion;
|
||||
this.nmsVersion = determineNMSVersion();
|
||||
init();
|
||||
mcMMO.p.getLogger().info("Finished loading compatibility layers.");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Finished loading compatibility layers.");
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
@@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -77,7 +78,7 @@ public class ExperienceBarManager {
|
||||
return;
|
||||
|
||||
ExperienceBarHideTask experienceBarHideTask = new ExperienceBarHideTask(this, mcMMOPlayer, primarySkillType);
|
||||
experienceBarHideTask.runTaskLater(plugin, 20L * delaySeconds);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mcMMOPlayer.getPlayer(), experienceBarHideTask, (long) delaySeconds * Misc.TICK_CONVERSION_FACTOR);
|
||||
experienceBarHideTaskHashMap.put(primarySkillType, experienceBarHideTask);
|
||||
}
|
||||
|
||||
|
@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
@@ -224,7 +225,7 @@ public class FormulaManager {
|
||||
* Save formula file.
|
||||
*/
|
||||
public void saveFormula() {
|
||||
mcMMO.p.debug("Saving previous XP formula type...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Saving previous XP formula type...");
|
||||
YamlConfiguration formulasFile = new YamlConfiguration();
|
||||
formulasFile.set("Previous_Formula", previousFormula.toString());
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.util.platform;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.compat.CompatibilityManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -47,7 +48,7 @@ public class PlatformManager {
|
||||
private @NotNull MinecraftGameVersion determineGameVersion(String platformVersionString) {
|
||||
int major = 0, minor = 0, patch = 0;
|
||||
|
||||
mcMMO.p.getLogger().info("Platform String: " + platformVersionString);
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Platform String: " + platformVersionString);
|
||||
|
||||
// Gets two numbers separated by . and optional third number after next dot. Must end with - or _
|
||||
Matcher versionMatch = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?[-_].*").matcher(platformVersionString);
|
||||
@@ -61,7 +62,7 @@ public class PlatformManager {
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Minecraft version determined to be - "
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Minecraft version determined to be - "
|
||||
+ major + "."
|
||||
+ minor + "."
|
||||
+ patch);
|
||||
|
@@ -16,7 +16,6 @@ import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.gmail.nossr50.util.text.McMMOMessageType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
@@ -49,7 +48,9 @@ public class NotificationManager {
|
||||
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
|
||||
return;
|
||||
|
||||
McMMOMessageType destination = mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(notificationType) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
|
||||
McMMOMessageType destination
|
||||
= mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(notificationType)
|
||||
? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
|
||||
|
||||
Component message = TextComponentFactory.getNotificationTextComponentFromLocale(key);
|
||||
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message);
|
||||
@@ -75,7 +76,8 @@ public class NotificationManager {
|
||||
* @param key Locale Key for the string to use with this event
|
||||
* @param values values to be injected into the locale string
|
||||
*/
|
||||
public static void sendNearbyPlayersInformation(Player targetPlayer, NotificationType notificationType, String key, String... values)
|
||||
public static void sendNearbyPlayersInformation(Player targetPlayer, NotificationType notificationType, String key,
|
||||
String... values)
|
||||
{
|
||||
sendPlayerInformation(targetPlayer, notificationType, key, values);
|
||||
}
|
||||
@@ -99,7 +101,8 @@ public class NotificationManager {
|
||||
player.sendMessage(prefixFormattedMessage);
|
||||
}
|
||||
|
||||
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
|
||||
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key,
|
||||
String... values)
|
||||
{
|
||||
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
|
||||
return;
|
||||
@@ -119,24 +122,28 @@ public class NotificationManager {
|
||||
final Audience audience = mcMMO.getAudiences().player(player);
|
||||
|
||||
//If the message is being sent to the action bar we need to check if the copy if a copy is sent to the chat system
|
||||
Component notificationTextComponent = customEvent.getNotificationTextComponent();
|
||||
if(customEvent.getChatMessageType() == McMMOMessageType.ACTION_BAR)
|
||||
{
|
||||
audience.sendActionBar(customEvent.getNotificationTextComponent());
|
||||
audience.sendActionBar(notificationTextComponent);
|
||||
|
||||
if(customEvent.isMessageAlsoBeingSentToChat())
|
||||
{
|
||||
//Send copy to chat system
|
||||
audience.sendMessage(Identity.nil(), customEvent.getNotificationTextComponent(), MessageType.SYSTEM);
|
||||
audience.sendMessage(notificationTextComponent);
|
||||
}
|
||||
} else {
|
||||
audience.sendMessage(Identity.nil(), customEvent.getNotificationTextComponent(), MessageType.SYSTEM);
|
||||
audience.sendMessage(notificationTextComponent);
|
||||
}
|
||||
}
|
||||
|
||||
private static McMMOPlayerNotificationEvent checkNotificationEvent(Player player, NotificationType notificationType, McMMOMessageType destination, Component message) {
|
||||
private static McMMOPlayerNotificationEvent checkNotificationEvent(Player player, NotificationType notificationType,
|
||||
McMMOMessageType destination,
|
||||
Component message) {
|
||||
//Init event
|
||||
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player,
|
||||
notificationType, message, destination, mcMMO.p.getAdvancedConfig().doesNotificationSendCopyToChat(notificationType));
|
||||
notificationType, message, destination,
|
||||
mcMMO.p.getAdvancedConfig().doesNotificationSendCopyToChat(notificationType));
|
||||
|
||||
//Call event
|
||||
Bukkit.getServer().getPluginManager().callEvent(customEvent);
|
||||
@@ -149,15 +156,23 @@ public class NotificationManager {
|
||||
* @param skillName skill that leveled up
|
||||
* @param newLevel new level of that skill
|
||||
*/
|
||||
public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkillType skillName, int levelsGained, int newLevel)
|
||||
public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkillType skillName,
|
||||
int levelsGained, int newLevel)
|
||||
{
|
||||
if(!mcMMOPlayer.useChatNotifications())
|
||||
return;
|
||||
|
||||
McMMOMessageType destination = mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
|
||||
McMMOMessageType destination
|
||||
= mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE)
|
||||
? McMMOMessageType.ACTION_BAR : McMMOMessageType.SYSTEM;
|
||||
|
||||
Component levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(skillName, levelsGained, newLevel);
|
||||
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(mcMMOPlayer.getPlayer(), NotificationType.LEVEL_UP_MESSAGE, destination, levelUpTextComponent);
|
||||
Component levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(
|
||||
skillName, levelsGained, newLevel);
|
||||
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(
|
||||
mcMMOPlayer.getPlayer(),
|
||||
NotificationType.LEVEL_UP_MESSAGE,
|
||||
destination,
|
||||
levelUpTextComponent);
|
||||
|
||||
sendNotification(mcMMOPlayer.getPlayer(), customEvent);
|
||||
}
|
||||
@@ -176,17 +191,12 @@ public class NotificationManager {
|
||||
return;
|
||||
|
||||
//CHAT MESSAGE
|
||||
mcMMO.getAudiences().player(mcMMOPlayer.getPlayer()).sendMessage(Identity.nil(), TextComponentFactory.getSubSkillUnlockedNotificationComponents(mcMMOPlayer.getPlayer(), subSkillType));
|
||||
mcMMO.getAudiences().player(mcMMOPlayer.getPlayer()).sendMessage(Identity.nil(),
|
||||
TextComponentFactory.getSubSkillUnlockedNotificationComponents(mcMMOPlayer.getPlayer(), subSkillType));
|
||||
|
||||
//Unlock Sound Effect
|
||||
SoundManager.sendCategorizedSound(mcMMOPlayer.getPlayer(), mcMMOPlayer.getPlayer().getLocation(), SoundType.SKILL_UNLOCKED, SoundCategory.MASTER);
|
||||
|
||||
//ACTION BAR MESSAGE
|
||||
/*if(mcMMO.p.getAdvancedConfig().doesNotificationUseActionBar(NotificationType.SUBSKILL_UNLOCKED))
|
||||
mcMMOPlayer.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(LocaleLoader.getString("JSON.SkillUnlockMessage",
|
||||
subSkillType.getLocaleName(),
|
||||
String.valueOf(RankUtils.getRank(mcMMOPlayer.getPlayer(),
|
||||
subSkillType)))));*/
|
||||
SoundManager.sendCategorizedSound(mcMMOPlayer.getPlayer(), mcMMOPlayer.getPlayer().getLocation(),
|
||||
SoundType.SKILL_UNLOCKED, SoundCategory.MASTER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +235,8 @@ public class NotificationManager {
|
||||
* @param commandSender the command user
|
||||
* @param sensitiveCommandType type of command issued
|
||||
*/
|
||||
public static void processSensitiveCommandNotification(CommandSender commandSender, SensitiveCommandType sensitiveCommandType, String... args) {
|
||||
public static void processSensitiveCommandNotification(CommandSender commandSender,
|
||||
SensitiveCommandType sensitiveCommandType, String... args) {
|
||||
/*
|
||||
* Determine the 'identity' of the one who executed the command to pass as a parameters
|
||||
*/
|
||||
@@ -233,19 +244,26 @@ public class NotificationManager {
|
||||
|
||||
if(commandSender instanceof Player)
|
||||
{
|
||||
senderName = ((Player) commandSender).getDisplayName() + ChatColor.RESET + "-" + ((Player) commandSender).getUniqueId();
|
||||
senderName = ((Player) commandSender).getDisplayName()
|
||||
+ ChatColor.RESET + "-" + ((Player) commandSender).getUniqueId();
|
||||
}
|
||||
|
||||
//Send the notification
|
||||
switch(sensitiveCommandType)
|
||||
{
|
||||
case XPRATE_MODIFY:
|
||||
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others", addItemToFirstPositionOfArray(senderName, args)));
|
||||
sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", args));
|
||||
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others",
|
||||
addItemToFirstPositionOfArray(senderName, args)));
|
||||
sendAdminCommandConfirmation(
|
||||
commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", args));
|
||||
break;
|
||||
case XPRATE_END:
|
||||
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.End.Others", addItemToFirstPositionOfArray(senderName, args)));
|
||||
sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.End.Self", args));
|
||||
sendAdminNotification(
|
||||
LocaleLoader.getString(
|
||||
"Notifications.Admin.XPRate.End.Others",
|
||||
addItemToFirstPositionOfArray(senderName, args)));
|
||||
sendAdminCommandConfirmation(commandSender,
|
||||
LocaleLoader.getString("Notifications.Admin.XPRate.End.Self", args));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -266,8 +284,6 @@ public class NotificationManager {
|
||||
return newArray;
|
||||
}
|
||||
|
||||
//TODO: Remove the code duplication, am lazy atm
|
||||
//TODO: Fix broadcasts being skipped for situations where a player skips over the milestone like with the addlevels command
|
||||
public static void processLevelUpBroadcasting(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType, int level) {
|
||||
if(level <= 0)
|
||||
return;
|
||||
@@ -290,13 +306,22 @@ public class NotificationManager {
|
||||
.append(Component.newline())
|
||||
.append(Component.text(LocalDate.now().toString()))
|
||||
.append(Component.newline())
|
||||
.append(Component.text(mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType)+" reached level "+level)).color(TextColor.fromHexString(HEX_BEIGE_COLOR))
|
||||
.append(Component.text(
|
||||
mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType)
|
||||
+ " reached level "+level)).color(TextColor.fromHexString(HEX_BEIGE_COLOR))
|
||||
.asHoverEvent();
|
||||
|
||||
String localeMessage = LocaleLoader.getString("Broadcasts.LevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), level, mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType));
|
||||
Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
|
||||
String localeMessage = LocaleLoader.getString(
|
||||
"Broadcasts.LevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), level,
|
||||
mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType));
|
||||
Component component = LegacyComponentSerializer
|
||||
.legacySection()
|
||||
.deserialize(localeMessage)
|
||||
.hoverEvent(levelMilestoneHover);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> audience.sendMessage(Identity.nil(), message), 0);
|
||||
// TODO: Update system msg API
|
||||
mcMMO.p.getFoliaLib().getImpl().runNextTick(
|
||||
t -> audience.sendMessage(component));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,7 +356,7 @@ public class NotificationManager {
|
||||
String localeMessage = LocaleLoader.getString("Broadcasts.PowerLevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), powerLevel);
|
||||
Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> audience.sendMessage(Identity.nil(), message), 0);
|
||||
mcMMO.p.getFoliaLib().getImpl().runNextTick(t -> audience.sendMessage(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.gmail.nossr50.util.player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -85,7 +86,7 @@ public final class UserManager {
|
||||
for (McMMOPlayer playerData : trackedSyncData) {
|
||||
try
|
||||
{
|
||||
mcMMO.p.getLogger().info("Saving data for player: "+playerData.getPlayerName());
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Saving data for player: "+playerData.getPlayerName());
|
||||
playerData.getProfile().save(true);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@@ -9,6 +9,7 @@ import com.gmail.nossr50.events.scoreboard.McMMOScoreboardMakeboardEvent;
|
||||
import com.gmail.nossr50.events.scoreboard.ScoreboardEventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -204,7 +205,7 @@ public class ScoreboardManager {
|
||||
// Called in onDisable()
|
||||
public static void teardownAll() {
|
||||
ImmutableList<Player> onlinePlayers = ImmutableList.copyOf(mcMMO.p.getServer().getOnlinePlayers());
|
||||
mcMMO.p.debug("Tearing down scoreboards... (" + onlinePlayers.size() + ")");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Tearing down scoreboards... (" + onlinePlayers.size() + ")");
|
||||
for (Player player : onlinePlayers) {
|
||||
teardownPlayer(player);
|
||||
}
|
||||
@@ -524,7 +525,7 @@ public class ScoreboardManager {
|
||||
|
||||
if (objective != null) {
|
||||
objective.unregister();
|
||||
mcMMO.p.debug("Removed leftover targetBoard objects from Power Level Tags.");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Removed leftover targetBoard objects from Power Level Tags.");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -12,17 +12,16 @@ import com.gmail.nossr50.events.scoreboard.ScoreboardObjectiveEventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Score;
|
||||
@@ -85,9 +84,9 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public BukkitTask updateTask = null;
|
||||
public WrappedTask updateTask = null;
|
||||
|
||||
private class ScoreboardQuickUpdate extends BukkitRunnable {
|
||||
private class ScoreboardQuickUpdate implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
updateSidebar();
|
||||
@@ -95,9 +94,9 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public BukkitTask revertTask = null;
|
||||
public WrappedTask revertTask = null;
|
||||
|
||||
private class ScoreboardChangeTask extends BukkitRunnable {
|
||||
private class ScoreboardChangeTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
tryRevertBoard();
|
||||
@@ -105,9 +104,9 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public BukkitTask cooldownTask = null;
|
||||
public WrappedTask cooldownTask = null;
|
||||
|
||||
private class ScoreboardCooldownTask extends BukkitRunnable {
|
||||
private class ScoreboardCooldownTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
// Stop updating if it's no longer something displaying cooldowns
|
||||
@@ -124,7 +123,7 @@ public class ScoreboardWrapper {
|
||||
public void doSidebarUpdateSoon() {
|
||||
if (updateTask == null) {
|
||||
// To avoid spamming the scheduler, store the instance and run 2 ticks later
|
||||
updateTask = new ScoreboardQuickUpdate().runTaskLater(mcMMO.p, 2L);
|
||||
updateTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ScoreboardQuickUpdate(), 2L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +131,7 @@ public class ScoreboardWrapper {
|
||||
if (cooldownTask == null) {
|
||||
// Repeat every 5 seconds.
|
||||
// Cancels once all cooldowns are done, using stopCooldownUpdating().
|
||||
cooldownTask = new ScoreboardCooldownTask().runTaskTimer(mcMMO.p, 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR);
|
||||
cooldownTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(player, new ScoreboardCooldownTask(), 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +214,7 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
|
||||
player.setScoreboard(scoreboard);
|
||||
revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks);
|
||||
revertTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ScoreboardChangeTask(), ticks);
|
||||
|
||||
// TODO is there any way to do the time that looks acceptable?
|
||||
// player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase(Locale.ENGLISH)), ticks / 20F));
|
||||
@@ -260,7 +259,7 @@ public class ScoreboardWrapper {
|
||||
oldBoard = null;
|
||||
}
|
||||
else {
|
||||
mcMMO.p.debug("Not reverting targetBoard for " + playerName + " - targetBoard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Not reverting targetBoard for " + playerName + " - targetBoard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,13 +418,13 @@ public class ScoreboardWrapper {
|
||||
} catch (IllegalStateException e) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
mcMMO.p.debug("Recovering scoreboard for player: " + player.getName());
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Recovering scoreboard for player: " + player.getName());
|
||||
|
||||
if(mmoPlayer.isDebugMode())
|
||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(player, "Scoreboard.Recovery");
|
||||
|
||||
initBoard(); //Start over
|
||||
Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> ScoreboardManager.retryLastSkillBoard(player), 0);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntity(player, t -> ScoreboardManager.retryLastSkillBoard(player));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,6 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
@@ -840,7 +839,8 @@ public final class CombatUtils {
|
||||
EntityType type = target.getType();
|
||||
baseXP = ExperienceConfig.getInstance().getAnimalsXP(type);
|
||||
}
|
||||
else if (target instanceof Monster) {
|
||||
else if (target instanceof Monster)
|
||||
{
|
||||
EntityType type = target.getType();
|
||||
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
|
||||
}
|
||||
@@ -887,7 +887,7 @@ public final class CombatUtils {
|
||||
baseXP *= multiplier;
|
||||
|
||||
if (baseXP > 0) {
|
||||
new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason).runTaskLater(mcMMO.p, 0);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntity(mcMMOPlayer.getPlayer(), new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1062,6 +1062,6 @@ public final class CombatUtils {
|
||||
* @param entity the projectile
|
||||
*/
|
||||
public static void delayArrowMetaCleanup(@NotNull Projectile entity) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(mcMMO.p, () -> cleanupArrowMetadata(entity), 20*60);
|
||||
mcMMO.p.getFoliaLib().getImpl().runLater(() -> cleanupArrowMetadata(entity), 20*60);
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public class RankUtils {
|
||||
{
|
||||
SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel);
|
||||
|
||||
skillUnlockNotificationTask.runTaskLater(plugin, (count * 100L));
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mcMMOPlayer.getPlayer(), skillUnlockNotificationTask, (count * 100L));
|
||||
|
||||
count++;
|
||||
}
|
||||
@@ -294,23 +294,6 @@ public class RankUtils {
|
||||
subSkillRanks.computeIfAbsent(s, k -> new HashMap<>());
|
||||
}
|
||||
|
||||
/* public static int getSubSkillUnlockRequirement(SubSkillType subSkillType)
|
||||
{
|
||||
String skillName = subSkillType.toString();
|
||||
int numRanks = subSkillType.getNumRanks();
|
||||
|
||||
if(subSkillRanks == null)
|
||||
subSkillRanks = new HashMap<>();
|
||||
|
||||
if(numRanks == 0)
|
||||
return -1; //-1 Means the skill doesn't have ranks
|
||||
|
||||
if(subSkillRanks.get(skillName) == null && numRanks > 0)
|
||||
addRanks(subSkillType);
|
||||
|
||||
return subSkillRanks.get(subSkillType.toString()).get(1);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Gets the unlock level for a specific rank in a subskill
|
||||
* @param subSkillType The target subskill
|
||||
|
@@ -12,8 +12,6 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
@@ -35,41 +33,37 @@ public class TextComponentFactory {
|
||||
|
||||
/**
|
||||
* Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleLoader
|
||||
*
|
||||
* @param localeKey target locale string address
|
||||
* @param values vars to be passed to the locale loader
|
||||
* @param values vars to be passed to the locale loader
|
||||
* @return
|
||||
*/
|
||||
public static TextComponent getNotificationMultipleValues(String localeKey, String... values)
|
||||
{
|
||||
public static TextComponent getNotificationMultipleValues(String localeKey, String... values) {
|
||||
String preColoredString = LocaleLoader.getString(localeKey, (Object[]) values);
|
||||
return Component.text(preColoredString);
|
||||
}
|
||||
|
||||
public static Component getNotificationTextComponentFromLocale(String localeKey)
|
||||
{
|
||||
public static Component getNotificationTextComponentFromLocale(String localeKey) {
|
||||
return getNotificationTextComponent(LocaleLoader.getString(localeKey));
|
||||
}
|
||||
|
||||
public static Component getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel)
|
||||
{
|
||||
return Component.text(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+ StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
|
||||
public static Component getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel) {
|
||||
return Component.text(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name." + StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
|
||||
}
|
||||
|
||||
private static TextComponent getNotificationTextComponent(String text)
|
||||
{
|
||||
private static TextComponent getNotificationTextComponent(String text) {
|
||||
//textComponent.setColor(getNotificationColor(notificationType));
|
||||
return Component.text(text);
|
||||
}
|
||||
|
||||
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted)
|
||||
{
|
||||
if(!mcMMO.p.getGeneralConfig().getUrlLinksEnabled())
|
||||
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted) {
|
||||
if (!mcMMO.p.getGeneralConfig().getUrlLinksEnabled())
|
||||
return;
|
||||
|
||||
TextComponent.Builder wikiLinkComponent = Component.text().content(LocaleLoader.getString("Overhaul.mcMMO.MmoInfo.Wiki"));
|
||||
wikiLinkComponent.decoration(TextDecoration.UNDERLINED, true);
|
||||
|
||||
String wikiUrl = "https://wiki.mcmmo.org/"+subskillformatted;
|
||||
String wikiUrl = "https://wiki.mcmmo.org/" + subskillformatted;
|
||||
|
||||
wikiLinkComponent.clickEvent(ClickEvent.openUrl(wikiUrl));
|
||||
|
||||
@@ -77,39 +71,40 @@ public class TextComponentFactory {
|
||||
|
||||
wikiLinkComponent.hoverEvent(HoverEvent.showText(componentBuilder.build()));
|
||||
|
||||
mcMMO.getAudiences().player(player).sendMessage(Identity.nil(), wikiLinkComponent, MessageType.SYSTEM);
|
||||
mcMMO.getAudiences().player(player).sendMessage(wikiLinkComponent);
|
||||
}
|
||||
|
||||
public static void sendPlayerUrlHeader(Player player) {
|
||||
TextComponent prefix = Component.text(LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " ");
|
||||
/*prefix.setColor(ChatColor.DARK_AQUA);*/
|
||||
TextComponent suffix = Component.text(" "+LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Suffix"));
|
||||
TextComponent suffix = Component.text(" " + LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Suffix"));
|
||||
/*suffix.setColor(ChatColor.DARK_AQUA);*/
|
||||
|
||||
TextComponent emptySpace = Component.space();
|
||||
|
||||
mcMMO.getAudiences().player(player).sendMessage(Identity.nil(),Component.textOfChildren(
|
||||
prefix,
|
||||
getWebLinkTextComponent(McMMOWebLinks.WEBSITE),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.DISCORD),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.PATREON),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.WIKI),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.SPIGOT),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.HELP_TRANSLATE),
|
||||
suffix
|
||||
), MessageType.SYSTEM);
|
||||
// TODO: Update system msg API
|
||||
mcMMO.getAudiences().player(player).sendMessage(Component.textOfChildren(
|
||||
prefix,
|
||||
getWebLinkTextComponent(McMMOWebLinks.WEBSITE),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.DISCORD),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.PATREON),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.WIKI),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.SPIGOT),
|
||||
emptySpace,
|
||||
getWebLinkTextComponent(McMMOWebLinks.HELP_TRANSLATE),
|
||||
suffix
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a player a bunch of text components that represent a list of sub-skills
|
||||
* Styling and formatting is applied before sending the messages
|
||||
*
|
||||
* @param player target player
|
||||
* @param player target player
|
||||
* @param subSkillComponents the text components representing the sub-skills by name
|
||||
*/
|
||||
public static void sendPlayerSubSkillList(@NotNull Player player, @NotNull List<Component> subSkillComponents) {
|
||||
@@ -129,13 +124,12 @@ public class TextComponentFactory {
|
||||
}
|
||||
|
||||
//Send each group
|
||||
for(Component curLine : individualLinesToSend) {
|
||||
audience.sendMessage(Identity.nil(), curLine);
|
||||
for (Component curLine : individualLinesToSend) {
|
||||
audience.sendMessage(curLine);
|
||||
}
|
||||
}
|
||||
|
||||
private static Component getWebLinkTextComponent(McMMOWebLinks webLinks)
|
||||
{
|
||||
private static Component getWebLinkTextComponent(McMMOWebLinks webLinks) {
|
||||
TextComponent.Builder webTextComponent;
|
||||
|
||||
switch (webLinks) {
|
||||
@@ -178,8 +172,7 @@ public class TextComponentFactory {
|
||||
return webTextComponent.build();
|
||||
}
|
||||
|
||||
private static Component getUrlHoverEvent(McMMOWebLinks webLinks)
|
||||
{
|
||||
private static Component getUrlHoverEvent(McMMOWebLinks webLinks) {
|
||||
TextComponent.Builder componentBuilder = Component.text().content(webLinks.getNiceTitle());
|
||||
|
||||
switch (webLinks) {
|
||||
@@ -232,13 +225,11 @@ public class TextComponentFactory {
|
||||
componentBuilder.append(Component.text(webLinks.getUrl(), NamedTextColor.GRAY, TextDecoration.ITALIC));
|
||||
}
|
||||
|
||||
private static ClickEvent getUrlClickEvent(String url)
|
||||
{
|
||||
private static ClickEvent getUrlClickEvent(String url) {
|
||||
return ClickEvent.openUrl(url);
|
||||
}
|
||||
|
||||
private static Component getSubSkillTextComponent(Player player, SubSkillType subSkillType)
|
||||
{
|
||||
private static Component getSubSkillTextComponent(Player player, SubSkillType subSkillType) {
|
||||
//Get skill name
|
||||
String skillName = subSkillType.getLocaleName();
|
||||
|
||||
@@ -255,8 +246,7 @@ public class TextComponentFactory {
|
||||
return textComponent.build();
|
||||
}
|
||||
|
||||
private static TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
private static TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill) {
|
||||
//String key = abstractSubSkill.getConfigKeyName();
|
||||
String skillName = abstractSubSkill.getNiceName();
|
||||
|
||||
@@ -295,46 +285,37 @@ public class TextComponentFactory {
|
||||
return textComponent;
|
||||
}
|
||||
|
||||
private static Component getSubSkillHoverComponent(Player player, AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
private static Component getSubSkillHoverComponent(Player player, AbstractSubSkill abstractSubSkill) {
|
||||
return getSubSkillHoverEventJSON(abstractSubSkill, player);
|
||||
}
|
||||
|
||||
private static Component getSubSkillHoverComponent(Player player, SubSkillType subSkillType)
|
||||
{
|
||||
private static Component getSubSkillHoverComponent(Player player, SubSkillType subSkillType) {
|
||||
return getSubSkillHoverEventJSON(subSkillType, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for the skill in the new skill system (Deriving from AbstractSubSkill)
|
||||
*
|
||||
* @param abstractSubSkill this subskill
|
||||
* @param player the player who owns this subskill
|
||||
* @param player the player who owns this subskill
|
||||
* @return the hover basecomponent object for this subskill
|
||||
*/
|
||||
private static Component getSubSkillHoverEventJSON(AbstractSubSkill abstractSubSkill, Player player)
|
||||
{
|
||||
private static Component getSubSkillHoverEventJSON(AbstractSubSkill abstractSubSkill, Player player) {
|
||||
String skillName = abstractSubSkill.getNiceName();
|
||||
|
||||
/*
|
||||
* Hover Event BaseComponent color table
|
||||
*/
|
||||
TextColor ccSubSkillHeader = NamedTextColor.GOLD;
|
||||
TextColor ccRank = NamedTextColor.BLUE;
|
||||
TextColor ccCurRank = NamedTextColor.GREEN;
|
||||
TextColor ccPossessive = NamedTextColor.WHITE;
|
||||
//ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE;
|
||||
//ChatColor ccDescription = ChatColor.WHITE;
|
||||
TextColor ccLocked = NamedTextColor.DARK_GRAY;
|
||||
TextColor ccLevelRequirement = NamedTextColor.BLUE;
|
||||
TextColor ccLevelRequired = NamedTextColor.RED;
|
||||
TextColor ccLocked = NamedTextColor.DARK_GRAY;
|
||||
TextColor ccLevelRequirement = NamedTextColor.BLUE;
|
||||
TextColor ccLevelRequired = NamedTextColor.RED;
|
||||
|
||||
SubSkillType subSkillType = abstractSubSkill.getSubSkillType();
|
||||
|
||||
//SubSkillType Name
|
||||
TextComponent.Builder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, abstractSubSkill));
|
||||
|
||||
if(!RankUtils.hasUnlockedSubskill(player, abstractSubSkill))
|
||||
{
|
||||
if (!RankUtils.hasUnlockedSubskill(player, abstractSubSkill)) {
|
||||
//Skill is not unlocked yet
|
||||
addLocked(abstractSubSkill, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
|
||||
} else {
|
||||
@@ -344,12 +325,11 @@ public class TextComponentFactory {
|
||||
int curRank = RankUtils.getRank(player, abstractSubSkill);
|
||||
int nextRank = 0;
|
||||
|
||||
if(curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0)
|
||||
{
|
||||
nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank+1);
|
||||
if (curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0) {
|
||||
nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank + 1);
|
||||
}
|
||||
|
||||
addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank);
|
||||
addRanked(componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank);
|
||||
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.DescriptionHeader")));
|
||||
componentBuilder.append(Component.newline()).append(Component.text(abstractSubSkill.getDescription())).append(Component.newline());
|
||||
@@ -384,17 +364,14 @@ public class TextComponentFactory {
|
||||
return componentBuilder;
|
||||
}
|
||||
|
||||
private static void addRanked(TextColor ccRank, TextColor ccCurRank, TextColor ccPossessive, TextColor ccNumRanks, TextComponent.Builder componentBuilder, int numRanks, int rank, int nextRank) {
|
||||
private static void addRanked(TextComponent.Builder componentBuilder, int numRanks, int rank, int nextRank) {
|
||||
if (numRanks > 0) {
|
||||
//Rank: x
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Hover.Rank", String.valueOf(rank)))).append(Component.newline());
|
||||
|
||||
//Next Rank: x
|
||||
if(nextRank > rank)
|
||||
if (nextRank > rank)
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Hover.NextRank", String.valueOf(nextRank)))).append(Component.newline());
|
||||
|
||||
/*componentBuilder.append(" " + LocaleLoader.getString("JSON.RankPossesive") + " ").color(ccPossessive);
|
||||
componentBuilder.append(String.valueOf(numRanks)).color(ccNumRanks);*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,47 +393,38 @@ public class TextComponentFactory {
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.LevelRequirement") + ": ", ccLevelRequirement));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static Component getSubSkillHoverEventJSON(SubSkillType subSkillType, Player player)
|
||||
{
|
||||
private static Component getSubSkillHoverEventJSON(SubSkillType subSkillType, Player player) {
|
||||
String skillName = subSkillType.getLocaleName();
|
||||
|
||||
/*
|
||||
* Hover Event BaseComponent color table
|
||||
*/
|
||||
TextColor ccSubSkillHeader = NamedTextColor.GOLD;
|
||||
TextColor ccRank = NamedTextColor.BLUE;
|
||||
TextColor ccCurRank = NamedTextColor.GREEN;
|
||||
TextColor ccPossessive = NamedTextColor.WHITE;
|
||||
TextColor ccDescriptionHeader = NamedTextColor.DARK_PURPLE;
|
||||
TextColor ccDescription = NamedTextColor.DARK_GRAY;
|
||||
TextColor ccLocked = NamedTextColor.DARK_GRAY;
|
||||
TextColor ccLevelRequirement = NamedTextColor.BLUE;
|
||||
TextColor ccLevelRequired = NamedTextColor.RED;
|
||||
TextColor ccDescriptionHeader = NamedTextColor.DARK_PURPLE;
|
||||
TextColor ccDescription = NamedTextColor.DARK_GRAY;
|
||||
TextColor ccLocked = NamedTextColor.DARK_GRAY;
|
||||
TextColor ccLevelRequirement = NamedTextColor.BLUE;
|
||||
TextColor ccLevelRequired = NamedTextColor.RED;
|
||||
|
||||
//SubSkillType Name
|
||||
TextComponent.Builder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, subSkillType));
|
||||
|
||||
if(!RankUtils.hasUnlockedSubskill(player, subSkillType))
|
||||
{
|
||||
if (!RankUtils.hasUnlockedSubskill(player, subSkillType)) {
|
||||
//Skill is not unlocked yet
|
||||
addLocked(subSkillType, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
|
||||
} else {
|
||||
//addSubSkillTypeToHoverEventJSON(subSkillType, componentBuilder);
|
||||
|
||||
//RANK
|
||||
if(subSkillType.getNumRanks() > 0)
|
||||
{
|
||||
if (subSkillType.getNumRanks() > 0) {
|
||||
int curRank = RankUtils.getRank(player, subSkillType);
|
||||
int nextRank = 0;
|
||||
|
||||
if(curRank < subSkillType.getNumRanks())
|
||||
{
|
||||
nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank+1);
|
||||
if (curRank < subSkillType.getNumRanks()) {
|
||||
nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank + 1);
|
||||
}
|
||||
|
||||
addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(player, subSkillType), nextRank);
|
||||
|
||||
addRanked(componentBuilder, subSkillType.getNumRanks(),
|
||||
RankUtils.getRank(player, subSkillType), nextRank);
|
||||
}
|
||||
|
||||
componentBuilder.append(Component.newline());
|
||||
@@ -470,55 +438,52 @@ public class TextComponentFactory {
|
||||
return componentBuilder.build();
|
||||
}
|
||||
|
||||
private static void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill, TextComponent.Builder componentBuilder)
|
||||
{
|
||||
if(abstractSubSkill.isSuperAbility())
|
||||
{
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.SuperAbility"), NamedTextColor.LIGHT_PURPLE, TextDecoration.BOLD));
|
||||
} else if(abstractSubSkill.isActiveUse())
|
||||
{
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.Active"), NamedTextColor.DARK_RED, TextDecoration.BOLD));
|
||||
private static void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill,
|
||||
TextComponent.Builder componentBuilder) {
|
||||
if (abstractSubSkill.isSuperAbility()) {
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.SuperAbility"),
|
||||
NamedTextColor.LIGHT_PURPLE, TextDecoration.BOLD));
|
||||
} else if (abstractSubSkill.isActiveUse()) {
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.Active"),
|
||||
NamedTextColor.DARK_RED, TextDecoration.BOLD));
|
||||
} else {
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.Passive"), NamedTextColor.GREEN, TextDecoration.BOLD));
|
||||
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.Type.Passive"),
|
||||
NamedTextColor.GREEN, TextDecoration.BOLD));
|
||||
}
|
||||
|
||||
componentBuilder.append(Component.newline());
|
||||
}
|
||||
|
||||
public static void getSubSkillTextComponents(Player player, List<Component> textComponents, PrimarySkillType parentSkill) {
|
||||
for(SubSkillType subSkillType : SubSkillType.values())
|
||||
{
|
||||
if(subSkillType.getParentSkill() == parentSkill)
|
||||
{
|
||||
public static void getSubSkillTextComponents(Player player, List<Component> textComponents,
|
||||
PrimarySkillType parentSkill) {
|
||||
for (SubSkillType subSkillType : SubSkillType.values()) {
|
||||
if (subSkillType.getParentSkill() == parentSkill) {
|
||||
//TODO: Hacky rewrite later
|
||||
//Only some versions of MC have this skill
|
||||
if(subSkillType == SubSkillType.FISHING_MASTER_ANGLER && mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() == null)
|
||||
if (subSkillType == SubSkillType.FISHING_MASTER_ANGLER
|
||||
&& mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() == null)
|
||||
continue;
|
||||
|
||||
if(Permissions.isSubSkillEnabled(player, subSkillType))
|
||||
{
|
||||
if(!InteractionManager.hasSubSkill(subSkillType))
|
||||
if (Permissions.isSubSkillEnabled(player, subSkillType)) {
|
||||
if (!InteractionManager.hasSubSkill(subSkillType))
|
||||
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, subSkillType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* NEW SKILL SYSTEM */
|
||||
for(AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList())
|
||||
{
|
||||
if(abstractSubSkill.getPrimarySkill() == parentSkill)
|
||||
{
|
||||
if(Permissions.isSubSkillEnabled(player, abstractSubSkill.getSubSkillType()))
|
||||
for (AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList()) {
|
||||
if (abstractSubSkill.getPrimarySkill() == parentSkill) {
|
||||
if (Permissions.isSubSkillEnabled(player, abstractSubSkill.getSubSkillType()))
|
||||
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, abstractSubSkill));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType)
|
||||
{
|
||||
public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType) {
|
||||
TextComponent.Builder unlockMessage = Component.text().content(LocaleLoader.getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(player, subSkillType)));
|
||||
unlockMessage.hoverEvent(HoverEvent.showText(getSubSkillHoverComponent(player, subSkillType)));
|
||||
unlockMessage.clickEvent(ClickEvent.runCommand("/"+subSkillType.getParentSkill().toString().toLowerCase(Locale.ENGLISH)));
|
||||
unlockMessage.clickEvent(ClickEvent.runCommand("/" + subSkillType.getParentSkill().toString().toLowerCase(Locale.ENGLISH)));
|
||||
return unlockMessage.build();
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.gmail.nossr50.util.upgrade;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
@@ -41,7 +42,7 @@ public class UpgradeManager extends BukkitConfig {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.debug("Saving upgrade status for type " + type.toString() + "...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Saving upgrade status for type " + type.toString() + "...");
|
||||
|
||||
config.set("Upgrades_Finished." + type.toString(), true);
|
||||
|
||||
@@ -61,6 +62,6 @@ public class UpgradeManager extends BukkitConfig {
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.debug("Needed upgrades: " + Arrays.toString(setNeededUpgrades.toArray(new UpgradeType[setNeededUpgrades.size()])));
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Needed upgrades: " + Arrays.toString(setNeededUpgrades.toArray(new UpgradeType[setNeededUpgrades.size()])));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user