Skip to content

Commit

Permalink
Merge pull request #46 from UltiKits/alpha
Browse files Browse the repository at this point in the history
Release 6.0.3
  • Loading branch information
wisdommen authored Dec 31, 2023
2 parents 5a5d2c7 + 0936915 commit 363a0f0
Show file tree
Hide file tree
Showing 29 changed files with 440 additions and 250 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.202310142230</version>
<version>6.0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -78,7 +78,7 @@
<identifyString>UltiTools-Basic-Functions</identifyString>
<shortDescription>All basic functions of the UltiTools</shortDescription>
<accessKeyFile>access_key.txt</accessKeyFile>
<pluginFolder>F:\SpigotServers\Servers\1.19.4\plugins\UltiTools\plugins</pluginFolder>
<pluginFolder>F:\SpigotServers\Servers\1.20.4\plugins\UltiTools\plugins</pluginFolder>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,35 @@
import com.ultikits.plugins.config.BasicConfig;
import com.ultikits.plugins.config.JoinWelcomeConfig;
import com.ultikits.plugins.listeners.BackListener;
import com.ultikits.plugins.listeners.BanListener;
import com.ultikits.plugins.listeners.JoinWelcomeListener;
import com.ultikits.plugins.listeners.WhitelistListener;
import com.ultikits.ultitools.abstracts.AbstractConfigEntity;
import com.ultikits.ultitools.abstracts.UltiToolsPlugin;
//import com.ultikits.ultitools.annotations.ContextEntry;
//import com.ultikits.ultitools.annotations.EnableAutoRegister;
import lombok.Getter;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

