package me.plugin.commands;
import me.plugin.Main;
import me.plugin.Ultils.Ultils;
import me.plugin.events.BasicEvents;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import static org.bukkit.Bukkit.getServer;
public class Commanders implements CommandExecutor {
private Main plugin;
public void Commands(Main plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("&4Lệnh chỉ dành cho người chơi");
return true;
}
Player p = (Player) sender;
if (cmd.getName().equalsIgnoreCase("heal")) {
if (p.hasPermission(Ultils.chat(plugin.getConfig().getString("Commands.Heal.permissions")))) {
double maxHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue();
p.setHealth(maxHealth);
p.sendMessage(Ultils.chat(plugin.getConfig().getString("Commands.Heal.susses")));
} else {
p.sendMessage(Ultils.chat(plugin.getConfig().getString("Commands.Heal.no_permissions")));
}
}
if (cmd.getName().equalsIgnoreCase("feed")) {
if (p.hasPermission(Ultils.chat(plugin.getConfig().getString("Commands.Feed.permissions")))) {
p.setFoodLevel(20);
p.sendMessage(Ultils.chat(plugin.getConfig().getString("Commands.Feed.susses")));
} else {
p.sendMessage(Ultils.chat(plugin.getConfig().getString("Commands.Feed.no_permissions")));
}
}
if (cmd.getName().equalsIgnoreCase("fly")) {
if (p.hasPermission(Ultils.chat(plugin.getConfig().getString("Commands.Fly.permissions")))) {
if (p.isFlying()) {
p.setAllowFlight(false);
p.setFlying(false);
p.sendMessage(Ultils.chat(plugin.getConfig().getString("Commands.Fly.disable")));
return true;
} else {
p.setAllowFlight(true);
p.setFlying(true);
p.sendMessage(Ultils.chat(plugin.getConfig().getString("Commands.Fly.enable")));
return true;
}
} else {
p.sendMessage(Ultils.chat(plugin.getConfig().getString("Commands.Fly.no_permissions")));
}
}
return false;
}
}