mirror of
https://github.com/darverdevs/Uranium.git
synced 2024-12-21 14:44:10 -08:00
feat(commands): add ip, uranium & vanish commands
This commit is contained in:
parent
c5ebf307d9
commit
e297420bc9
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import uranium.commands.*;
|
||||
import uranium.listeners.*;
|
||||
import uranium.tasks.IPCheck;
|
||||
import uranium.user.*;
|
||||
|
@ -35,7 +36,12 @@ public class Main extends JavaPlugin implements PluginMessageListener {
|
|||
}
|
||||
|
||||
private void setupCommands() {
|
||||
|
||||
getCommand("ubanip").setExecutor(new BanIP(this));
|
||||
getCommand("ip").setExecutor(new IP(this));
|
||||
getCommand("domain").setExecutor(new Domain(this));
|
||||
getCommand("vanish").setExecutor(new Vanish(this));
|
||||
getCommand("uranium").setExecutor(new Uranium(this));
|
||||
getCommand("commandspy").setExecutor(new CommandSpy(this));
|
||||
}
|
||||
|
||||
private void setupTasks() {
|
||||
|
|
58
src/main/java/uranium/commands/IP.java
Normal file
58
src/main/java/uranium/commands/IP.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package uranium.commands;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import uranium.Main;
|
||||
import uranium.user.User;
|
||||
import uranium.user.UserManager;
|
||||
import uranium.util.StringUtil;
|
||||
|
||||
public class IP implements CommandExecutor {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public IP(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(StringUtil.cc(plugin.getConfig().getString("prefix") + "&cThis command can only be used in-game."));
|
||||
return true;
|
||||
}
|
||||
User user = UserManager.getUser((Player) sender);
|
||||
|
||||
if (!user.hasPermission("uranium.ip")) {
|
||||
user.sendMessage(plugin.getConfig().getString("prefix") + "&cYou do not have permission to use this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
user.sendMessage(plugin.getConfig().getString("prefix") + "&cUsage: /ip <player>");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
User targetUser;
|
||||
if (target == null) {
|
||||
user.sendMessage(plugin.getConfig().getString("prefix") + "&cPlayer " + args[0] + " is not online.");
|
||||
return true;
|
||||
}
|
||||
targetUser = UserManager.getUser(target);
|
||||
|
||||
String ip = targetUser.getIP();
|
||||
if (ip == null) {
|
||||
user.sendMessage(plugin.getConfig().getString("prefix") + "&c" + target.getName() + "'s IP has not been detected yet.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ip = (user.hasPermission("uranium.ip.full")
|
||||
? ip
|
||||
: ip.substring(0, ip.length() / 2) + Strings.repeat("*", Math.round((float) ip.length() / 2)));
|
||||
user.sendMessage(plugin.getConfig().getString("prefix") + "&a" + target.getName() + "&7's IP is &a" + ip + "&7.");
|
||||
return true;
|
||||
}
|
||||
}
|
38
src/main/java/uranium/commands/Uranium.java
Normal file
38
src/main/java/uranium/commands/Uranium.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package uranium.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import uranium.Main;
|
||||
import uranium.user.User;
|
||||
import uranium.user.UserManager;
|
||||
import uranium.util.StringUtil;
|
||||
|
||||
public class Uranium implements CommandExecutor {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public Uranium(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.reloadConfig();
|
||||
sender.sendMessage(StringUtil.cc(plugin.getConfig().getString("prefix") + "The configuration file has been reloaded."));
|
||||
return true;
|
||||
}
|
||||
|
||||
User user = UserManager.getUser((Player) sender);
|
||||
if (!user.hasPermission("uranium.reload")) {
|
||||
user.sendMessage(plugin.getConfig().getString("prefix") + "&cYou do not have permission to use this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.reloadConfig();
|
||||
user.sendMessage(plugin.getConfig().getString("prefix") + "The configuration file has been reloaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
38
src/main/java/uranium/commands/Vanish.java
Normal file
38
src/main/java/uranium/commands/Vanish.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package uranium.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import uranium.Main;
|
||||
import uranium.user.User;
|
||||
import uranium.user.UserManager;
|
||||
import uranium.util.StringUtil;
|
||||
|
||||
public class Vanish implements CommandExecutor {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public Vanish(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(StringUtil.cc(plugin.getConfig().getString("prefix") + "&cThis command can only be used in-game."));
|
||||
return true;
|
||||
}
|
||||
|
||||
User user = UserManager.getUser((Player) sender);
|
||||
|
||||
if (!user.hasPermission("uranium.vanish")) {
|
||||
user.sendMessage(plugin.getConfig().getString("prefix") + "&cYou do not have permission to use this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
user.setVanished(!user.isVanished());
|
||||
user.sendMessage(plugin.getConfig().getString("prefix") + "You have " + (user.isVanished() ? "enabled" : "disabled") + " &aVanish&7.");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -49,7 +49,7 @@ public class CommandListener implements Listener {
|
|||
User user = UserManager.getUser(event.getPlayer());
|
||||
String message = event.getMessage();
|
||||
|
||||
if (user.hasPermission("uranium.commandspy")) return;
|
||||
if (user.hasPermission("uranium.commandspy.exempt")) return;
|
||||
UserManager.getUsers().forEach((u) -> {
|
||||
if (u.isCommandSpy())
|
||||
u.sendMessage(plugin.getConfig().getString("prefix") + "&e" + user.getName() + ": " + message);
|
||||
|
|
Loading…
Reference in New Issue
Block a user