Fixed Shop Comparison to XMaterial As Well As Added F Points Balance Command

This commit is contained in:
Driftay 2020-04-02 11:01:01 -04:00
parent 663bd96d26
commit 95a202d2cf
5 changed files with 62 additions and 4 deletions

View File

@ -13,7 +13,7 @@ import net.dv8tion.jda.core.entities.TextChannel;
public class CmdWeeWoo extends FCommand {
/**
* @author Driftay
* @author Vankka
*/
public CmdWeeWoo() {

View File

@ -17,6 +17,7 @@ public class CmdPoints extends FCommand {
public CmdPointsRemove cmdPointsRemove = new CmdPointsRemove();
public CmdPointsSet cmdPointsSet = new CmdPointsSet();
public CmdPointsAdd cmdPointsAdd = new CmdPointsAdd();
public CmdPointsBalance cmdPointsBalance = new CmdPointsBalance();
public CmdPoints() {
super();
@ -26,7 +27,7 @@ public class CmdPoints extends FCommand {
.playerOnly()
.build();
this.addSubCommand(this.cmdPointsBalance);
this.addSubCommand(this.cmdPointsAdd);
this.addSubCommand(this.cmdPointsRemove);
this.addSubCommand(this.cmdPointsSet);

View File

@ -0,0 +1,56 @@
package com.massivecraft.factions.cmd.points;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 3/30/2020
*/
public class CmdPointsBalance extends FCommand {
public CmdPointsBalance() {
super();
this.aliases.addAll(Aliases.points_balance);
this.optionalArgs.put("faction", "yours");
this.requirements = new CommandRequirements.Builder(Permission.POINTS)
.build();
}
@Override
public void perform(CommandContext context) {
Faction faction;
if (context.argIsSet(0)) {
faction = context.argAsFaction(0);
} else if(context.faction.isNormal()){
context.msg(TL.COMMAND_POINTS_SHOW_OWN, context.faction.getPoints());
return;
} else {
context.msg(TL.COMMAND_POINTS_SHOW_WILDERNESS);
return;
}
if (faction == null) return;
if (faction != context.faction && !context.fPlayer.isAdminBypassing()) return;
context.msg(TL.COMMAND_POINTS_SHOW_OTHER.toString().replace("{faction}", faction.getTag()).replace("{points}", faction.getPoints() + ""));
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_POINTS_SHOW_DESCRIPTION;
}
}

View File

@ -14,6 +14,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@ -48,7 +49,7 @@ public class ShopGUIFrame {
for (int a = 1; a <= items; a++) {
String s = a + "";
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
Material material = XMaterial.matchXMaterial(Objects.requireNonNull(ShopConfig.getShop().getString("items." + s + ".block"))).get().parseMaterial();
ItemStack material = XMaterial.matchXMaterial(Objects.requireNonNull(ShopConfig.getShop().getString("items." + s + ".block"))).get().parseItem();
int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
String name = ShopConfig.getShop().getString("items." + s + ".name");
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");

View File

@ -678,7 +678,7 @@ public enum TL {
COMMAND_POINTS_SHOW_DESCRIPTION("See the point balance of factions"),
COMMAND_POINTS_SHOW_WILDERNESS("&c&l[!] &7You may not check the point balance of wilderness!"),
COMMAND_POINTS_SHOW_OWN("&c&l[!] &7Your faction has &e%1$s &7points."),
COMMAND_POINTS_SHOW("&c&l[!] &e%1$s &7has a point balance of &b%2$s&7."),
COMMAND_POINTS_SHOW_OTHER("&c&l[!] &e{faction} &7has a point balance of &b{points}&7."),
COMMAND_POINTS_FAILURE("&c&l[!] &c{faction} does not exist."),
COMMAND_POINTS_SUCCESSFUL("&c&l[!] &7You have added &e%1$s &7points to &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"),
COMMAND_POINTS_INSUFFICIENT("&c&l[!] &7You may not add/set/remove a negative number of points to a faction!"),