updata
This commit is contained in:
@ -5,6 +5,7 @@ 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.command.UpdataUserDataCommand;
|
||||||
import com.alphaae.mcpe.servers.event.FormRespondedEvent;
|
import com.alphaae.mcpe.servers.event.FormRespondedEvent;
|
||||||
import com.alphaae.mcpe.servers.event.PlayerInventoryEvent;
|
import com.alphaae.mcpe.servers.event.PlayerInventoryEvent;
|
||||||
import com.alphaae.mcpe.servers.event.PlayerInteractSetEvent;
|
import com.alphaae.mcpe.servers.event.PlayerInteractSetEvent;
|
||||||
@ -45,6 +46,7 @@ public class MainPlugin extends PluginBase {
|
|||||||
private void registerCommands() {
|
private void registerCommands() {
|
||||||
SimpleCommandMap commandMap = getServer().getCommandMap();
|
SimpleCommandMap commandMap = getServer().getCommandMap();
|
||||||
commandMap.register("AlphaAPI", new HiCommand(this));
|
commandMap.register("AlphaAPI", new HiCommand(this));
|
||||||
|
commandMap.register("AlphaAPI", new UpdataUserDataCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.alphaae.mcpe.servers.command;
|
||||||
|
|
||||||
|
import cn.nukkit.command.Command;
|
||||||
|
import cn.nukkit.command.CommandSender;
|
||||||
|
import cn.nukkit.utils.TextFormat;
|
||||||
|
import com.alphaae.mcpe.servers.MainPlugin;
|
||||||
|
|
||||||
|
public class UpdataUserDataCommand extends Command {
|
||||||
|
private MainPlugin plugin;
|
||||||
|
|
||||||
|
public UpdataUserDataCommand(MainPlugin plugin) {
|
||||||
|
super("updatauserdata", "更新用户数据指令", "/updatauserdata");
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender commandSender, String s, String[] strings) {
|
||||||
|
if (!this.plugin.isEnabled()) return false;
|
||||||
|
if (!commandSender.hasPermission("alphaapi.command.console")) {
|
||||||
|
commandSender.sendMessage(TextFormat.RED + "你没有权限使用该指令");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commandSender.isPlayer()) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,8 @@ import cn.nukkit.form.element.ElementButton;
|
|||||||
import cn.nukkit.form.element.ElementButtonImageData;
|
import cn.nukkit.form.element.ElementButtonImageData;
|
||||||
import cn.nukkit.form.response.FormResponseSimple;
|
import cn.nukkit.form.response.FormResponseSimple;
|
||||||
import cn.nukkit.form.window.FormWindowSimple;
|
import cn.nukkit.form.window.FormWindowSimple;
|
||||||
|
import cn.nukkit.level.Location;
|
||||||
|
import cn.nukkit.level.Position;
|
||||||
import cn.nukkit.utils.TextFormat;
|
import cn.nukkit.utils.TextFormat;
|
||||||
import com.alphaae.mcpe.servers.StaticData;
|
import com.alphaae.mcpe.servers.StaticData;
|
||||||
import com.alphaae.mcpe.servers.event.block.form.FormEvent;
|
import com.alphaae.mcpe.servers.event.block.form.FormEvent;
|
||||||
@ -27,6 +29,7 @@ public class FormWindowTeleport extends FormWindowSimple implements FormEvent {
|
|||||||
private void createButtons(Player player, RePlayer rePlayer) {
|
private void createButtons(Player player, RePlayer rePlayer) {
|
||||||
addButton(new ElementButton("返回"));
|
addButton(new ElementButton("返回"));
|
||||||
addButton(new ElementButton("上次死亡地点"));
|
addButton(new ElementButton("上次死亡地点"));
|
||||||
|
addButton(new ElementButton("主城"));
|
||||||
addButton(new ElementButton(""));
|
addButton(new ElementButton(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,8 +43,13 @@ public class FormWindowTeleport extends FormWindowSimple implements FormEvent {
|
|||||||
player.showFormWindow(formWindowMeun);
|
player.showFormWindow(formWindowMeun);
|
||||||
break;
|
break;
|
||||||
case "上次死亡地点":
|
case "上次死亡地点":
|
||||||
player.sendMessage("传送");
|
player.sendMessage("" + player.getLevel().getName());
|
||||||
break;
|
break;
|
||||||
|
case "主城":
|
||||||
|
Position spawnLocation = player.getLevel().getSpawnLocation();
|
||||||
|
player.teleport(spawnLocation);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.alphaae.mcpe.servers.model;
|
package com.alphaae.mcpe.servers.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class RePlayer implements Serializable {
|
public class RePlayer implements Serializable {
|
||||||
@ -9,6 +11,8 @@ public class RePlayer implements Serializable {
|
|||||||
private String title;
|
private String title;
|
||||||
//硬币
|
//硬币
|
||||||
private int coin;
|
private int coin;
|
||||||
|
//记录的传送点
|
||||||
|
private Map<String, UserLocation> userLocationMap = new HashMap<>();
|
||||||
|
|
||||||
public RePlayer(UUID uuid, String title, int coin) {
|
public RePlayer(UUID uuid, String title, int coin) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
@ -39,4 +43,28 @@ public class RePlayer implements Serializable {
|
|||||||
public void setCoin(int coin) {
|
public void setCoin(int coin) {
|
||||||
this.coin = coin;
|
this.coin = coin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, UserLocation> getUserLocationMap() {
|
||||||
|
return userLocationMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean putUserLocation(String name, UserLocation location) {
|
||||||
|
try {
|
||||||
|
userLocationMap.put(name, location);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeUserLocation(String name) {
|
||||||
|
try {
|
||||||
|
userLocationMap.remove(name);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
7
src/com/alphaae/mcpe/servers/model/UserLocation.java
Normal file
7
src/com/alphaae/mcpe/servers/model/UserLocation.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.alphaae.mcpe.servers.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class UserLocation implements Serializable {
|
||||||
|
|
||||||
|
}
|
@ -26,7 +26,7 @@ public class ChangePlayerCoinUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean GaveIcon(RePlayer rePlayer1, RePlayer rePlayer2, int count) {
|
public static boolean GiveIcon(RePlayer rePlayer1, RePlayer rePlayer2, int count) {
|
||||||
int userCoin1 = rePlayer1.getCoin();
|
int userCoin1 = rePlayer1.getCoin();
|
||||||
int userCoin2 = rePlayer2.getCoin();
|
int userCoin2 = rePlayer2.getCoin();
|
||||||
int newCoin1 = userCoin1 - count;
|
int newCoin1 = userCoin1 - count;
|
||||||
|
Reference in New Issue
Block a user