This commit is contained in:
parent
79979c9825
commit
00898f3ef3
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>cn.lunadeer</groupId>
|
<groupId>cn.lunadeer</groupId>
|
||||||
<artifactId>MiniPlayerTitle</artifactId>
|
<artifactId>MiniPlayerTitle</artifactId>
|
||||||
<version>2.7.2</version>
|
<version>2.8.5</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>MiniPlayerTitle</name>
|
<name>MiniPlayerTitle</name>
|
||||||
|
@ -3,6 +3,7 @@ package cn.lunadeer.miniplayertitle;
|
|||||||
import cn.lunadeer.miniplayertitle.utils.Notification;
|
import cn.lunadeer.miniplayertitle.utils.Notification;
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
@ -11,33 +12,21 @@ public class Events implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
XPlayer player = new XPlayer(event.getPlayer());
|
Player bukkitPlayer = event.getPlayer();
|
||||||
Commands.home_view(event.getPlayer());
|
XPlayer player = new XPlayer(bukkitPlayer);
|
||||||
|
Commands.home_view(bukkitPlayer);
|
||||||
|
player.updateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerSendChat(AsyncChatEvent event) {
|
public void onPlayerSendChat(AsyncChatEvent event) {
|
||||||
XPlayer xPlayer = new XPlayer(event.getPlayer());
|
|
||||||
PlayerTitle title = xPlayer.getTitle();
|
|
||||||
Component nameComponent = event.getPlayer().displayName();
|
Component nameComponent = event.getPlayer().displayName();
|
||||||
Component chatComponent = event.message();
|
Component chatComponent = event.message();
|
||||||
if (title == null) {
|
|
||||||
Component newChatComponent = Component.text()
|
Component newChatComponent = Component.text()
|
||||||
.append(Component.text("<"))
|
|
||||||
.append(nameComponent)
|
.append(nameComponent)
|
||||||
.append(Component.text("> "))
|
.append(Component.text(" "))
|
||||||
.append(chatComponent).build();
|
.append(chatComponent).build();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().getServer().sendMessage(newChatComponent);
|
event.getPlayer().getServer().sendMessage(newChatComponent);
|
||||||
} else {
|
|
||||||
Component titleComponent = title.getTitle();
|
|
||||||
Component newChatComponent = Component.text().append(titleComponent)
|
|
||||||
.append(Component.text("<"))
|
|
||||||
.append(nameComponent)
|
|
||||||
.append(Component.text("> "))
|
|
||||||
.append(chatComponent).build();
|
|
||||||
event.setCancelled(true);
|
|
||||||
event.getPlayer().getServer().sendMessage(newChatComponent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public class XPlayer {
|
|||||||
sql += "updated_at = CURRENT_TIMESTAMP ";
|
sql += "updated_at = CURRENT_TIMESTAMP ";
|
||||||
sql += "WHERE uuid = '" + _player.getUniqueId() + "';";
|
sql += "WHERE uuid = '" + _player.getUniqueId() + "';";
|
||||||
Database.query(sql);
|
Database.query(sql);
|
||||||
|
updateName();
|
||||||
if (_current_title_id == -1) {
|
if (_current_title_id == -1) {
|
||||||
Notification.info(_player, "成功卸下称号");
|
Notification.info(_player, "成功卸下称号");
|
||||||
return;
|
return;
|
||||||
@ -196,7 +197,7 @@ public class XPlayer {
|
|||||||
Notification.info(_player, title.getTitle().append(Component.text(" 已购买至 " + title_bought.getExpireAtStr())));
|
Notification.info(_player, title.getTitle().append(Component.text(" 已购买至 " + title_bought.getExpireAtStr())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void custom(String title_str){
|
public void custom(String title_str) {
|
||||||
if (this.get_coin() < MiniPlayerTitle.config.getCustomCost()) {
|
if (this.get_coin() < MiniPlayerTitle.config.getCustomCost()) {
|
||||||
Notification.error(this._player, "称号币不足");
|
Notification.error(this._player, "称号币不足");
|
||||||
return;
|
return;
|
||||||
@ -226,4 +227,32 @@ public class XPlayer {
|
|||||||
Notification.info(this._player, Component.text("成功创建自定义称号: ").append(title.getTitle()));
|
Notification.info(this._player, Component.text("成功创建自定义称号: ").append(title.getTitle()));
|
||||||
Notification.info(this._player, "花费: " + MiniPlayerTitle.config.getCustomCost() + "称号币,余额: " + this.get_coin() + "称号币");
|
Notification.info(this._player, "花费: " + MiniPlayerTitle.config.getCustomCost() + "称号币,余额: " + this.get_coin() + "称号币");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateName() {
|
||||||
|
PlayerTitle title = getTitle();
|
||||||
|
if (title == null) {
|
||||||
|
Component newDisplayName = Component.text()
|
||||||
|
.append(Component.text("<"))
|
||||||
|
.append(_player.name())
|
||||||
|
.append(Component.text("> ")).build();
|
||||||
|
Component newListName = Component.text()
|
||||||
|
.append(_player.name()).build();
|
||||||
|
_player.displayName(newDisplayName);
|
||||||
|
_player.playerListName(newListName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Component titleComponent = title.getTitle();
|
||||||
|
Component newDisplayName = Component.text()
|
||||||
|
.append(titleComponent)
|
||||||
|
.append(Component.text("<"))
|
||||||
|
.append(_player.name())
|
||||||
|
.append(Component.text(">")).build();
|
||||||
|
Component newListName = Component.text()
|
||||||
|
.append(titleComponent)
|
||||||
|
.append(Component.text(" "))
|
||||||
|
.append(_player.name()).build();
|
||||||
|
_player.displayName(newDisplayName);
|
||||||
|
_player.playerListName(newListName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user