mirror of
https://github.com/CarmJos/MoeTeleport.git
synced 2024-09-19 21:35:56 +00:00
实装setHome判断最多设置数量的功能
This commit is contained in:
parent
fe243c9214
commit
af99af9827
@ -18,6 +18,15 @@ public class SetHomeCommand implements CommandExecutor {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
UserData data = Main.getUserManager().getData(player);
|
UserData data = Main.getUserManager().getData(player);
|
||||||
String homeName = args.length >= 1 ? args[0] : "home";
|
String homeName = args.length >= 1 ? args[0] : "home";
|
||||||
|
|
||||||
|
int maxHome = Main.getUserManager().getMaxHome(player);
|
||||||
|
if (data.getHomeLocations().size() >= maxHome && data.getHomeLocation(homeName) == null) {
|
||||||
|
PluginMessages.Home.OVER_LIMIT.sendWithPlaceholders(sender,
|
||||||
|
new String[]{"%(max)"}, new Object[]{maxHome}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
data.setHomeLocation(homeName, player.getLocation());
|
data.setHomeLocation(homeName, player.getLocation());
|
||||||
PluginMessages.Home.SET.sendWithPlaceholders(player,
|
PluginMessages.Home.SET.sendWithPlaceholders(player,
|
||||||
new String[]{"%(name)"}, new Object[]{homeName}
|
new String[]{"%(name)"}, new Object[]{homeName}
|
||||||
|
@ -40,6 +40,9 @@ public class PluginMessages {
|
|||||||
public static final ConfigMessageList HEADER = new ConfigMessageList("home-list-header");
|
public static final ConfigMessageList HEADER = new ConfigMessageList("home-list-header");
|
||||||
public static final ConfigMessage LIST_OBJECT = new ConfigMessage("home-list-object");
|
public static final ConfigMessage LIST_OBJECT = new ConfigMessage("home-list-object");
|
||||||
|
|
||||||
|
public static final ConfigMessageList OVER_LIMIT = new ConfigMessageList("home-over-limit");
|
||||||
|
|
||||||
|
|
||||||
public static final ConfigMessageList NOT_FOUND = new ConfigMessageList("home-not-found");
|
public static final ConfigMessageList NOT_FOUND = new ConfigMessageList("home-not-found");
|
||||||
public static final ConfigMessageList SET = new ConfigMessageList("home-set");
|
public static final ConfigMessageList SET = new ConfigMessageList("home-set");
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.carm.plugin.moeteleport.manager;
|
package cc.carm.plugin.moeteleport.manager;
|
||||||
|
|
||||||
import cc.carm.plugin.moeteleport.Main;
|
import cc.carm.plugin.moeteleport.Main;
|
||||||
|
import cc.carm.plugin.moeteleport.configuration.PluginConfig;
|
||||||
import cc.carm.plugin.moeteleport.model.UserData;
|
import cc.carm.plugin.moeteleport.model.UserData;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -8,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UserManager {
|
public class UserManager {
|
||||||
@ -38,6 +40,17 @@ public class UserManager {
|
|||||||
return getUserDataMap().get(player.getUniqueId());
|
return getUserDataMap().get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxHome(Player player) {
|
||||||
|
Map<String, Integer> permissions = PluginConfig.PERMISSIONS.get();
|
||||||
|
int value = PluginConfig.DEFAULT_HOME.get();
|
||||||
|
for (Map.Entry<String, Integer> entry : permissions.entrySet()) {
|
||||||
|
if (entry.getValue() > value && player.hasPermission(entry.getKey())) {
|
||||||
|
value = entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public HashMap<UUID, UserData> getUserDataMap() {
|
public HashMap<UUID, UserData> getUserDataMap() {
|
||||||
return userDataMap;
|
return userDataMap;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.carm.plugin.moeteleport.model;
|
package cc.carm.plugin.moeteleport.model;
|
||||||
|
|
||||||
import cc.carm.plugin.moeteleport.Main;
|
import cc.carm.plugin.moeteleport.Main;
|
||||||
|
import cc.carm.plugin.moeteleport.configuration.PluginConfig;
|
||||||
import cc.carm.plugin.moeteleport.configuration.location.DataLocation;
|
import cc.carm.plugin.moeteleport.configuration.location.DataLocation;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -103,6 +104,8 @@ public class UserData {
|
|||||||
return receivedRequests;
|
return receivedRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public @NotNull File getDataFile() {
|
public @NotNull File getDataFile() {
|
||||||
return dataFile;
|
return dataFile;
|
||||||
}
|
}
|
||||||
|
@ -54,3 +54,7 @@ home-set:
|
|||||||
home-removed:
|
home-removed:
|
||||||
- "&f成功移除名为 &6%(name) &f的家传送点。"
|
- "&f成功移除名为 &6%(name) &f的家传送点。"
|
||||||
- "&7原先位置为 &f%(location) &7。"
|
- "&7原先位置为 &f%(location) &7。"
|
||||||
|
home-over-limit:
|
||||||
|
- "&f您最多只能设置 &6%(max) &f个家传送点!"
|
||||||
|
- "&7可以输入 &e/delHome <家名称> &7删除之前的家传送点,"
|
||||||
|
- "&7或输入 &e/setHome <家名称> &7覆盖之前的家传送点。"
|
Loading…
Reference in New Issue
Block a user