Make polls look better
Allow tokens to be bought using droplets Update MVP calculations, update mutation poll and guis, and minor interface changes
This commit is contained in:
parent
c0202b4b2f
commit
4f3e25ac50
|
@ -22,6 +22,8 @@ public class LastPageButton extends Button {
|
|||
public LastPageButton(SinglePageInterface gui, int slot) {
|
||||
super(null, slot);
|
||||
this.page = gui;
|
||||
this.setIcon(new ItemCreator(Material.BARRIER)
|
||||
.setName(Constants.PREFIX + "Previous"));
|
||||
}
|
||||
|
||||
public SinglePageInterface getPage() {
|
||||
|
@ -49,12 +51,6 @@ public class LastPageButton extends Button {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCreator getIcon() {
|
||||
return new ItemCreator(Material.BARRIER)
|
||||
.setName(Constants.PREFIX + "Previous");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
Interface currentInterface = InterfaceManager.getInterface(player.getOpenInventory());
|
||||
|
|
|
@ -36,9 +36,9 @@ public class RaindropCommands implements Commands {
|
|||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"raindrops", "rds"},
|
||||
aliases = {"droplets", "drp"},
|
||||
usage = "[player]",
|
||||
desc = "Shows the amount of raindrops that you have",
|
||||
desc = "Shows the amount of droplets that you have",
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
|
|
|
@ -156,7 +156,7 @@ public class RaindropUtil {
|
|||
private static BaseComponent raindropsMessage(int count, int multiplier, @Nullable BaseComponent reason) {
|
||||
Component message = new Component(ChatColor.GRAY);
|
||||
message.extra(new Component((count > 0 ? "+" : "") + count, ChatColor.GREEN, ChatColor.BOLD),
|
||||
new Component(" Raindrop" + (count == 1 || count == -1 ? "" : "s"), ChatColor.AQUA));
|
||||
new Component(" Droplet" + (count == 1 || count == -1 ? "" : "s"), ChatColor.AQUA));
|
||||
if(multiplier != 100) {
|
||||
message.extra(new Component(" | ", ChatColor.DARK_PURPLE),
|
||||
new Component((multiplier / 100f) + "x", ChatColor.GOLD, ChatColor.ITALIC));
|
||||
|
|
|
@ -83,10 +83,10 @@ public class TokenCommands implements Commands {
|
|||
TokenUtil.giveMapTokens(result.user, numberOfTokens);
|
||||
} else if (type.equals("mutation") || type.equals("mt")) {
|
||||
TokenUtil.giveMutationTokens(result.user, numberOfTokens);
|
||||
} else if (type.equals("raindrops")) {
|
||||
} else if (type.equals("droplets") || type.equals("raindrops") || type.equals("rds")) {
|
||||
RaindropUtil.giveRaindrops(result.user, numberOfTokens, null);
|
||||
} else {
|
||||
throw new CommandUsageException(ChatColor.RED + "/givetokens [player] [map|mutation] [count]");
|
||||
throw new CommandUsageException(ChatColor.RED + "/givetokens [player] [setnext|mutation] [count]");
|
||||
}
|
||||
})
|
||||
);
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ItemCreator {
|
|||
private Color armorColor;
|
||||
private String skullOwner;
|
||||
private PotionEffect potionEffect;
|
||||
private boolean hideFlags;
|
||||
private List<HideFlag> hideFlags;
|
||||
private boolean unbreakable;
|
||||
|
||||
public ItemCreator(Material material) {
|
||||
|
@ -138,12 +138,44 @@ public class ItemCreator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public boolean getHideFlags() {
|
||||
public enum HideFlag {
|
||||
ENCHANTMENTS(1),
|
||||
ATTRIBUTES(2),
|
||||
UNBREAKABLE(4),
|
||||
CAN_DESTROY(8),
|
||||
CAN_PLACE_ON(16),
|
||||
OTHERS(32),
|
||||
ALL(ENCHANTMENTS.getValue() +
|
||||
ATTRIBUTES.getValue() +
|
||||
UNBREAKABLE.getValue() +
|
||||
CAN_DESTROY.getValue() +
|
||||
CAN_PLACE_ON.getValue() +
|
||||
OTHERS.getValue()
|
||||
);
|
||||
|
||||
private int value;
|
||||
|
||||
HideFlag(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<HideFlag> getHideFlags() {
|
||||
return hideFlags;
|
||||
}
|
||||
|
||||
public ItemCreator setHideFlags(boolean hideFlags) {
|
||||
this.hideFlags = hideFlags;
|
||||
@Deprecated
|
||||
public ItemCreator setHideFlags(boolean all) {
|
||||
this.hideFlags = all ? Collections.singletonList(HideFlag.ALL) : Collections.emptyList();
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemCreator setHideFlags(HideFlag... hideFlags) {
|
||||
this.hideFlags = Arrays.asList(hideFlags);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -152,8 +184,13 @@ public class ItemCreator {
|
|||
if (!item.getType().equals(Material.AIR)) {
|
||||
net.minecraft.server.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
if (hideFlags) {
|
||||
tag.setInt("HideFlags", 63);
|
||||
if (hideFlags != null && hideFlags.size() > 0) {
|
||||
int hideFlagValue = 0;
|
||||
for (HideFlag flag : getHideFlags()) {
|
||||
hideFlagValue += flag.getValue();
|
||||
}
|
||||
hideFlagValue = Math.max(1, Math.min(63, hideFlagValue));
|
||||
tag.setInt("HideFlags", hideFlagValue);
|
||||
}
|
||||
if (skullOwner != null) {
|
||||
tag.setString("SkullOwner", skullOwner);
|
||||
|
|
|
@ -11,7 +11,7 @@ depend: [API, BukkitSettings, Channels]
|
|||
permissions:
|
||||
tokens.give:
|
||||
description: Allows the player to give other players tokens
|
||||
default: op
|
||||
default: false
|
||||
nick.see-through-all:
|
||||
description: See the real names of all nicked players
|
||||
default: op
|
||||
|
@ -43,7 +43,7 @@ permissions:
|
|||
default: op
|
||||
ocn.developer:
|
||||
description: Various developer commands
|
||||
default: op
|
||||
default: false
|
||||
ocn.console:
|
||||
description: Parent for perms that are always granted to console
|
||||
default: false
|
||||
|
|
|
@ -103,6 +103,7 @@ command.mutation.error.enabled = {0} mutation is already enabled
|
|||
command.mutation.error.enabled.all = All mutations have already been enabled
|
||||
command.mutation.error.disabled = {0} mutation is already disabled
|
||||
command.mutation.error.disabled.all = All mutations have already been disabled
|
||||
command.mutation.error.illegal = You are not able to use that mutation
|
||||
|
||||
command.mutation.list.current = Current Mutations
|
||||
command.mutation.list.queued = Queued Mutations
|
||||
|
@ -254,6 +255,7 @@ stats.hotbar = {0} kills ({1} streak) {2} deaths {3} K/D
|
|||
|
||||
poll.map.alreadyset = A map has already been set!
|
||||
poll.map.notallowed = You are not allowed to set that map!
|
||||
poll.tutorialmessage = Use {0}/vote [yes|no] {1}to vote
|
||||
|
||||
announce.online = Announced server as online
|
||||
announce.offline = Announced server as offline
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package tc.oc.pgm.commands;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Inject;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import tc.oc.api.bukkit.users.BukkitUserStore;
|
||||
import tc.oc.api.docs.PlayerId;
|
||||
import tc.oc.commons.bukkit.commands.UserFinder;
|
||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||
import tc.oc.commons.core.formatting.StringUtils;
|
||||
import tc.oc.pgm.PGM;
|
||||
|
@ -18,12 +18,13 @@ import tc.oc.pgm.map.PGMMap;
|
|||
import tc.oc.pgm.mutation.Mutation;
|
||||
import tc.oc.pgm.mutation.MutationMatchModule;
|
||||
import tc.oc.pgm.mutation.command.MutationCommands;
|
||||
import tc.oc.pgm.polls.*;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import tc.oc.pgm.polls.Poll;
|
||||
import tc.oc.pgm.polls.PollCustom;
|
||||
import tc.oc.pgm.polls.PollEndReason;
|
||||
import tc.oc.pgm.polls.PollKick;
|
||||
import tc.oc.pgm.polls.PollManager;
|
||||
import tc.oc.pgm.polls.PollMutation;
|
||||
import tc.oc.pgm.polls.PollNextMap;
|
||||
import static tc.oc.commons.bukkit.commands.CommandUtils.newCommandException;
|
||||
|
||||
public class PollCommands {
|
||||
|
@ -158,24 +159,41 @@ public class PollCommands {
|
|||
String mutationString = args.getString(0);
|
||||
MutationMatchModule module = PGM.getMatchManager().getCurrentMatch(sender).getMatchModule(MutationMatchModule.class);
|
||||
|
||||
|
||||
Mutation mutation = StringUtils.bestFuzzyMatch(mutationString, Sets.newHashSet(Mutation.values()), 0.9);
|
||||
if(mutation == null) {
|
||||
throw newCommandException(sender, new TranslatableComponent("command.mutation.error.find", mutationString));
|
||||
} else if(MutationCommands.getInstance().getMutationQueue().mutations().contains(mutation)) {
|
||||
throw newCommandException(sender, new TranslatableComponent(true ? "command.mutation.error.enabled" : "command.mutation.error.disabled", mutation.getComponent(net.md_5.bungee.api.ChatColor.RED)));
|
||||
} else if (!mutation.isPollable()) {
|
||||
throw newCommandException(sender, new TranslatableComponent("command.mutation.error.illegal", mutationString));
|
||||
}
|
||||
|
||||
startPoll(new PollMutation(PGM.getPollManager(), Bukkit.getServer(), sender, mutation, module));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"custom"},
|
||||
desc = "Start a poll with the supplied text",
|
||||
usage = "[text...]",
|
||||
min = 1,
|
||||
max = -1
|
||||
)
|
||||
@CommandPermissions("poll.custom")
|
||||
public static void pollCustom(CommandContext args, CommandSender sender) throws CommandException {
|
||||
String text = args.getJoinedStrings(0);
|
||||
Player initiator = tc.oc.commons.bukkit.commands.CommandUtils.senderToPlayer(sender);
|
||||
|
||||
startPoll(new PollCustom(PGM.getPollManager(), Bukkit.getServer(), initiator.getName(), text));
|
||||
}
|
||||
|
||||
public static void startPoll(Poll poll) throws CommandException {
|
||||
PollManager pollManager = PGM.getPollManager();
|
||||
if(pollManager.isPollRunning()) {
|
||||
throw new CommandException("Another poll is already running.");
|
||||
}
|
||||
pollManager.startPoll(poll);
|
||||
Bukkit.getServer().broadcastMessage(ChatColor.RED + poll.getInitiator() + ChatColor.YELLOW + " has started a poll to " + poll.getActionString(ChatColor.YELLOW));
|
||||
Bukkit.getServer().broadcastMessage(Poll.boldAqua + poll.getInitiator() + Poll.normalize + " has started a poll " + poll.getDescriptionMessage());
|
||||
Bukkit.broadcastMessage(Poll.tutorialMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
|||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||
import tc.oc.commons.core.chat.Component;
|
||||
import tc.oc.pgm.destroyable.DestroyableContribution;
|
||||
import tc.oc.pgm.events.MatchEndEvent;
|
||||
|
@ -27,7 +28,7 @@ public class HighlightListener implements Listener {
|
|||
public void matchEnd(MatchEndEvent event) {
|
||||
StatsUserFacet bestPlayerStats = null;
|
||||
MatchPlayer bestPlayer = null;
|
||||
int bestPlayerPoints = 0;
|
||||
double bestPlayerPoints = 0;
|
||||
|
||||
if (event.getMatch().getParticipatingPlayers().size() < 10) {
|
||||
return;
|
||||
|
@ -36,26 +37,26 @@ public class HighlightListener implements Listener {
|
|||
for (MatchPlayer player : event.getMatch().getParticipatingPlayers()) {
|
||||
StatsUserFacet facet = player.getUserContext().facet(StatsUserFacet.class);
|
||||
|
||||
int points = 0;
|
||||
points += facet.matchKills() * 2;
|
||||
double points = 0;
|
||||
points += facet.matchKills();
|
||||
points -= facet.deaths();
|
||||
for (long wool : facet.getWoolCaptureTimes()) {
|
||||
int woolPoints = (int)((wool * 2) - 2);
|
||||
int woolPoints = (int)((wool * 2.5) - 2);
|
||||
points += Math.min(Math.max(woolPoints, 0), 120);
|
||||
}
|
||||
|
||||
for (long core : facet.getCoreLeakTimes()) {
|
||||
int corePoints = (int)((core * 2) - 2);
|
||||
int corePoints = (int)((core * 2.5) - 2);
|
||||
points += Math.min(Math.max(corePoints, 0), 120);
|
||||
}
|
||||
|
||||
for (DestroyableContribution destroyable : facet.getDestroyableDestroyTimes().keySet()) {
|
||||
int destroyablePoints = (int)((facet.getDestroyableDestroyTimes().get(destroyable) * 2 * destroyable.getPercentage()) - 2);
|
||||
int destroyablePoints = (int)((facet.getDestroyableDestroyTimes().get(destroyable) * 2.5 * destroyable.getPercentage()) - 2);
|
||||
points += Math.min(Math.max(destroyablePoints, 0), 120);
|
||||
}
|
||||
|
||||
for (long flag : facet.getFlagCaptureTimes()) {
|
||||
int flagPoints = (int)(flag / 2);
|
||||
int flagPoints = (int)(flag / 1.75);
|
||||
points += Math.min(Math.max(flagPoints, 0), 120);
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,20 @@ public class HighlightListener implements Listener {
|
|||
|
||||
if (bestPlayer != null) {
|
||||
final BaseComponent title = new Component(new TranslatableComponent("broadcast.gameOver.mvp"), ChatColor.AQUA, ChatColor.BOLD);
|
||||
Component subtitle = new Component(bestPlayer.getDisplayName());
|
||||
Component subtitle;
|
||||
if (Math.random() < 0.05) {
|
||||
String appendMe;
|
||||
if (Math.random() > 0.25) {
|
||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
||||
appendMe = ChatColor.YELLOW + ": +1 Mutation Token!";
|
||||
} else {
|
||||
TokenUtil.giveMapTokens(TokenUtil.getUser(bestPlayer.getBukkit()), 1);
|
||||
appendMe = ChatColor.YELLOW + ": +1 SetNext Token!";
|
||||
}
|
||||
subtitle = new Component(bestPlayer.getDisplayName() + appendMe);
|
||||
} else {
|
||||
subtitle = new Component(bestPlayer.getDisplayName());
|
||||
}
|
||||
|
||||
for(MatchPlayer viewer : event.getMatch().getPlayers()) {
|
||||
scheduler.createDelayedTask(100L, () -> {
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.md_5.bungee.api.ChatColor;
|
|||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import org.bukkit.Material;
|
||||
import tc.oc.commons.core.chat.Component;
|
||||
import tc.oc.pgm.PGM;
|
||||
import tc.oc.pgm.mutation.types.MutationModule;
|
||||
|
@ -33,38 +34,54 @@ import java.util.stream.Stream;
|
|||
|
||||
public enum Mutation {
|
||||
|
||||
BLITZ (BlitzMutation.class),
|
||||
RAGE (RageMutation.class),
|
||||
HARDCORE (HardcoreMutation.class),
|
||||
JUMP (JumpMutation.class),
|
||||
EXPLOSIVE (ExplosiveMutation.class),
|
||||
ELYTRA (ElytraMutation.class),
|
||||
PROJECTILE (ProjectileMutation.class),
|
||||
ENCHANTMENT(EnchantmentMutation.class),
|
||||
POTION (PotionMutation.class),
|
||||
EQUESTRIAN (EquestrianMutation.class),
|
||||
HEALTH (HealthMutation.class),
|
||||
GLOW (GlowMutation.class),
|
||||
STEALTH (StealthMutation.class),
|
||||
ARMOR (ArmorMutation.class),
|
||||
MOBS (MobsMutation.class),
|
||||
LIGHTNING (LightningMutation.class),
|
||||
BOMBER (BomberMutation.class),
|
||||
APOCALYPSE (ApocalypseMutation.class);
|
||||
BLITZ (BlitzMutation.class, Material.IRON_FENCE, false),
|
||||
RAGE (RageMutation.class, Material.SKULL_ITEM, false),
|
||||
HARDCORE (HardcoreMutation.class, Material.GOLDEN_APPLE),
|
||||
JUMP (JumpMutation.class, Material.FEATHER),
|
||||
EXPLOSIVE (ExplosiveMutation.class, Material.FLINT_AND_STEEL),
|
||||
ELYTRA (ElytraMutation.class, Material.ELYTRA),
|
||||
PROJECTILE (ProjectileMutation.class, Material.TIPPED_ARROW),
|
||||
ENCHANTMENT(EnchantmentMutation.class, Material.ENCHANTMENT_TABLE),
|
||||
POTION (PotionMutation.class, Material.POTION),
|
||||
EQUESTRIAN (EquestrianMutation.class, Material.SADDLE),
|
||||
HEALTH (HealthMutation.class, Material.COOKED_BEEF),
|
||||
GLOW (GlowMutation.class, Material.GLOWSTONE_DUST, false),
|
||||
STEALTH (StealthMutation.class, Material.THIN_GLASS),
|
||||
ARMOR (ArmorMutation.class, Material.DIAMOND_CHESTPLATE),
|
||||
MOBS (MobsMutation.class, Material.MONSTER_EGG),
|
||||
LIGHTNING (LightningMutation.class, Material.JACK_O_LANTERN),
|
||||
BOMBER (BomberMutation.class, Material.TNT),
|
||||
APOCALYPSE (ApocalypseMutation.class, Material.NETHER_STAR);
|
||||
|
||||
public static final String TYPE_KEY = "mutation.type.";
|
||||
public static final String DESCRIPTION_KEY = ".desc";
|
||||
|
||||
private final @Nullable Class<? extends MutationModule> loader;
|
||||
private final Material guiDisplay;
|
||||
private final boolean pollable;
|
||||
|
||||
Mutation(@Nullable Class<? extends MutationModule> loader) {
|
||||
Mutation(@Nullable Class<? extends MutationModule> loader, Material guiDisplay) {
|
||||
this(loader, guiDisplay, true);
|
||||
}
|
||||
|
||||
Mutation(@Nullable Class<? extends MutationModule> loader, Material guiDisplay, boolean pollable) {
|
||||
this.loader = loader;
|
||||
this.guiDisplay = guiDisplay;
|
||||
this.pollable = pollable;
|
||||
}
|
||||
|
||||
public Class<? extends MutationModule> loader() {
|
||||
return loader;
|
||||
}
|
||||
|
||||
public Material getGuiDisplay() {
|
||||
return guiDisplay;
|
||||
}
|
||||
|
||||
public boolean isPollable() {
|
||||
return pollable;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return TYPE_KEY + name().toLowerCase();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@ public abstract class Poll implements Runnable {
|
|||
protected String initiator;
|
||||
protected int timeLeftSeconds;
|
||||
|
||||
public static String boldAqua = ChatColor.BOLD + "" + ChatColor.AQUA;
|
||||
public static String normalize = ChatColor.RESET + "" + ChatColor.DARK_AQUA;
|
||||
public static String seperator = ChatColor.RESET + " | ";
|
||||
|
||||
public Poll(PollManager pollManager, Server server, String initiator) {
|
||||
this.pollManager = pollManager;
|
||||
this.server = server;
|
||||
|
@ -64,15 +68,23 @@ public abstract class Poll implements Runnable {
|
|||
|
||||
public abstract void executeAction();
|
||||
|
||||
public abstract String getActionString(ChatColor neutral);
|
||||
public abstract String getActionString();
|
||||
|
||||
public abstract String getDescriptionMessage();
|
||||
|
||||
public String getStatusMessage() {
|
||||
ChatColor neutral = ChatColor.YELLOW;
|
||||
return ChatColor.GOLD.toString() + this.getTimeLeftSeconds() + neutral + " seconds left in poll " + this.getActionString(neutral) + neutral + " " + this.formatForAgainst(neutral);
|
||||
String message = boldAqua + "[Poll] " + this.getTimeLeftSeconds() + normalize + " seconds left" + seperator;
|
||||
message += getActionString() + seperator + formatForAgainst();
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
protected String formatForAgainst(ChatColor neutral) {
|
||||
return "[" + ChatColor.DARK_GREEN + this.getVotesFor() + " " + ChatColor.DARK_RED + this.getVotesAgainst() + neutral + "]";
|
||||
protected String formatForAgainst() {
|
||||
return normalize + "Yes: " + boldAqua + this.getVotesFor() + " " + normalize + "No: " + boldAqua + this.getVotesAgainst();
|
||||
}
|
||||
|
||||
public static String tutorialMessage() {
|
||||
return normalize + "Use " + boldAqua + "/vote [yes|no]" + normalize + " to vote";
|
||||
}
|
||||
|
||||
public boolean hasVoted(String playerName) {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package tc.oc.pgm.polls;
|
||||
|
||||
import org.bukkit.Server;
|
||||
|
||||
public class PollCustom extends Poll {
|
||||
|
||||
private String text;
|
||||
|
||||
public PollCustom(PollManager pollManager, Server server, String initiator, String text) {
|
||||
super(pollManager, server, initiator);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeAction() {
|
||||
//I do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionString() {
|
||||
return boldAqua + text.substring(0, 1).toUpperCase() + text.substring(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionMessage() {
|
||||
return boldAqua + text;
|
||||
}
|
||||
}
|
|
@ -20,7 +20,12 @@ public class PollKick extends Poll {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getActionString(ChatColor neutral) {
|
||||
return "to kick " + ChatColor.RED + this.player;
|
||||
public String getActionString() {
|
||||
return normalize + "Kick: " + boldAqua + this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionMessage() {
|
||||
return "to kick " + boldAqua + this.player;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package tc.oc.pgm.polls;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import tc.oc.pgm.match.Match;
|
||||
import tc.oc.pgm.match.MatchManager;
|
||||
|
||||
|
||||
public class PollListener implements Listener {
|
||||
@SuppressWarnings("unused")
|
||||
private final PollManager pollManager;
|
||||
|
@ -23,10 +20,14 @@ public class PollListener implements Listener {
|
|||
if(event.getReason() == PollEndReason.Completed) {
|
||||
Match match = this.mm.getCurrentMatch();
|
||||
if(event.getPoll().isSuccessful()) {
|
||||
match.sendMessage(ChatColor.DARK_GREEN + "The poll " + event.getPoll().getActionString(ChatColor.DARK_GREEN) + ChatColor.DARK_GREEN + " succeeded.");
|
||||
match.sendMessage(Poll.normalize + "The poll " + event.getPoll().getDescriptionMessage()
|
||||
+ Poll.normalize + " has succeeded" + Poll.seperator);
|
||||
match.sendMessage(event.getPoll().formatForAgainst());
|
||||
event.getPoll().executeAction();
|
||||
} else {
|
||||
match.sendMessage(ChatColor.DARK_RED + "The poll " + event.getPoll().getActionString(ChatColor.DARK_RED) + ChatColor.DARK_RED + " failed.");
|
||||
match.sendMessage(Poll.normalize + "The poll " + event.getPoll().getDescriptionMessage()
|
||||
+ Poll.normalize + " has failed" + Poll.seperator + event.getPoll().formatForAgainst());
|
||||
match.sendMessage(event.getPoll().formatForAgainst());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package tc.oc.pgm.polls;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -37,8 +36,14 @@ public class PollMutation extends Poll {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getActionString(ChatColor neutral) {
|
||||
return "to add the mutation " + ChatColor.GOLD + mutation.name().substring(0,1)
|
||||
public String getActionString() {
|
||||
return normalize + "Add mutation: " + boldAqua + mutation.name().substring(0,1)
|
||||
+ mutation.name().toLowerCase().substring(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionMessage() {
|
||||
return "to add the " + boldAqua + mutation.name().substring(0,1)
|
||||
+ mutation.name().toLowerCase().substring(1) + " mutation";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package tc.oc.pgm.polls;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -8,7 +7,6 @@ import tc.oc.commons.bukkit.tokens.TokenUtil;
|
|||
import tc.oc.pgm.map.PGMMap;
|
||||
import tc.oc.pgm.match.MatchManager;
|
||||
|
||||
|
||||
public class PollNextMap extends Poll {
|
||||
private final MatchManager mm;
|
||||
private final PGMMap nextMap;
|
||||
|
@ -31,7 +29,12 @@ public class PollNextMap extends Poll {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getActionString(ChatColor neutral) {
|
||||
return "to set the next map to " + ChatColor.GOLD + this.nextMap.getInfo().name;
|
||||
public String getActionString() {
|
||||
return normalize + "Next map: " + boldAqua + this.nextMap.getInfo().name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionMessage() {
|
||||
return "to set the next map to " + boldAqua + this.nextMap.getInfo().name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,10 +32,10 @@ public class TeamCommands implements NestedCommands {
|
|||
@Singleton
|
||||
public static class Parent implements Commands {
|
||||
@Command(
|
||||
aliases = {"team"},
|
||||
desc = "Commands for working with teams",
|
||||
min = 1,
|
||||
max = -1
|
||||
aliases = {"team"},
|
||||
desc = "Commands for working with teams",
|
||||
min = 1,
|
||||
max = -1
|
||||
)
|
||||
@NestedCommand({TeamCommands.class})
|
||||
public void team() {}
|
||||
|
@ -50,10 +50,10 @@ public class TeamCommands implements NestedCommands {
|
|||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"myteam", "mt"},
|
||||
desc = "Shows you what team you are on",
|
||||
min = 0,
|
||||
max = 0
|
||||
aliases = {"myteam", "mt"},
|
||||
desc = "Shows you what team you are on",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("pgm.myteam")
|
||||
public void myteam(CommandContext args, CommandSender sender) throws CommandException {
|
||||
|
@ -66,11 +66,11 @@ public class TeamCommands implements NestedCommands {
|
|||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"force"},
|
||||
desc = "Force a player onto a team",
|
||||
usage = "<player> [team]",
|
||||
min = 1,
|
||||
max = 2
|
||||
aliases = {"force"},
|
||||
desc = "Force a player onto a team",
|
||||
usage = "<player> [team]",
|
||||
min = 1,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("pgm.team.force")
|
||||
public void force(CommandContext args, CommandSender sender) throws CommandException, SuggestException {
|
||||
|
@ -90,10 +90,10 @@ public class TeamCommands implements NestedCommands {
|
|||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"shuffle"},
|
||||
desc = "Shuffle the teams",
|
||||
min = 0,
|
||||
max = 0
|
||||
aliases = {"shuffle"},
|
||||
desc = "Shuffle the teams",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("pgm.team.shuffle")
|
||||
public void shuffle(CommandContext args, CommandSender sender) throws CommandException {
|
||||
|
@ -114,11 +114,11 @@ public class TeamCommands implements NestedCommands {
|
|||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"alias"},
|
||||
desc = "Rename a team",
|
||||
usage = "<old name> <new name>",
|
||||
min = 2,
|
||||
max = -1
|
||||
aliases = {"alias"},
|
||||
desc = "Rename a team",
|
||||
usage = "<old name> <new name>",
|
||||
min = 2,
|
||||
max = -1
|
||||
)
|
||||
@CommandPermissions("pgm.team.alias")
|
||||
public void alias(CommandContext args, CommandSender sender) throws CommandException, SuggestException {
|
||||
|
@ -143,42 +143,62 @@ public class TeamCommands implements NestedCommands {
|
|||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"max", "size"},
|
||||
desc = "Change the maximum size of a team. If max-overfill is not specified, it will be the same as max-players.",
|
||||
usage = "<team> (default | <max-players> [max-overfill])",
|
||||
min = 2,
|
||||
max = 3
|
||||
aliases = {"max", "size"},
|
||||
desc = "Change the maximum size of a team. If max-overfill is not specified, it will be the same as max-players.",
|
||||
usage = "<team> (default | <max-players> [max-overfill])",
|
||||
min = 2,
|
||||
max = 3
|
||||
)
|
||||
@CommandPermissions("pgm.team.size")
|
||||
public void max(CommandContext args, CommandSender sender) throws CommandException, SuggestException {
|
||||
Team team = utils.teamArgument(args, 0);
|
||||
|
||||
if("default".equals(args.getString(1))) {
|
||||
team.resetMaxSize();
|
||||
} else {
|
||||
int maxPlayers = args.getInteger(1);
|
||||
if(maxPlayers < 0) throw new CommandException("max-players cannot be less than 0");
|
||||
int maxPlayers = args.getInteger(1);
|
||||
if(maxPlayers < 0) throw new CommandException("max-players cannot be less than 0");
|
||||
|
||||
Integer maxOverfill = null;
|
||||
if(args.argsLength() == 3) {
|
||||
maxOverfill = args.getInteger(2);
|
||||
if(maxOverfill < maxPlayers) throw new CommandException("max-overfill cannot be less than max-players");
|
||||
}
|
||||
|
||||
team.setMaxSize(maxPlayers, maxOverfill != null ? maxOverfill : maxPlayers);
|
||||
Integer maxOverfill = null;
|
||||
if(args.argsLength() == 3) {
|
||||
maxOverfill = args.getInteger(2);
|
||||
if (maxOverfill < maxPlayers) throw new CommandException("max-overfill cannot be less than max-players");
|
||||
}
|
||||
|
||||
sender.sendMessage(team.getColoredName() +
|
||||
ChatColor.WHITE + " now has max size " + ChatColor.AQUA + team.getMaxPlayers() +
|
||||
ChatColor.WHITE + " and max overfill " + ChatColor.AQUA + team.getMaxOverfill());
|
||||
List<Team> teams = new ArrayList<>();
|
||||
|
||||
if (args.getString(0).equals("*")) {
|
||||
List<String> teamNames = utils.teamNames();
|
||||
for (String teamName: teamNames) {
|
||||
if (!teamName.toLowerCase().contains("obs")) {
|
||||
teams.add(utils.team(teamName));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
teams.add(utils.teamArgument(args, 0));
|
||||
}
|
||||
|
||||
for (Team team: teams) {
|
||||
if("default".equals(args.getString(1))) {
|
||||
team.resetMaxSize();
|
||||
} else {
|
||||
team.setMaxSize(maxPlayers, maxOverfill != null ? maxOverfill : maxPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
if (teams.size() == 1) {
|
||||
sender.sendMessage(teams.get(0).getColoredName() +
|
||||
ChatColor.WHITE + " now has max size " + ChatColor.AQUA + teams.get(0).getMaxPlayers() +
|
||||
ChatColor.WHITE + " and max overfill " + ChatColor.AQUA + teams.get(0).getMaxOverfill());
|
||||
} else if (teams.size() > 1) {
|
||||
sender.sendMessage("All teams" +
|
||||
ChatColor.WHITE + " now have max size " + ChatColor.AQUA + teams.get(0).getMaxPlayers() +
|
||||
ChatColor.WHITE + " and max overfill " + ChatColor.AQUA + teams.get(0).getMaxOverfill());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"min"},
|
||||
desc = "Change the minimum size of a team.",
|
||||
usage = "<team> (default | <min-players>)",
|
||||
min = 2,
|
||||
max = 2
|
||||
aliases = {"min"},
|
||||
desc = "Change the minimum size of a team.",
|
||||
usage = "<team> (default | <min-players>)",
|
||||
min = 2,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("pgm.team.size")
|
||||
public void min(CommandContext args, CommandSender sender) throws CommandException, SuggestException {
|
||||
|
@ -193,6 +213,6 @@ public class TeamCommands implements NestedCommands {
|
|||
}
|
||||
|
||||
sender.sendMessage(team.getColoredName() +
|
||||
ChatColor.WHITE + " now has min size " + ChatColor.AQUA + team.getMinPlayers());
|
||||
ChatColor.WHITE + " now has min size " + ChatColor.AQUA + team.getMinPlayers());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package tc.oc.pgm.tokens;
|
|||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -10,25 +9,16 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import tc.oc.commons.bukkit.event.ObserverKitApplyEvent;
|
||||
import tc.oc.commons.bukkit.gui.Interface;
|
||||
import tc.oc.commons.bukkit.gui.InterfaceManager;
|
||||
import tc.oc.commons.bukkit.gui.buttons.Button;
|
||||
import tc.oc.commons.bukkit.raindrops.RaindropConstants;
|
||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||
import tc.oc.commons.core.util.Comparables;
|
||||
import tc.oc.pgm.events.MatchEndEvent;
|
||||
import tc.oc.pgm.events.ObserverInteractEvent;
|
||||
import tc.oc.pgm.match.Competitor;
|
||||
import tc.oc.pgm.match.Match;
|
||||
import tc.oc.pgm.match.MatchPlayer;
|
||||
import tc.oc.pgm.teams.Team;
|
||||
import tc.oc.pgm.tokens.gui.MainTokenButton;
|
||||
import tc.oc.pgm.victory.VictoryMatchModule;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TokenListener implements Listener {
|
||||
|
||||
|
@ -52,13 +42,7 @@ public class TokenListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void handleMatchEndEvent(final MatchEndEvent event) {
|
||||
//1 percent chance of happening
|
||||
if (Math.random() > 0.01) {
|
||||
return;
|
||||
}
|
||||
final Set<Competitor> winners = event.getMatch().needMatchModule(VictoryMatchModule.class).winners();
|
||||
Match match = event.getMatch();
|
||||
List<MatchPlayer> playersOnWinningTeam = new ArrayList<MatchPlayer>();
|
||||
//use the same playtime rules as raindrops
|
||||
boolean applyCutoff = Comparables.greaterThan(match.getLength(), RaindropConstants.TEAM_REWARD_CUTOFF);
|
||||
for(MatchPlayer player : match.getParticipatingPlayers()) {
|
||||
|
@ -66,24 +50,17 @@ public class TokenListener implements Listener {
|
|||
Team team = (Team) player.getParty();
|
||||
Duration teamTime = team.getCumulativeParticipation(player.getPlayerId());
|
||||
if(!(applyCutoff && Comparables.lessThan(teamTime, RaindropConstants.TEAM_REWARD_CUTOFF))) {
|
||||
Competitor playerTeam = player.getCompetitor();
|
||||
assert playerTeam != null;
|
||||
if(winners.contains(playerTeam)) {
|
||||
playersOnWinningTeam.add(player);
|
||||
if (Math.random() < 0.005) {
|
||||
if (Math.random() > 0.25) {
|
||||
Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.AQUA + " has won a Mutation Token!");
|
||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||
} else {
|
||||
Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.AQUA + " has won a SetNext Token!");
|
||||
TokenUtil.giveMapTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!playersOnWinningTeam.isEmpty()) {
|
||||
MatchPlayer player = playersOnWinningTeam.get((int)(playersOnWinningTeam.size() * Math.random()));
|
||||
if (Math.random() > 0.5) {
|
||||
Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.AQUA + " has won a Mutation Token!");
|
||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||
} else {
|
||||
Bukkit.broadcastMessage(player.getDisplayName() + ChatColor.AQUA + " has won a SetNext Token!");
|
||||
TokenUtil.giveMapTokens(TokenUtil.getUser(player.getBukkit()), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,16 @@ public class MainTokenMenu extends ChestInterface {
|
|||
}
|
||||
});
|
||||
|
||||
buttons.add(new Button(
|
||||
new ItemCreator(Material.EMERALD)
|
||||
.setName(Constants.PREFIX + "Buy Tokens")
|
||||
, 13) {
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
player.openInventory(new TokenPurchaseInterface(player).getInventory());
|
||||
}
|
||||
});
|
||||
|
||||
setButtons(buttons);
|
||||
updateInventory();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ import org.bukkit.Material;
|
|||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.commons.bukkit.gui.buttons.Button;
|
||||
import tc.oc.commons.bukkit.gui.interfaces.ChestInterface;
|
||||
import tc.oc.commons.bukkit.gui.buttons.empty.EmptyButton;
|
||||
import tc.oc.commons.bukkit.gui.interfaces.SinglePageInterface;
|
||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||
import tc.oc.commons.bukkit.util.Constants;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
@ -18,84 +19,44 @@ import tc.oc.pgm.mutation.command.MutationCommands;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MutationTokenInterface extends ChestInterface {
|
||||
|
||||
private static MutationTokenInterface instance;
|
||||
|
||||
private Player player;
|
||||
public class MutationTokenInterface extends SinglePageInterface {
|
||||
|
||||
public MutationTokenInterface(Player player) {
|
||||
super(player, new ArrayList<Button>(), 54, "Token Menu", getInstance());
|
||||
this.player = player;
|
||||
updateButtons();
|
||||
instance = this;
|
||||
super(player, new ArrayList<>(), 54, "Token Menu - Mutations", new MainTokenMenu(player));
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChestInterface getParent() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
public static MutationTokenInterface getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateButtons() {
|
||||
public void setButtons() {
|
||||
List<Button> buttons = new ArrayList<>();
|
||||
|
||||
buttons.add(getMutationButton(Mutation.EQUESTRIAN, Material.SADDLE, 10));
|
||||
buttons.add(getMutationButton(Mutation.POTION, Material.POTION, 11));
|
||||
buttons.add(getMutationButton(Mutation.ELYTRA, Material.ELYTRA, 12));
|
||||
buttons.add(getMutationButton(Mutation.PROJECTILE, Material.TIPPED_ARROW, 13));
|
||||
buttons.add(getMutationButton(Mutation.MOBS, Material.MONSTER_EGG, 14));
|
||||
buttons.add(getMutationButton(Mutation.HARDCORE, Material.GOLDEN_APPLE, 15));
|
||||
buttons.add(getMutationButton(Mutation.GLOW, Material.GLOWSTONE_DUST, 16));
|
||||
|
||||
buttons.add(getMutationButton(Mutation.ENCHANTMENT, Material.ENCHANTMENT_TABLE, 19));
|
||||
buttons.add(getMutationButton(Mutation.JUMP, Material.FEATHER, 20));
|
||||
buttons.add(getMutationButton(Mutation.EXPLOSIVE, Material.FLINT_AND_STEEL, 21));
|
||||
buttons.add(getMutationButton(Mutation.HEALTH, Material.COOKED_BEEF, 22));
|
||||
buttons.add(getMutationButton(Mutation.ARMOR, Material.DIAMOND_CHESTPLATE, 23));
|
||||
buttons.add(getMutationButton(Mutation.LIGHTNING, Material.JACK_O_LANTERN, 24));
|
||||
buttons.add(getMutationButton(Mutation.APOCALYPSE, Material.NETHER_STAR, 25));
|
||||
|
||||
buttons.add(getMutationButton(Mutation.BLITZ, Material.IRON_FENCE, 28));
|
||||
buttons.add(getMutationButton(Mutation.STEALTH, Material.THIN_GLASS, 29));
|
||||
buttons.add(getMutationButton(Mutation.BOMBER, Material.TNT, 30));
|
||||
|
||||
buttons.add(new Button(new ItemCreator(Material.WOOL)
|
||||
.setData(14)
|
||||
.setName( ChatColor.GREEN + "Go Back" ), 49){
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
player.openInventory(new MainTokenMenu(player).getInventory());
|
||||
for (Mutation mutation : Mutation.values()) {
|
||||
if (mutation.isPollable()) {
|
||||
buttons.add(getMutationButton(mutation));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
setButtons(buttons);
|
||||
updateInventory();
|
||||
}
|
||||
|
||||
private Button getMutationButton(Mutation mutation, Material material, int slot) {
|
||||
ItemCreator itemCreator = new ItemCreator(material)
|
||||
.setName(Constants.PREFIX + getMutationName(mutation))
|
||||
.addLore(Constants.SUBTEXT + getMutationDescription(mutation));
|
||||
private Button getMutationButton(Mutation mutation) {
|
||||
ItemCreator itemCreator = new ItemCreator(mutation.getGuiDisplay())
|
||||
.setName(Constants.PREFIX + getMutationName(mutation, this.getPlayer()))
|
||||
.addLore(Constants.SUBTEXT + getMutationDescription(mutation, this.getPlayer()))
|
||||
.setHideFlags(ItemCreator.HideFlag.ALL);
|
||||
if (MutationCommands.getInstance().getMutationQueue().mutations().contains(mutation)) {
|
||||
itemCreator.addEnchantment(Enchantment.DURABILITY, 1);
|
||||
}
|
||||
return new Button(itemCreator, slot) {
|
||||
return new Button(itemCreator) {
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
if (hasEnoughTokens()) {
|
||||
if (hasEnoughTokens(player)) {
|
||||
player.closeInventory();
|
||||
MutationMatchModule module = PGM.getMatchManager().getCurrentMatch(player).getMatchModule(MutationMatchModule.class);
|
||||
if (MutationCommands.getInstance().getMutationQueue().mutations().contains(mutation)) {
|
||||
player.sendMessage(ChatColor.RED + "The " + getMutationName(mutation)
|
||||
player.sendMessage(ChatColor.RED + "The " + getMutationName(mutation, player)
|
||||
+ " mutation is already enabled!");
|
||||
} else if (PGM.getMatchManager().getCurrentMatch(player).isStarting()) {
|
||||
if (module.mutationsActive().contains(mutation)) {
|
||||
player.sendMessage(ChatColor.RED + "The " + getMutationName(mutation)
|
||||
player.sendMessage(ChatColor.RED + "The " + getMutationName(mutation, player)
|
||||
+ " mutation is already enabled!");
|
||||
}
|
||||
} else {
|
||||
|
@ -109,16 +70,37 @@ public class MutationTokenInterface extends ChestInterface {
|
|||
};
|
||||
}
|
||||
|
||||
private String getMutationName(Mutation mutation) {
|
||||
private String getMutationName(Mutation mutation, Player player) {
|
||||
return PGMTranslations.get().t(mutation.getName(), player);
|
||||
}
|
||||
|
||||
private String getMutationDescription(Mutation mutation) {
|
||||
return PGMTranslations.get().t(mutation.getDescription(), player);
|
||||
private String getMutationDescription(Mutation mutation, Player player) {
|
||||
String description = PGMTranslations.get().t(mutation.getDescription(), player);
|
||||
return description.substring(0, 1).toUpperCase() + description.substring(1);
|
||||
}
|
||||
|
||||
private boolean hasEnoughTokens() {
|
||||
private boolean hasEnoughTokens(Player player) {
|
||||
return TokenUtil.getUser(player).mutationtokens() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultButtons() {
|
||||
defaultButtons.clear();
|
||||
defaultButtons.add(this.lastPageButton);
|
||||
this.lastPageButton.setSlot(49);
|
||||
this.lastPageButton.setIcon(new ItemCreator(Material.WOOL)
|
||||
.setData(14)
|
||||
.setName(ChatColor.GREEN + "Go Back"));
|
||||
for (Integer integer : new Integer[]{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 17,
|
||||
18, 26,
|
||||
27, 35,
|
||||
36, 44,
|
||||
45, 46, 47, 48, 50, 51, 52, 53}) {
|
||||
EmptyButton button = new EmptyButton(integer);
|
||||
defaultButtons.add(button);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package tc.oc.pgm.tokens.gui;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.commons.bukkit.gui.buttons.Button;
|
||||
import tc.oc.commons.bukkit.gui.interfaces.ChestInterface;
|
||||
import tc.oc.commons.bukkit.raindrops.RaindropUtil;
|
||||
import tc.oc.commons.bukkit.tokens.TokenUtil;
|
||||
import tc.oc.commons.bukkit.util.Constants;
|
||||
import tc.oc.commons.bukkit.util.ItemCreator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TokenPurchaseInterface extends ChestInterface {
|
||||
|
||||
private static TokenPurchaseInterface instance;
|
||||
|
||||
private Player player;
|
||||
|
||||
public TokenPurchaseInterface(Player player) {
|
||||
super(player, new ArrayList<Button>(), 36, "Purchase Tokens", getInstance());
|
||||
this.player = player;
|
||||
updateButtons();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChestInterface getParent() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
public static TokenPurchaseInterface getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateButtons() {
|
||||
List<Button> buttons = new ArrayList<>();
|
||||
|
||||
int numRaindrops = TokenUtil.getUser(player).raindrops();
|
||||
|
||||
buttons.add(new Button(
|
||||
new ItemCreator(Material.GHAST_TEAR)
|
||||
.setName(Constants.PREFIX + "Droplets")
|
||||
.addLore(Constants.SUBTEXT + "You have "
|
||||
+ Integer.valueOf(numRaindrops) + " Droplet" + (numRaindrops == 1 ? "" : "s" ))
|
||||
, 13));
|
||||
|
||||
buttons.add(new Button(
|
||||
new ItemCreator(Material.EMERALD)
|
||||
.setName(Constants.PREFIX + "You can buy Tokens at")
|
||||
.addLore(Constants.SUBTEXT + "stratusnetwork.buycraft.net")
|
||||
, 4));
|
||||
|
||||
buttons.add(new Button(
|
||||
new ItemCreator(Material.WOOL)
|
||||
.setData(14)
|
||||
.setName( ChatColor.GREEN + "Go Back" ), 31){
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
player.openInventory(new MainTokenMenu(player).getInventory());
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(getMapPurchaseButton(1, 15000, 2));
|
||||
buttons.add(getMapPurchaseButton(3, 40000, 11));
|
||||
buttons.add(getMapPurchaseButton(5, 60000, 20));
|
||||
|
||||
buttons.add(getMutationPurchaseButton(1, 10000, 6));
|
||||
buttons.add(getMutationPurchaseButton(3, 25000, 15));
|
||||
buttons.add(getMutationPurchaseButton(5, 40000, 24));
|
||||
|
||||
setButtons(buttons);
|
||||
updateInventory();
|
||||
}
|
||||
|
||||
private Button getMutationPurchaseButton(int amount, int cost, int slot) {
|
||||
return new Button(
|
||||
new ItemCreator(Material.ELYTRA)
|
||||
.setName(Constants.PREFIX + "Buy " + amount + " Mutation Tokens")
|
||||
.addLore(Constants.SUBTEXT + "Cost: " + cost + " Droplets")
|
||||
.setSize(amount), slot){
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
if (TokenUtil.getUser(player).raindrops() >= cost) {
|
||||
RaindropUtil.giveRaindrops(TokenUtil.getUser(player), -cost, 100, null, null, true, true);
|
||||
TokenUtil.giveMutationTokens(TokenUtil.getUser(player), amount);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Button getMapPurchaseButton(int amount, int cost, int slot) {
|
||||
return new Button(
|
||||
new ItemCreator(Material.ELYTRA)
|
||||
.setName(Constants.PREFIX + "Buy " + amount + " SetNext Tokens")
|
||||
.addLore(Constants.SUBTEXT + "Cost: " + cost + " Droplets")
|
||||
.setSize(amount), slot){
|
||||
@Override
|
||||
public void function(Player player) {
|
||||
if (TokenUtil.getUser(player).raindrops() >= cost) {
|
||||
RaindropUtil.giveRaindrops(TokenUtil.getUser(player), -cost, 100, null, null, true, true);
|
||||
TokenUtil.giveMapTokens(TokenUtil.getUser(player), amount);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue