Skip to content

Commit

Permalink
got rid of bungee api (yuck)
Browse files Browse the repository at this point in the history
  • Loading branch information
YouHaveTrouble committed Feb 22, 2021
1 parent 8086586 commit e05a841
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import eu.endermite.togglepvp.util.PluginMessages;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;

import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down
41 changes: 15 additions & 26 deletions src/main/java/eu/endermite/togglepvp/commands/PvpToggleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import eu.endermite.togglepvp.TogglePvp;
import eu.endermite.togglepvp.util.CombatTimer;
import eu.endermite.togglepvp.util.PluginMessages;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

Expand All @@ -17,9 +15,8 @@ public static void toggle(CommandSender sender, String[] args) {
Bukkit.getScheduler().runTaskAsynchronously(TogglePvp.getPlugin(), () -> {

if (!sender.hasPermission("togglepvp.command.toggle")) {
String message = TogglePvp.getPlugin().getConfigCache().getNo_permission();
BaseComponent[] component = TextComponent.fromLegacyText(message);
sender.spigot().sendMessage(component);
String message = ChatColor.translateAlternateColorCodes('&', TogglePvp.getPlugin().getConfigCache().getNo_permission());
sender.sendMessage(message);
return;
}

Expand All @@ -40,16 +37,14 @@ public static void toggle(CommandSender sender, String[] args) {
} else {
message = PluginMessages.parseMessage(TogglePvp.getPlugin().getConfigCache().getPvp_disabled());
}
BaseComponent[] component = TextComponent.fromLegacyText(message);
player.spigot().sendMessage(ChatMessageType.CHAT, component);
player.sendMessage(message);
} else {
sender.sendMessage("Try /pvp toggle <player>");
}
} else if (args.length == 2) {
if (!sender.hasPermission("togglepvp.command.toggle.others")) {
String message = TogglePvp.getPlugin().getConfigCache().getNo_permission();
BaseComponent[] component = TextComponent.fromLegacyText(message);
sender.spigot().sendMessage(component);
String message = ChatColor.translateAlternateColorCodes('&', TogglePvp.getPlugin().getConfigCache().getNo_permission());
sender.sendMessage(message);
return;
}

Expand Down Expand Up @@ -86,9 +81,8 @@ public static void toggle(CommandSender sender, String[] args) {

public static void enable(CommandSender sender, String[] args) {
if (!sender.hasPermission("togglepvp.command.toggle")) {
String message = TogglePvp.getPlugin().getConfigCache().getNo_permission();
BaseComponent[] component = TextComponent.fromLegacyText(message);
sender.spigot().sendMessage(component);
String message = ChatColor.translateAlternateColorCodes('&', TogglePvp.getPlugin().getConfigCache().getNo_permission());
sender.sendMessage(message);
return;
}
if (args.length == 1) {
Expand All @@ -100,16 +94,14 @@ public static void enable(CommandSender sender, String[] args) {
}
TogglePvp.getPlugin().getPlayerManager().setPlayerPvpState(player.getUniqueId(), true);
String message = PluginMessages.parseMessage(TogglePvp.getPlugin().getConfigCache().getPvp_enabled());
BaseComponent[] component = TextComponent.fromLegacyText(message);
player.spigot().sendMessage(ChatMessageType.CHAT, component);
player.sendMessage(message);
} else {
sender.sendMessage("Try /pvp enable <player>");
}
} else if (args.length == 2) {
if (!sender.hasPermission("togglepvp.command.toggle.others")) {
String message = TogglePvp.getPlugin().getConfigCache().getNo_permission();
BaseComponent[] component = TextComponent.fromLegacyText(message);
sender.spigot().sendMessage(component);
String message = ChatColor.translateAlternateColorCodes('&', TogglePvp.getPlugin().getConfigCache().getNo_permission());
sender.sendMessage(message);
return;
}
if (sender instanceof Player) {
Expand Down Expand Up @@ -138,9 +130,8 @@ public static void enable(CommandSender sender, String[] args) {

public static void disable(CommandSender sender, String[] args) {
if (!sender.hasPermission("togglepvp.command.toggle")) {
String message = TogglePvp.getPlugin().getConfigCache().getNo_permission();
BaseComponent[] component = TextComponent.fromLegacyText(message);
sender.spigot().sendMessage(component);
String message = ChatColor.translateAlternateColorCodes('&', TogglePvp.getPlugin().getConfigCache().getNo_permission());
sender.sendMessage(message);
return;
}
if (args.length == 1) {
Expand All @@ -152,16 +143,14 @@ public static void disable(CommandSender sender, String[] args) {
}
TogglePvp.getPlugin().getPlayerManager().setPlayerPvpState(player.getUniqueId(), false);
String message = PluginMessages.parseMessage(TogglePvp.getPlugin().getConfigCache().getPvp_disabled());
BaseComponent[] component = TextComponent.fromLegacyText(message);
player.spigot().sendMessage(ChatMessageType.CHAT, component);
player.sendMessage(message);
} else {
sender.sendMessage("Try /pvp disable <player>");
}
} else if (args.length == 2) {
if (!sender.hasPermission("togglepvp.command.toggle.others")) {
String message = TogglePvp.getPlugin().getConfigCache().getNo_permission();
BaseComponent[] component = TextComponent.fromLegacyText(message);
sender.spigot().sendMessage(component);
sender.sendMessage(message);
return;
}
if (sender instanceof Player) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package eu.endermite.togglepvp.commands;

import eu.endermite.togglepvp.TogglePvp;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

public class ReloadCommand {
Expand All @@ -12,9 +11,8 @@ public static void reload(CommandSender sender) {

Bukkit.getScheduler().runTaskAsynchronously(TogglePvp.getPlugin(), () -> {
if (!sender.hasPermission("togglepvp.command.reload")) {
String message = TogglePvp.getPlugin().getConfigCache().getNo_permission();
BaseComponent[] component = TextComponent.fromLegacyText(message);
sender.spigot().sendMessage(component);
String message = ChatColor.translateAlternateColorCodes('&', TogglePvp.getPlugin().getConfigCache().getNo_permission());
sender.sendMessage(message);
return;
}
TogglePvp.getPlugin().reloadPluginConfig(sender);
Expand Down

0 comments on commit e05a841

Please sign in to comment.