Skip to content

Commit

Permalink
feat(command): implement new java plugin main class
Browse files Browse the repository at this point in the history
  • Loading branch information
jonakls committed Apr 9, 2023
1 parent 76f4939 commit 4fefad2
Showing 1 changed file with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
package com.xism4.sternalboard.commands;

import com.xism4.sternalboard.SternalBoard;
import com.xism4.sternalboard.SternalBoardPlugin;
import com.xism4.sternalboard.managers.animation.AnimationManager;
import com.xism4.sternalboard.utils.TextUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class SternalCommand implements CommandExecutor {

private final SternalBoard core;
private final SternalBoardPlugin plugin;
private FileConfiguration config;

public SternalCommand(SternalBoard plugin) {
this.core = plugin;
public SternalCommand(SternalBoardPlugin plugin) {
this.plugin = plugin;
this.config = plugin.getConfig();
}

@Override
public boolean onCommand(CommandSender sender, Command commands, String label, String[] args){
public boolean onCommand(
@NotNull CommandSender sender,
@NotNull Command commands,
@NotNull String label,
String[] args
){
if (args.length == 0) {
sender.sendMessage(
TextUtils.parseToLegacyColors("&eUse /sternalboard help &fto see more info about the plugin")
Expand Down Expand Up @@ -72,7 +78,7 @@ private void helpSubcommand(CommandSender sender){
private void toggleSubcommand(CommandSender sender) {
if (sender instanceof Player){
if (sender.hasPermission("sternalboard.toggle")){
core.getScoreboardManager().toggle((Player) sender);
plugin.getScoreboardManager().toggle((Player) sender);
return;
}
}
Expand All @@ -81,20 +87,20 @@ private void toggleSubcommand(CommandSender sender) {

private void reloadSubcommand(CommandSender sender) {
if (sender.hasPermission("sternalboard.reload")){
core.reloadConfig();
this.config = core.getConfig();
core.setAnimateScoreboard(config.getBoolean("settings.animated"));
core.getScoreboardManager().reload();
if (core.isAnimationEnabled()) {
core.loadAnimConfig();
if (core.getAnimationManager() != null) {
core.getAnimationManager().reload();
plugin.getRawConfig().reload();
this.config = plugin.getConfig();
plugin.setAnimateScoreboard(config.getBoolean("settings.animated"));
plugin.getScoreboardManager().reload();
if (plugin.isAnimationEnabled()) {
plugin.getRawAnimConfig().reload();
if (plugin.getAnimationManager() != null) {
plugin.getAnimationManager().reload();
} else {
core.setAnimationManager(new AnimationManager());
plugin.setAnimationManager(new AnimationManager(plugin));
}
} else {
if (core.getAnimationManager() != null) {
core.getAnimationManager().reload();
if (plugin.getAnimationManager() != null) {
plugin.getAnimationManager().reload();
}
}
sender.sendMessage(TextUtils.parseToLegacyColors(
Expand Down

0 comments on commit 4fefad2

Please sign in to comment.