-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from UltiKits/alpha
Release 6.0.3
- Loading branch information
Showing
29 changed files
with
440 additions
and
250 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
41 changes: 41 additions & 0 deletions
41
BasicFunctions/src/main/java/com/ultikits/plugins/commands/BanCommands.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,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) { | ||
|
||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
BasicFunctions/src/main/java/com/ultikits/plugins/data/BanedUserData.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,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; | ||
} |
17 changes: 17 additions & 0 deletions
17
BasicFunctions/src/main/java/com/ultikits/plugins/listeners/BanListener.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,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("你已被封禁"); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
BasicFunctions/src/main/java/com/ultikits/plugins/services/BanPlayerService.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,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()); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -16,3 +16,5 @@ enableJoinWelcome: true | |
enableTpa: true | ||
# 是否启用速度设置功能 | ||
enableSpeed: true | ||
# 是否启用封禁功能 | ||
enableBan: true |
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
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
9 changes: 0 additions & 9 deletions
9
Home/src/main/java/com/ultikits/plugins/home/context/ContextConfig.java
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
Home/src/main/java/com/ultikits/plugins/home/context/HomeBean.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.