Merge branches 'tridentsxbows' and 'master' of github.com:mcMMO-Dev/mcMMO into tridentsxbows

This commit is contained in:
nossr50
2021-03-19 12:35:34 -07:00
10 changed files with 243 additions and 201 deletions

View File

@@ -1,64 +1,64 @@
package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender;
public class HardcoreCommand extends HardcoreModeCommand {
@Override
protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.hardcoreToggle(sender);
}
@Override
protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.hardcoreModify(sender);
}
@Override
protected boolean checkEnabled(PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
if (!primarySkillType.getHardcoreStatLossEnabled()) {
return false;
}
}
return true;
}
return skill.getHardcoreStatLossEnabled();
}
@Override
protected void enable(PrimarySkillType skill) {
toggle(true, skill);
}
@Override
protected void disable(PrimarySkillType skill) {
toggle(false, skill);
}
@Override
protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
private void toggle(boolean enable, PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreStatLossEnabled(enable);
}
}
else {
skill.setHardcoreStatLossEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), (skill == null ? "all skills" : skill.getName())));
}
}
//package com.gmail.nossr50.commands.hardcore;
//
//import com.gmail.nossr50.config.Config;
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
//import com.gmail.nossr50.locale.LocaleLoader;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.Permissions;
//import org.bukkit.command.CommandSender;
//
//public class HardcoreCommand extends HardcoreModeCommand {
// @Override
// protected boolean checkTogglePermissions(CommandSender sender) {
// return Permissions.hardcoreToggle(sender);
// }
//
// @Override
// protected boolean checkModifyPermissions(CommandSender sender) {
// return Permissions.hardcoreModify(sender);
// }
//
// @Override
// protected boolean checkEnabled(PrimarySkillType skill) {
// if (skill == null) {
// for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
// if (!primarySkillType.getHardcoreStatLossEnabled()) {
// return false;
// }
// }
//
// return true;
// }
//
// return skill.getHardcoreStatLossEnabled();
// }
//
// @Override
// protected void enable(PrimarySkillType skill) {
// toggle(true, skill);
// }
//
// @Override
// protected void disable(PrimarySkillType skill) {
// toggle(false, skill);
// }
//
// @Override
// protected void modify(CommandSender sender, double newPercentage) {
// Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
// sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
// }
//
// private void toggle(boolean enable, PrimarySkillType skill) {
// if (skill == null) {
// for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
// primarySkillType.setHardcoreStatLossEnabled(enable);
// }
// }
// else {
// skill.setHardcoreStatLossEnabled(enable);
// }
//
// mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), (skill == null ? "all skills" : skill.getName())));
// }
//}

View File

@@ -1,64 +1,64 @@
package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender;
public class VampirismCommand extends HardcoreModeCommand {
@Override
protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.vampirismToggle(sender);
}
@Override
protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.vampirismModify(sender);
}
@Override
protected boolean checkEnabled(PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
if (!primarySkillType.getHardcoreVampirismEnabled()) {
return false;
}
}
return true;
}
return skill.getHardcoreVampirismEnabled();
}
@Override
protected void enable(PrimarySkillType skill) {
toggle(true, skill);
}
@Override
protected void disable(PrimarySkillType skill) {
toggle(false, skill);
}
@Override
protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
private void toggle(boolean enable, PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreVampirismEnabled(enable);
}
}
else {
skill.setHardcoreVampirismEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
}
}
//package com.gmail.nossr50.commands.hardcore;
//
//import com.gmail.nossr50.config.Config;
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
//import com.gmail.nossr50.locale.LocaleLoader;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.Permissions;
//import org.bukkit.command.CommandSender;
//
//public class VampirismCommand extends HardcoreModeCommand {
// @Override
// protected boolean checkTogglePermissions(CommandSender sender) {
// return Permissions.vampirismToggle(sender);
// }
//
// @Override
// protected boolean checkModifyPermissions(CommandSender sender) {
// return Permissions.vampirismModify(sender);
// }
//
// @Override
// protected boolean checkEnabled(PrimarySkillType skill) {
// if (skill == null) {
// for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
// if (!primarySkillType.getHardcoreVampirismEnabled()) {
// return false;
// }
// }
//
// return true;
// }
//
// return skill.getHardcoreVampirismEnabled();
// }
//
// @Override
// protected void enable(PrimarySkillType skill) {
// toggle(true, skill);
// }
//
// @Override
// protected void disable(PrimarySkillType skill) {
// toggle(false, skill);
// }
//
// @Override
// protected void modify(CommandSender sender, double newPercentage) {
// Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
// sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
// }
//
// private void toggle(boolean enable, PrimarySkillType skill) {
// if (skill == null) {
// for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
// primarySkillType.setHardcoreVampirismEnabled(enable);
// }
// }
// else {
// skill.setHardcoreVampirismEnabled(enable);
// }
//
// mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
// }
//}

View File

@@ -27,7 +27,12 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) {
super(player);
this.skill = skill;
this.skillLevel = mcMMO.getUserManager().getPlayer(player).getSkillLevel(skill);
if(UserManager.getPlayer(player) != null) {
this.skillLevel = mcMMO.getUserManager().getPlayer(player).getSkillLevel(skill);
} else {
this.skillLevel = 0;
}
this.xpGainReason = xpGainReason;
}

View File

