Skip to content

Commit

Permalink
Merge pull request #39 from UltiKits/alpha
Browse files Browse the repository at this point in the history
Release 6.0.1
  • Loading branch information
wisdommen authored Dec 25, 2023
2 parents c7abea4 + 099ac6a commit 11442f3
Show file tree
Hide file tree
Showing 112 changed files with 3,540 additions and 1,977 deletions.
4 changes: 2 additions & 2 deletions BasicFunctions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>com.ultikits</groupId>
<artifactId>UltiTools-API</artifactId>
<version>6.0.0.202308112144</version>
<version>6.0.0.202310142230</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -74,7 +74,7 @@
<artifactId>ultitools-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<name>Basic Functions</name>
<name>BasicFunctions</name>
<identifyString>UltiTools-Basic-Functions</identifyString>
<shortDescription>All basic functions of the UltiTools</shortDescription>
<accessKeyFile>access_key.txt</accessKeyFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public boolean registerSelf() throws IOException {
if (configEntity.isEnableJoinWelcome()) {
getListenerManager().register(this, new JoinWelcomeListener());
}
if (configEntity.isEnableTpa()) {
getCommandManager().register(new TpaCommands(), "ultikits.tools.command.tpa", i18n("传送请求功能"), "tpa");
getCommandManager().register(new TpaHereCommands(), "ultikits.tools.command.tphere", i18n("请求传送到此功能"), "tphere");
}
if (configEntity.isEnableSpeed()){
getCommandManager().register(new SpeedCommands(), "ultikits.tools.command.speed", i18n("速度设置功能"), "speed");
}
return true;
}

Expand All @@ -56,6 +63,9 @@ public void unregisterSelf() {
getCommandManager().unregister("wild");
getCommandManager().unregister("fly");
getCommandManager().unregister("wl");
getCommandManager().unregister("tpa");
getCommandManager().unregister("tphere");
getCommandManager().unregister("speed");
getListenerManager().unregisterAll(this);
}

