new block
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
package com.alphaae.mcpe.servers;
|
package com.alphaae.mcpe.servers;
|
||||||
|
|
||||||
public interface Config {
|
public interface Config {
|
||||||
int JOIN_WAITING_TIME = 174;
|
int JOIN_WAITING_TIME = 200;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
12
src/com/alphaae/mcpe/servers/StaticData.java
Normal file
12
src/com/alphaae/mcpe/servers/StaticData.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package com.alphaae.mcpe.servers;
|
||||||
|
|
||||||
|
import com.alphaae.mcpe.servers.model.RePlayer;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class StaticData {
|
||||||
|
public static Map<UUID, RePlayer> rePlayerMap = new HashMap<>();
|
||||||
|
|
||||||
|
}
|
@ -8,6 +8,7 @@ import cn.nukkit.event.player.PlayerQuitEvent;
|
|||||||
import com.alphaae.mcpe.servers.event.block.joinquit.DisplayInfoBlock;
|
import com.alphaae.mcpe.servers.event.block.joinquit.DisplayInfoBlock;
|
||||||
import com.alphaae.mcpe.servers.event.block.joinquit.JoinQuitEventBlock;
|
import com.alphaae.mcpe.servers.event.block.joinquit.JoinQuitEventBlock;
|
||||||
import com.alphaae.mcpe.servers.event.block.joinquit.JoinWindowBlock;
|
import com.alphaae.mcpe.servers.event.block.joinquit.JoinWindowBlock;
|
||||||
|
import com.alphaae.mcpe.servers.event.block.joinquit.LoadPlayerDataBlock;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -20,6 +21,7 @@ public class JoinQuitEvent implements Listener {
|
|||||||
eventBlockList = new ArrayList<>();
|
eventBlockList = new ArrayList<>();
|
||||||
eventBlockList.add(new DisplayInfoBlock());
|
eventBlockList.add(new DisplayInfoBlock());
|
||||||
eventBlockList.add(new JoinWindowBlock());
|
eventBlockList.add(new JoinWindowBlock());
|
||||||
|
eventBlockList.add(new LoadPlayerDataBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
|
@ -12,6 +12,10 @@ import cn.nukkit.scheduler.TaskHandler;
|
|||||||
import cn.nukkit.utils.TextFormat;
|
import cn.nukkit.utils.TextFormat;
|
||||||
import com.alphaae.mcpe.servers.Config;
|
import com.alphaae.mcpe.servers.Config;
|
||||||
import com.alphaae.mcpe.servers.MainPlugin;
|
import com.alphaae.mcpe.servers.MainPlugin;
|
||||||
|
import com.alphaae.mcpe.servers.StaticData;
|
||||||
|
import com.alphaae.mcpe.servers.model.RePlayer;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DisplayInfoBlock implements JoinQuitEventBlock {
|
public class DisplayInfoBlock implements JoinQuitEventBlock {
|
||||||
|
|
||||||
@ -20,6 +24,7 @@ public class DisplayInfoBlock implements JoinQuitEventBlock {
|
|||||||
public DisplayInfoBlock() {
|
public DisplayInfoBlock() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
@ -27,12 +32,13 @@ public class DisplayInfoBlock implements JoinQuitEventBlock {
|
|||||||
infoHandler = MainPlugin.getPlugin().getServer().getScheduler().scheduleDelayedRepeatingTask(new Task() {
|
infoHandler = MainPlugin.getPlugin().getServer().getScheduler().scheduleDelayedRepeatingTask(new Task() {
|
||||||
@Override
|
@Override
|
||||||
public void onRun(int i) {
|
public void onRun(int i) {
|
||||||
String name = player.getName();
|
String name = player.getDisplayName();
|
||||||
int ping = player.getPing();
|
int ping = player.getPing();
|
||||||
String uuid = player.getUniqueId().toString();
|
UUID uuid = player.getUniqueId();
|
||||||
int coin = 2000;
|
RePlayer rePlayer = StaticData.rePlayerMap.get(uuid);
|
||||||
|
int coin = rePlayer.getCoin();
|
||||||
|
|
||||||
player.sendActionBar(TextFormat.colorize("&b" + name + " &f延迟: " + ping + "ms 硬币: " + coin));
|
player.sendActionBar(TextFormat.colorize("" + name + " &f延迟: " + ping + "ms 硬币: " + coin));
|
||||||
}
|
}
|
||||||
}, Config.JOIN_WAITING_TIME, 12);
|
}, Config.JOIN_WAITING_TIME, 12);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -42,6 +48,7 @@ public class DisplayInfoBlock implements JoinQuitEventBlock {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
if (infoHandler != null)
|
if (infoHandler != null)
|
||||||
infoHandler.cancel();
|
infoHandler.cancel();
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.alphaae.mcpe.servers.event.block.joinquit;
|
||||||
|
|
||||||
|
import cn.nukkit.Player;
|
||||||
|
import cn.nukkit.event.player.PlayerJoinEvent;
|
||||||
|
import cn.nukkit.event.player.PlayerQuitEvent;
|
||||||
|
import cn.nukkit.utils.TextFormat;
|
||||||
|
import com.alphaae.mcpe.servers.StaticData;
|
||||||
|
import com.alphaae.mcpe.servers.model.RePlayer;
|
||||||
|
|
||||||
|
public class LoadPlayerDataBlock implements JoinQuitEventBlock {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
//读取数据
|
||||||
|
|
||||||
|
String title = "[称号]";
|
||||||
|
|
||||||
|
player.setDisplayName(TextFormat.colorize("&e" + title + " &b" + player.getName() + "&f"));
|
||||||
|
|
||||||
|
RePlayer rePlayer = new RePlayer(player, title, 4000);
|
||||||
|
StaticData.rePlayerMap.put(player.getUniqueId(), rePlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
StaticData.rePlayerMap.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
30
src/com/alphaae/mcpe/servers/model/RePlayer.java
Normal file
30
src/com/alphaae/mcpe/servers/model/RePlayer.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package com.alphaae.mcpe.servers.model;
|
||||||
|
|
||||||
|
import cn.nukkit.Player;
|
||||||
|
|
||||||
|
public class RePlayer {
|
||||||
|
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
private int coin;
|
||||||
|
|
||||||
|
public RePlayer(Player player, String title, int coin) {
|
||||||
|
this.player = player;
|
||||||
|
this.title = title;
|
||||||
|
this.coin = coin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCoin() {
|
||||||
|
return coin;
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
package com.alphaae.mcpe.servers.model;
|
|
||||||
|
|
||||||
import cn.nukkit.Player;
|
|
||||||
|
|
||||||
public class SuPlayer {
|
|
||||||
private Player player;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user