@@ -149,6 +149,11 @@ public class mcMMO extends JavaPlugin {
public static FixedMetadataValue metadataValue;
public static final String ULTRA_PERMISSONS = "UltraPermissons";
public static final String UP_WARNING_2 = "Stop using " + ULTRA_PERMISSONS + " with mcMMO immediately!";
public static final String UP_WARNING_1 = "mcMMO has detected " + ULTRA_PERMISSONS + " on your server, users have reported a severe plugin conflict between these two plugins which severely degrades server performance";
public static final String UP_WARNING_3 = "The author of UltraPermissions has passed away and its unlikely this issue will ever be solved";
public mcMMO() {
p = this;
}
@@ -263,6 +268,24 @@ public class mcMMO extends JavaPlugin {
else
metrics.addCustomChart(new SimplePie("leveling_system", () -> "Standard"));
}
//Can't confirm this bug myself as the plugin is premium
// //TODO: Remove this when ChatControlRed fixes itself
// if(pluginManager.getPlugin("ChatControlRed") != null) {
// getLogger().severe("mcMMO has detected ChatControlRed on your server, users have reported a severe plugin conflict between these two plugins which degrades server performance and wastes many server resources.");
// getLogger().severe("It is HIGHLY RECOMMENDED that you do --NOT-- use ChatControlRed until this issue is resolved!");
// }
if(pluginManager.getPlugin(ULTRA_PERMISSONS) != null) {
Bukkit.getScheduler().runTaskTimer(this, () -> {
getLogger().severe(UP_WARNING_1);
getLogger().severe(UP_WARNING_2);
getLogger().severe(UP_WARNING_3);
Bukkit.broadcastMessage(UP_WARNING_1);
Bukkit.broadcastMessage(UP_WARNING_2);
Bukkit.broadcastMessage(UP_WARNING_3);
}, 0L, 1200L);
}
}
catch (Throwable t) {
getLogger().severe("There was an error while enabling mcMMO!");

View File

@@ -7,6 +7,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class SaveTimerTask extends BukkitRunnable {
@Override
public void run() {
mcMMO.p.debug("[User Data] Saving...");
// All player data will be saved periodically through this
int count = 1;

View File

@@ -126,7 +126,12 @@ public final class Permissions {
public static boolean doubleXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.double." + skill.toString().toLowerCase(Locale.ENGLISH)); }
public static boolean oneAndOneHalfXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.50percentboost." + skill.toString().toLowerCase(Locale.ENGLISH)); }
public static boolean oneAndOneTenthXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.10percentboost." + skill.toString().toLowerCase(Locale.ENGLISH)); }
public static boolean customXpBoost(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.customboost." + skill.toString().toLowerCase(Locale.ENGLISH)); }
public static boolean customXpBoost(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.customboost.all")
||permissible.hasPermission("mcmmo.perks.xp.customboost." + skill.toString().toLowerCase(Locale.ENGLISH));
}
/* ACTIVATION PERKS */
public static boolean twelveSecondActivationBoost(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.activationtime.twelveseconds"); }

View File

@@ -11,8 +11,6 @@ import com.gmail.nossr50.commands.experience.AddlevelsCommand;
import com.gmail.nossr50.commands.experience.AddxpCommand;
import com.gmail.nossr50.commands.experience.MmoeditCommand;
import com.gmail.nossr50.commands.experience.SkillresetCommand;
import com.gmail.nossr50.commands.hardcore.HardcoreCommand;
import com.gmail.nossr50.commands.hardcore.VampirismCommand;
import com.gmail.nossr50.commands.party.PartyCommand;
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.commands.player.*;
@@ -369,25 +367,25 @@ public final class CommandRegistrationManager {
command.setExecutor(new PtpCommand());
}
private static void registerHardcoreCommand() {
PluginCommand command = mcMMO.p.getCommand("hardcore");
command.setDescription(LocaleLoader.getString("Commands.Description.hardcore"));
command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "hardcore", "[on|off]"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "hardcore", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
command.setExecutor(new HardcoreCommand());
}
private static void registerVampirismCommand() {
PluginCommand command = mcMMO.p.getCommand("vampirism");
command.setDescription(LocaleLoader.getString("Commands.Description.vampirism"));
command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "vampirism", "[on|off]"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
command.setExecutor(new VampirismCommand());
}
// private static void registerHardcoreCommand() {
// PluginCommand command = mcMMO.p.getCommand("hardcore");
// command.setDescription(LocaleLoader.getString("Commands.Description.hardcore"));
// command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify");
// command.setPermissionMessage(permissionsMessage);
// command.setUsage(LocaleLoader.getString("Commands.Usage.1", "hardcore", "[on|off]"));
// command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "hardcore", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
// command.setExecutor(new HardcoreCommand());
// }
//
// private static void registerVampirismCommand() {
// PluginCommand command = mcMMO.p.getCommand("vampirism");
// command.setDescription(LocaleLoader.getString("Commands.Description.vampirism"));
// command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify");
// command.setPermissionMessage(permissionsMessage);
// command.setUsage(LocaleLoader.getString("Commands.Usage.1", "vampirism", "[on|off]"));
// command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
// command.setExecutor(new VampirismCommand());
// }
private static void registerMcnotifyCommand() {
PluginCommand command = mcMMO.p.getCommand("mcnotify");
@@ -469,8 +467,8 @@ public final class CommandRegistrationManager {
registerSkillresetCommand();
// Hardcore Commands
registerHardcoreCommand();
registerVampirismCommand();
// registerHardcoreCommand();
// registerVampirismCommand();
// Party Commands
registerPartyCommand();

View File

@@ -125,7 +125,8 @@ public class ScoreboardWrapper {
try {
cooldownTask.cancel();
}
catch (Throwable ignored) {
catch (Exception e) {
e.printStackTrace();
}
cooldownTask = null;
@@ -429,8 +430,9 @@ public class ScoreboardWrapper {
try {
updateTask.cancel();
}
catch (Throwable ignored) {
} // catch NullPointerException and IllegalStateException and any Error; don't care
catch (Exception e) {
e.printStackTrace();
}
updateTask = null;