Expand All @@ -72,8 +82,8 @@ public List<String> supported() {
@Override
public List<AbstractConfigEntity> getAllConfigs() {
return Arrays.asList(
new BasicConfig("res/config/config.yml"),
new JoinWelcomeConfig("res/config/join.yml")
new BasicConfig("config/config.yml"),
new JoinWelcomeConfig("config/join.yml")
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.ultikits.plugins.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.ultitools.abstracts.AbstractTabExecutor;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.List;

import static com.ultikits.ultitools.utils.MessageUtils.info;
import static com.ultikits.ultitools.utils.MessageUtils.warning;


public class SpeedCommands extends AbstractTabExecutor {
List<String> speeds = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");

@Override
protected boolean onPlayerCommand(@NotNull Command command, @NotNull String[] strings, @NotNull Player player) {
if (player.hasPermission("ultikits.tools.command.speed")) {
if (!speeds.contains(strings[0])) {
return false;
}
player.setWalkSpeed(Float.parseFloat(strings[0]) / 10);
player.setFlySpeed(Float.parseFloat(strings[0]) / 10);
player.sendMessage(ChatColor.YELLOW + String.format(BasicFunctions.getInstance().i18n("行走/飞行速度已设置为%s,默认速度为2"), strings[0]));
return true;
}
player.sendMessage(warning(BasicFunctions.getInstance().i18n("你没有权限使用此指令!")));
return true;
}

@Nullable
@Override
protected List<String> onPlayerTabComplete(@NotNull Command command, @NotNull String[] strings, @NotNull Player player) {
if (!player.hasPermission("ultikits.tools.commands.speed")) {
return null;
}
if (strings.length == 1) {
return speeds;
}
return null;
}

@Override
protected void sendHelpMessage(CommandSender sender) {
sender.sendMessage(info(BasicFunctions.getInstance().i18n("/speed <0-10> 设置速度")));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.ultikits.plugins.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.tasks.TpTimerTask;
import com.ultikits.ultitools.abstracts.AbstractTabExecutor;
import com.ultikits.ultitools.utils.MessageUtils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

import static com.ultikits.ultitools.utils.MessageUtils.info;
import static com.ultikits.ultitools.utils.MessageUtils.warning;


public class TpaCommands extends AbstractTabExecutor {

@Override
protected boolean onPlayerCommand(@NotNull Command command, @NotNull String[] strings, @NotNull Player player) {
if (!player.isOp() && !player.hasPermission("ultikits.tools.command.tpa")) {
player.sendMessage(warning(BasicFunctions.getInstance().i18n("你没有权限使用此指令!")));
return false;
}
switch (strings.length) {
case 1:
switch (strings[0]) {
case "accept":
Player teleporter = TpTimerTask.tpTemp.get(player);
if (teleporter == null) {
player.sendMessage(warning(BasicFunctions.getInstance().i18n("并没有玩家给你发送传送请求!")));
return true;
}
TpTimerTask.tpTemp.put(player, null);
TpTimerTask.tpTimer.put(player, 0);
teleporter.teleport(player.getLocation());
teleporter.sendMessage(info(BasicFunctions.getInstance().i18n("传送成功!")));
return true;
case "reject":
Player teleporter2 = TpTimerTask.tpTemp.get(player);
if (teleporter2 == null) {
player.sendMessage(warning(BasicFunctions.getInstance().i18n("并没有玩家给你发送传送请求!")));
return true;
}
teleporter2.sendMessage(warning(BasicFunctions.getInstance().i18n("对方拒绝了你的传送请求 :(")));
player.sendMessage(info(BasicFunctions.getInstance().i18n("已拒绝!")));
TpTimerTask.tpTemp.put(player, null);
TpTimerTask.tpTimer.put(player, 0);
return true;
default:
Player target = Bukkit.getPlayerExact(strings[0]);
if (target == null) {
player.sendMessage(warning(BasicFunctions.getInstance().i18n("未找到目标,无法请求传送!")));
return true;
}
if (TpTimerTask.tpTemp.get(target) != null) {
player.sendMessage(warning(BasicFunctions.getInstance().i18n("对方正在处理另一个传送请求!")));
return true;
}
TpTimerTask.tpTemp.put(target, player);
TpTimerTask.tpTimer.put(target, 20);
player.sendMessage(info(String.format(BasicFunctions.getInstance().i18n("你已向%s发送TP请求!"), target.getName())));
target.sendMessage(info(String.format(BasicFunctions.getInstance().i18n("%s请求传送到您的位置"), player.getName())));
TextComponent ask = Component
.text(BasicFunctions.getInstance().i18n("[同意]"))
.color(TextColor.color(0x00FF00))
.hoverEvent(Component.text(BasicFunctions.getInstance().i18n("点击同意传送")))
.clickEvent(ClickEvent.runCommand("/tpa accept"))
.append(Component.text(" "))
.append(
Component
.text(BasicFunctions.getInstance().i18n("[拒绝]"))
.color(TextColor.color(0xFF0000))
.hoverEvent(Component.text(BasicFunctions.getInstance().i18n("点击拒绝传送")))
.clickEvent(ClickEvent.runCommand("/tpa reject"))
);
MessageUtils.sendMessage(target, ask);
return true;
}
default:
return false;
}
}

@Override
protected @Nullable
List<String> onPlayerTabComplete(@NotNull Command command, @NotNull String[] strings, @NotNull Player player) {
return TpaHereCommands.getTpTabList(strings);
}

@Override
protected void sendHelpMessage(CommandSender sender) {
sender.sendMessage(info(BasicFunctions.getInstance().i18n("----传送请求帮助----")));
sender.sendMessage(info(BasicFunctions.getInstance().i18n("/tpa [玩家名] 向玩家发送传送请求")));
sender.sendMessage(info(BasicFunctions.getInstance().i18n("/tpa accept 接受传送请求")));
sender.sendMessage(info(BasicFunctions.getInstance().i18n("/tpa reject 拒绝传送请求")));
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.ultikits.plugins.commands;

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.tasks.TpTimerTask;
import com.ultikits.ultitools.abstracts.AbstractTabExecutor;
import com.ultikits.ultitools.utils.MessageUtils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

import static com.ultikits.ultitools.utils.MessageUtils.info;
import static com.ultikits.ultitools.utils.MessageUtils.warning;


public class TpaHereCommands extends AbstractTabExecutor {
@Nullable
public static List<String> getTpTabList(@NotNull String[] strings) {
List<String> tabCommands = new ArrayList<>();
if (strings.length == 1) {
tabCommands.add("accept");
tabCommands.add("reject");
for (Player player1 : Bukkit.getOnlinePlayers()) {
tabCommands.add(player1.getName());
}
return tabCommands;
}
return null;
}

@Override
protected boolean onPlayerCommand(@NotNull Command command, @NotNull String[] strings, @NotNull Player player) {
if (!player.isOp() && !player.hasPermission("ultikits.tools.command.tphere")) {
player.sendMessage(warning(BasicFunctions.getInstance().i18n("你没有权限使用此指令!")));
return false;
}
if (strings.length == 1) {
switch (strings[0]) {
case "accept":
Player teleporter = TpTimerTask.tphereTemp.get(player);
if (teleporter == null) {
player.sendMessage(warning(BasicFunctions.getInstance().i18n("并没有玩家给你发送传送请求!")));
return true;
}
TpTimerTask.tphereTemp.put(player, null);
TpTimerTask.tphereTimer.put(player, 0);
player.teleport(teleporter.getLocation());
teleporter.sendMessage(info(BasicFunctions.getInstance().i18n("传送成功!")));
return true;
case "reject":
Player teleporter2 = TpTimerTask.tphereTemp.get(player);
if (teleporter2 == null) {
player.sendMessage(warning(BasicFunctions.getInstance().i18n("并没有玩家给你发送传送请求!")));
return true;
}
teleporter2.sendMessage(warning(BasicFunctions.getInstance().i18n("对方拒绝了你的传送请求 :(")));
player.sendMessage(info(BasicFunctions.getInstance().i18n("已拒绝!")));
TpTimerTask.tphereTemp.put(player, null);
TpTimerTask.tphereTimer.put(player, 0);
return true;
default:
Player target = Bukkit.getPlayerExact(strings[0]);
if (target == null) {
player.sendMessage(warning(BasicFunctions.getInstance().i18n("未找到目标,无法请求传送!")));
return true;
}
TpTimerTask.tphereTemp.put(target, player);
TpTimerTask.tphereTimer.put(target, 20);
player.sendMessage(info(String.format(BasicFunctions.getInstance().i18n("你已向%s发送TP请求!"), target.getName())));
target.sendMessage(info(String.format(BasicFunctions.getInstance().i18n("%s请求您传送至他的位置"), player.getName())));
TextComponent ask = Component
.text(BasicFunctions.getInstance().i18n("[同意]"))
.color(TextColor.color(0x00FF00))
.hoverEvent(Component.text(BasicFunctions.getInstance().i18n("点击同意传送")))
.clickEvent(ClickEvent.runCommand("/tphere accept"))
.append(Component.text(" "))
.append(
Component
.text(BasicFunctions.getInstance().i18n("[拒绝]"))
.color(TextColor.color(0xFF0000))
.hoverEvent(Component.text(BasicFunctions.getInstance().i18n("点击拒绝传送")))
.clickEvent(ClickEvent.runCommand("/tphere reject"))
);
MessageUtils.sendMessage(target, ask);
return true;
}
}
return false;
}

@Nullable
@Override
protected List<String> onPlayerTabComplete(@NotNull Command command, @NotNull String[] strings, @NotNull Player player) {
return getTpTabList(strings);
}

@Override
protected void sendHelpMessage(CommandSender sender) {
sender.sendMessage(info(BasicFunctions.getInstance().i18n("----传送至此请求帮助----")));
sender.sendMessage(info(BasicFunctions.getInstance().i18n("/tphere accept 接受传送请求")));
sender.sendMessage(info(BasicFunctions.getInstance().i18n("/tphere reject 拒绝传送请求")));
sender.sendMessage(info(BasicFunctions.getInstance().i18n("/tphere [玩家名] 向玩家发送传送至此请求")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class BasicConfig extends AbstractConfigEntity {
private boolean enableRandomTeleport = true;
@ConfigEntry(path = "enableJoinWelcome", comment = "是否启用入服欢迎")
private boolean enableJoinWelcome = true;
@ConfigEntry(path = "enableTpa", comment = "是否启用传送请求")
private boolean enableTpa = true;
@ConfigEntry(path = "enableSpeed", comment = "是否启用速度设置")
private boolean enableSpeed = true;

public BasicConfig(String configFilePath) {
super(configFilePath);
Expand Down
Loading

0 comments on commit 11442f3

Please sign in to comment.