//@EnableAutoRegister(
// scanPackage = "com.ultikits.plugins",
// eventListener = false,
// cmdExecutor = false
//)
public class BasicFunctions extends UltiToolsPlugin {
@Getter
private static BasicFunctions instance;

public BasicFunctions() {
super();
instance = this;
}

@Override
public boolean registerSelf() throws IOException {
instance = this;
BasicConfig configEntity = getConfigManager().getConfigEntity(this, BasicConfig.class);
if (configEntity.isEnableHeal()) {
getCommandManager().register(new HealCommand(), "ultikits.tools.command.heal", i18n("指令治愈功能"), "heal", "h");
Expand Down Expand Up @@ -49,9 +61,13 @@ public boolean registerSelf() throws IOException {
getCommandManager().register(new TpaCommands(), "ultikits.tools.command.tpa", i18n("传送请求功能"), "tpa");
getCommandManager().register(new TpaHereCommands(), "ultikits.tools.command.tphere", i18n("请求传送到此功能"), "tphere");
}
if (configEntity.isEnableSpeed()){
if (configEntity.isEnableSpeed()) {
getCommandManager().register(new SpeedCommands(), "ultikits.tools.command.speed", i18n("速度设置功能"), "speed");
}
if (configEntity.isEnableBan()) {
getCommandManager().register(new BanCommands(), "ultikits.tools.command.uban", i18n("封禁功能"), "uban");
getListenerManager().register(this, new BanListener());
}
return true;
}

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

import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.services.BanPlayerService;
import com.ultikits.ultitools.abstracts.AbstractCommendExecutor;
import com.ultikits.ultitools.annotations.command.*;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.springframework.beans.factory.annotation.Autowired;


@CmdTarget(CmdTarget.CmdTargetType.BOTH)
@CmdExecutor(permission = "ultikits.ban.command.all", description = "Ban功能", alias = {"uban"})
public class BanCommands extends AbstractCommendExecutor {
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Autowired
private BanPlayerService banPlayerService = new BanPlayerService();

@CmdMapping(format = "ban <player> <reason>")
public void banPlayer(@CmdSender CommandSender sender, @CmdParam("player") String player, @CmdParam("reason") String reason) {
OfflinePlayer kickedPlayer = Bukkit.getOfflinePlayer(player);
banPlayerService.banPlayer(kickedPlayer, sender.getName(), reason);
if (kickedPlayer.isOnline()) {
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) {
banPlayerService.unBanPlayer(Bukkit.getOfflinePlayer(player));
sender.sendMessage(BasicFunctions.getInstance().i18n("§a解封成功"));
}


@Override
protected void handleHelp(CommandSender sender) {

}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.ultikits.plugins.config;

import com.ultikits.ultitools.abstracts.AbstractConfigEntity;
import com.ultikits.ultitools.annotations.ConfigEntity;
import com.ultikits.ultitools.annotations.ConfigEntry;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@ConfigEntity("config/config.yml")
public class BasicConfig extends AbstractConfigEntity {
@ConfigEntry(path = "enableWhitelist", comment = "是否启用白名单")
private boolean enableWhitelist = false;
Expand All @@ -26,6 +28,8 @@ public class BasicConfig extends AbstractConfigEntity {
private boolean enableTpa = true;
@ConfigEntry(path = "enableSpeed", comment = "是否启用速度设置")
private boolean enableSpeed = true;
@ConfigEntry(path = "enableBan", comment = "是否启用封禁")
private boolean enableBan = true;

public BasicConfig(String configFilePath) {
super(configFilePath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ultikits.plugins.config;

import com.ultikits.ultitools.abstracts.AbstractConfigEntity;
import com.ultikits.ultitools.annotations.ConfigEntity;
import com.ultikits.ultitools.annotations.ConfigEntry;
import lombok.Getter;
import lombok.Setter;
Expand All @@ -10,6 +11,7 @@

@Getter
@Setter
@ConfigEntity("config/join.yml")
public class JoinWelcomeConfig extends AbstractConfigEntity {

@ConfigEntry(path = "sendMessageDelay", comment = "x秒后发送入服欢迎")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.ultikits.plugins.data;

import com.ultikits.ultitools.abstracts.AbstractDataEntity;
import com.ultikits.ultitools.annotations.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@Table("baned_user")
@EqualsAndHashCode(callSuper = true)
public class BanedUserData extends AbstractDataEntity {
private String name;
private String reason;
private String operator;
private String time;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ultikits.plugins.listeners;

import com.ultikits.plugins.services.BanPlayerService;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

public class BanListener implements Listener {
private BanPlayerService banPlayerService = new BanPlayerService();

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (banPlayerService.isBaned(event.getPlayer())) {
event.getPlayer().kickPlayer("你已被封禁");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.ultikits.plugins.services;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.ultikits.plugins.BasicFunctions;
import com.ultikits.plugins.data.BanedUserData;
import com.ultikits.ultitools.interfaces.DataOperator;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class BanPlayerService {

public boolean isBaned(Player player) {
DataOperator<BanedUserData> dataOperator = BasicFunctions.getInstance().getDataOperator(BanedUserData.class);
BanedUserData banedUserData = dataOperator.getById(player.getUniqueId().toString());
return banedUserData != null;
}

public void banPlayer(OfflinePlayer player, String operator, String reason) {
DataOperator<BanedUserData> dataOperator = BasicFunctions.getInstance().getDataOperator(BanedUserData.class);
BanedUserData banedUserData = new BanedUserData();
banedUserData.setId(player.getUniqueId().toString());
banedUserData.setName(player.getName());
banedUserData.setReason(reason);
banedUserData.setOperator(operator);
banedUserData.setTime(LocalDateTimeUtil.format(LocalDateTimeUtil.of(new Date()), "yyyy-MM-dd HH:mm:ss"));
dataOperator.insert(banedUserData);
}

public void unBanPlayer(OfflinePlayer player) {
DataOperator<BanedUserData> dataOperator = BasicFunctions.getInstance().getDataOperator(BanedUserData.class);
dataOperator.delById(player.getUniqueId().toString());
}
}
2 changes: 2 additions & 0 deletions BasicFunctions/src/main/resources/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ enableJoinWelcome: true
enableTpa: true
# 是否启用速度设置功能
enableSpeed: true
# 是否启用封禁功能
enableBan: true
5 changes: 4 additions & 1 deletion BasicFunctions/src/main/resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@
"请求传送至此功能": "Request teleport to here function",
"/speed <0-10> 设置速度": "/speed <0-10> Set speed",
"行走/飞行速度已设置为%s,默认速度为2": "Walking/flying speed has been set to %s, the default speed is 2",
"速度设置功能": "Speed setting function"
"速度设置功能": "Speed setting function",
"你已被封禁! 原因: %s": "You have been banned! Reason: %s",
"§a封禁成功!": "§aBanned successfully!",
"§a解封成功!": "§aUnbanned successfully!"
}
2 changes: 1 addition & 1 deletion Economy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dependency>
<groupId>com.ultikits</groupId>
<artifactId>UltiTools-API</artifactId>
<version>6.0.0.202310142230</version>
<version>6.0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions Home/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.2</version>
<version>6.0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -57,7 +57,7 @@
<identifyString>UltiTools-Home</identifyString>
<shortDescription>A Home Plugin</shortDescription>
<accessKeyFile>access_key.txt</accessKeyFile>
<pluginFolder>F:\SpigotServers\Servers\1.19.4\plugins\UltiTools\plugins</pluginFolder>
<pluginFolder>F:\SpigotServers\Servers\1.20.4\plugins\UltiTools\plugins</pluginFolder>
</configuration>
</plugin>
</plugins>
Expand Down
28 changes: 24 additions & 4 deletions Home/src/main/java/com/ultikits/plugins/home/PluginMain.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package com.ultikits.plugins.home;

import com.ultikits.plugins.home.context.ContextConfig;
import com.ultikits.plugins.home.config.HomeConfig;
import com.ultikits.plugins.home.entity.HomeEntity;
import com.ultikits.ultitools.abstracts.UltiToolsPlugin;
import com.ultikits.ultitools.annotations.ContextEntry;
import com.ultikits.ultitools.annotations.EnableAutoRegister;
import com.ultikits.ultitools.annotations.I18n;
import com.ultikits.ultitools.interfaces.DataOperator;
import com.ultikits.ultitools.interfaces.DataStore;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

@EnableAutoRegister
@Component
@ComponentScan
@I18n({"zh", "en"})
@ContextEntry(ContextConfig.class)
@EnableAutoRegister
public class PluginMain extends UltiToolsPlugin {
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
@Autowired
private DataStore dataStore;

@Getter
private static PluginMain pluginMain;

Expand All @@ -27,4 +38,13 @@ public boolean registerSelf() {
@Override
public void unregisterSelf() {
}

@Bean
public HomeConfig homeConfig() {
return getConfig("config/config.yml", HomeConfig.class);
}
@Bean
public DataOperator<HomeEntity> dataOperator() {
return dataStore.getOperator(pluginMain, HomeEntity.class);
}
}

This file was deleted.

33 changes: 0 additions & 33 deletions Home/src/main/java/com/ultikits/plugins/home/context/HomeBean.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class HomeServiceImpl implements HomeService {
private final DataOperator<HomeEntity> dataOperator;
private final TeleportService teleportService;

public HomeServiceImpl(HomeConfig homeConfig, DataOperator<HomeEntity> dataOperator, TeleportService teleportService) {
public HomeServiceImpl(DataOperator<HomeEntity> dataOperator, HomeConfig homeConfig, TeleportService teleportService) {
this.homeConfig = homeConfig;
this.dataOperator = dataOperator;
this.teleportService = teleportService;
Expand Down
2 changes: 1 addition & 1 deletion Home/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ name: UltiTools-Home
version: '${project.version}'
main: com.ultikits.plugins.home.PluginMain
base-package: com.ultikits.plugins.home
api-version: 600
api-version: 603
authors: [ wisdomme ]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<br>

<div align="center">
<img src="https://www.freeimg.cn/i/2023/12/24/65883862cbd7d.png" width="96" height="96"/>
<img src="https://github.com/UltiKits/UltiTools-Reborn/assets/62180110/f5e8e7d3-e97d-4d37-a9ab-ba3722dc6faa" width="96" height="96"/>
</div>


<h1 align="center">UltiTools 6</h1>

<div align="center"><strong>UltiTools' Reborn</strong></div>
Expand Down
Loading

0 comments on commit 363a0f0

Please sign in to comment.