Skip to content

Commit

Permalink
Merge pull request #91 from UltiKits/alpha
Browse files Browse the repository at this point in the history
Release 6.0.6
  • Loading branch information
wisdommen authored Jan 19, 2024
2 parents 1cdee5c + 73be22d commit ca5dd6b
Show file tree
Hide file tree
Showing 84 changed files with 1,093 additions and 741 deletions.
4 changes: 2 additions & 2 deletions BasicFunctions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ultikits.plugins</groupId>
<artifactId>BasicFunctions</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>com.ultikits</groupId>
<artifactId>UltiTools-API</artifactId>
<version>6.0.5</version>
<version>6.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package com.ultikits.plugins;
package com.ultikits.plugins.basic;

import com.ultikits.plugins.commands.*;
import com.ultikits.plugins.config.BasicConfig;
import com.ultikits.plugins.config.JoinWelcomeConfig;
import com.ultikits.plugins.config.PlayerNameTagConfig;
import com.ultikits.plugins.config.WarpConfig;
import com.ultikits.plugins.listeners.*;
import com.ultikits.plugins.services.WarpService;
import com.ultikits.plugins.tasks.NamePrefixSuffixTask;
import com.ultikits.plugins.basic.commands.*;
import com.ultikits.plugins.basic.config.BasicConfig;
import com.ultikits.plugins.basic.config.PlayerNameTagConfig;
import com.ultikits.plugins.basic.config.WarpConfig;
import com.ultikits.plugins.basic.listeners.*;
import com.ultikits.plugins.basic.services.WarpService;
import com.ultikits.plugins.basic.tasks.NamePrefixSuffixTask;
import com.ultikits.plugins.basic.utils.BlueMapUtils;
import com.ultikits.ultitools.UltiTools;
import com.ultikits.ultitools.abstracts.AbstractConfigEntity;
import com.ultikits.ultitools.abstracts.UltiToolsPlugin;
import com.ultikits.ultitools.annotations.UltiToolsModule;
import de.bluecolored.bluemap.api.BlueMapAPI;
import lombok.Getter;

