mirror of
https://e.coding.net/circlecloud/PvPTitles.git
synced 2024-12-21 15:28:46 +00:00
添加点数命令 完成配置选项...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
215d8164b5
commit
1973fd217e
13
.classpath
13
.classpath
@ -1,7 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.mikeundead</groupId>
|
||||
<artifactId>PvPTitles</artifactId>
|
||||
<version>1.2.9d</version>
|
||||
<version>1.3</version>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<resources>
|
||||
|
53
src/main/java/com/gmail/mikeundead/CashCommand.java
Normal file
53
src/main/java/com/gmail/mikeundead/CashCommand.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.gmail.mikeundead;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CashCommand implements CommandExecutor {
|
||||
private final DatabaseHandler databaseHandler;
|
||||
|
||||
public CashCommand(final DatabaseHandler databaseHandler) {
|
||||
this.databaseHandler = databaseHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String arg, final String[] args) {
|
||||
Player player = null;
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
player = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
this.databaseHandler.LoadPlayerData(player.getName());
|
||||
this.databaseHandler.LoadConfig();
|
||||
final int point = this.databaseHandler.getPoints();
|
||||
final String strnum = args[0];
|
||||
int num = 0;
|
||||
try {
|
||||
num = Integer.valueOf(strnum);
|
||||
} catch (final Exception e) {
|
||||
sender.sendMessage("§c参数必须为数字!");
|
||||
return true;
|
||||
}
|
||||
if (num > point) {
|
||||
sender.sendMessage("§c您的点数不足以购买!");
|
||||
return true;
|
||||
}
|
||||
if (!databaseHandler.getCashList().containsKey(num)) {
|
||||
sender.sendMessage("§c不存在当前的物品!");
|
||||
return true;
|
||||
}
|
||||
databaseHandler.setPoints(point - num);
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), databaseHandler.getCashList().get(num).replace("{player}", player.getName()));
|
||||
databaseHandler.SaveConfig();
|
||||
sender.sendMessage("§a兑换成功!");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "不正确的参数!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@ -17,13 +18,16 @@ public class DatabaseHandler {
|
||||
private int Points;
|
||||
private final Map<Integer, String> rankList;
|
||||
private final Map<Integer, Integer> reqFame;
|
||||
private final Map<Integer, String> cashList;
|
||||
public ChatColor PrefixColor;
|
||||
|
||||
private String tag;
|
||||
private String ptag;
|
||||
|
||||
public DatabaseHandler(final PvPTitles pvpTitles) {
|
||||
this.rankList = new HashMap<Integer, String>();
|
||||
this.reqFame = new HashMap<Integer, Integer>();
|
||||
this.rankList = new HashMap<>();
|
||||
this.reqFame = new HashMap<>();
|
||||
this.cashList = new HashMap<>();
|
||||
this.pvpTitles = pvpTitles;
|
||||
this.SaveConfig();
|
||||
}
|
||||
@ -52,6 +56,13 @@ public class DatabaseHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return cashList
|
||||
*/
|
||||
public Map<Integer, String> getCashList() {
|
||||
return cashList;
|
||||
}
|
||||
|
||||
public int getFame() {
|
||||
return this.Fame;
|
||||
}
|
||||
@ -81,6 +92,15 @@ public class DatabaseHandler {
|
||||
this.reqFame.put(i, derp.get(i));
|
||||
}
|
||||
this.GetPrefixColor(config.getString("PrefixColor"));
|
||||
final ConfigurationSection cash = config.getConfigurationSection("Cash");
|
||||
for (final String key : cash.getKeys(false)) {
|
||||
try {
|
||||
final Integer num = Integer.valueOf(key);
|
||||
cashList.put(num, cash.getString(key));
|
||||
} catch (final Exception e) {
|
||||
pvpTitles.getLogger().warning(key + "不是一个数字 已忽略!");
|
||||
}
|
||||
}
|
||||
tag = config.getString("Tag");
|
||||
if (configList.size() != derp.size()) {
|
||||
this.pvpTitles.log.info("WARNING - RankNames and ReqFame are not equal in their numbers.");
|
||||
@ -138,6 +158,9 @@ public class DatabaseHandler {
|
||||
config.set("PrefixColor", "green");
|
||||
config.set("RankNames", Arrays.asList(ranks));
|
||||
config.set("ReqFame", Arrays.asList(reqfame));
|
||||
config.set("Cash.10", "give {player} 1 1");
|
||||
config.set("Cash.20", "give {player} 1 2");
|
||||
config.set("Cash.30", "give {player} 1 3");
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (final IOException e) {
|
||||
|
@ -32,7 +32,7 @@ public class LeaderBoardCommand implements CommandExecutor {
|
||||
this.LadderCmd(player);
|
||||
}
|
||||
if (args.length > 0) {
|
||||
player.sendMessage(ChatColor.RED + "Too many arguments!");
|
||||
player.sendMessage(ChatColor.RED + "过多的参数!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -40,7 +40,7 @@ public class LeaderBoardCommand implements CommandExecutor {
|
||||
private void LadderCmd(final Player player) {
|
||||
this.SetTopTenPlayers(player);
|
||||
|
||||
player.sendMessage(ChatColor.AQUA + "Ladder - Top Five Players");
|
||||
player.sendMessage(ChatColor.AQUA + "天梯 - 前五的玩家");
|
||||
player.sendMessage(ChatColor.AQUA + "------------------------");
|
||||
final NavigableMap<Integer, String> sortedMap = this.RankedPlayers.descendingMap();
|
||||
int number = 0;
|
||||
|
@ -11,6 +11,7 @@ public class PvPTitles extends JavaPlugin {
|
||||
private Ranks ranks;
|
||||
private HandlePlayerPrefix handlePlayerPrefix;
|
||||
private LeaderBoardCommand ladder;
|
||||
private CashCommand cash;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -20,8 +21,10 @@ public class PvPTitles extends JavaPlugin {
|
||||
this.rankCommand = new RankCommand(this.databaseHandler, this.ranks);
|
||||
this.handlePlayerPrefix = new HandlePlayerPrefix(this.databaseHandler, this.ranks, this);
|
||||
this.ladder = new LeaderBoardCommand(this);
|
||||
this.cash = new CashCommand(databaseHandler);
|
||||
getServer().getPluginManager().registerEvents(handlePlayerPrefix, this);
|
||||
getCommand("rank").setExecutor(this.rankCommand);
|
||||
getCommand("ladder").setExecutor(this.ladder);
|
||||
getCommand("cash").setExecutor(this.cash);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class RankCommand implements CommandExecutor {
|
||||
this.HandleRankCmd(player);
|
||||
}
|
||||
if (args.length > 0) {
|
||||
player.sendMessage(ChatColor.RED + "Too many arguments!");
|
||||
player.sendMessage(ChatColor.RED + "过多的参数!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -37,16 +37,19 @@ public class RankCommand implements CommandExecutor {
|
||||
final String rank = this.ranks.GetRank(fame);
|
||||
final int rankup = this.ranks.FameToRankUp();
|
||||
final String tag = this.databaseHandler.getTag();
|
||||
final int point = this.databaseHandler.getPoints();
|
||||
if (rank == "") {
|
||||
player.sendMessage("Rank: none");
|
||||
player.sendMessage("等级: 无");
|
||||
} else {
|
||||
player.sendMessage("Rank: " + rank);
|
||||
player.sendMessage("等级: " + rank);
|
||||
}
|
||||
|
||||
player.sendMessage(tag + ": " + fame);
|
||||
player.sendMessage("点数: " + point);
|
||||
if (rankup == 999999) {
|
||||
player.sendMessage("You are max ranked.");
|
||||
player.sendMessage("您已到达最大等级.");
|
||||
} else {
|
||||
player.sendMessage("Rankup: " + rankup);
|
||||
player.sendMessage("下一级: " + rankup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ ReqFame:
|
||||
- 36000
|
||||
- 60000
|
||||
- 100000
|
||||
ReqShengwang:
|
||||
Cash:
|
||||
5: give {player} 1
|
||||
10: give {player} 1
|
||||
30: give {player} 1
|
||||
|
@ -1,13 +1,16 @@
|
||||
name: PvPTitles
|
||||
main: com.gmail.mikeundead.PvPTitles
|
||||
version: 1.2.9d
|
||||
version: ${project.version}
|
||||
softdepend: [Vault]
|
||||
commands:
|
||||
rank:
|
||||
description: Shows your current stats
|
||||
description: 显示状态
|
||||
usage: /rank
|
||||
ladder:
|
||||
description: Shows the top 5 players
|
||||
description: 显示前五名玩家
|
||||
usage: /ladder
|
||||
cash:
|
||||
description: 兑换物品
|
||||
usage: /ladder
|
||||
permissions:
|
||||
pvptitles.rank:
|
||||
|
Loading…
Reference in New Issue
Block a user