Initial commit
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>ProjectCranked</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>PvPTop</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>Factions</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Spawners</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Enchants</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Armor</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>StorageUtilsShaded</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../StorageUtils/target/StorageUtils-1.0-shaded.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>FactionsKore</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../.lib/FactionsKore-1.3.431.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.crankedpvp.pvptop;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import net.crankedpvp.crankedutils.utils.Arrow;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.FactionUtils;
|
||||
import net.crankedpvp.pvptop.data.FactionData;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PvPTopAPI {
|
||||
|
||||
public static final String PREFIX = "&b&lPoints &8" + Arrow.arrow() + " &7";
|
||||
|
||||
public static FactionData getFactionData(Faction faction) {
|
||||
return PvPTopPlugin.getInstance().getPvpTopManager().getOrCreate(faction);
|
||||
}
|
||||
|
||||
public static FactionData getFactionData(String factionId) {
|
||||
return PvPTopPlugin.getInstance().getPvpTopManager().getOrCreate(Factions.getInstance().getFactionById(factionId));
|
||||
}
|
||||
|
||||
public static FactionData getFactionData(Player player) {
|
||||
return PvPTopPlugin.getInstance().getPvpTopManager().getOrCreate(FactionUtils.getFaction(player));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package net.crankedpvp.pvptop;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import lombok.Getter;
|
||||
import me.mattstudios.mf.base.CommandManager;
|
||||
import me.mattstudios.mf.base.components.TypeResult;
|
||||
import net.crankedpvp.crankedenchants.struct.enchantstruct.Enchantment;
|
||||
import net.crankedpvp.crankedenchants.struct.enums.EnchantTier;
|
||||
import net.crankedpvp.pvptop.commands.PvPTopCommand;
|
||||
import net.crankedpvp.pvptop.data.FactionData;
|
||||
import net.crankedpvp.pvptop.data.PvPTopManager;
|
||||
import net.crankedpvp.pvptop.inventory.ObtainPointsMethodsInventory;
|
||||
import net.crankedpvp.pvptop.inventory.PvPTopInventory;
|
||||
import net.crankedpvp.pvptop.listeners.FactionDisbandCheck;
|
||||
import net.crankedpvp.pvptop.listeners.KothCaptureListener;
|
||||
import net.crankedpvp.pvptop.listeners.PlayerDeathListener;
|
||||
import net.crankedpvp.pvptop.tasks.UpdateLeaderboardTask;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PvPTopPlugin extends JavaPlugin {
|
||||
|
||||
@Getter
|
||||
private static PvPTopPlugin instance;
|
||||
|
||||
@Getter
|
||||
private PvPTopManager pvpTopManager;
|
||||
|
||||
@Getter
|
||||
private UpdateLeaderboardTask updateLeaderboardTask;
|
||||
|
||||
@Getter
|
||||
private CommandManager commandManager;
|
||||
|
||||
@Getter
|
||||
private PvPTopInventory pvPTopInventory;
|
||||
@Getter
|
||||
private ObtainPointsMethodsInventory obtainPointsMethodsInventory;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
this.pvpTopManager = new PvPTopManager(this);
|
||||
this.pvpTopManager.loadAll();
|
||||
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.registerCommandParameters();
|
||||
this.registerCommandCompletion();
|
||||
this.commandManager.register(new PvPTopCommand(this));
|
||||
|
||||
this.pvPTopInventory = new PvPTopInventory(this, true);
|
||||
this.obtainPointsMethodsInventory = new ObtainPointsMethodsInventory();
|
||||
|
||||
this.registerListeners();
|
||||
|
||||
this.updateLeaderboardTask = new UpdateLeaderboardTask(this);
|
||||
this.updateLeaderboardTask.runTaskTimer(this, 10 * 20L, 30 * 20L);
|
||||
}
|
||||
|
||||
private void registerCommandParameters() {
|
||||
this.commandManager.getParameterHandler().register(FactionData.Points.class, argument -> {
|
||||
FactionData.Points points = FactionData.Points.valueOf(String.valueOf(argument).toUpperCase());
|
||||
return new TypeResult(points, argument);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void registerCommandCompletion() {
|
||||
this.commandManager.getCompletionHandler().register("#factions", input -> Factions.getInstance().getAllFactions().stream().map(Faction::getTag).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
PluginManager pluginManager = this.getServer().getPluginManager();
|
||||
pluginManager.registerEvents(new PlayerDeathListener(this), this);
|
||||
pluginManager.registerEvents(new FactionDisbandCheck(), this);
|
||||
pluginManager.registerEvents(new KothCaptureListener(this), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.pvpTopManager.saveAll();
|
||||
}
|
||||
|
||||
public void updateInventory() {
|
||||
this.pvPTopInventory = new PvPTopInventory(this, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.crankedpvp.pvptop.commands;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import me.mattstudios.mf.annotations.*;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.FactionUtils;
|
||||
import net.crankedpvp.pvptop.PvPTopPlugin;
|
||||
import net.crankedpvp.pvptop.data.FactionData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Command("pvptop")
|
||||
public class PvPTopCommand extends CommandBase {
|
||||
|
||||
private final PvPTopPlugin plugin;
|
||||
public PvPTopCommand(PvPTopPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Default
|
||||
public void defaultCommand(final Player player) {
|
||||
this.plugin.getPvPTopInventory().getUI().open(player);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
@SubCommand("force")
|
||||
@Alias("update")
|
||||
@Permission("pvptop.admin")
|
||||
public void forceUpdateCommand(final CommandSender commandSender) {
|
||||
this.plugin.getUpdateLeaderboardTask().update();
|
||||
}
|
||||
|
||||
@SubCommand("add")
|
||||
@Permission("pvptop.admin")
|
||||
public void addPointsCommand(final CommandSender commandSender, @Completion("#factions") String factionTag, @Completion("#enum") final FactionData.Points points) {
|
||||
Faction faction = Factions.getInstance().getByTag(factionTag);
|
||||
if(faction == null) {
|
||||
commandSender.sendMessage(CC.translate("&cThat is not a faction g"));
|
||||
return;
|
||||
}
|
||||
this.plugin.getPvpTopManager().getOrCreate(faction).addPoint(points);
|
||||
commandSender.sendMessage(CC.translate("&aSuccessfully added " + points.getPoints() + " points to " + factionTag));
|
||||
}
|
||||
|
||||
@SubCommand("remove")
|
||||
@Permission("pvptop.admin")
|
||||
public void removePointsCommand(final CommandSender commandSender, @Completion("#factions") String factionTag, @Completion("#enum") final FactionData.Points points) {
|
||||
Faction faction = Factions.getInstance().getByTag(factionTag);
|
||||
if(faction == null) {
|
||||
commandSender.sendMessage(CC.translate("&cThat is not a faction g"));
|
||||
return;
|
||||
}
|
||||
this.plugin.getPvpTopManager().getOrCreate(faction).removePoint(points);
|
||||
commandSender.sendMessage(CC.translate("&aSuccessfully removed " + points.getPoints() + " points from " + factionTag));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package net.crankedpvp.pvptop.data;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.pvptop.PvPTopAPI;
|
||||
import net.crankedpvp.pvptop.PvPTopPlugin;
|
||||
import net.crankedpvp.storageutils.struct.NewKeyToSave;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter @Setter
|
||||
public class FactionData implements NewKeyToSave<String> {
|
||||
|
||||
private String factionId;
|
||||
private Map<Points, Integer> points;
|
||||
|
||||
public void addPoint(Points points) {
|
||||
if(this.points.containsKey(points)) {
|
||||
int amount = this.points.get(points);
|
||||
amount += 1;
|
||||
this.points.put(points, amount);
|
||||
return;
|
||||
}
|
||||
this.points.put(points, 1);
|
||||
}
|
||||
|
||||
public void removePoint(Points points) {
|
||||
if(this.points.containsKey(points)) {
|
||||
int amount = this.points.get(points);
|
||||
amount -= 1;
|
||||
this.points.put(points, amount);
|
||||
return;
|
||||
}
|
||||
this.points.put(points, 0);
|
||||
}
|
||||
|
||||
public int calculateAllPoints() {
|
||||
int amount = 0;
|
||||
for(Points points : this.points.keySet()) {
|
||||
if(points == Points.DEATH) {
|
||||
amount -= this.points.get(points);
|
||||
continue;
|
||||
}
|
||||
amount += this.points.get(points) * points.getPoints();
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
public FactionData(String factionId) {
|
||||
this.factionId = factionId;
|
||||
this.points = new HashMap<>();
|
||||
}
|
||||
|
||||
public int getPointsFor(Points points) {
|
||||
return this.points.getOrDefault(points, 0);
|
||||
}
|
||||
|
||||
public int getKills() {
|
||||
return this.points.getOrDefault(Points.KILL, 0);
|
||||
}
|
||||
|
||||
public int getDeaths() {
|
||||
return this.points.getOrDefault(Points.DEATH, 0);
|
||||
}
|
||||
|
||||
public int getStrongholdControlled() {
|
||||
return this.points.getOrDefault(Points.STRONHOLD_CONTROL, 0);
|
||||
}
|
||||
|
||||
public int getCitadelCaptured() {
|
||||
return this.points.getOrDefault(Points.CITADEL_CAPTURE, 0);
|
||||
}
|
||||
|
||||
public int getDeadmansChestCaptures() {
|
||||
return this.points.getOrDefault(Points.DEADMANS_CHEST, 0);
|
||||
}
|
||||
|
||||
public int getWarpKothCaptured() {
|
||||
return this.points.getOrDefault(Points.WARP_KOTH_CAPTURE, 0);
|
||||
}
|
||||
|
||||
public int getKothCaptured() {
|
||||
return this.points.getOrDefault(Points.KOTH_CAPTURE, 0);
|
||||
}
|
||||
|
||||
public int getCerberusKills() {
|
||||
return this.points.getOrDefault(Points.CERBERUS_KILLED, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return this.factionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKey(String string) {
|
||||
this.factionId = string;
|
||||
}
|
||||
|
||||
public enum Points {
|
||||
KOTH_CAPTURE(50, "&d&lKoth Capture"),
|
||||
WARP_KOTH_CAPTURE(75, "&5&lWarp Koth Capture"),
|
||||
KILL(1, "&a&lPlayer Kill"),
|
||||
DEATH(1, "&c&lMember Death"),
|
||||
STRONHOLD_CONTROL(15, "&4&lStronghold Control"),
|
||||
DEADMANS_CHEST(100, "&d&lDead Mans Chest Capture"),
|
||||
CERBERUS_KILLED(150, "&6&lCerberus Slain"),
|
||||
CITADEL_CAPTURE(1000, "&e&lCitadel Capture"),
|
||||
;
|
||||
|
||||
@Getter
|
||||
private final int points;
|
||||
@Getter
|
||||
private final String due;
|
||||
Points(int points, String due) {
|
||||
this.points = points;
|
||||
this.due = due;
|
||||
}
|
||||
|
||||
public void add(Faction faction) {
|
||||
FactionData factionData = PvPTopPlugin.getInstance().getPvpTopManager().getOrCreate(faction);
|
||||
String plural = this.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has gained &a" + this.getPoints() + " &7faction " + plural + " due to " + this.getDue()));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LEVEL_UP, 1.0f, 1.0f);
|
||||
}
|
||||
factionData.addPoint(this);
|
||||
}
|
||||
|
||||
public void remove(Faction faction) {
|
||||
FactionData factionData = PvPTopPlugin.getInstance().getPvpTopManager().getOrCreate(faction);
|
||||
String plural = this.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has lost &c" + this.getPoints() + " &7faction " + plural + " due to " + this.getDue()));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LEVEL_UP, 1.0f, 1.0f);
|
||||
}
|
||||
factionData.removePoint(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public final static transient int KOTH_CAPTURE_POINTS = 50;
|
||||
public final static transient int WARP_KOTH_CAPTURE_POINTS = 75;
|
||||
public final static transient int KILL_POINTS = 1;
|
||||
public final static transient int DEATH_POINTS = 1;
|
||||
public final static transient int STRONGHOLD_HOLD_POINTS = 15;
|
||||
public final static transient int DEADMANS_CHEST_POINTS = 100;
|
||||
public final static transient int CITADEL_CAPTURE_POINTS = 1000;
|
||||
public final static transient int CERBERUS_KILLED = 150;
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
public void addCerberusKilled() {
|
||||
Faction faction = Factions.getInstance().getFactionById(this.factionId);
|
||||
String plural = Points.CERBERUS_KILLED.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has gained &a" + Points.CERBERUS_KILLED.getPoints() + " &7faction " + plural + " due to " + "&9&lCerberus Killed"));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LEVEL_UP, 1.0f, 1.0f);
|
||||
}
|
||||
this.cerberusKilled += 1;
|
||||
}
|
||||
|
||||
public void addKothCapture() {
|
||||
Faction faction = Factions.getInstance().getFactionById(this.factionId);
|
||||
String plural = Points.KOTH_CAPTURE.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has gained &a" + Points.KOTH_CAPTURE.getPoints() + " &7faction " + plural + " due to " + "&d&lKoth Capture"));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LEVEL_UP, 1.0f, 1.0f);
|
||||
}
|
||||
this.kothsCaptured += 1;
|
||||
}
|
||||
|
||||
public void addWarpKothCapture() {
|
||||
Faction faction = Factions.getInstance().getFactionById(this.factionId);
|
||||
String plural = Points.WARP_KOTH_CAPTURE.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has gained &a" + Points.WARP_KOTH_CAPTURE.getPoints() + " &7faction " + plural + " due to " + "&6&lWarp Koth Capture"));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LEVEL_UP, 1.0f, 1.0f);
|
||||
}
|
||||
this.warpKothsCaptured += 1;
|
||||
}
|
||||
|
||||
public void addCitadelCapture() {
|
||||
Faction faction = Factions.getInstance().getFactionById(this.factionId);
|
||||
String plural = Points.CITADEL_CAPTURE.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has gained &a" + Points.CITADEL_CAPTURE.getPoints() + " &7faction " + plural + " due to " + "&e&lCitadel Capture"));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LEVEL_UP, 1.0f, 1.0f);
|
||||
}
|
||||
this.citadelsCaptured += 1;
|
||||
}
|
||||
|
||||
public void addStrongholdHold() {
|
||||
Faction faction = Factions.getInstance().getFactionById(this.factionId);
|
||||
String plural = Points.STRONHOLD_CONTROL.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has gained &a" + Points.STRONHOLD_CONTROL.getPoints() + " &7faction " + plural + " due to " + "&4&lStronghold Hold"));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LEVEL_UP, 1.0f, 1.0f);
|
||||
}
|
||||
this.strongholdHeld += 1;
|
||||
}
|
||||
|
||||
public void addPlayerKill() {
|
||||
Faction faction = Factions.getInstance().getFactionById(this.factionId);
|
||||
String plural = Points.KILL.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has gained &a" + Points.KILL.getPoints() + " &7faction " + plural + " due to " + "&a&lEnemy Kill"));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LEVEL_UP, 1.0f, 1.0f);
|
||||
}
|
||||
this.kills += 1;
|
||||
}
|
||||
|
||||
public void addPlayerDeath() {
|
||||
Faction faction = Factions.getInstance().getFactionById(this.factionId);
|
||||
String plural = Points.DEATH.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has lost &c" + Points.DEATH.getPoints() + " &7faction " + plural + " due to " + "&c&lMember Death"));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LAVA_POP, 1.0f, 1.0f);
|
||||
}
|
||||
this.deaths += 1;
|
||||
}
|
||||
|
||||
public void addDeadMansChestCapture() {
|
||||
Faction faction = Factions.getInstance().getFactionById(this.factionId);
|
||||
String plural = Points.DEADMANS_CHEST.getPoints() > 1 ? "points" : "point";
|
||||
for(Player onlinePlayer : faction.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(CC.translate(PvPTopAPI.PREFIX + "Your faction has gained &a" + Points.DEADMANS_CHEST.getPoints() + " &7faction " + plural + " due to " + "&d&lDead Mans Chest Capture"));
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.LEVEL_UP, 1.0f, 1.0f);
|
||||
}
|
||||
this.deadmansChestCaptured += 1;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.crankedpvp.pvptop.data;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import net.crankedpvp.pvptop.PvPTopPlugin;
|
||||
import net.crankedpvp.storageutils.StorageUtils;
|
||||
import net.crankedpvp.storageutils.struct.NewSaveLoadManager;
|
||||
|
||||
public class PvPTopManager extends NewSaveLoadManager<String, FactionData> {
|
||||
|
||||
public PvPTopManager(PvPTopPlugin plugin) {
|
||||
super(plugin, StorageUtils.getInstance().getGson(), "data", FactionData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize(String string) {
|
||||
return string;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deserialize(String string) {
|
||||
return string;
|
||||
}
|
||||
|
||||
public FactionData getOrCreate(Faction faction) {
|
||||
|
||||
if(!faction.isNormal()) return null;
|
||||
|
||||
if(super.containsKey(faction.getId())) {
|
||||
return super.getFromCache(faction.getId());
|
||||
}
|
||||
|
||||
FactionData factionData = new FactionData(faction.getId());
|
||||
super.addToCache(factionData);
|
||||
return factionData;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.crankedpvp.pvptop.events;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
public class UpdateFactionPointsEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean canceled = false;
|
||||
|
||||
@Getter
|
||||
private final Faction faction;
|
||||
|
||||
@Getter
|
||||
private final long oldPoints;
|
||||
|
||||
@Getter
|
||||
private final long newPoints;
|
||||
|
||||
public UpdateFactionPointsEvent(Faction faction, long oldPoints, long newPoints) {
|
||||
this.oldPoints = oldPoints;
|
||||
this.newPoints = newPoints;
|
||||
this.faction = faction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.canceled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b) {
|
||||
this.canceled = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return UpdateFactionPointsEvent.handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return UpdateFactionPointsEvent.handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
package net.crankedpvp.pvptop.inventory;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import dev.triumphteam.gui.guis.Gui;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import net.crankedpvp.crankedutils.utils.GuiUtil;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.pvptop.PvPTopPlugin;
|
||||
import net.crankedpvp.pvptop.data.FactionData;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class FactionPointsBreakdownInventory {
|
||||
|
||||
private static final DecimalFormat moneyFormat = new DecimalFormat("#,###");
|
||||
|
||||
private final Faction faction;
|
||||
private final FactionData factionData;
|
||||
|
||||
|
||||
private final Gui pointsBreakdownInventory;
|
||||
|
||||
public Gui getUI() {
|
||||
return this.pointsBreakdownInventory;
|
||||
}
|
||||
|
||||
public FactionPointsBreakdownInventory(Faction faction) {
|
||||
this.faction = faction;
|
||||
this.factionData = PvPTopPlugin.getInstance().getPvpTopManager().getOrCreate(faction);
|
||||
this.pointsBreakdownInventory = new Gui(4, faction.getTag() + " Points Breakdown");
|
||||
this.pointsBreakdownInventory.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
|
||||
this.pointsBreakdownInventory.getFiller().fillBorder(GuiUtil.createFillerGuiItem());
|
||||
|
||||
ItemStack info = new ItemBuilder(Material.BOOK, "&f" + faction.getTag())
|
||||
.setLore(
|
||||
"",
|
||||
"&b&lInformation",
|
||||
" &f• Leader: &3" + faction.getLeader().getName(),
|
||||
"",
|
||||
"&b&lStatistics",
|
||||
" &f• Faction Points: &3" + moneyFormat.format(factionData.calculateAllPoints())
|
||||
)
|
||||
.colorize().build();
|
||||
|
||||
this.pointsBreakdownInventory.setItem(1, 5, new GuiItem(info));
|
||||
|
||||
this.pointsBreakdownInventory.addItem(new GuiItem(this.buildKillsItemStack()));
|
||||
this.pointsBreakdownInventory.addItem(new GuiItem(this.buildDeathsItemStack()));
|
||||
this.pointsBreakdownInventory.addItem(new GuiItem(this.buildDeadmansChestCapturedItemStack()));
|
||||
this.pointsBreakdownInventory.addItem(new GuiItem(this.buildKothsCapturedItemStack()));
|
||||
this.pointsBreakdownInventory.addItem(new GuiItem(this.buildWarpKothsCapturedItemStack()));
|
||||
this.pointsBreakdownInventory.addItem(new GuiItem(this.buildCitadelsCapturedItemStack()));
|
||||
this.pointsBreakdownInventory.addItem(new GuiItem(this.buildCerberusKillItemStack()));
|
||||
this.pointsBreakdownInventory.addItem(new GuiItem(this.buildStrongholdControlledItemStack()));
|
||||
}
|
||||
|
||||
|
||||
private ItemStack buildKillsItemStack() {
|
||||
return new ItemBuilder(Material.GOLD_SWORD, "&aPlayer Kills",
|
||||
"&f+" + FactionData.Points.KILL.getPoints() + " &bFaction Point",
|
||||
"",
|
||||
" &f• Total: &e" + this.factionData.getKills(),
|
||||
" &f• Points Gained: &8(&a+" + (this.factionData.getKills() * FactionData.Points.KILL.getPoints()) + "&8)"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildKothsCapturedItemStack() {
|
||||
return new ItemBuilder(Material.WOOL, 1, DyeColor.RED.getWoolData(), "&aKOTH Capture",
|
||||
"&f+" + FactionData.Points.KOTH_CAPTURE.getPoints() + " &bFaction Points",
|
||||
"",
|
||||
" &f• Total: &e" + this.factionData.getKothCaptured(),
|
||||
" &f• Points Gained: &8(&a+" + (this.factionData.getKothCaptured() * FactionData.Points.KOTH_CAPTURE.getPoints()) + "&8)"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildWarpKothsCapturedItemStack() {
|
||||
return new ItemBuilder(Material.ENDER_PORTAL_FRAME, "&aWarp KOTH Capture",
|
||||
"&f+" + FactionData.Points.WARP_KOTH_CAPTURE.getPoints() + " &bFaction Points",
|
||||
"",
|
||||
" &f• Total: &e" + this.factionData.getWarpKothCaptured(),
|
||||
" &f• Points Gained: &8(&a+" + (this.factionData.getWarpKothCaptured() * FactionData.Points.WARP_KOTH_CAPTURE.getPoints()) + "&8)"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildCitadelsCapturedItemStack() {
|
||||
return new ItemBuilder(Material.BEACON, "&aCitadel Capture",
|
||||
"&f+" + FactionData.Points.CITADEL_CAPTURE.getPoints() + " &bFaction Points",
|
||||
"",
|
||||
" &f• Total: &e" + this.factionData.getCitadelCaptured(),
|
||||
" &f• Points Gained: &8(&a+" + (this.factionData.getCitadelCaptured() * FactionData.Points.CITADEL_CAPTURE.getPoints()) + "&8)"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildDeadmansChestCapturedItemStack() {
|
||||
return new ItemBuilder(Material.ENDER_CHEST, "&aDead Mans Chest Capture",
|
||||
"&f+" + FactionData.Points.DEADMANS_CHEST.getPoints() + " &bFaction Points",
|
||||
"",
|
||||
" &f• Total: &e" + this.factionData.getDeadmansChestCaptures(),
|
||||
" &f• Points Gained: &8(&a+" + (this.factionData.getDeadmansChestCaptures() * FactionData.Points.DEADMANS_CHEST.getPoints()) + "&8)"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildDeathsItemStack() {
|
||||
return new ItemBuilder(Material.INK_SACK, 1, DyeColor.RED.getDyeData(), "&cPlayer Deaths",
|
||||
"&f-" + FactionData.Points.DEATH.getPoints() + " &bFaction Point",
|
||||
"",
|
||||
" &f• Total: &e" + this.factionData.getDeaths(),
|
||||
" &f• Points Gained: &8(&c-" + (this.factionData.getDeaths() * FactionData.Points.DEATH.getPoints()) + "&8)"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildStrongholdControlledItemStack() {
|
||||
return new ItemBuilder(Material.BLAZE_POWDER, "&aStronghold Controlled &7(30 Minutes)",
|
||||
"&f+" + FactionData.Points.STRONHOLD_CONTROL.getPoints() + " &bFaction Points",
|
||||
"",
|
||||
" &f• Total: &e" + this.factionData.getStrongholdControlled(),
|
||||
" &f• Points Gained: &8(&a+" + (this.factionData.getStrongholdControlled() * FactionData.Points.STRONHOLD_CONTROL.getPoints()) + "&8)"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildCerberusKillItemStack() {
|
||||
return new ItemBuilder(Material.MONSTER_EGG, "&aCerberus Kills",
|
||||
"&f+" + FactionData.Points.CERBERUS_KILLED.getPoints() + " &bFaction Points",
|
||||
"",
|
||||
" &f• Total: &e" + this.factionData.getCerberusKills(),
|
||||
" &f• Points Gained: &8(&a+" + (this.factionData.getCerberusKills() * FactionData.Points.CERBERUS_KILLED.getPoints()) + "&8)"
|
||||
).colorize().build();
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package net.crankedpvp.pvptop.inventory;
|
||||
|
||||
import dev.triumphteam.gui.guis.Gui;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import net.crankedpvp.crankedutils.utils.GuiUtil;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.pvptop.data.FactionData;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class ObtainPointsMethodsInventory {
|
||||
|
||||
private static final DecimalFormat moneyFormat = new DecimalFormat("#,###");
|
||||
|
||||
private final Gui obtainPointsMethodInventory;
|
||||
|
||||
public Gui getUI() {
|
||||
return this.obtainPointsMethodInventory;
|
||||
}
|
||||
|
||||
public ObtainPointsMethodsInventory() {
|
||||
this.obtainPointsMethodInventory = new Gui(4, "Obtain Points Methods");
|
||||
this.obtainPointsMethodInventory.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
|
||||
this.obtainPointsMethodInventory.getFiller().fillBorder(GuiUtil.createFillerGuiItem());
|
||||
|
||||
this.obtainPointsMethodInventory.addItem(new GuiItem(this.buildKillsItemStack()));
|
||||
this.obtainPointsMethodInventory.addItem(new GuiItem(this.buildDeathsItemStack()));
|
||||
this.obtainPointsMethodInventory.addItem(new GuiItem(this.buildDeadmansChestCapturedItemStack()));
|
||||
this.obtainPointsMethodInventory.addItem(new GuiItem(this.buildKothsCapturedItemStack()));
|
||||
this.obtainPointsMethodInventory.addItem(new GuiItem(this.buildWarpKothsCapturedItemStack()));
|
||||
this.obtainPointsMethodInventory.addItem(new GuiItem(this.buildCitadelsCapturedItemStack()));
|
||||
this.obtainPointsMethodInventory.addItem(new GuiItem(this.buildCerberusKillItemStack()));
|
||||
this.obtainPointsMethodInventory.addItem(new GuiItem(this.buildStrongholdControlledItemStack()));
|
||||
}
|
||||
|
||||
|
||||
private ItemStack buildKillsItemStack() {
|
||||
return new ItemBuilder(Material.GOLD_SWORD, "&aPlayer Kills",
|
||||
"&f+" + FactionData.Points.KILL.getPoints() + " &bFaction Point"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildKothsCapturedItemStack() {
|
||||
return new ItemBuilder(Material.WOOL, 1, DyeColor.RED.getWoolData(), "&aKOTH Capture",
|
||||
"&f+" + FactionData.Points.KOTH_CAPTURE.getPoints() + " &bFaction Points"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildDeadmansChestCapturedItemStack() {
|
||||
return new ItemBuilder(Material.ENDER_CHEST, "&aDead Mans Chest Capture",
|
||||
"&f+" + FactionData.Points.DEADMANS_CHEST.getPoints() + " &bFaction Points").colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildDeathsItemStack() {
|
||||
return new ItemBuilder(Material.INK_SACK, 1, DyeColor.RED.getDyeData(), "&cPlayer Deaths",
|
||||
"&f-" + FactionData.Points.DEATH.getPoints() + " &bFaction Point"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildWarpKothsCapturedItemStack() {
|
||||
return new ItemBuilder(Material.ENDER_PORTAL_FRAME, "&aWarp KOTH Capture",
|
||||
"&f+" + FactionData.Points.WARP_KOTH_CAPTURE.getPoints() + " &bFaction Points"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildCitadelsCapturedItemStack() {
|
||||
return new ItemBuilder(Material.BEACON, "&aCitadel Capture",
|
||||
"&f+" + FactionData.Points.CITADEL_CAPTURE.getPoints() + " &bFaction Points"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildStrongholdControlledItemStack() {
|
||||
return new ItemBuilder(Material.BLAZE_POWDER, "&aStronghold Controlled &7(30 Minutes)",
|
||||
"&f+" + FactionData.Points.STRONHOLD_CONTROL.getPoints() + " &bFaction Points"
|
||||
).colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack buildCerberusKillItemStack() {
|
||||
return new ItemBuilder(Material.MONSTER_EGG, "&aCerberus Kills",
|
||||
"&f+" + FactionData.Points.CERBERUS_KILLED.getPoints() + " &bFaction Points"
|
||||
).colorize().build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package net.crankedpvp.pvptop.inventory;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import dev.triumphteam.gui.guis.Gui;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import net.crankedpvp.crankedutils.utils.GuiUtil;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.pvptop.PvPTopPlugin;
|
||||
import net.crankedpvp.pvptop.data.FactionData;
|
||||
import net.crankedpvp.spawners.SpawnerPlugin;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class PvPTopInventory {
|
||||
|
||||
private static final DecimalFormat moneyFormat = new DecimalFormat("#,###");
|
||||
|
||||
private final Gui pvpTopInventory;
|
||||
|
||||
public Gui getUI() {
|
||||
return this.pvpTopInventory;
|
||||
}
|
||||
|
||||
public PvPTopInventory(PvPTopPlugin plugin, boolean firstLoad) {
|
||||
this.pvpTopInventory = new Gui(6, "PvP Top");
|
||||
this.pvpTopInventory.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
|
||||
this.pvpTopInventory.getFiller().fillBorder(GuiUtil.createFillerGuiItem());
|
||||
this.pvpTopInventory.getFiller().fillBetweenPoints(2, 2, 2, 8, GuiUtil.createFillerGuiItem());
|
||||
this.pvpTopInventory.getFiller().fillBetweenPoints(5, 2, 5, 8, GuiUtil.createFillerGuiItem());
|
||||
|
||||
|
||||
ItemStack info = new ItemBuilder(Material.BOOK, "&b&lTop Point Factions",
|
||||
"&fThe top factions amongst Cranked are",
|
||||
"&flisted below, sorted by &bFaction Points"
|
||||
).colorize().build();
|
||||
|
||||
ItemStack facPoints = new ItemBuilder(Material.SIGN, "&3&lObtaining Points",
|
||||
"&fThere are numerous ways to obtain",
|
||||
"&ffaction points, and you need these",
|
||||
"&fpoints to show up on the leaderboard",
|
||||
"&fand to compete for the /pvptop payouts.",
|
||||
"",
|
||||
"&3Obtaining Point Methods:",
|
||||
" &f• Player Kills",
|
||||
" &f• Capturing KOTHs",
|
||||
" &f• Holding control of /stronghold",
|
||||
" &f• Capturing Dead Mans Chests",
|
||||
" &f• Capturing Citadel",
|
||||
"",
|
||||
"&7&oClick to view all methods of obtaining points"
|
||||
).colorize().build();
|
||||
|
||||
ItemStack questionMark = new ItemBuilder(Material.SKULL_ITEM, "&f&l???", "&7Click me to make player skulls visible"
|
||||
).colorize().build();
|
||||
|
||||
this.pvpTopInventory.setItem(1, 5, new GuiItem(info));
|
||||
this.pvpTopInventory.setItem(6, 4, new GuiItem(facPoints, event -> {
|
||||
event.getWhoClicked().closeInventory();
|
||||
PvPTopPlugin.getInstance().getObtainPointsMethodsInventory().getUI().open(event.getWhoClicked());
|
||||
}));
|
||||
this.pvpTopInventory.setItem(6, 6, new GuiItem(questionMark));
|
||||
|
||||
if(firstLoad) return;
|
||||
int count = 1;
|
||||
for(FactionData value : plugin.getUpdateLeaderboardTask().getSortedFactionData()) {
|
||||
ItemStack itemToAddToInventory = this.buildItemOfFactionData(value, count);
|
||||
if(itemToAddToInventory == null) continue;
|
||||
this.pvpTopInventory.addItem(new GuiItem(itemToAddToInventory, event -> {
|
||||
event.getWhoClicked().closeInventory();
|
||||
FactionPointsBreakdownInventory factionPointsBreakdownInventory = new FactionPointsBreakdownInventory(Factions.getInstance().getFactionById(value.getFactionId()));
|
||||
factionPointsBreakdownInventory.getUI().open(event.getWhoClicked());
|
||||
}));
|
||||
count++;
|
||||
if(count == 15) return;
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack buildItemOfFactionData(FactionData value, int count) {
|
||||
Faction faction = Factions.getInstance().getFactionById(value.getKey());
|
||||
if(faction == null) {
|
||||
PvPTopPlugin.getInstance().getPvpTopManager().removeFromCache(value);
|
||||
PvPTopPlugin.getInstance().getUpdateLeaderboardTask().update();
|
||||
return null;
|
||||
}
|
||||
net.crankedpvp.spawners.data.ftop.FactionData factionData = SpawnerPlugin.getInstance().getFactionsTopManager().getFactionData(faction);
|
||||
if(factionData == null) {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(getSkull(faction.getLeader().getName()))
|
||||
.setName("&3" + faction.getTag() + " &7(Points #" + count + ")")
|
||||
.setLore(
|
||||
"",
|
||||
"&b&lInformation",
|
||||
" &f• Leader: &3" + faction.getLeader().getName(),
|
||||
"",
|
||||
"&b&lStatistics",
|
||||
" &f• Faction Points: &3" + moneyFormat.format(value.calculateAllPoints())
|
||||
);
|
||||
return itemBuilder.colorize().build();
|
||||
}
|
||||
ItemBuilder itemBuilder = new ItemBuilder(getSkull(faction.getLeader().getName()))
|
||||
.setName("&3" + faction.getTag() + " &7(Points #" + count + ")")
|
||||
.setLore(
|
||||
"",
|
||||
"&b&lInformation",
|
||||
" &f• Leader: &3" + faction.getLeader().getName(),
|
||||
" &f• Richest Member: &3" + factionData.getRichestPlayer(),
|
||||
"",
|
||||
"&b&lStatistics",
|
||||
" &f• Faction Points: &3" + moneyFormat.format(value.calculateAllPoints()),
|
||||
" &f• Spawner Value: &3$" + moneyFormat.format(factionData.getSpawnerValue()),
|
||||
" &f• Spawner Count: &3" + moneyFormat.format(factionData.getSpawnerCount())
|
||||
);
|
||||
|
||||
return itemBuilder.colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack getSkull(String playerName) {
|
||||
ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
||||
NBTItem nbtItem = new NBTItem(playerSkull);
|
||||
nbtItem.setString("SkullOwner", playerName);
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.crankedpvp.pvptop.listeners;
|
||||
|
||||
import com.massivecraft.factions.event.FactionDisbandEvent;
|
||||
import net.crankedpvp.pvptop.PvPTopPlugin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class FactionDisbandCheck implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void facDisband(FactionDisbandEvent event) {
|
||||
PvPTopPlugin.getInstance().getPvpTopManager().removeFromCache(event.getFaction().getId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.crankedpvp.pvptop.listeners;
|
||||
|
||||
import com.golfing8.kore.event.KothCaptureEvent;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import net.crankedpvp.crankedutils.utils.FactionUtils;
|
||||
import net.crankedpvp.pvptop.PvPTopPlugin;
|
||||
import net.crankedpvp.pvptop.data.FactionData;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class KothCaptureListener implements Listener {
|
||||
|
||||
private final PvPTopPlugin plugin;
|
||||
public KothCaptureListener(PvPTopPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKothCapture(KothCaptureEvent event) {
|
||||
if(event.getPlayerCapper() == null) return;
|
||||
|
||||
Faction faction = FactionUtils.getFaction(event.getPlayerCapper());
|
||||
FactionData factionData = this.plugin.getPvpTopManager().getOrCreate(faction);
|
||||
if(factionData == null) return;
|
||||
if(event.getKoth().getName().equalsIgnoreCase("Citadel")) {
|
||||
factionData.addPoint(FactionData.Points.CITADEL_CAPTURE);
|
||||
return;
|
||||
}
|
||||
if(event.getKoth().getName().equalsIgnoreCase("End")) {
|
||||
factionData.addPoint(FactionData.Points.WARP_KOTH_CAPTURE);
|
||||
return;
|
||||
}
|
||||
factionData.addPoint(FactionData.Points.KOTH_CAPTURE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.crankedpvp.pvptop.listeners;
|
||||
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import net.crankedpvp.crankedarmor.CrankedArmorAPI;
|
||||
import net.crankedpvp.crankedenchants.CrankedEnchantsAPI;
|
||||
import net.crankedpvp.crankedutils.struct.factions.CrankedFactionHandler;
|
||||
import net.crankedpvp.crankedutils.utils.FactionUtils;
|
||||
import net.crankedpvp.pvptop.PvPTopAPI;
|
||||
import net.crankedpvp.pvptop.PvPTopPlugin;
|
||||
import net.crankedpvp.pvptop.data.FactionData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
public class PlayerDeathListener implements Listener {
|
||||
|
||||
private final PvPTopPlugin plugin;
|
||||
public PlayerDeathListener(PvPTopPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerDeath(PlayerDeathEvent event) {
|
||||
if(event.getEntity() == null) return;
|
||||
if(event.getEntity().getKiller() == null) return;
|
||||
|
||||
Player attacker = event.getEntity().getKiller();
|
||||
Player victim = event.getEntity();
|
||||
|
||||
if(FPlayers.getInstance().getByPlayer(victim).hasFaction()) PvPTopAPI.getFactionData(victim).addPoint(FactionData.Points.DEATH);
|
||||
if(FPlayers.getInstance().getByPlayer(attacker).hasFaction()) {
|
||||
if (CrankedArmorAPI.getCurrentArmorSet(victim) == null) return;
|
||||
if (CrankedEnchantsAPI.getEnchantments(victim).size() < 16) return;
|
||||
PvPTopAPI.getFactionData(attacker).addPoint(FactionData.Points.KILL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.crankedpvp.pvptop.tasks;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.pvptop.PvPTopPlugin;
|
||||
import net.crankedpvp.pvptop.data.FactionData;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class UpdateLeaderboardTask extends BukkitRunnable {
|
||||
|
||||
@Getter
|
||||
private List<FactionData> sortedFactionData;
|
||||
|
||||
private final PvPTopPlugin plugin;
|
||||
public UpdateLeaderboardTask(PvPTopPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.sortedFactionData = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.update();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
this.sortedFactionData = new ArrayList<>(this.plugin.getPvpTopManager().getCacheValues());
|
||||
this.sortedFactionData.sort(Comparator.comparingInt(FactionData::calculateAllPoints));
|
||||
Collections.reverse(this.sortedFactionData);
|
||||
PvPTopPlugin.getInstance().updateInventory();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
name: CrankedPvPTop
|
||||
main: net.crankedpvp.pvptop.PvPTopPlugin
|
||||
version: ${git.total.commit.count}.0
|
||||
description: "§fCommit ID: §a${git.commit.id.abbrev}"
|
||||
website: https://crankedpvp.net/
|
||||
depend:
|
||||
- CrankedUtils
|
||||
- Factions
|
||||
- StorageUtil
|
||||
- CrankedSpawners
|
||||
Reference in New Issue
Block a user