auto commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.alttd.chat.commands;
|
||||
|
||||
import com.alttd.chat.ChatPlugin;
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Ignore implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) { // must be a player
|
||||
return true;
|
||||
}
|
||||
if(args.length > 1) return false; // todo error message or command info
|
||||
String targetName = args[0];
|
||||
Player targetPlayer = Bukkit.getPlayer(targetName);
|
||||
if(targetPlayer == null) { // can't ignore offline players
|
||||
//sender.sendMessage("Target not found..."); // TODO load from config and minimessage
|
||||
return false;
|
||||
}
|
||||
if(targetPlayer.hasPermission("chat.ignorebypass")) {
|
||||
sender.sendMessage("You can't ignore this player"); // TODO load from config and minimessage
|
||||
return false;
|
||||
}
|
||||
UUID target = targetPlayer.getUniqueId();
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(((Player) sender).getUniqueId());
|
||||
if(!chatUser.getIgnoredPlayers().contains(target)) {
|
||||
chatUser.addIgnoredPlayers(target);
|
||||
Queries.ignoreUser(((Player) sender).getUniqueId(), target);
|
||||
sender.sendMessage("You have turned ignored " + targetName + "."); // TODO load from config and minimessage
|
||||
} else {
|
||||
sender.sendMessage("You have already ignored " + targetName + "."); // TODO load from config and minimessage
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.alttd.chat.commands;
|
||||
|
||||
import com.alttd.chat.ChatPlugin;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Mail implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) { // must be a player, @teri should console be able to /msg?
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if(args.length > 2) return false; // todo error message or command info
|
||||
|
||||
String message = StringUtils.join(args, " ", 1, args.length);
|
||||
ChatPlugin.getInstance().getChatHandler().privateMessage(player, args[0], message);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,11 +11,11 @@ public class Message implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) { // must be a player, @teri should console be able to /msg?
|
||||
if(!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if(args.length > 2) return false; // todo error message or command info
|
||||
if(args.length < 2) return false; // todo error message or command info
|
||||
|
||||
String message = StringUtils.join(args, " ", 1, args.length);
|
||||
ChatPlugin.getInstance().getChatHandler().privateMessage(player, args[0], message);
|
||||
|
||||
@@ -13,7 +13,7 @@ public class Reply implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) { // must be a player, @teri should console be able to /msg?
|
||||
if(!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.alttd.chat.commands;
|
||||
|
||||
import com.alttd.chat.ChatPlugin;
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -24,9 +26,10 @@ public class ToggleGlobalChat implements CommandExecutor {
|
||||
public void run() {
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(((Player) sender).getUniqueId());
|
||||
chatUser.toggleGc();
|
||||
sender.sendMessage("You have turned globalchat " + (chatUser.isGcOn() ? "<green>on." : "<red>off.")); // TODO load from config and minimessage
|
||||
Queries.setGlobalChatState(chatUser.isGcOn(), chatUser.getUuid());
|
||||
sender.sendMessage(MiniMessage.get().parse("You have turned globalchat " + (chatUser.isGcOn() ? "<green>on." : "<red>off."))); // TODO load from config and minimessage
|
||||
}
|
||||
}.runTask(ChatPlugin.getInstance());
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.alttd.chat.commands;
|
||||
|
||||
import com.alttd.chat.ChatPlugin;
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Unignore implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) { // must be a player
|
||||
return true;
|
||||
}
|
||||
if(args.length > 1) return false; // todo error message or command info
|
||||
String targetName = args[0];
|
||||
UUID target = Bukkit.getOfflinePlayer(targetName).getUniqueId();
|
||||
if(target == null) {
|
||||
//sender.sendMessage("Target not found..."); // TODO load from config and minimessage
|
||||
return false;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(((Player) sender).getUniqueId());
|
||||
if(chatUser.getIgnoredPlayers().contains(target)) {
|
||||
chatUser.removeIgnoredPlayers(target);
|
||||
Queries.ignoreUser(((Player) sender).getUniqueId(), target);
|
||||
sender.sendMessage("You no longer ignore " + targetName + "."); // TODO load from config and minimessage
|
||||
} else {
|
||||
sender.sendMessage("You don't have " + targetName + " ignored."); // TODO load from config and minimessage
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user