090501
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 = 200;
|
int JOIN_WAITING_TIME = 240;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ import cn.nukkit.plugin.Plugin;
|
|||||||
import cn.nukkit.plugin.PluginBase;
|
import cn.nukkit.plugin.PluginBase;
|
||||||
import cn.nukkit.plugin.PluginManager;
|
import cn.nukkit.plugin.PluginManager;
|
||||||
import com.alphaae.mcpe.servers.command.HiCommand;
|
import com.alphaae.mcpe.servers.command.HiCommand;
|
||||||
import com.alphaae.mcpe.servers.event.JoinQuitEvent;
|
import com.alphaae.mcpe.servers.event.PlayerInteractSetEvent;
|
||||||
|
import com.alphaae.mcpe.servers.event.PlayerJoinQuitEvent;
|
||||||
|
|
||||||
public class MainPlugin extends PluginBase {
|
public class MainPlugin extends PluginBase {
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ public class MainPlugin extends PluginBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
getLogger().info("onLoad! QwQ");
|
getLogger().info("AlphaAPI被加载!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,11 +42,12 @@ public class MainPlugin extends PluginBase {
|
|||||||
|
|
||||||
private void registerCommands() {
|
private void registerCommands() {
|
||||||
SimpleCommandMap commandMap = getServer().getCommandMap();
|
SimpleCommandMap commandMap = getServer().getCommandMap();
|
||||||
commandMap.register("TestPlugin", new HiCommand(this));
|
commandMap.register("AlphaAPI", new HiCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
PluginManager pluginManager = getServer().getPluginManager();
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
pluginManager.registerEvents(new JoinQuitEvent(), this);
|
pluginManager.registerEvents(new PlayerJoinQuitEvent(), this);
|
||||||
|
pluginManager.registerEvents(new PlayerInteractSetEvent(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
src/com/alphaae/mcpe/servers/command/CoinCommand.java
Normal file
4
src/com/alphaae/mcpe/servers/command/CoinCommand.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package com.alphaae.mcpe.servers.command;
|
||||||
|
|
||||||
|
public class CoinCommand {
|
||||||
|
}
|
@ -6,7 +6,6 @@ import cn.nukkit.command.CommandSender;
|
|||||||
import cn.nukkit.utils.TextFormat;
|
import cn.nukkit.utils.TextFormat;
|
||||||
import com.alphaae.mcpe.servers.MainPlugin;
|
import com.alphaae.mcpe.servers.MainPlugin;
|
||||||
import com.alphaae.mcpe.servers.StaticData;
|
import com.alphaae.mcpe.servers.StaticData;
|
||||||
import com.alphaae.mcpe.servers.form.FormWindowMy;
|
|
||||||
import com.alphaae.mcpe.servers.model.RePlayer;
|
import com.alphaae.mcpe.servers.model.RePlayer;
|
||||||
import com.alphaae.mcpe.servers.utils.ChangePlayerCoinUtils;
|
import com.alphaae.mcpe.servers.utils.ChangePlayerCoinUtils;
|
||||||
|
|
||||||
@ -23,16 +22,15 @@ public class HiCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender commandSender, String s, String[] strings) {
|
public boolean execute(CommandSender commandSender, String s, String[] strings) {
|
||||||
if (!this.plugin.isEnabled()) return false;
|
if (!this.plugin.isEnabled()) return false;
|
||||||
if (!commandSender.hasPermission("testplugin.command.menu")) {
|
if (!commandSender.hasPermission("alphaapi.command.everybody")) {
|
||||||
commandSender.sendMessage(TextFormat.RED + "你没有权限使用该指令");
|
commandSender.sendMessage(TextFormat.RED + "你没有权限使用该指令");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commandSender.isPlayer()) {
|
||||||
Player player = commandSender.getServer().getPlayer(commandSender.getName());
|
Player player = commandSender.getServer().getPlayer(commandSender.getName());
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (commandSender.isPlayer()) {
|
//测试指令
|
||||||
// FormWindowMy form = new FormWindowMy(player);
|
|
||||||
// player.showFormWindow(form);
|
|
||||||
RePlayer rePlayer = StaticData.rePlayerMap.get(uuid);
|
RePlayer rePlayer = StaticData.rePlayerMap.get(uuid);
|
||||||
ChangePlayerCoinUtils.ReduceIcon(rePlayer, 100);
|
ChangePlayerCoinUtils.ReduceIcon(rePlayer, 100);
|
||||||
return true;
|
return true;
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.alphaae.mcpe.servers.event;
|
||||||
|
|
||||||
|
import cn.nukkit.Player;
|
||||||
|
import cn.nukkit.event.EventHandler;
|
||||||
|
import cn.nukkit.event.EventPriority;
|
||||||
|
import cn.nukkit.event.Listener;
|
||||||
|
import cn.nukkit.event.player.PlayerInteractEvent;
|
||||||
|
import cn.nukkit.event.player.PlayerItemHeldEvent;
|
||||||
|
import cn.nukkit.item.Item;
|
||||||
|
import com.alphaae.mcpe.servers.form.FormWindowMeun;
|
||||||
|
|
||||||
|
public class PlayerInteractSetEvent implements Listener {
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Item item = event.getItem();
|
||||||
|
if (player != null && item != null) {
|
||||||
|
if (item.getId() == 347) {
|
||||||
|
FormWindowMeun form = new FormWindowMeun(player);
|
||||||
|
player.showFormWindow(form);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Item item = event.getItem();
|
||||||
|
if (player != null && item != null) {
|
||||||
|
if (item.getId() == 347) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -13,7 +13,7 @@ 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;
|
||||||
|
|
||||||
public class JoinQuitEvent implements Listener {
|
public class PlayerJoinQuitEvent implements Listener {
|
||||||
|
|
||||||
private static List<JoinQuitEventBlock> eventBlockList;
|
private static List<JoinQuitEventBlock> eventBlockList;
|
||||||
|
|
@ -19,6 +19,7 @@ public class LoadPlayerDataBlock implements JoinQuitEventBlock {
|
|||||||
|
|
||||||
String title = rePlayer.getTitle();
|
String title = rePlayer.getTitle();
|
||||||
|
|
||||||
|
player.setNameTag(TextFormat.colorize("&e[" + title + "] &b" + player.getName() + "&f"));
|
||||||
player.setDisplayName(TextFormat.colorize("&e[" + title + "] &b" + player.getName() + "&f"));
|
player.setDisplayName(TextFormat.colorize("&e[" + title + "] &b" + player.getName() + "&f"));
|
||||||
StaticData.rePlayerMap.put(player.getUniqueId(), rePlayer);
|
StaticData.rePlayerMap.put(player.getUniqueId(), rePlayer);
|
||||||
}
|
}
|
||||||
|
93
src/com/alphaae/mcpe/servers/form/FormWindowMeun.java
Normal file
93
src/com/alphaae/mcpe/servers/form/FormWindowMeun.java
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package com.alphaae.mcpe.servers.form;
|
||||||
|
|
||||||
|
import cn.nukkit.Player;
|
||||||
|
import cn.nukkit.form.element.ElementButton;
|
||||||
|
import cn.nukkit.form.element.ElementButtonImageData;
|
||||||
|
import cn.nukkit.form.response.FormResponseSimple;
|
||||||
|
import cn.nukkit.form.window.FormWindow;
|
||||||
|
import cn.nukkit.utils.TextFormat;
|
||||||
|
import com.alphaae.mcpe.servers.StaticData;
|
||||||
|
import com.alphaae.mcpe.servers.model.RePlayer;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FormWindowMeun extends FormWindow {
|
||||||
|
private final String type = "form";
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private List<ElementButton> buttons;
|
||||||
|
private FormResponseSimple response;
|
||||||
|
|
||||||
|
public FormWindowMeun(Player player) {
|
||||||
|
this.title = "我";
|
||||||
|
this.buttons = new ArrayList();
|
||||||
|
|
||||||
|
String name = player.getName();
|
||||||
|
RePlayer rePlayer = StaticData.rePlayerMap.get(player.getUniqueId());
|
||||||
|
|
||||||
|
this.content = TextFormat.colorize("&b" + name + "&f\n" +
|
||||||
|
"---------------------------------\n" +
|
||||||
|
"称号: " + rePlayer.getTitle() + "\n" +
|
||||||
|
"硬币: " + rePlayer.getCoin() + "\n" +
|
||||||
|
"---------------------------------\n" +
|
||||||
|
"");
|
||||||
|
|
||||||
|
buttons.add(new ElementButton("传送", new ElementButtonImageData(ElementButtonImageData.IMAGE_DATA_TYPE_PATH, "textures/items/ender_pearl.png")));
|
||||||
|
buttons.add(new ElementButton("任务", new ElementButtonImageData(ElementButtonImageData.IMAGE_DATA_TYPE_PATH, "textures/items/book_writable.png")));
|
||||||
|
buttons.add(new ElementButton("升级", new ElementButtonImageData(ElementButtonImageData.IMAGE_DATA_TYPE_PATH, "textures/items/iron_pickaxe.png")));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return this.content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ElementButton> getButtons() {
|
||||||
|
return this.buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addButton(ElementButton button) {
|
||||||
|
this.buttons.add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJSONData() {
|
||||||
|
return (new Gson()).toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormResponseSimple getResponse() {
|
||||||
|
return this.response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponse(String data) {
|
||||||
|
if (data.equals("null")) {
|
||||||
|
this.closed = true;
|
||||||
|
} else {
|
||||||
|
int buttonID;
|
||||||
|
try {
|
||||||
|
buttonID = Integer.parseInt(data);
|
||||||
|
} catch (Exception var4) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonID >= this.buttons.size()) {
|
||||||
|
this.response = new FormResponseSimple(buttonID, (ElementButton) null);
|
||||||
|
} else {
|
||||||
|
this.response = new FormResponseSimple(buttonID, (ElementButton) this.buttons.get(buttonID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
90
src/com/alphaae/mcpe/servers/form/FormWindowOtherPlayer.java
Normal file
90
src/com/alphaae/mcpe/servers/form/FormWindowOtherPlayer.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
package com.alphaae.mcpe.servers.form;
|
||||||
|
|
||||||
|
import cn.nukkit.Player;
|
||||||
|
import cn.nukkit.form.element.ElementButton;
|
||||||
|
import cn.nukkit.form.element.ElementButtonImageData;
|
||||||
|
import cn.nukkit.form.response.FormResponseSimple;
|
||||||
|
import cn.nukkit.form.window.FormWindow;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FormWindowOtherPlayer extends FormWindow {
|
||||||
|
private final String type = "form";
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private List<ElementButton> buttons;
|
||||||
|
private FormResponseSimple response;
|
||||||
|
|
||||||
|
public FormWindowOtherPlayer(Player player) {
|
||||||
|
this.title = "";
|
||||||
|
this.content = "";
|
||||||
|
this.response = null;
|
||||||
|
|
||||||
|
String name = player.getName();
|
||||||
|
String coin = "2000";
|
||||||
|
|
||||||
|
String content = "" + name + "\n" +
|
||||||
|
"---------------------------------\n---------------------------------\n" +
|
||||||
|
"硬币: " + coin + "\n" +
|
||||||
|
"";
|
||||||
|
|
||||||
|
this.title = name;
|
||||||
|
this.content = content;
|
||||||
|
this.buttons = new ArrayList();
|
||||||
|
|
||||||
|
buttons.add(new ElementButton("", new ElementButtonImageData(ElementButtonImageData.IMAGE_DATA_TYPE_PATH, "")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return this.content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ElementButton> getButtons() {
|
||||||
|
return this.buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addButton(ElementButton button) {
|
||||||
|
this.buttons.add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJSONData() {
|
||||||
|
return (new Gson()).toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormResponseSimple getResponse() {
|
||||||
|
return this.response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponse(String data) {
|
||||||
|
if (data.equals("null")) {
|
||||||
|
this.closed = true;
|
||||||
|
} else {
|
||||||
|
int buttonID;
|
||||||
|
try {
|
||||||
|
buttonID = Integer.parseInt(data);
|
||||||
|
} catch (Exception var4) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonID >= this.buttons.size()) {
|
||||||
|
this.response = new FormResponseSimple(buttonID, (ElementButton) null);
|
||||||
|
} else {
|
||||||
|
this.response = new FormResponseSimple(buttonID, (ElementButton) this.buttons.get(buttonID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.alphaae.mcpe.servers.utils;
|
package com.alphaae.mcpe.servers.utils;
|
||||||
|
|
||||||
import cn.nukkit.Player;
|
import cn.nukkit.Player;
|
||||||
|
import cn.nukkit.utils.TextFormat;
|
||||||
import com.alphaae.mcpe.servers.MainPlugin;
|
import com.alphaae.mcpe.servers.MainPlugin;
|
||||||
import com.alphaae.mcpe.servers.model.RePlayer;
|
import com.alphaae.mcpe.servers.model.RePlayer;
|
||||||
|
|
||||||
@ -13,7 +14,6 @@ public class ChangePlayerCoinUtils {
|
|||||||
return PlayerDataLoadUtils.ChangeData(rePlayer);
|
return PlayerDataLoadUtils.ChangeData(rePlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean ReduceIcon(RePlayer rePlayer, int count) {
|
public static boolean ReduceIcon(RePlayer rePlayer, int count) {
|
||||||
int userCoin = rePlayer.getCoin();
|
int userCoin = rePlayer.getCoin();
|
||||||
int newCoin = userCoin - count;
|
int newCoin = userCoin - count;
|
||||||
@ -22,7 +22,22 @@ public class ChangePlayerCoinUtils {
|
|||||||
return PlayerDataLoadUtils.ChangeData(rePlayer);
|
return PlayerDataLoadUtils.ChangeData(rePlayer);
|
||||||
}
|
}
|
||||||
Player player = MainPlugin.getPlugin().getServer().getPlayer(rePlayer.getUuid()).get();
|
Player player = MainPlugin.getPlugin().getServer().getPlayer(rePlayer.getUuid()).get();
|
||||||
player.sendMessage("");
|
player.sendMessage(TextFormat.colorize("&4硬币不足"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean GaveIcon(RePlayer rePlayer1, RePlayer rePlayer2, int count) {
|
||||||
|
int userCoin1 = rePlayer1.getCoin();
|
||||||
|
int userCoin2 = rePlayer2.getCoin();
|
||||||
|
int newCoin1 = userCoin1 - count;
|
||||||
|
int newCoin2 = userCoin2 + count;
|
||||||
|
if (newCoin1 >= 0) {
|
||||||
|
rePlayer1.setCoin(newCoin1);
|
||||||
|
rePlayer2.setCoin(newCoin2);
|
||||||
|
return PlayerDataLoadUtils.ChangeData(rePlayer1) & PlayerDataLoadUtils.ChangeData(rePlayer2);
|
||||||
|
}
|
||||||
|
Player player = MainPlugin.getPlugin().getServer().getPlayer(rePlayer1.getUuid()).get();
|
||||||
|
player.sendMessage(TextFormat.colorize("&4硬币不足"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name: MainPlugin
|
name: AlphaAPI
|
||||||
main: com.alphaae.mcpe.servers.MainPlugin
|
main: com.alphaae.mcpe.servers.MainPlugin
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
api: ["1.0.8"]
|
api: ["1.0.8"]
|
||||||
@ -6,12 +6,18 @@ api: ["1.0.8"]
|
|||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
|
|
||||||
author: alphaAE
|
author: alphaAE
|
||||||
description: AlpheAE的测试插件
|
description: AlpheAE 插件组 核心插件
|
||||||
website: http://www.alphaae.com
|
website: http://www.alphaae.com
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
testplugin.command.menu:
|
alphaapi.command.console:
|
||||||
description: 允许用户使用menu指令
|
description: 允许控制台使用的指令
|
||||||
|
default: false
|
||||||
|
alphaapi.command.op:
|
||||||
|
description: 允许OP用户使用的指令
|
||||||
|
default: op
|
||||||
|
alphaapi.command.everybody:
|
||||||
|
description: 允许所有用户使用的指令
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
#commands:
|
#commands:
|
||||||
|
Reference in New Issue
Block a user