import java.util.Arrays;
Expand Down Expand Up @@ -69,10 +67,8 @@ public boolean registerSelf() {
getCommandManager().register(this, WarpCommands.class);
WarpConfig warpConfig = getConfigManager().getConfigEntity(this, WarpConfig.class);
if (warpConfig.isEnableBlueMap()) {
BlueMapAPI.onEnable(api -> {
WarpService warpService = getContext().getBean(WarpService.class);
warpService.initBlueMap();
});
WarpService warpService = getContext().getBean(WarpService.class);
BlueMapUtils.initBlueMap(warpService.getAllWarps());
}
}
if (configEntity.isEnableSpawn()) {
Expand Down Expand Up @@ -101,13 +97,4 @@ public boolean registerSelf() {
public List<String> supported() {
return Arrays.asList("zh", "en");
}

@Override
public List<AbstractConfigEntity> getAllConfigs() {
return Arrays.asList(
new BasicConfig("config/config.yml"),
new JoinWelcomeConfig("config/join.yml"),
new PlayerNameTagConfig("config/title.yml")
);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.listeners.BackListener;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.plugins.basic.listeners.BackListener;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.CmdExecutor;
import com.ultikits.ultitools.annotations.command.CmdMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.services.BanPlayerService;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.plugins.basic.services.BanPlayerService;
import com.ultikits.plugins.basic.suggests.CommonSuggest;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.*;
import org.bukkit.Bukkit;
Expand All @@ -10,24 +11,28 @@
import org.springframework.beans.factory.annotation.Autowired;


@CmdSuggest({CommonSuggest.class})
@CmdTarget(CmdTarget.CmdTargetType.BOTH)
@CmdExecutor(permission = "ultikits.ban.command.all", description = "封禁功能", alias = {"uban"}, manualRegister = true)
public class BanCommands extends AbstractCommendExecutor {
@Autowired
private BanPlayerService banPlayerService;

@CmdMapping(format = "ban <player> <reason>")
public void banPlayer(@CmdSender CommandSender sender, @CmdParam("player") String player, @CmdParam("reason") String reason) {
public void banPlayer(@CmdSender CommandSender sender,
@CmdParam(value = "player", suggest = "suggestPlayer") String player,
@CmdParam(value = "reason", suggest = "[原因]") String reason) {
OfflinePlayer kickedPlayer = Bukkit.getOfflinePlayer(player);
banPlayerService.banPlayer(kickedPlayer, sender.getName(), reason);
if (kickedPlayer.isOnline()) {
if (kickedPlayer.getPlayer() != null) {
kickedPlayer.getPlayer().kickPlayer(String.format(BasicFunctions.getInstance().i18n("你已被封禁! 原因: %s"), reason));
}
sender.sendMessage(BasicFunctions.getInstance().i18n("§a封禁成功"));
}

@CmdMapping(format = "unban <player>")
public void unBanPlayer(@CmdSender CommandSender sender, @CmdParam("player") String player) {
public void unBanPlayer(@CmdSender CommandSender sender,
@CmdParam(value = "player", suggest = "suggestPlayer") String player) {
banPlayerService.unBanPlayer(Bukkit.getOfflinePlayer(player));
sender.sendMessage(BasicFunctions.getInstance().i18n("§a解封成功"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.CmdExecutor;
import com.ultikits.ultitools.annotations.command.CmdMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.CmdExecutor;
import com.ultikits.ultitools.annotations.command.CmdMapping;
Expand All @@ -16,25 +16,25 @@
public class GMChangeCommand extends AbstractCommendExecutor {

@CmdMapping(format = "0", permission = "ultikits.tools.command.gm.0")
public void changeGameMode0(@CmdSender Player player, String mode) {
public void changeGameMode0(@CmdSender Player player) {
player.setGameMode(GameMode.SURVIVAL);
player.sendMessage(ChatColor.YELLOW + String.format(BasicFunctions.getInstance().i18n("你的游戏模式已设置为%s"), BasicFunctions.getInstance().i18n("生存模式")));
}

@CmdMapping(format = "1", permission = "ultikits.tools.command.gm.1")
public void changeGameMode1(@CmdSender Player player, String mode) {
public void changeGameMode1(@CmdSender Player player) {
player.setGameMode(GameMode.CREATIVE);
player.sendMessage(ChatColor.YELLOW + String.format(BasicFunctions.getInstance().i18n("你的游戏模式已设置为%s"), BasicFunctions.getInstance().i18n("创造模式")));
}

@CmdMapping(format = "2", permission = "ultikits.tools.command.gm.2")
public void changeGameMode2(@CmdSender Player player, String mode) {
public void changeGameMode2(@CmdSender Player player) {
player.setGameMode(GameMode.ADVENTURE);
player.sendMessage(ChatColor.YELLOW + String.format(BasicFunctions.getInstance().i18n("你的游戏模式已设置为%s"), BasicFunctions.getInstance().i18n("冒险模式")));
}

@CmdMapping(format = "3", permission = "ultikits.tools.command.gm.3")
public void changeGameMode3(@CmdSender Player player, String mode) {
public void changeGameMode3(@CmdSender Player player) {
player.setGameMode(GameMode.SPECTATOR);
player.sendMessage(ChatColor.YELLOW + String.format(BasicFunctions.getInstance().i18n("你的游戏模式已设置为%s"), BasicFunctions.getInstance().i18n("旁观模式")));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.CmdExecutor;
import com.ultikits.ultitools.annotations.command.CmdMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.ultitools.UltiTools;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.CmdExecutor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.*;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;

import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import static com.ultikits.ultitools.utils.MessageUtils.coloredMsg;

Expand All @@ -21,7 +22,7 @@
public class LoreCommands extends AbstractCommendExecutor {

@CmdMapping(format = "add <lore...>")
public void addLore(@CmdSender Player player, @CmdParam("lore...") String[] lore) {
public void addLore(@CmdSender Player player, @CmdParam(value = "lore...", suggest = "[内容]") String[] lore) {
ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType() == Material.AIR) {
player.sendMessage(ChatColor.RED + BasicFunctions.getInstance().i18n("请手持物品来修改Lore"));
Expand All @@ -41,7 +42,7 @@ public void addLore(@CmdSender Player player, @CmdParam("lore...") String[] lore
}

@CmdMapping(format = "delete <position>")
public void deleteLore(@CmdSender Player player, @CmdParam("position") int position) {
public void deleteLore(@CmdSender Player player, @CmdParam(value = "position", suggest = "positionSuggest()") int position) {
ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType() == Material.AIR) {
player.sendMessage(ChatColor.RED + BasicFunctions.getInstance().i18n("请手持物品来修改Lore"));
Expand All @@ -64,8 +65,22 @@ public void deleteLore(@CmdSender Player player, @CmdParam("position") int posit
player.sendMessage(ChatColor.GREEN + BasicFunctions.getInstance().i18n("物品Lore已修改"));
}

@CmdMapping(format = "edit name <name>")
public void editName(@CmdSender Player player, @CmdParam(value = "name", suggest = "[名称]") String name) {
ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType() == Material.AIR) {
player.sendMessage(ChatColor.RED + BasicFunctions.getInstance().i18n("请手持物品来修改Lore"));
return;
}
ItemMeta itemMeta = Objects.requireNonNull(itemStack.getItemMeta());
itemMeta.setDisplayName(coloredMsg(name));
itemStack.setItemMeta(itemMeta);
player.getInventory().setItemInMainHand(itemStack);
player.sendMessage(ChatColor.GREEN + BasicFunctions.getInstance().i18n("物品Lore已修改"));
}

@CmdMapping(format = "edit <position> <lore...>")
public void editLore(@CmdSender Player player, @CmdParam("position") int position, @CmdParam("lore...") String[] lore) {
public void editLore(@CmdSender Player player, @CmdParam(value = "position", suggest = "positionSuggest()") int position, @CmdParam(value = "lore...", suggest = "[内容]") String[] lore) {
ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType() == Material.AIR) {
player.sendMessage(ChatColor.RED + BasicFunctions.getInstance().i18n("请手持物品来修改Lore"));
Expand Down Expand Up @@ -93,60 +108,30 @@ public void editLore(@CmdSender Player player, @CmdParam("position") int positio
player.sendMessage(ChatColor.GREEN + BasicFunctions.getInstance().i18n("物品Lore已修改"));
}

@Override
protected List<String> suggest(Player player, String[] strings) {
switch (strings.length) {
case 1:
return Arrays.asList(
"add",
"delete",
"edit"
);
case 2:
case 3:
if (strings[0].equals("add")) {
return Collections.singletonList(BasicFunctions.getInstance().i18n("<内容>"));
}
ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType() == Material.AIR) {
player.sendMessage(ChatColor.RED + BasicFunctions.getInstance().i18n("请手持物品来修改Lore"));
return Collections.emptyList();
}
ItemMeta itemMeta = Objects.requireNonNull(itemStack.getItemMeta());
List<String> lore = itemMeta.getLore();
if (lore == null || lore.isEmpty()) {
player.sendMessage(ChatColor.RED + BasicFunctions.getInstance().i18n("物品Lore为空"));
return Collections.emptyList();
}
List<String> list = new ArrayList<>();
for (int i = 1; i <= lore.size(); i++) {
list.add(i + ". " + lore.get(i - 1));
}

if ((strings[0].equals("edit") || strings[0].equals("delete")) && strings.length == 2) {
return list;
} else if (strings[0].equals("edit")) {
int position;
try {
position = Integer.parseInt(strings[1]);
} catch (NumberFormatException e) {
return Collections.singletonList(BasicFunctions.getInstance().i18n("<- 请输入对应的lore行数"));
}
if (position - 1 < lore.size() && position - 1 >= 0) {
return Collections.singletonList(lore.get(position - 1));
}
}
break;
default:
return Collections.emptyList();
public List<String> positionSuggest(Player player) {
ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType() == Material.AIR) {
player.sendMessage(ChatColor.RED + BasicFunctions.getInstance().i18n("请手持物品来修改Lore"));
return Collections.emptyList();
}
ItemMeta itemMeta = Objects.requireNonNull(itemStack.getItemMeta());
List<String> lore = itemMeta.getLore();
if (lore == null || lore.isEmpty()) {
player.sendMessage(ChatColor.RED + BasicFunctions.getInstance().i18n("物品Lore为空"));
return Collections.emptyList();
}
List<String> list = new ArrayList<>();
for (int i = 1; i <= lore.size(); i++) {
list.add(i + ". " + lore.get(i - 1));
}
return Collections.emptyList();
return list;
}

@Override
protected void handleHelp(CommandSender sender) {
sender.sendMessage(ChatColor.RED + "lore add <内容>" + ChatColor.GRAY + " - " + BasicFunctions.getInstance().i18n("添加Lore"));
sender.sendMessage(ChatColor.RED + "lore delete <行数>" + ChatColor.GRAY + " - " + BasicFunctions.getInstance().i18n("删除Lore"));
sender.sendMessage(ChatColor.RED + "lore edit <行数> <内容>" + ChatColor.GRAY + " - " + BasicFunctions.getInstance().i18n("编辑Lore"));
sender.sendMessage(ChatColor.RED + "lore edit name <名称>" + ChatColor.GRAY + " - " + BasicFunctions.getInstance().i18n("编辑物品名称"));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.ultitools.UltiTools;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.CmdExecutor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.CmdExecutor;
import com.ultikits.ultitools.annotations.command.CmdMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.CmdExecutor;
import com.ultikits.ultitools.annotations.command.CmdMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ultikits.plugins.commands;
package com.ultikits.plugins.basic.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.basic.BasicFunctions;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.*;
import org.bukkit.ChatColor;
Expand All @@ -19,7 +19,7 @@ public class SpeedCommands extends AbstractCommendExecutor {
List<String> speeds = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");

@CmdMapping(format = "<speed>")
public void setSpeeds(@CmdSender Player player, @CmdParam("speed") String speed) {
public void setSpeeds(@CmdSender Player player, @CmdParam(value = "speed", suggest = "speedSuggest") String speed) {
if (!speeds.contains(speed)) {
return;
}
Expand All @@ -28,6 +28,10 @@ public void setSpeeds(@CmdSender Player player, @CmdParam("speed") String speed)
player.sendMessage(ChatColor.YELLOW + String.format(BasicFunctions.getInstance().i18n("行走/飞行速度已设置为%s,默认速度为2"), speed));
}

public List<String> speedSuggest() {
return speeds;
}

@Override
protected void handleHelp(CommandSender sender) {
sender.sendMessage(info(BasicFunctions.getInstance().i18n("/speed <0-10> 设置速度")));
Expand Down
Loading

0 comments on commit ca5dd6b

Please sign in to comment.