- Add the ability to customize game rules per world in config

- Add gamerules argument to /debug
This commit is contained in:
Taah
2022-02-25 01:54:11 -08:00
parent 1b856db297
commit 1333f06dad
6 changed files with 117 additions and 78 deletions

View File

@ -508,6 +508,17 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
return LegacyComponentSerializer.legacyAmpersand().deserialize(s);
}
/**
* Converts a string to a mini message kyori component
*
* @param s The string to convert
* @return A Kyori component
*/
protected Component mmString(String s)
{
return MiniMessage.miniMessage().parse(s);
}
public Rank getLevel()
{
return level;

View File

@ -5,16 +5,20 @@ import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils;
import java.util.List;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "debug", description = "Debug command", usage = "/<command> redis-reset [player]")
import java.util.List;
@CommandParameters(name = "debug", description = "Debug command", usage = "/<command> <redis-reset | gamerules> [player]")
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
public class DebugCMD extends PlexCommand
{
@ -35,6 +39,15 @@ public class DebugCMD extends PlexCommand
}
return componentFromString("Couldn't find player in Redis punishments.");
}
if (args[0].equalsIgnoreCase("gamerules"))
{
for (World world : Bukkit.getWorlds())
{
PlexUtils.commitGameRules(world);
PlexLog.debug("Set gamerules for world: " + world.getName());
}
return mmString("<aqua>Re-applied game all the game rules!");
}
return null;
}