Debug Stick is now replaced by /mmodebug

This commit is contained in:
nossr50
2019-07-02 17:29:33 -07:00
parent 8eeebf63e9
commit 1307169d8b
10 changed files with 86 additions and 21 deletions

View File

@ -23,6 +23,7 @@ public class McmmoCommand implements CommandExecutor {
String description = LocaleLoader.getString("mcMMO.Description");
String[] mcSplit = description.split(",");
sender.sendMessage(mcSplit);
sender.sendMessage(LocaleLoader.getString("mcMMO.Description.FormerDevs"));
if (Config.getInstance().getDonateMessageEnabled()) {
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));

View File

@ -1,13 +0,0 @@
package com.gmail.nossr50.commands.admin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PlayerDebug implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
}

View File

@ -0,0 +1,25 @@
package com.gmail.nossr50.commands.admin;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PlayerDebugCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
mcMMOPlayer.toggleDebugMode(); //Toggle debug mode
NotificationManager.sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode()));
return true;
} else {
return false;
}
}
}

View File

@ -81,6 +81,7 @@ public class McMMOPlayer {
private boolean partyChatMode;
private boolean adminChatMode;
private boolean displaySkillNotifications = true;
private boolean debugMode;
private boolean abilityUse = true;
private boolean godMode;
@ -139,6 +140,8 @@ public class McMMOPlayer {
}
experienceBarManager = new ExperienceBarManager(this);
debugMode = false; //Debug mode helps solve support issues, players can toggle it on or off
}
public String getPlayerName() {
@ -437,6 +440,18 @@ public class McMMOPlayer {
public void togglePartyChatSpying() { chatSpy = !chatSpy;}
/*
* Debug Mode Flags
*/
public boolean isDebugMode() {
return debugMode;
}
public void toggleDebugMode() {
debugMode = !debugMode;
}
/*
* Skill notifications
*/

View File

@ -30,10 +30,7 @@ import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
@ -619,14 +616,16 @@ public class BlockListener implements Listener {
debugStickDump(player, blockState);
}
public void debugStickDump(Player player, BlockState blockState) {
//TODO: Rewrite this
//TODO: Convert into locale strings
private void debugStickDump(Player player, BlockState blockState) {
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
return;
}
if(player.getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK)
if(UserManager.getPlayer(player).isDebugMode())
{
if(mcMMO.getPlaceStore().isTrue(blockState))
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
@ -667,10 +666,12 @@ public class BlockListener implements Listener {
if(ExperienceConfig.getInstance().isExperienceBarsEnabled())
player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled.");
player.sendMessage(ChatColor.RED+"You can turn this debug info off by typing "+ChatColor.GOLD+"/mmodebug");
}
}
public void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) {
private void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) {
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
SkillUtils.removeAbilityBuff(heldItem);

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.util.commands;
import com.gmail.nossr50.commands.*;
import com.gmail.nossr50.commands.admin.McmmoReloadLocaleCommand;
import com.gmail.nossr50.commands.admin.PlayerDebugCommand;
import com.gmail.nossr50.commands.chat.AdminChatCommand;
import com.gmail.nossr50.commands.chat.McChatSpy;
import com.gmail.nossr50.commands.chat.PartyChatCommand;
@ -150,6 +151,15 @@ public final class CommandRegistrationManager {
command.setExecutor(new MmoInfoCommand());
}
private static void registerMmoDebugCommand() {
PluginCommand command = mcMMO.p.getCommand("mmodebug");
command.setDescription(LocaleLoader.getString("Commands.Description.mmodebug"));
command.setPermission(null); //No perm required to save support headaches
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmodebug"));
command.setExecutor(new PlayerDebugCommand());
}
private static void registerMcChatSpyCommand() {
PluginCommand command = mcMMO.p.getCommand("mcchatspy");
command.setDescription(LocaleLoader.getString("Commands.Description.mcchatspy"));
@ -413,6 +423,7 @@ public final class CommandRegistrationManager {
public static void registerCommands() {
// Generic Commands
registerMmoInfoCommand();
registerMmoDebugCommand();
registerMcImportCommand();
registerMcabilityCommand();
registerMcgodCommand();

View File

@ -76,6 +76,16 @@ public class NotificationManager {
player.sendMessage(preColoredString);
}
public static void sendPlayerInformationChatOnlyPrefixed(Player player, String key, String... values)
{
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
return;
String preColoredString = LocaleLoader.getString(key, (Object[]) values);
String prefixFormattedMessage = LocaleLoader.getString("mcMMO.Template.Prefix", preColoredString);
player.sendMessage(prefixFormattedMessage);
}
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
{
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())