This repository has been archived by the owner on Oct 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lucky-fish
authored and
lucky-fish
committed
Aug 18, 2020
1 parent
fdf3d73
commit 6e99b42
Showing
18 changed files
with
489 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/cn/mcres/luckyfish/antileakaccount/bungee/command/WhiteListCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package cn.mcres.luckyfish.antileakaccount.bungee.command; | ||
|
||
import cn.mcres.luckyfish.antileakaccount.bungee.AntiLeakAccount; | ||
import cn.mcres.luckyfish.antileakaccount.mojang.MojangApiHelper; | ||
import net.md_5.bungee.api.ChatColor; | ||
import net.md_5.bungee.api.CommandSender; | ||
import net.md_5.bungee.api.chat.TextComponent; | ||
import net.md_5.bungee.api.plugin.Command; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public class WhiteListCommand extends Command { | ||
public WhiteListCommand() { | ||
super("alawhitelist", "antileakaccount.whitelist", "awhitelist", "aw"); | ||
} | ||
|
||
@Override | ||
public void execute(CommandSender sender, String[] args) { | ||
switch (args[0]) { | ||
case "add": { | ||
if (args.length != 2) { | ||
sender.sendMessage(new TextComponent("用法:/alawhitelist add <玩家名>")); | ||
break; | ||
} | ||
|
||
if (AntiLeakAccount.getInstance().getWhiteListStorage().addWhitelistPlayer(args[1])) { | ||
sender.sendMessage(new TextComponent(ChatColor.GREEN + "已将" + args[1] + "加入白名单,该玩家不再需要接受黑卡验证")); | ||
} else { | ||
sender.sendMessage(new TextComponent(ChatColor.RED + "你说的" + args[1] + ",她长什么样?")); | ||
} | ||
|
||
break; | ||
} | ||
case "remove": { | ||
if (args.length != 2) { | ||
sender.sendMessage(new TextComponent("用法:/alawhitelist remove <玩家名>")); | ||
break; | ||
} | ||
|
||
if (AntiLeakAccount.getInstance().getWhiteListStorage().removeWhitelistPlayer(args[1])) { | ||
sender.sendMessage(new TextComponent(ChatColor.GREEN + "已将" + args[1] + "移除白名单,该玩家再次需要接受黑卡验证")); | ||
} else { | ||
sender.sendMessage(new TextComponent(ChatColor.RED + "你说的" + args[1] + ",她长什么样?")); | ||
} | ||
break; | ||
} | ||
case "list": { | ||
List<UUID> whiteList = AntiLeakAccount.getInstance().getWhiteListStorage().getWhiteList();; | ||
for (UUID uid : whiteList) { | ||
sender.sendMessage(new TextComponent(ChatColor.YELLOW + "玩家 " + ChatColor.GREEN + MojangApiHelper.getMinecraftNameByUuid(uid) + " - " + uid)); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/cn/mcres/luckyfish/antileakaccount/command/CommandHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package cn.mcres.luckyfish.antileakaccount.command; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CommandHelper { | ||
static List<String> listPlayers(String[] args) { | ||
if (args.length > 1) { | ||
return new ArrayList<>(); | ||
} | ||
|
||
List<String> playerNames = new ArrayList<>(); | ||
|
||
for (Player p : Bukkit.getOnlinePlayers()) { | ||
playerNames.add(p.getName()); | ||
} | ||
|
||
if (args.length == 1) { | ||
playerNames.removeIf((name) -> !name.startsWith(args[0])); | ||
} | ||
|
||
return playerNames; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/cn/mcres/luckyfish/antileakaccount/command/WhiteListAddCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cn.mcres.luckyfish.antileakaccount.command; | ||
|
||
import cn.mcres.luckyfish.antileakaccount.AntiLeakAccount; | ||
import cn.mcres.luckyfish.plugincommons.commands.SubCommandBase; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
|
||
import java.util.List; | ||
|
||
public class WhiteListAddCommand extends SubCommandBase { | ||
@Override | ||
public String getName() { | ||
return "add"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "添加白名单玩家"; | ||
} | ||
|
||
@Override | ||
public String getUsage() { | ||
return "add <玩家名>"; | ||
} | ||
|
||
@Override | ||
public String getPermissionRequired() { | ||
return "antileakaccount.whitelist.add"; | ||
} | ||
|
||
@Override | ||
public boolean execute(CommandSender sender, Command command, String[] args) { | ||
if (args.length != 1) { | ||
return false; | ||
} | ||
|
||
if (AntiLeakAccount.getInstance().getWhiteListStorage().addWhitelistPlayer(args[0])) { | ||
sender.sendMessage(ChatColor.GREEN + "已将" + args[0] + "加入白名单,该玩家不再需要接受黑卡验证"); | ||
} else { | ||
sender.sendMessage(ChatColor.RED + "你说的" + args[0] + ",她长什么样?"); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public List<String> tabComplete(CommandSender sender, String[] args) { | ||
return CommandHelper.listPlayers(args); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/cn/mcres/luckyfish/antileakaccount/command/WhiteListListCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cn.mcres.luckyfish.antileakaccount.command; | ||
|
||
import cn.mcres.luckyfish.antileakaccount.AntiLeakAccount; | ||
import cn.mcres.luckyfish.antileakaccount.mojang.MojangApiHelper; | ||
import cn.mcres.luckyfish.plugincommons.commands.SubCommandBase; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public class WhiteListListCommand extends SubCommandBase { | ||
@Override | ||
public String getName() { | ||
return "list"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "列出所有白名单玩家"; | ||
} | ||
|
||
@Override | ||
public String getUsage() { | ||
return "list"; | ||
} | ||
|
||
@Override | ||
public boolean execute(CommandSender sender, Command command, String[] args) { | ||
if (args.length != 0) { | ||
return false; | ||
} | ||
|
||
List<UUID> whiteList = AntiLeakAccount.getInstance().getWhiteListStorage().getWhiteList();; | ||
for (UUID uid : whiteList) { | ||
sender.sendMessage(ChatColor.YELLOW + "玩家 " + ChatColor.GREEN + MojangApiHelper.getMinecraftNameByUuid(uid) + " - " + uid); | ||
} | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.