Code Overhaul and Added ALOT
This commit is contained in:
parent
1f680b56f0
commit
4833cafa0e
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.massivecraft</groupId>
|
<groupId>com.massivecraft</groupId>
|
||||||
<artifactId>Factions</artifactId>
|
<artifactId>Factions</artifactId>
|
||||||
<version>1.6.9.5-U0.2.1-1.1-BETA</version>
|
<version>1.6.9.5-U0.2.1-1.2-STABLE</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SavageFactionsPlus</name>
|
<name>SavageFactionsPlus</name>
|
||||||
|
@ -21,6 +21,8 @@ import com.massivecraft.factions.zcore.fperms.Permissable;
|
|||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.fupgrades.*;
|
import com.massivecraft.factions.zcore.fupgrades.*;
|
||||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||||
|
import me.driftay.addons.bankxp.Deposit;
|
||||||
|
import me.driftay.addons.bankxp.Withdraw;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
@ -82,6 +84,7 @@ public class SavageFactions extends MPlugin {
|
|||||||
private ClipPlaceholderAPIManager clipPlaceholderAPIManager;
|
private ClipPlaceholderAPIManager clipPlaceholderAPIManager;
|
||||||
private boolean mvdwPlaceholderAPIManager = false;
|
private boolean mvdwPlaceholderAPIManager = false;
|
||||||
private Listener[] eventsListener;
|
private Listener[] eventsListener;
|
||||||
|
public static Economy econ = null;
|
||||||
|
|
||||||
public SavageFactions() {
|
public SavageFactions() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
@ -239,7 +242,7 @@ public class SavageFactions extends MPlugin {
|
|||||||
new EXPUpgrade(),
|
new EXPUpgrade(),
|
||||||
new CropUpgrades(),
|
new CropUpgrades(),
|
||||||
new RedstoneUpgrade(),
|
new RedstoneUpgrade(),
|
||||||
new SpawnerUpgrades(),
|
new SpawnerUpgrades()
|
||||||
};
|
};
|
||||||
|
|
||||||
for (Listener eventListener : eventsListener)
|
for (Listener eventListener : eventsListener)
|
||||||
@ -249,6 +252,15 @@ public class SavageFactions extends MPlugin {
|
|||||||
getCommand(this.refCommand).setExecutor(this);
|
getCommand(this.refCommand).setExecutor(this);
|
||||||
getCommand(this.refCommand).setTabCompleter(this);
|
getCommand(this.refCommand).setTabCompleter(this);
|
||||||
|
|
||||||
|
if(getConfig().getBoolean("XP-BankNote-Enabled")) {
|
||||||
|
getCommand("withdraw").setExecutor(new Withdraw());
|
||||||
|
getCommand("bottle").setExecutor(new Withdraw());
|
||||||
|
getServer().getPluginManager().registerEvents(new Deposit(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisteredServiceProvider<Economy> rsp = SavageFactions.this.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
SavageFactions.econ = rsp.getProvider();
|
||||||
|
|
||||||
if (getDescription().getFullName().contains("BETA")) {
|
if (getDescription().getFullName().contains("BETA")) {
|
||||||
divider();
|
divider();
|
||||||
System.out.println("You are using a BETA version of the plugin!");
|
System.out.println("You are using a BETA version of the plugin!");
|
||||||
|
@ -14,11 +14,11 @@ public class CmdPaypalSee extends FCommand {
|
|||||||
permission = Permission.ADMIN.node;
|
permission = Permission.ADMIN.node;
|
||||||
|
|
||||||
disableOnLock = false;
|
disableOnLock = false;
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeColeader = false;
|
senderMustBeColeader = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,10 +9,12 @@ public class CmdPaypalSet extends FCommand {
|
|||||||
public CmdPaypalSet() {
|
public CmdPaypalSet() {
|
||||||
this.aliases.add("setpaypal");
|
this.aliases.add("setpaypal");
|
||||||
this.requiredArgs.add("email");
|
this.requiredArgs.add("email");
|
||||||
|
|
||||||
this.permission = Permission.PAYPALSET.node;
|
this.permission = Permission.PAYPALSET.node;
|
||||||
|
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
this.senderMustBePlayer = true;
|
this.senderMustBePlayer = true;
|
||||||
this.senderMustBeMember = false;
|
this.senderMustBeMember = true;
|
||||||
this.senderMustBeModerator = false;
|
this.senderMustBeModerator = false;
|
||||||
this.senderMustBeColeader = false;
|
this.senderMustBeColeader = false;
|
||||||
this.senderMustBeAdmin = true;
|
this.senderMustBeAdmin = true;
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.*;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
public class CmdStrike extends FCommand {
|
public class CmdStrike extends FCommand {
|
||||||
|
|
||||||
|
|
||||||
public CmdStrike() {
|
public CmdStrike() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -50,3 +49,4 @@ public class CmdStrike extends FCommand {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@ import com.massivecraft.factions.Factions;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
public class CmdSetStrikes extends FCommand {
|
public class CmdStrikeSet extends FCommand {
|
||||||
|
|
||||||
|
|
||||||
public CmdSetStrikes() {
|
public CmdStrikeSet() {
|
||||||
super();
|
super();
|
||||||
this.aliases.add("setstrikes");
|
this.aliases.add("setstrikes");
|
||||||
this.aliases.add("setstrike");
|
this.aliases.add("setstrike");
|
@ -106,7 +106,7 @@ public class FCmdRoot extends FCommand {
|
|||||||
public CmdChest cmdChest = new CmdChest();
|
public CmdChest cmdChest = new CmdChest();
|
||||||
public CmdSetBanner cmdSetBanner = new CmdSetBanner();
|
public CmdSetBanner cmdSetBanner = new CmdSetBanner();
|
||||||
public CmdStrike cmdStrike = new CmdStrike();
|
public CmdStrike cmdStrike = new CmdStrike();
|
||||||
public CmdSetStrikes cmdSetStrikes = new CmdSetStrikes();
|
public CmdStrikeSet cmdStrikeSet = new CmdStrikeSet();
|
||||||
public CmdAlts cmdAlts = new CmdAlts();
|
public CmdAlts cmdAlts = new CmdAlts();
|
||||||
|
|
||||||
|
|
||||||
@ -146,7 +146,6 @@ public class FCmdRoot extends FCommand {
|
|||||||
this.addSubCommand(this.cmdDescription);
|
this.addSubCommand(this.cmdDescription);
|
||||||
this.addSubCommand(this.cmdDisband);
|
this.addSubCommand(this.cmdDisband);
|
||||||
this.addSubCommand(this.cmdStrike);
|
this.addSubCommand(this.cmdStrike);
|
||||||
this.addSubCommand(this.cmdSetStrikes);
|
|
||||||
this.addSubCommand(this.cmdHelp);
|
this.addSubCommand(this.cmdHelp);
|
||||||
this.addSubCommand(this.cmdHome);
|
this.addSubCommand(this.cmdHome);
|
||||||
this.addSubCommand(this.cmdInvite);
|
this.addSubCommand(this.cmdInvite);
|
||||||
@ -222,6 +221,7 @@ public class FCmdRoot extends FCommand {
|
|||||||
this.addSubCommand(this.cmdTntFill);
|
this.addSubCommand(this.cmdTntFill);
|
||||||
this.addSubCommand(this.cmdChest);
|
this.addSubCommand(this.cmdChest);
|
||||||
this.addSubCommand(this.cmdSetBanner);
|
this.addSubCommand(this.cmdSetBanner);
|
||||||
|
this.addSubCommand(this.cmdStrikeSet);
|
||||||
|
|
||||||
|
|
||||||
if(SavageFactions.plugin.getConfig().getBoolean("f-alts.Enabled")){
|
if(SavageFactions.plugin.getConfig().getBoolean("f-alts.Enabled")){
|
||||||
@ -246,7 +246,7 @@ public class FCmdRoot extends FCommand {
|
|||||||
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight", false)) {
|
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight", false)) {
|
||||||
this.addSubCommand(this.cmdFly);
|
this.addSubCommand(this.cmdFly);
|
||||||
}
|
}
|
||||||
if (Bukkit.getServer().getPluginManager().getPlugin("FactionsTop") != null) {
|
if (Bukkit.getServer().getPluginManager().getPlugin("FactionsTop") != null || Bukkit.getServer().getPluginManager().getPlugin("SavageFTOP") != null) {
|
||||||
SavageFactions.plugin.log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command.");
|
SavageFactions.plugin.log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command.");
|
||||||
} else {
|
} else {
|
||||||
SavageFactions.plugin.log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc.");
|
SavageFactions.plugin.log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc.");
|
||||||
|
@ -4,7 +4,6 @@ public enum UpgradeType {
|
|||||||
|
|
||||||
CHEST("Chest"), SPAWNER("Spawner"), EXP("Exp"), CROP("Crop"), POWER("Power"), REDSTONE("Redstone");
|
CHEST("Chest"), SPAWNER("Spawner"), EXP("Exp"), CROP("Crop"), POWER("Power"), REDSTONE("Redstone");
|
||||||
|
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
UpgradeType(String id) {
|
UpgradeType(String id) {
|
||||||
|
@ -134,6 +134,7 @@ public enum TL {
|
|||||||
COMMAND_ANNOUNCE_DESCRIPTION("Announce a message to players in faction."),
|
COMMAND_ANNOUNCE_DESCRIPTION("Announce a message to players in faction."),
|
||||||
|
|
||||||
COMMAND_ALTS_DESCRIPTION("Faction Alts Commands"),
|
COMMAND_ALTS_DESCRIPTION("Faction Alts Commands"),
|
||||||
|
COMMAND_STRIKE_DESCRIPTION("Faction Strike Commands"),
|
||||||
|
|
||||||
COMMAND_ALTS_LIST_DESCRIPTION("List all alts in your faction"),
|
COMMAND_ALTS_LIST_DESCRIPTION("List all alts in your faction"),
|
||||||
|
|
||||||
@ -366,6 +367,11 @@ public enum TL {
|
|||||||
COMMAND_INVITE_DESCRIPTION("Invite a player to your faction"),
|
COMMAND_INVITE_DESCRIPTION("Invite a player to your faction"),
|
||||||
COMMAND_INVITE_BANNED("&c&l[!]&7 &7%1$s &cis banned &7from your Faction. &cNot &7sending an invite."),
|
COMMAND_INVITE_BANNED("&c&l[!]&7 &7%1$s &cis banned &7from your Faction. &cNot &7sending an invite."),
|
||||||
|
|
||||||
|
BANKNOTE_WITHDRAW_NOT_ENOUGH("&c&l[!] &7You do not have enough money!"),
|
||||||
|
BANKNOTE_WITHDRAW_NO_ARGS("&c&l[!] &7Try /withdraw <amount>"),
|
||||||
|
XPBOTTLE_NOT_ENOUGH("&c&l[!] &7You do not have enough experience!"),
|
||||||
|
XPBOTTLE_WITHDRAW_NO_ARGS("&c&l[!] &7Try /bottle <amount>"),
|
||||||
|
|
||||||
COMMAND_JOIN_CANNOTFORCE("&c&l[!]&7 You&c do not&7 have permission to &cmove other players&7 into a faction."),
|
COMMAND_JOIN_CANNOTFORCE("&c&l[!]&7 You&c do not&7 have permission to &cmove other players&7 into a faction."),
|
||||||
COMMAND_JOIN_SYSTEMFACTION("&c&l[!]&7 Players may only join &cnormal factions&7. This is a &c&lsystem faction&7."),
|
COMMAND_JOIN_SYSTEMFACTION("&c&l[!]&7 Players may only join &cnormal factions&7. This is a &c&lsystem faction&7."),
|
||||||
COMMAND_JOIN_ALREADYMEMBER("&c&l[!]&7 &c%1$s %2$s already a member of&c %3$s"),
|
COMMAND_JOIN_ALREADYMEMBER("&c&l[!]&7 &c%1$s %2$s already a member of&c %3$s"),
|
||||||
@ -617,6 +623,7 @@ public enum TL {
|
|||||||
COMMAND_SETHOME_SET("&c&l[!]&c %1$s&7 set the home for your faction. You can now use:"),
|
COMMAND_SETHOME_SET("&c&l[!]&c %1$s&7 set the home for your faction. You can now use:"),
|
||||||
COMMAND_SETHOME_SETOTHER("&c&l[!]&7 You have set the home for the &c%1$s&7 faction."),
|
COMMAND_SETHOME_SETOTHER("&c&l[!]&7 You have set the home for the &c%1$s&7 faction."),
|
||||||
COMMAND_SETHOME_DESCRIPTION("Set the faction home"),
|
COMMAND_SETHOME_DESCRIPTION("Set the faction home"),
|
||||||
|
COMMAND_STRIKE_FACTION("View Factions Strikes"),
|
||||||
|
|
||||||
COMMAND_SETMAXVAULTS_DESCRIPTION("Set max vaults for a Faction."),
|
COMMAND_SETMAXVAULTS_DESCRIPTION("Set max vaults for a Faction."),
|
||||||
COMMAND_SETMAXVAULTS_SUCCESS("&aSet max vaults for &e%s &ato &b%d"),
|
COMMAND_SETMAXVAULTS_SUCCESS("&aSet max vaults for &e%s &ato &b%d"),
|
||||||
@ -624,12 +631,14 @@ public enum TL {
|
|||||||
COMMAND_SETSTRIKES_FAILURE("&c&l[!]&7 &c{faction} does not exist."),
|
COMMAND_SETSTRIKES_FAILURE("&c&l[!]&7 &c{faction} does not exist."),
|
||||||
COMMAND_SETSTRIKES_BROADCAST("&c&l[!]&7 &c{faction} has received a strike for {reason}"),
|
COMMAND_SETSTRIKES_BROADCAST("&c&l[!]&7 &c{faction} has received a strike for {reason}"),
|
||||||
COMMAND_SETSTRIKES_SUCCESS("&c&l[!]&7 &c{faction}'s&7 new strikes are &c{strikes}"),
|
COMMAND_SETSTRIKES_SUCCESS("&c&l[!]&7 &c{faction}'s&7 new strikes are &c{strikes}"),
|
||||||
COMMAND_SETSTRIKES_DESCRIPTION("Set a faction's points"),
|
COMMAND_SETSTRIKES_DESCRIPTION("Set a faction's strikes"),
|
||||||
|
COMMAND_STRIKEREMOVE_DESCRIPTION("Remove a faction's strikes"),
|
||||||
|
|
||||||
COMMAND_STRIKE_MESSAGE("&c&l[!] &7{faction} has {strikes} strikes."),
|
COMMAND_STRIKE_MESSAGE("&c&l[!] &7{faction} has {strikes} strikes."),
|
||||||
COMMAND_STRIKE_NOTFOUND("&c&l[!] &7{faction} does not exist."),
|
COMMAND_STRIKE_NOTFOUND("&c&l[!] &7{faction} does not exist."),
|
||||||
COMMAND_STRIKE_NEEDFACTION("&c&l[!] &7&cYou need to join a faction to view your own!"),
|
COMMAND_STRIKE_NEEDFACTION("&c&l[!] &7&cYou need to join a faction to view your own!"),
|
||||||
COMMAND_STRIKE_DESCRIPTION("Give a faction strikes."),
|
|
||||||
|
COMMAND_STRIKEGIVE_DESCRIPTION("Give a faction strikes"),
|
||||||
|
|
||||||
COMMAND_VAULT_DESCRIPTION("Open your placed faction vault!"),
|
COMMAND_VAULT_DESCRIPTION("Open your placed faction vault!"),
|
||||||
COMMAND_VAULT_INVALID("&c&l[!]&7 Your vault was either&c claimed&7, &cbroken&7, or has&c not been&7 placed yet."),
|
COMMAND_VAULT_INVALID("&c&l[!]&7 Your vault was either&c claimed&7, &cbroken&7, or has&c not been&7 placed yet."),
|
||||||
|
4
src/main/java/me/driftay/addons/Utils.java
Normal file
4
src/main/java/me/driftay/addons/Utils.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package me.driftay.addons;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
}
|
103
src/main/java/me/driftay/addons/bankxp/Deposit.java
Normal file
103
src/main/java/me/driftay/addons/bankxp/Deposit.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
package me.driftay.addons.bankxp;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.SavageFactions;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Deposit implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void DepositEvent(PlayerInteractEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
Action a = e.getAction();
|
||||||
|
ItemStack mainhand = p.getInventory().getItemInHand();
|
||||||
|
if (mainhand != null && (a.equals(Action.RIGHT_CLICK_AIR) || a.equals(Action.RIGHT_CLICK_BLOCK)) && mainhand.hasItemMeta() && mainhand.getItemMeta().hasLore()) {
|
||||||
|
try {
|
||||||
|
Material item = Material.getMaterial(SavageFactions.plugin.getConfig().getString("Banknote.Item.ID"));
|
||||||
|
if (mainhand.getType() == item) {
|
||||||
|
this.takeBanknote(e, mainhand);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception e3) {
|
||||||
|
try {
|
||||||
|
Material item2 = Material.getMaterial(String.valueOf(SavageFactions.plugin.getConfig().getInt("Banknote.Item.ID")));
|
||||||
|
if (mainhand.getType() == item2) {
|
||||||
|
this.takeBanknote(e, mainhand);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Material item = Material.getMaterial(SavageFactions.plugin.getConfig().getString("XpBottle.Item.ID"));
|
||||||
|
if (mainhand.getType() == item) {
|
||||||
|
this.takeXpBottle(e, mainhand);
|
||||||
|
}
|
||||||
|
} catch (Exception e3) {
|
||||||
|
try {
|
||||||
|
Material item2 = Material.getMaterial(String.valueOf(SavageFactions.plugin.getConfig().getInt("XpBottle.Item.ID")));
|
||||||
|
if (mainhand.getType() == item2) {
|
||||||
|
this.takeXpBottle(e, mainhand);
|
||||||
|
}
|
||||||
|
} catch (Exception e2) {
|
||||||
|
e.getPlayer().sendMessage("&c&l[!] &7Unknown Command!");
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void takeXpBottle(PlayerInteractEvent e, ItemStack mainhand) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
ItemMeta meta = mainhand.getItemMeta();
|
||||||
|
for (String lore : meta.getLore()) {
|
||||||
|
String newlore = ChatColor.stripColor(lore.replace(",", ""));
|
||||||
|
if (newlore.startsWith(ChatColor.stripColor(SavageFactions.plugin.getConfig().getString("XpBottle.Item.Checks-for")))) {
|
||||||
|
try {
|
||||||
|
Scanner in = new Scanner(newlore).useDelimiter("[^0-9]+");
|
||||||
|
int value = in.nextInt() * mainhand.getAmount();
|
||||||
|
ExperienceFIX.setTotalExperience(p, ExperienceFIX.getTotalExperience(p) + value);
|
||||||
|
p.sendMessage(color(SavageFactions.plugin.getConfig().getString("Messages.xpbottle.deposit")).replace("{exp}", String.valueOf(value)).replace("{exp-balance}", String.valueOf(p.getTotalExperience())));
|
||||||
|
e.setCancelled(true);
|
||||||
|
p.getInventory().removeItem(mainhand);
|
||||||
|
} catch (Exception x) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void takeBanknote(PlayerInteractEvent e, ItemStack mainhand) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
ItemMeta meta = mainhand.getItemMeta();
|
||||||
|
for (String lore : meta.getLore()) {
|
||||||
|
String newlore = ChatColor.stripColor(lore.replace(",", ""));
|
||||||
|
if (newlore.startsWith(ChatColor.stripColor(SavageFactions.plugin.getConfig().getString("Banknote.Item.Checks-for")))) {
|
||||||
|
try {
|
||||||
|
Scanner in = new Scanner(newlore).useDelimiter("[^0-9]+");
|
||||||
|
long value = in.nextLong() * mainhand.getAmount();
|
||||||
|
SavageFactions.econ.depositPlayer( p, (double) value);
|
||||||
|
p.sendMessage(color(SavageFactions.plugin.getConfig().getString("Messages.banknote.deposit")).replace("{money}", SavageFactions.econ.format((double) value)).replace("{balance}", SavageFactions.econ.format(SavageFactions.econ.getBalance(p))));
|
||||||
|
e.setCancelled(true);
|
||||||
|
p.getInventory().remove(mainhand);
|
||||||
|
} catch (Exception x) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String color(String message){
|
||||||
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
70
src/main/java/me/driftay/addons/bankxp/ExperienceFIX.java
Normal file
70
src/main/java/me/driftay/addons/bankxp/ExperienceFIX.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package me.driftay.addons.bankxp;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ExperienceFIX {
|
||||||
|
public static void setTotalExperience(Player player, int exp) {
|
||||||
|
if (exp < 0) {
|
||||||
|
throw new IllegalArgumentException("Experience is negative!");
|
||||||
|
}
|
||||||
|
player.setExp(0.0f);
|
||||||
|
player.setLevel(0);
|
||||||
|
player.setTotalExperience(0);
|
||||||
|
int amount = exp;
|
||||||
|
while (amount > 0) {
|
||||||
|
int expToLevel = getExpAtLevel(player);
|
||||||
|
amount -= expToLevel;
|
||||||
|
if (amount >= 0) {
|
||||||
|
player.giveExp(expToLevel);
|
||||||
|
} else {
|
||||||
|
amount += expToLevel;
|
||||||
|
player.giveExp(amount);
|
||||||
|
amount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getExpAtLevel(Player player) {
|
||||||
|
return getExpAtLevel(player.getLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getExpAtLevel(int level) {
|
||||||
|
if (level <= 15) {
|
||||||
|
return 2 * level + 7;
|
||||||
|
}
|
||||||
|
if (level >= 16 && level <= 30) {
|
||||||
|
return 5 * level - 38;
|
||||||
|
}
|
||||||
|
return 9 * level - 158;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getExpToLevel(int level) {
|
||||||
|
int currentLevel = 0;
|
||||||
|
int exp = 0;
|
||||||
|
while (currentLevel < level) {
|
||||||
|
exp += getExpAtLevel(currentLevel);
|
||||||
|
++currentLevel;
|
||||||
|
}
|
||||||
|
if (exp < 0) {
|
||||||
|
exp = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getTotalExperience(Player player) {
|
||||||
|
int exp = Math.round(getExpAtLevel(player) * player.getExp());
|
||||||
|
for (int currentLevel = player.getLevel(); currentLevel > 0; --currentLevel, exp += getExpAtLevel(currentLevel)) {
|
||||||
|
}
|
||||||
|
if (exp < 0) {
|
||||||
|
exp = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getExpUntilNextLevel(Player player) {
|
||||||
|
int exp = Math.round(getExpAtLevel(player) * player.getExp());
|
||||||
|
int nextLevel = player.getLevel();
|
||||||
|
return getExpAtLevel(nextLevel) - exp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
162
src/main/java/me/driftay/addons/bankxp/Withdraw.java
Normal file
162
src/main/java/me/driftay/addons/bankxp/Withdraw.java
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
package me.driftay.addons.bankxp;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.SavageFactions;
|
||||||
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Withdraw implements CommandExecutor {
|
||||||
|
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
if (cmd.getName().equalsIgnoreCase("withdraw")) {
|
||||||
|
if (sender.hasPermission("factions.withdraw.money")) {
|
||||||
|
Player p;
|
||||||
|
if ((p = Bukkit.getPlayer(sender.getName())) != null) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
long max = SavageFactions.plugin.getConfig().getLong("Banknote.Range.MAX");
|
||||||
|
long min = SavageFactions.plugin.getConfig().getLong("Banknote.Range.MIN");
|
||||||
|
List<String> lore = SavageFactions.plugin.getConfig().getStringList("Banknote.Item.Display.lore");
|
||||||
|
String name = SavageFactions.plugin.getConfig().getString("Banknote.Item.Display.name");
|
||||||
|
boolean glow = SavageFactions.plugin.getConfig().getBoolean("Banknote.Item.Display.glow");
|
||||||
|
try {
|
||||||
|
long value = Long.parseLong(args[0]);
|
||||||
|
if (value >= min && max >= value) {
|
||||||
|
if (value <= SavageFactions.econ.getBalance(p)) {
|
||||||
|
try {
|
||||||
|
ItemStack item = new ItemStack(Material.getMaterial(SavageFactions.plugin.getConfig().getString("Banknote.Item.ID")));
|
||||||
|
item.setDurability((short) SavageFactions.plugin.getConfig().getInt("Banknote.Item.DamageValue"));
|
||||||
|
p.getInventory().addItem(this.Item(p.getName(), p, item, name, lore, value, (int) value, glow));
|
||||||
|
SavageFactions.econ.withdrawPlayer(p, (double) value);
|
||||||
|
this.banknotemsg(p, value);
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
ItemStack item2 = new ItemStack(Material.getMaterial(String.valueOf(SavageFactions.plugin.getConfig().getInt("Banknote.Item.ID"))));
|
||||||
|
item2.setDurability((short) SavageFactions.plugin.getConfig().getInt("Banknote.Item.DamageValue"));
|
||||||
|
p.getInventory().addItem(this.Item(p.getName(), p, item2, name, lore, value, (int) value, glow));
|
||||||
|
SavageFactions.econ.withdrawPlayer(p, (double) value);
|
||||||
|
this.banknotemsg(p, value);
|
||||||
|
} catch (Exception x2) {
|
||||||
|
sender.sendMessage("&c&l[!] &7Unknown Command!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.sendMessage(TL.BANKNOTE_WITHDRAW_NOT_ENOUGH.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(color("&c&l[!] &b" + args[0] + " &7is not in range of " + min + " - " + max));
|
||||||
|
//sender.sendMessage(color(SavageFactions.plugin.getConfig().getString("Messages.Not-In-Range")).replace("{min}", String.valueOf(min)).replace("{max}", String.valueOf(max)).replace("{arg}", args[0]));
|
||||||
|
}
|
||||||
|
} catch (Exception e2) {
|
||||||
|
sender.sendMessage(color("&c&l[!] &b" + args[0] + " &7is not a number!"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(TL.BANKNOTE_WITHDRAW_NO_ARGS.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(color("&4Umm... Your not a player, you don't have an inventory to give this too"));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
sender.sendMessage(TL.GENERIC_NOPERMISSION.toString());
|
||||||
|
}
|
||||||
|
if (cmd.getName().equalsIgnoreCase("bottle")) {
|
||||||
|
if (sender.hasPermission("factions.withdraw.exp")) {
|
||||||
|
Player p;
|
||||||
|
if ((p = Bukkit.getPlayer(sender.getName())) != null) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
int max2 = SavageFactions.plugin.getConfig().getInt("XpBottle.Range.MAX");
|
||||||
|
int min2 = SavageFactions.plugin.getConfig().getInt("XpBottle.Range.MIN");
|
||||||
|
List<String> lore2 = SavageFactions.plugin.getConfig().getStringList("XpBottle.Item.Display.lore");
|
||||||
|
String name2 = SavageFactions.plugin.getConfig().getString("XpBottle.Item.Display.name");
|
||||||
|
boolean glow2 = SavageFactions.plugin.getConfig().getBoolean("XpBottle.Item.Display.glow");
|
||||||
|
try {
|
||||||
|
int value2 = Integer.parseInt(args[0]);
|
||||||
|
if (value2 >= min2 && max2 >= value2) {
|
||||||
|
if (value2 <= ExperienceFIX.getTotalExperience(p)) {
|
||||||
|
try {
|
||||||
|
ItemStack item3 = new ItemStack(Material.getMaterial(SavageFactions.plugin.getConfig().getString("XpBottle.Item.ID")));
|
||||||
|
item3.setDurability((short) SavageFactions.plugin.getConfig().getInt("XpBottle.Item.DamageValue"));
|
||||||
|
p.getInventory().addItem(this.Item(p.getName(), p, item3, name2, lore2, value2, value2, glow2));
|
||||||
|
ExperienceFIX.setTotalExperience(p, ExperienceFIX.getTotalExperience(p) - value2);
|
||||||
|
this.xpbottlemsg(p, value2);
|
||||||
|
} catch (Exception e3) {
|
||||||
|
try {
|
||||||
|
ItemStack item4 = new ItemStack(Material.getMaterial(String.valueOf(SavageFactions.plugin.getConfig().getInt("XpBottle.Item.ID"))));
|
||||||
|
item4.setDurability((short) SavageFactions.plugin.getConfig().getInt("XpBottle.Item.DamageValue"));
|
||||||
|
p.getInventory().addItem(this.Item(p.getName(), p, item4, name2, lore2, value2, value2, glow2));
|
||||||
|
ExperienceFIX.setTotalExperience(p, value2);
|
||||||
|
this.xpbottlemsg(p, value2);
|
||||||
|
} catch (Exception x) {
|
||||||
|
sender.sendMessage("&c&l[!] &7Unknown Command!");
|
||||||
|
x.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.sendMessage(TL.XPBOTTLE_NOT_ENOUGH.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(color("&c&l[!] &b" + args[0] + " &7is not in range of " + min2 + " - " + max2));
|
||||||
|
//sender.sendMessage(color(SavageFactions.plugin.getConfig().getString("Messages.Not-In-Range")).replace("{min}", String.valueOf(min2)).replace("{max}", String.valueOf(max2)).replace("{arg}", args[0]));
|
||||||
|
}
|
||||||
|
} catch (Exception e4) {
|
||||||
|
sender.sendMessage(color("&c&l[!] &b" + args[0] + " &7is not a number!"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(TL.XPBOTTLE_WITHDRAW_NO_ARGS.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(color("&4Umm... Your not a player, you don't have an inventory to give this too"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(TL.GENERIC_NOPERMISSION.toString());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void banknotemsg(Player p, long l) {
|
||||||
|
p.sendMessage(color(SavageFactions.plugin.getConfig().getString("Messages.banknote.withdraw")).replace("{money}", SavageFactions.econ.format((double) l)).replace("{balance}", SavageFactions.econ.format(SavageFactions.econ.getBalance(p))).replace("{player}", p.getName()).replace("{displayname}", p.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void xpbottlemsg(Player p, int i) {
|
||||||
|
p.sendMessage(color(SavageFactions.plugin.getConfig().getString("Messages.xpbottle.withdraw")).replace("{exp}", String.valueOf(i)).replace("{exp-balance}", String.valueOf(p.getTotalExperience())).replace("{player}", p.getName()).replace("{displayname}", p.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String color(String message) {
|
||||||
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack Item(String getPlayer, Player p, ItemStack Item, String name, List<String> lore, long l, int i, boolean b) {
|
||||||
|
ItemMeta meta = Item.getItemMeta();
|
||||||
|
meta.setDisplayName(color(name.replace("{player}", getPlayer).replace("{money}", SavageFactions.econ.format((double) l)).replace("{exp}", String.valueOf(i)).replace("{balance}", SavageFactions.econ.format(SavageFactions.econ.getBalance(p)))));
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
for (String s : lore) {
|
||||||
|
String old = color(s.replace("{player}", getPlayer).replace("{money}", SavageFactions.econ.format((double) l)).replace("{exp}", String.valueOf(i)).replace("{balance}", SavageFactions.econ.format(SavageFactions.econ.getBalance(p))));
|
||||||
|
list.add(old);
|
||||||
|
}
|
||||||
|
lore.addAll(list);
|
||||||
|
meta.setLore(list);
|
||||||
|
if (b) {
|
||||||
|
meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 0, true);
|
||||||
|
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
|
}
|
||||||
|
Item.setItemMeta(meta);
|
||||||
|
return Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -703,6 +703,51 @@ fwarp-gui:
|
|||||||
-
|
-
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# +------------------------------------------------------+ #
|
||||||
|
# | BankNote/XPBottles | #
|
||||||
|
# +------------------------------------------------------+ #
|
||||||
|
############################################################
|
||||||
|
XP-BankNote-Enabled: true
|
||||||
|
Banknote:
|
||||||
|
Item:
|
||||||
|
Display:
|
||||||
|
glow: true
|
||||||
|
name: '&aBanknote'
|
||||||
|
lore:
|
||||||
|
- '&eValue: &6{money}'
|
||||||
|
- '&eOwner: &6{player}'
|
||||||
|
- '&fThis is just a peace of paper'
|
||||||
|
ID: PAPER
|
||||||
|
DamageValue: 0
|
||||||
|
Checks-for: 'Value: '
|
||||||
|
Range:
|
||||||
|
MIN: 1000
|
||||||
|
MAX: 9999999999
|
||||||
|
XpBottle:
|
||||||
|
Item:
|
||||||
|
Display:
|
||||||
|
glow: true
|
||||||
|
name: '&eXpBottle'
|
||||||
|
lore:
|
||||||
|
- '&eValue: &6{exp} EXP'
|
||||||
|
- '&eOwner: &6{player}'
|
||||||
|
- '&fThis is just a XpBottle'
|
||||||
|
ID: EXP_BOTTLE
|
||||||
|
DamageValue: 0
|
||||||
|
Checks-for: 'Value: '
|
||||||
|
Range:
|
||||||
|
MIN: 100
|
||||||
|
MAX: 2147483647
|
||||||
|
Messages:
|
||||||
|
banknote:
|
||||||
|
withdraw: '&bYou have withdrawn &d{money} &bfrom your balance, you now have &d{balance}'
|
||||||
|
deposit: '&bYou have deposited &d{money} &bto your balance, you now have &d{balance}'
|
||||||
|
xpbottle:
|
||||||
|
withdraw: '&bYou have withdrawn &d{exp} &bfrom your experience, you know have &d{exp-balance}'
|
||||||
|
deposit: '&bYou have deposited &d{exp} &bto your experience, you know have &d{exp-balance}'
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
# | Faction Creation/Disband Broadcast | #
|
# | Faction Creation/Disband Broadcast | #
|
||||||
|
@ -9,6 +9,10 @@ commands:
|
|||||||
factions:
|
factions:
|
||||||
description: Reference command for Factions.
|
description: Reference command for Factions.
|
||||||
aliases: [f]
|
aliases: [f]
|
||||||
|
bottle:
|
||||||
|
description: withdraw experience.
|
||||||
|
withdraw:
|
||||||
|
description: withdraw money.
|
||||||
permissions:
|
permissions:
|
||||||
factions.kit.admin:
|
factions.kit.admin:
|
||||||
description: All faction permissions.
|
description: All faction permissions.
|
||||||
|
Loading…
Reference in New Issue
Block a user