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:
commit
e43e20debb
16
.classpath
Normal file
16
.classpath
Normal file
@ -0,0 +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="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"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
# Eclipse stuff
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
/repo
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Project Stuff
|
||||
/src/main/resources/Soulbound
|
||||
|
||||
# Atlassian Stuff
|
||||
/atlassian-ide-plugin.xml
|
23
.project
Normal file
23
.project
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>PvPTitles</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
46
pom.xml
Normal file
46
pom.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.mikeundead</groupId>
|
||||
<artifactId>PvPTitles</artifactId>
|
||||
<version>1.2.9d</version>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
||||
<update.description></update.description>
|
||||
<env.BUILD_NUMBER>Debug</env.BUILD_NUMBER>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
168
src/main/java/com/gmail/mikeundead/DatabaseHandler.java
Normal file
168
src/main/java/com/gmail/mikeundead/DatabaseHandler.java
Normal file
@ -0,0 +1,168 @@
|
||||
package com.gmail.mikeundead;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class DatabaseHandler {
|
||||
private final PvPTitles pvpTitles;
|
||||
private int Fame;
|
||||
private final Map<Integer, String> rankList;
|
||||
private final Map<Integer, Integer> reqFame;
|
||||
public ChatColor PrefixColor;
|
||||
private String tag;
|
||||
|
||||
public DatabaseHandler(final PvPTitles pvpTitles) {
|
||||
this.rankList = new HashMap<Integer, String>();
|
||||
this.reqFame = new HashMap<Integer, Integer>();
|
||||
this.pvpTitles = pvpTitles;
|
||||
this.SaveConfig();
|
||||
}
|
||||
|
||||
public void FirstRun(final String playername) {
|
||||
final File file = new File((new StringBuilder())
|
||||
.append(this.pvpTitles.getDataFolder())
|
||||
.append(File.separator)
|
||||
.append("players")
|
||||
.append(File.separator)
|
||||
.append(playername)
|
||||
.append(".yml")
|
||||
.toString());
|
||||
|
||||
if (!file.exists()) {
|
||||
this.pvpTitles.getDataFolder().mkdirs();
|
||||
|
||||
final FileConfiguration config = new YamlConfiguration();
|
||||
config.set("Fame", 0);
|
||||
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
public void LoadConfig() {
|
||||
final File file = new File(this.pvpTitles.getDataFolder(), "config.yml");
|
||||
final FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
final List<String> configList = config.getStringList("RankNames");
|
||||
for (int i = 0; i < configList.size(); i++) {
|
||||
this.rankList.put(i, configList.get(i));
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<Integer> derp = (List<Integer>) config.getList("ReqFame");
|
||||
for (int i = 0; i < derp.size(); i++) {
|
||||
this.reqFame.put(i, derp.get(i));
|
||||
}
|
||||
this.GetPrefixColor(config.getString("PrefixColor"));
|
||||
tag = config.getString("Tag");
|
||||
if (configList.size() != derp.size()) {
|
||||
this.pvpTitles.log.info("WARNING - RankNames and ReqFame are not equal in their numbers.");
|
||||
this.pvpTitles.log.info("WARNING - RankNames and ReqFame are not equal in their numbers.");
|
||||
this.pvpTitles.log.info("WARNING - RankNames and ReqFame are not equal in their numbers.");
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadPlayerFame(final String playername) {
|
||||
final File file = new File((new StringBuilder())
|
||||
.append(this.pvpTitles.getDataFolder())
|
||||
.append(File.separator)
|
||||
.append("players")
|
||||
.append(File.separator)
|
||||
.append(playername)
|
||||
.append(".yml")
|
||||
.toString());
|
||||
|
||||
final FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
this.Fame = config.getInt("Fame");
|
||||
}
|
||||
|
||||
public int PlayerFame() {
|
||||
return this.Fame;
|
||||
}
|
||||
|
||||
public Map<Integer, String> RankList() {
|
||||
return this.rankList;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> reqFame() {
|
||||
return this.reqFame;
|
||||
}
|
||||
|
||||
public void SaveConfig() {
|
||||
final File file = new File(this.pvpTitles.getDataFolder(), "config.yml");
|
||||
|
||||
if (!file.exists()) {
|
||||
this.pvpTitles.getDataFolder().mkdirs();
|
||||
final FileConfiguration config = new YamlConfiguration();
|
||||
final String[] ranks = { "None",
|
||||
"Hero",
|
||||
"Fierce Hero",
|
||||
"Mighty Hero",
|
||||
"Deadly Hero",
|
||||
"Terrifying Hero",
|
||||
"Conquering Hero",
|
||||
"Subjugating Hero",
|
||||
"Vanquishing Hero",
|
||||
"Renowned Hero",
|
||||
"Illustrious Hero",
|
||||
"Eminent Hero",
|
||||
"King's Hero",
|
||||
"Emperor's Hero",
|
||||
"Balthazar's Hero",
|
||||
"Legendary Hero" };
|
||||
final Integer[] reqfame = { 0, 25, 75, 180, 360, 600, 1000, 1680, 2800, 4665, 7750, 12960, 21600, 36000, 60000, 100000 };
|
||||
config.set("Tag", "Fame");
|
||||
config.set("PrefixColor", "green");
|
||||
config.set("RankNames", Arrays.asList(ranks));
|
||||
config.set("ReqFame", Arrays.asList(reqfame));
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SavePlayerFame(final String playername, final int fame) {
|
||||
final File file = new File((new StringBuilder())
|
||||
.append(this.pvpTitles.getDataFolder())
|
||||
.append(File.separator)
|
||||
.append("players")
|
||||
.append(File.separator)
|
||||
.append(playername)
|
||||
.append(".yml")
|
||||
.toString());
|
||||
if (!file.exists()) {
|
||||
this.pvpTitles.getDataFolder().mkdir();
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
final FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
config.set("Fame", fame);
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void GetPrefixColor(final String color) {
|
||||
this.PrefixColor = ChatColor.valueOf(color.toUpperCase());
|
||||
}
|
||||
}
|
111
src/main/java/com/gmail/mikeundead/HandlePlayerPrefix.java
Normal file
111
src/main/java/com/gmail/mikeundead/HandlePlayerPrefix.java
Normal file
@ -0,0 +1,111 @@
|
||||
package com.gmail.mikeundead;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class HandlePlayerPrefix implements Listener {
|
||||
private final DatabaseHandler databaseHandler;
|
||||
private final Ranks ranks;
|
||||
@SuppressWarnings("unused")
|
||||
private final PvPTitles pvpTitles;
|
||||
|
||||
Map<String, Integer> map = new HashMap<String, Integer>();
|
||||
|
||||
public HandlePlayerPrefix(final DatabaseHandler databaseHandler, final Ranks ranks, final PvPTitles pvpTitles) {
|
||||
this.databaseHandler = databaseHandler;
|
||||
this.ranks = ranks;
|
||||
this.pvpTitles = pvpTitles;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKill(final PlayerDeathEvent death) {
|
||||
int kills = 0;
|
||||
|
||||
if (death.getEntity().getKiller() != null) {
|
||||
final String killed = death.getEntity().getName();
|
||||
final Player player = death.getEntity().getKiller();
|
||||
|
||||
if (this.map.containsKey(player.getName())) {
|
||||
kills = this.map.get(player.getName());
|
||||
}
|
||||
if (this.map.containsKey(killed)) {
|
||||
this.map.put(killed, 0);
|
||||
}
|
||||
|
||||
this.databaseHandler.LoadPlayerFame(player.getName());
|
||||
final int fame = this.databaseHandler.PlayerFame();
|
||||
|
||||
if (!player.getName().equalsIgnoreCase(killed)) {
|
||||
this.calculateFame(killed, player, fame, kills);
|
||||
}
|
||||
|
||||
kills++;
|
||||
this.map.put(player.getName(), kills);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChat(final AsyncPlayerChatEvent event) {
|
||||
String rank = null;
|
||||
|
||||
this.databaseHandler.LoadPlayerFame(event.getPlayer().getName());
|
||||
this.databaseHandler.LoadConfig();
|
||||
|
||||
rank = this.ranks.GetRank(this.databaseHandler.PlayerFame());
|
||||
|
||||
if (rank != null && rank != "") {
|
||||
final String a = String.format(ChatColor.WHITE + "[" + this.databaseHandler.PrefixColor + rank + ChatColor.WHITE + "] ");
|
||||
final String format = event.getFormat();
|
||||
event.setFormat(a + format);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLogin(final PlayerLoginEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
try {
|
||||
this.databaseHandler.FirstRun(player.getName());
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
this.map.put(player.getName(), 0);
|
||||
}
|
||||
|
||||
private void calculateFame(final String killed, final Player player, int fame, final int kills) {
|
||||
final int a = this.databaseHandler.PlayerFame();
|
||||
final String tag = this.databaseHandler.getTag();
|
||||
if (kills == 0) {
|
||||
fame++;
|
||||
player.sendMessage(ChatColor.GREEN + "You killed " + killed + " and received 1 " + tag + ".");
|
||||
}
|
||||
if (kills >= 1) {
|
||||
fame = fame + 1;
|
||||
player.sendMessage(ChatColor.GREEN + "You killed " + killed + " and received 1 " + tag + ".");
|
||||
}
|
||||
this.databaseHandler.SavePlayerFame(player.getName(), fame);
|
||||
this.databaseHandler.LoadPlayerFame(player.getName());
|
||||
|
||||
final String currentRank = this.ranks.GetRank(a);
|
||||
final String newRank = this.ranks.GetRank(fame);
|
||||
|
||||
if (!currentRank.equalsIgnoreCase(newRank)) {
|
||||
player.sendMessage(ChatColor.GREEN + "Congrats! You are now a " + newRank);
|
||||
}
|
||||
}
|
||||
}
|
76
src/main/java/com/gmail/mikeundead/LeaderBoardCommand.java
Normal file
76
src/main/java/com/gmail/mikeundead/LeaderBoardCommand.java
Normal file
@ -0,0 +1,76 @@
|
||||
package com.gmail.mikeundead;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LeaderBoardCommand implements CommandExecutor {
|
||||
private final PvPTitles pvpTitles;
|
||||
private final TreeMap<Integer, String> RankedPlayers;
|
||||
|
||||
public LeaderBoardCommand(final PvPTitles pvpTitles) {
|
||||
this.pvpTitles = pvpTitles;
|
||||
this.RankedPlayers = new TreeMap<Integer, String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String arg, final String[] args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
if (cmd.getName().equalsIgnoreCase("ladder")) {
|
||||
this.LadderCmd(player);
|
||||
}
|
||||
if (args.length > 0) {
|
||||
player.sendMessage(ChatColor.RED + "Too many arguments!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void LadderCmd(final Player player) {
|
||||
this.SetTopTenPlayers(player);
|
||||
|
||||
player.sendMessage(ChatColor.AQUA + "Ladder - Top Five Players");
|
||||
player.sendMessage(ChatColor.AQUA + "------------------------");
|
||||
final NavigableMap<Integer, String> sortedMap = this.RankedPlayers.descendingMap();
|
||||
int number = 0;
|
||||
for (final Map.Entry<Integer, String> entry : sortedMap.entrySet()) {
|
||||
if (number != 5) {
|
||||
player.sendMessage((number + 1) + ". " + entry.getValue() + " (" + entry.getKey() + ")");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
number++;
|
||||
}
|
||||
|
||||
sortedMap.clear();
|
||||
this.RankedPlayers.clear();
|
||||
}
|
||||
|
||||
private void SetTopTenPlayers(final Player player) {
|
||||
final File file = new File((new StringBuilder()).append(this.pvpTitles.getDataFolder()).append(File.separator).append("players").toString());
|
||||
final File[] allFiles = file.listFiles();
|
||||
for (final File item : allFiles) {
|
||||
final File ladderFile = new File((new StringBuilder())
|
||||
.append(this.pvpTitles.getDataFolder())
|
||||
.append(File.separator)
|
||||
.append("players")
|
||||
.append(File.separator)
|
||||
.append(item.getName())
|
||||
.toString());
|
||||
final FileConfiguration config = YamlConfiguration.loadConfiguration(ladderFile);
|
||||
final int fame = config.getInt("Fame");
|
||||
this.RankedPlayers.put(fame, item.getName().replaceAll(".yml", ""));
|
||||
}
|
||||
}
|
||||
}
|
27
src/main/java/com/gmail/mikeundead/PvPTitles.java
Normal file
27
src/main/java/com/gmail/mikeundead/PvPTitles.java
Normal file
@ -0,0 +1,27 @@
|
||||
package com.gmail.mikeundead;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class PvPTitles extends JavaPlugin {
|
||||
public Logger log;
|
||||
private RankCommand rankCommand;
|
||||
private DatabaseHandler databaseHandler;
|
||||
private Ranks ranks;
|
||||
private HandlePlayerPrefix handlePlayerPrefix;
|
||||
private LeaderBoardCommand ladder;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.log = getLogger();
|
||||
this.databaseHandler = new DatabaseHandler(this);
|
||||
this.ranks = new Ranks(this.databaseHandler, this);
|
||||
this.rankCommand = new RankCommand(this.databaseHandler, this.ranks);
|
||||
this.handlePlayerPrefix = new HandlePlayerPrefix(this.databaseHandler, this.ranks, this);
|
||||
this.ladder = new LeaderBoardCommand(this);
|
||||
getServer().getPluginManager().registerEvents(handlePlayerPrefix, this);
|
||||
getCommand("rank").setExecutor(this.rankCommand);
|
||||
getCommand("ladder").setExecutor(this.ladder);
|
||||
}
|
||||
}
|
52
src/main/java/com/gmail/mikeundead/RankCommand.java
Normal file
52
src/main/java/com/gmail/mikeundead/RankCommand.java
Normal file
@ -0,0 +1,52 @@
|
||||
package com.gmail.mikeundead;
|
||||
|
||||
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 RankCommand implements CommandExecutor {
|
||||
private final DatabaseHandler databaseHandler;
|
||||
private final Ranks ranks;
|
||||
|
||||
public RankCommand(final DatabaseHandler databaseHandler, final Ranks ranks) {
|
||||
this.databaseHandler = databaseHandler;
|
||||
this.ranks = ranks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String arg, final String[] args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
if (cmd.getName().equalsIgnoreCase("rank")) {
|
||||
this.HandleRankCmd(player);
|
||||
}
|
||||
if (args.length > 0) {
|
||||
player.sendMessage(ChatColor.RED + "Too many arguments!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void HandleRankCmd(final Player player) {
|
||||
this.databaseHandler.LoadPlayerFame(player.getName());
|
||||
this.databaseHandler.LoadConfig();
|
||||
final int fame = this.databaseHandler.PlayerFame();
|
||||
final String rank = this.ranks.GetRank(fame);
|
||||
final int rankup = this.ranks.FameToRankUp();
|
||||
final String tag = this.databaseHandler.getTag();
|
||||
if (rank == "") {
|
||||
player.sendMessage("Rank: none");
|
||||
} else {
|
||||
player.sendMessage("Rank: " + rank);
|
||||
}
|
||||
player.sendMessage(tag + ": " + fame);
|
||||
if (rankup == 999999) {
|
||||
player.sendMessage("You are max ranked.");
|
||||
} else {
|
||||
player.sendMessage("Rankup: " + rankup);
|
||||
}
|
||||
}
|
||||
}
|
46
src/main/java/com/gmail/mikeundead/Ranks.java
Normal file
46
src/main/java/com/gmail/mikeundead/Ranks.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.gmail.mikeundead;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Ranks {
|
||||
private int nextRank;
|
||||
private final DatabaseHandler databaseHandler;
|
||||
private final Map<Integer, String> rankList;
|
||||
private Map<Integer, Integer> reqFame;
|
||||
|
||||
public Ranks(final DatabaseHandler databaseHandler, final PvPTitles pvpTitles) {
|
||||
this.databaseHandler = databaseHandler;
|
||||
this.databaseHandler.LoadConfig();
|
||||
this.rankList = this.databaseHandler.RankList();
|
||||
this.reqFame = this.databaseHandler.reqFame();
|
||||
}
|
||||
|
||||
public int FameToRankUp() {
|
||||
return this.nextRank;
|
||||
}
|
||||
|
||||
public String GetRank(final int fame) {
|
||||
String rank = "";
|
||||
this.reqFame = this.databaseHandler.reqFame();
|
||||
for (int i = 0; i < this.reqFame.size(); i++) {
|
||||
if (fame >= this.reqFame.get(0) && fame < this.reqFame.get(1)) {
|
||||
if (!this.rankList.get(0).equalsIgnoreCase("none")) {
|
||||
rank = this.rankList.get(0);
|
||||
}
|
||||
this.nextRank = this.reqFame.get(1) - fame;
|
||||
break;
|
||||
}
|
||||
if (fame >= this.reqFame.get(i) && fame < this.reqFame.get(i + 1)) {
|
||||
rank = this.rankList.get(i);
|
||||
this.nextRank = this.reqFame.get(i + 1) - fame;
|
||||
break;
|
||||
}
|
||||
if (fame >= this.reqFame.get(this.reqFame.values().size() - 1)) {
|
||||
rank = this.rankList.get(this.reqFame.values().size() - 1);
|
||||
this.nextRank = 999999;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rank;
|
||||
}
|
||||
}
|
41
src/main/resources/config.yml
Normal file
41
src/main/resources/config.yml
Normal file
@ -0,0 +1,41 @@
|
||||
Tag: Fame
|
||||
PrefixColor: green
|
||||
RankNames:
|
||||
- None
|
||||
- Hero
|
||||
- Fierce Hero
|
||||
- Mighty Hero
|
||||
- Deadly Hero
|
||||
- Terrifying Hero
|
||||
- Conquering Hero
|
||||
- Subjugating Hero
|
||||
- Vanquishing Hero
|
||||
- Renowned Hero
|
||||
- Illustrious Hero
|
||||
- Eminent Hero
|
||||
- King's Hero
|
||||
- Emperor's Hero
|
||||
- Balthazar's Hero
|
||||
- Legendary Hero
|
||||
ReqFame:
|
||||
- 0
|
||||
- 25
|
||||
- 75
|
||||
- 180
|
||||
- 360
|
||||
- 600
|
||||
- 1000
|
||||
- 1680
|
||||
- 2800
|
||||
- 4665
|
||||
- 7750
|
||||
- 12960
|
||||
- 21600
|
||||
- 36000
|
||||
- 60000
|
||||
- 100000
|
||||
ReqShengwang:
|
||||
5: give {player} 1
|
||||
10: give {player} 1
|
||||
30: give {player} 1
|
||||
80: give {player} 1
|
18
src/main/resources/plugin.yml
Normal file
18
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,18 @@
|
||||
name: PvPTitles
|
||||
main: com.gmail.mikeundead.PvPTitles
|
||||
version: 1.2.9d
|
||||
softdepend: [Vault]
|
||||
commands:
|
||||
rank:
|
||||
description: Shows your current stats
|
||||
usage: /rank
|
||||
ladder:
|
||||
description: Shows the top 5 players
|
||||
usage: /ladder
|
||||
permissions:
|
||||
pvptitles.rank:
|
||||
description: Allows you to see rank
|
||||
pvptitles.ladder:
|
||||
description: Allows you to see the ladder
|
||||
pvptitles.fame:
|
||||
description: Allow you to use fame
|
Loading…
Reference in New Issue
Block a user