版本更新至:3.825

新增:/tlib tagprefix 设置头顶前缀称号
新增:/tlib tagsuffix 设置头顶后缀称号
新增:/tlib tagdelete 删除头顶称号
新增:TagManager 工具新增方法 removeData() 用于删除玩家数据
This commit is contained in:
坏黑 2018-03-19 23:38:30 +08:00
parent 6aa5dbc5bd
commit a4381c39bc
7 changed files with 169 additions and 2 deletions

View File

@ -6,7 +6,7 @@ website: http://www.15imc.com/index.html
main: me.skymc.taboolib.Main main: me.skymc.taboolib.Main
version: 3.81 version: 3.825
commands: commands:
taboolib: taboolib:

View File

@ -22,6 +22,9 @@ import me.skymc.taboolib.commands.sub.ItemCommand;
import me.skymc.taboolib.commands.sub.PotionCommand; import me.skymc.taboolib.commands.sub.PotionCommand;
import me.skymc.taboolib.commands.sub.SaveCommand; import me.skymc.taboolib.commands.sub.SaveCommand;
import me.skymc.taboolib.commands.sub.SlotCommand; import me.skymc.taboolib.commands.sub.SlotCommand;
import me.skymc.taboolib.commands.sub.TagDeleteCommand;
import me.skymc.taboolib.commands.sub.TagPrefixCommand;
import me.skymc.taboolib.commands.sub.TagSuffixCommand;
import me.skymc.taboolib.commands.sub.VariableGetCommand; import me.skymc.taboolib.commands.sub.VariableGetCommand;
import me.skymc.taboolib.commands.sub.VariableSetCommand; import me.skymc.taboolib.commands.sub.VariableSetCommand;
import me.skymc.taboolib.commands.sub.cycle.CycleCommand; import me.skymc.taboolib.commands.sub.cycle.CycleCommand;
@ -88,6 +91,15 @@ public class MainCommands implements CommandExecutor{
else if (args[0].equalsIgnoreCase("sounds")) { else if (args[0].equalsIgnoreCase("sounds")) {
new SoundsCommand(sender, args); new SoundsCommand(sender, args);
} }
else if (args[0].equalsIgnoreCase("tagprefix")) {
new TagPrefixCommand(sender, args);
}
else if (args[0].equalsIgnoreCase("tagsuffix")) {
new TagSuffixCommand(sender, args);
}
else if (args[0].equalsIgnoreCase("tagdelete")) {
new TagDeleteCommand(sender, args);
}
else { else {
MsgUtils.send(sender, "&4指令错误"); MsgUtils.send(sender, "&4指令错误");
} }

View File

@ -44,6 +44,10 @@ public class HelpCommand extends SubCommand {
helps.put("§f", null); helps.put("§f", null);
helps.put("/taboolib shell load §8[§7名称§8]", "§e载入某个脚本"); helps.put("/taboolib shell load §8[§7名称§8]", "§e载入某个脚本");
helps.put("/taboolib shell unload §8[§7名称§8]", "§e卸载某个脚本"); helps.put("/taboolib shell unload §8[§7名称§8]", "§e卸载某个脚本");
helps.put("§g", null);
helps.put("/taboolib tagprefix §8[§7名称§8] §8[§7文本§8]", "§e设置玩家头顶前缀");
helps.put("/taboolib tagsuffix §8[§7名称§8] §8[§7文本§8]", "§e设置玩家头顶后缀");
helps.put("/taboolib tagdelete §8[§7名称§8]", "§e删除玩家称号数据");
helps.put("§e", null); helps.put("§e", null);
helps.put("/taboolib importdata", "§4向数据库导入本地数据 §8(该操作将会清空数据库)"); helps.put("/taboolib importdata", "§4向数据库导入本地数据 §8(该操作将会清空数据库)");

View File

@ -0,0 +1,41 @@
package me.skymc.taboolib.commands.sub;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.clip.placeholderapi.PlaceholderAPI;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.team.TagManager;
/**
* @author sky
* @since 2018-03-19 23:13:35
*/
public class TagDeleteCommand extends SubCommand {
/**
* @param sender
* @param args
*/
public TagDeleteCommand(CommandSender sender, String[] args) {
super(sender, args);
if (args.length < 2) {
MsgUtils.send(sender, "参数错误");
return;
}
Player player = Bukkit.getPlayerExact(args[1]);
if (player == null) {
MsgUtils.send(sender, "玩家 &f" + args[1] + " &7不在线");
return;
}
TagManager.getInst().removeData(player);
if (sender instanceof Player) {
MsgUtils.send(sender, "删除玩家 &f" + args[1] + " &7的称号数据");
}
}
}

View File

@ -0,0 +1,46 @@
package me.skymc.taboolib.commands.sub;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.clip.placeholderapi.PlaceholderAPI;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.team.TagManager;
/**
* @author sky
* @since 2018-03-19 23:13:35
*/
public class TagPrefixCommand extends SubCommand {
/**
* @param sender
* @param args
*/
public TagPrefixCommand(CommandSender sender, String[] args) {
super(sender, args);
if (args.length < 3) {
MsgUtils.send(sender, "参数错误");
return;
}
Player player = Bukkit.getPlayerExact(args[1]);
if (player == null) {
MsgUtils.send(sender, "玩家 &f" + args[1] + " &7不在线");
return;
}
String value = getArgs(2).replace("&", "§");
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
value = PlaceholderAPI.setPlaceholders(player, value);
}
TagManager.getInst().setPrefix(player, value);
if (sender instanceof Player) {
MsgUtils.send(sender, "设置玩家 &f" + args[1] + " &7的前缀为 &f" + value);
}
}
}

View File

@ -0,0 +1,46 @@
package me.skymc.taboolib.commands.sub;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.clip.placeholderapi.PlaceholderAPI;
import me.skymc.taboolib.commands.SubCommand;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.team.TagManager;
/**
* @author sky
* @since 2018-03-19 23:13:35
*/
public class TagSuffixCommand extends SubCommand {
/**
* @param sender
* @param args
*/
public TagSuffixCommand(CommandSender sender, String[] args) {
super(sender, args);
if (args.length < 3) {
MsgUtils.send(sender, "参数错误");
return;
}
Player player = Bukkit.getPlayerExact(args[1]);
if (player == null) {
MsgUtils.send(sender, "玩家 &f" + args[1] + " &7不在线");
return;
}
String value = getArgs(2).replace("&", "§");
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
value = PlaceholderAPI.setPlaceholders(player, value);
}
TagManager.getInst().setSuffix(player, value);
if (sender instanceof Player) {
MsgUtils.send(sender, "设置玩家 &f" + args[1] + " &7的后缀为 &f" + value);
}
}
}

View File

@ -96,6 +96,24 @@ public class TagManager implements Listener {
return data; return data;
} }
/**
* 删除该玩家的称号数据
*
* @param player
*/
public void removeData(Player player) {
playerdata.remove(player.getName());
for (Player _player : Bukkit.getOnlinePlayers()) {
Scoreboard scoreboard = _player.getScoreboard();
if (scoreboard != null) {
Team team = scoreboard.getTeam(player.getName());
if (team != null) {
team.unregister();
}
}
}
}
/** /**
* 将该玩家的数据向服务器所有玩家更新 * 将该玩家的数据向服务器所有玩家更新
* *
@ -162,7 +180,7 @@ public class TagManager implements Listener {
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent e) { public void onQuit(PlayerQuitEvent e) {
playerdata.remove(e.getPlayer().getName()); removeData(e.getPlayer());
} }
static class PlayerData { static class PlayerData {