Tracks in chests!
This commit is contained in:
parent
d1993465a6
commit
035f4637ba
@ -135,12 +135,12 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
|
||||
return matches;
|
||||
}
|
||||
|
||||
protected List<String> tabCompletePlayerNames(CommandSender sender, String commandLabel, String[] args)
|
||||
protected List<String> tabCompletePlayerNames(CommandSender sender, String[] args)
|
||||
{
|
||||
return tabCompletePlayerNames(sender, commandLabel, args, t -> true);
|
||||
return tabCompletePlayerNames(sender, args, t -> true);
|
||||
}
|
||||
|
||||
protected List<String> tabCompletePlayerNames(CommandSender sender, String commandLabel, String[] args, Predicate<Player> filter)
|
||||
protected List<String> tabCompletePlayerNames(CommandSender sender, String[] args, Predicate<Player> filter)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
|
@ -47,6 +47,6 @@ public class AddFriend extends CommandBase<FriendManager>
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
return tabCompletePlayerNames(sender, commandLabel, args);
|
||||
return tabCompletePlayerNames(sender, args);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ public class MessageAdminCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
return tabCompletePlayerNames(sender, commandLabel, args);
|
||||
return tabCompletePlayerNames(sender, args);
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,6 @@ public class MessageCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
return tabCompletePlayerNames(sender, commandLabel, args);
|
||||
return tabCompletePlayerNames(sender, args);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineplex.core.party.command.cli;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -39,7 +38,7 @@ public class PartyInviteCommand extends CommandBase<PartyManager>
|
||||
Player player = (Player) sender;
|
||||
Party party = Plugin.getPartyByPlayer(player);
|
||||
|
||||
return tabCompletePlayerNames(sender, commandLabel, args, other -> party == null || !party.isMember(other));
|
||||
return tabCompletePlayerNames(sender, args, other -> party == null || !party.isMember(other));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -50,7 +50,7 @@ public class PartyKickCommand extends CommandBase<PartyManager>
|
||||
|
||||
if (party != null && party.isOwner(player))
|
||||
{
|
||||
return tabCompletePlayerNames(sender, commandLabel, args, other -> other != player && party.isMember(other));
|
||||
return tabCompletePlayerNames(sender, args, other -> other != player && party.isMember(other));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class PartyTransferOwnerCommand extends CommandBase<PartyManager>
|
||||
|
||||
if (party != null && party.isOwner(player))
|
||||
{
|
||||
return tabCompletePlayerNames(sender, commandLabel, args, other -> other != player && party.isMember(other));
|
||||
return tabCompletePlayerNames(sender, args, other -> other != player && party.isMember(other));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class PartyGUIInviteCommand extends CommandBase<PartyManager>
|
||||
Player player = (Player) sender;
|
||||
Party party = Plugin.getPartyByPlayer(player);
|
||||
|
||||
return tabCompletePlayerNames(sender, commandLabel, args, other -> party == null || !party.isMember(other));
|
||||
return tabCompletePlayerNames(sender, args, other -> party == null || !party.isMember(other));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -143,6 +143,6 @@ public class PunishCommand extends CommandBase<Punish>
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
return tabCompletePlayerNames(sender, commandLabel, args);
|
||||
return tabCompletePlayerNames(sender, args);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package mineplex.core.titles.commands;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
@ -14,7 +18,7 @@ public class GiveTrackCommand extends CommandBase<TrackManager>
|
||||
{
|
||||
public GiveTrackCommand(TrackManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "givetrack");
|
||||
super(plugin, Rank.ADMIN, "givetrack" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,16 +37,43 @@ public class GiveTrackCommand extends CommandBase<TrackManager>
|
||||
|
||||
if (trackObj == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That is not a track"));
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That is not a track" ));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(trackObj instanceof ItemizedTrack))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That is not an unlockable track"));
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That is not an unlockable track" ));
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.unlockTrack(caller, player, track);
|
||||
Plugin.unlockTrack(player, track, result -> {
|
||||
switch (result)
|
||||
{
|
||||
case PLAYER_NOT_FOUND:
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That player has never joined Mineplex!"));
|
||||
break;
|
||||
case UNKNOWN_ERROR:
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Oops. Something has gone wrong while giving " + F.elem(player) + " the track " + F.elem(track) + "!"));
|
||||
break;
|
||||
case SUCCESS:
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Successfully gave " + F.elem(player) + " the track " + F.elem(track) + "!"));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return tabCompletePlayerNames(sender, args);
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
return getMatches(args[1], Plugin.getAllTracks().stream().filter(track -> track instanceof ItemizedTrack).map(Track::getId).collect(Collectors.toList()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package mineplex.core.titles.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
@ -10,6 +13,7 @@ import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.titles.Titles;
|
||||
import mineplex.core.titles.tracks.ItemizedTrack;
|
||||
import mineplex.core.titles.tracks.Track;
|
||||
import mineplex.core.titles.tracks.TrackManager;
|
||||
|
||||
@ -52,4 +56,17 @@ public class TrackCommand extends CommandBase<Titles>
|
||||
}
|
||||
Plugin.setOrToggleTrackForPlayer(caller, track, args.length > 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
return getMatches(args[0], _trackManager.getAllTracks().stream().filter(track -> track.getRequirements().getTier((Player) sender) != null).map(Track::getId));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -14,16 +14,19 @@ public class ItemizedTrack extends Track
|
||||
public ItemizedTrack(String trackId, String shortName, String description, boolean hideIfUnowned)
|
||||
{
|
||||
super(trackId, shortName, description, hideIfUnowned);
|
||||
special();
|
||||
}
|
||||
|
||||
public ItemizedTrack(String trackId, ChatColor color, String shortName, String longName, String description)
|
||||
{
|
||||
super(trackId, color, shortName, longName, description);
|
||||
special();
|
||||
}
|
||||
|
||||
public ItemizedTrack(String trackId, ChatColor color, String shortName, String longName, String description, boolean hideIfUnowned)
|
||||
{
|
||||
super(trackId, color, shortName, longName, description, hideIfUnowned);
|
||||
special();
|
||||
}
|
||||
|
||||
public boolean owns(Player player) {
|
||||
|
@ -50,7 +50,7 @@ public class Track implements Listener
|
||||
{
|
||||
// Book limits
|
||||
Validate.isTrue(shortName.length() <= 16, "Short name cannot be longer than 16 characters");
|
||||
Validate.isTrue(trackId.length() <= 16, "ID cannot be longer than 16 characters");
|
||||
Validate.isTrue(trackId.length() <= 32, "ID cannot be longer than 32 characters");
|
||||
|
||||
this._id = trackId;
|
||||
this._shortName = shortName;
|
||||
|
@ -5,20 +5,17 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.ClientItem;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.titles.commands.GiveTrackCommand;
|
||||
import mineplex.core.titles.tracks.award.Bridges2017Track;
|
||||
@ -28,6 +25,7 @@ import mineplex.core.titles.tracks.custom.HappyGaryTrack;
|
||||
import mineplex.core.titles.tracks.custom.LeaderTrack;
|
||||
import mineplex.core.titles.tracks.custom.SnekTrack;
|
||||
import mineplex.core.titles.tracks.custom.TableFlipTrack;
|
||||
import mineplex.core.titles.tracks.custom.TrackBuilder;
|
||||
import mineplex.core.titles.tracks.custom.WizardTrack;
|
||||
import mineplex.core.titles.tracks.standard.GemCollectorTrack;
|
||||
import mineplex.core.titles.tracks.standard.HolidayCheerTrack;
|
||||
@ -82,6 +80,57 @@ public class TrackManager extends MiniPlugin
|
||||
|
||||
// Awarded tracks
|
||||
registerTrack(new Bridges2017Track());
|
||||
|
||||
// Custom tracks
|
||||
registerTrack(track("lenny", "Lenny", "( ͡° ͜ʖ ͡°)"));
|
||||
registerTrack(track("lenny-disgusted", "Disgusted Lenny", "( ͡ಠ ʖ̯ ͡ಠ)"));
|
||||
registerTrack(track("lenny-winking", "Winking Lenny", "( ͡~ ͜ʖ ͡°)"));
|
||||
registerTrack(track("ayyye", "Ayyye", "(づ ̄ ³ ̄)づ"));
|
||||
registerTrack(track("ameno", "Ameno", "༼ つ ◕_◕ ༽つ Gib me gems"));
|
||||
// registerTrack(track("unknown", "Unknown", "(☞゚ヮ゚)☞"));
|
||||
registerTrack(track("shrug", "Shrug", "¯\\_(ツ)_/¯"));
|
||||
registerTrack(track("tableflip", "Tableflip", "(╯°□°)╯︵ ┻━┻"));
|
||||
registerTrack(track("tablerespecter", "Table Respecter", "┬─┬ノ(ಠ_ಠノ)\n"));
|
||||
registerTrack(track("tableflip-disgusted", "Disgusted Flip", "Disgusted Tableflip", "(╯ಠ_ಠ)╯︵ ┳━┳"));
|
||||
registerTrack(track("tableflip-donger", "Donger Flip", "ヽ༼ຈل͜ຈ༽ノ︵┻━┻"));
|
||||
registerTrack(track("tableflip-enraged", "Enraged Flip", "(ノಠдಠ)ノ︵┻━┻"));
|
||||
registerTrack(track("tableflip-riot", "Rioting Flip", "(┛◉Д◉)┛彡┻━┻"));
|
||||
registerTrack(track("magician", "Magician", "(ノ◕ヮ◕)ノ*:・゚✧"));
|
||||
registerTrack(track("teddy-bear", "Teddy Bear", "ʕ•ᴥ•ʔ"));
|
||||
registerTrack(track("disgust", "Disgust", "ಠ_ಠ"));
|
||||
registerTrack(track("old-man", "Old Man", "໒( •̀ ╭ ͟ʖ╮ •́ )७"));
|
||||
registerTrack(track("jake", "Jake", "(❍ᴥ❍ʋ)"));
|
||||
registerTrack(track("finn", "Finn", "| (• ◡•)|"));
|
||||
registerTrack(track("finn-and-jake", "Finn 'n Jake", "| (• ◡•)| (❍ᴥ❍ʋ)"));
|
||||
registerTrack(track("boxer", "Boxer", "(ง'̀-'́)ง"));
|
||||
registerTrack(track0("zoidberg", "Zoidberg", "Why not?", "(\\/) (°,,°) (\\/)"));
|
||||
registerTrack(track("crying", "Crying", "(ಥ﹏ಥ)"));
|
||||
// registerTrack(track("unknown", "Unknown", "(◕‿◕✿)"));
|
||||
registerTrack(track("fireball", "Fireball", "༼つಠ益ಠ༽つ ─=≡ΣO))"));
|
||||
registerTrack(track("stardust", "Stardust", "(つ◕౪◕)つ━☆゚.*・。゚"));
|
||||
registerTrack(track("magic-whistle", "Magic Whistle", "( °-°)シ ミ★ ミ☆\n"));
|
||||
registerTrack(track("blow-a-kiss", "Blowing a Kiss", "♡(´ε` )"));
|
||||
registerTrack(track("pewpewpew", "PEWPEWPEW", "(☞^o^)☞"));
|
||||
registerTrack(track("pewpew", "pew pew", "(☞゚ヮ゚)☞"));
|
||||
registerTrack(track("cool-guy", "Cool Guy", "(⌐■_■)"));
|
||||
// registerTrack(track("unknown", "Unknown", "(ง •̀ω•́)ง✧"));
|
||||
// registerTrack(track("unknown", "Unknown", "(╯⊙ ⊱ ⊙╰ )"));
|
||||
registerTrack(track("party-time", "Party Time", "♪~ ᕕ(ᐛ)ᕗ"));
|
||||
registerTrack(track1("whats-a-liter", "What's a Liter?", "also wats a leader"));
|
||||
|
||||
registerTrack(animatedTrack("deal-with-it", "Deal With It", "(⌐■_■)", "( •_•);( •_•)>⌐■-■;(⌐■_■);( •_•)>⌐■-■", 5));
|
||||
registerTrack(animatedTrack("this-guy", "This Guy", "(☞゚ヮ゚)☞", "(☞゚ヮ゚)☞;☜(゚ヮ゚☜)", 5));
|
||||
registerTrack(animatedTrack("lalala", "La La La", "♪┏(・o・) ┛", "♪┏(・o・) ┛;♪┗ ( ・o・) ┓♪;┏ ( ・o・) ┛♪;┗ (・o・ ) ┓♪;┏(・o・)┛♪", 1));
|
||||
registerTrack(animatedTrack("gotta-go", "Gotta Go", "┬┴┬┴┤(・_├┬┴┬┴", "┬┴┬┴┤(・_├┬┴┬┴;┬┴┬┴┤ (・├┬┴┬┴;┬┴┬┴┤ (├┬┴┬┴;┬┴┬┴┤ (・├┬┴┬┴", 5));
|
||||
// registerTrack(animatedTrack("unknown", "Unknown", "(o°▽°)o", "(o°▽°)o;(o_△_)o;(o°▽°)o", 5));
|
||||
registerTrack(animatedTrack("rolling-around", "Rolling Around", "(゚‐゚)", "(.-.);(:I );(゚‐゚);( I:)", 1));
|
||||
// registerTrack(animatedTrack("unknown", "Unknown", "('ω')", "('ω');( ε: );(.ω.);( :3 );('ω');( ε: );(.ω.);( :3 )", 5));
|
||||
registerTrack(animatedTrack("whee", "Whee", "(゚ー゚)", "(゚ー゚);( ゚ー);( ゚);( );(゚ );(ー゚ );(゚ー゚)", 1));
|
||||
registerTrack(animatedTrack("lets-spin", "Let's Spin", "I Say, Let's Spin", "(・ω・)", "( ・ω);( ・);( );(・ );(ω・ );(・ω・)", 1));
|
||||
// registerTrack(animatedTrack("unknown", "Unknown", "(^∀^)", "(^∀^);( ^∀);( ^);( );(^ );(∀^ );(^∀^)", 5));
|
||||
registerTrack(animatedTrack("whaaat", "Whaaaaaat?", "(°o°)", "(°o°);(°o。);(。o。);(。o°);(°o°);(°o。);(。o。);(。o°)", 5));
|
||||
registerTrack(animatedTrack("spinning", "Spinning", "(゚◇゚)", "(゚◇゚);( ゚◇);( ゚);( );(゚ );(◇゚ );(゚◇", 5));
|
||||
// registerTrack(animatedTrack("unknown", "Unknown", "(・∇・)", "(・∇・);( ・∇);( ・);( );(・ );(∇・ );(・∇・)", 5));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,9 +139,10 @@ public class TrackManager extends MiniPlugin
|
||||
addCommand(new GiveTrackCommand(this));
|
||||
}
|
||||
|
||||
|
||||
private void registerTrack(Track track)
|
||||
{
|
||||
if (_trackById.containsKey(track.getId()))
|
||||
throw new IllegalArgumentException("Duplicate id: " + track.getId());
|
||||
_registeredTracks.put(track.getClass(), track);
|
||||
_trackById.put(track.getId(), track);
|
||||
}
|
||||
@ -109,16 +159,22 @@ public class TrackManager extends MiniPlugin
|
||||
|
||||
public final List<Track> getAllTracks()
|
||||
{
|
||||
return new ArrayList<>(_registeredTracks.values());
|
||||
return new ArrayList<>(_trackById.values());
|
||||
}
|
||||
|
||||
public void unlockTrack(Player caller, String player, String track)
|
||||
public void unlockTrack(String player, String track)
|
||||
{
|
||||
unlockTrack(player, track, null);
|
||||
}
|
||||
|
||||
public void unlockTrack(String player, String track, Consumer<TrackGiveResult> consumer)
|
||||
{
|
||||
_coreClientManager.getOrLoadClient(player, client ->
|
||||
{
|
||||
if (client == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(getName(), "That player has never joined Mineplex!"));
|
||||
if (consumer != null)
|
||||
consumer.accept(TrackGiveResult.PLAYER_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -128,11 +184,13 @@ public class TrackManager extends MiniPlugin
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(getName(), "Successfully gave " + F.elem(player) + " the track " + F.elem(track) + "!"));
|
||||
if (consumer != null)
|
||||
consumer.accept(TrackGiveResult.SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(getName(), "Oops. Something has gone wrong while giving " + F.elem(player) + " the track " + F.elem(track) + "!"));
|
||||
if (consumer != null)
|
||||
consumer.accept(TrackGiveResult.UNKNOWN_ERROR);
|
||||
}
|
||||
};
|
||||
|
||||
@ -149,4 +207,86 @@ public class TrackManager extends MiniPlugin
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public enum TrackGiveResult
|
||||
{
|
||||
PLAYER_NOT_FOUND,
|
||||
UNKNOWN_ERROR,
|
||||
SUCCESS
|
||||
}
|
||||
|
||||
// Begin helper methods
|
||||
private ItemizedTrack animatedTrack(String id, String name, String desc, String frames, int ticks)
|
||||
{
|
||||
return TrackBuilder.builder(id)
|
||||
.withShortName(name)
|
||||
.withDescription(desc)
|
||||
.setFrames(frames.split(";"))
|
||||
.setTicks(ticks)
|
||||
.withColor(ChatColor.GOLD)
|
||||
.setHideIfUnowned(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
private ItemizedTrack animatedTrack(String id, String name, String longName, String desc, String frames, int ticks)
|
||||
{
|
||||
return TrackBuilder.builder(id)
|
||||
.withShortName(name)
|
||||
.withLongName(longName)
|
||||
.withDescription(desc)
|
||||
.setFrames(frames.split(";"))
|
||||
.setTicks(ticks)
|
||||
.withColor(ChatColor.GOLD)
|
||||
.setHideIfUnowned(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
private ItemizedTrack track(String id, String name, String tierName)
|
||||
{
|
||||
return TrackBuilder.builder(id)
|
||||
.withShortName(name)
|
||||
.withDescription(tierName)
|
||||
.setTierName(tierName)
|
||||
.withColor(ChatColor.GOLD)
|
||||
.setTierColor(ChatColor.GOLD)
|
||||
.setHideIfUnowned(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
private ItemizedTrack track0(String id, String shortName, String desc, String tierName)
|
||||
{
|
||||
return TrackBuilder.builder(id)
|
||||
.withShortName(shortName)
|
||||
.withDescription(desc)
|
||||
.setTierName(tierName)
|
||||
.withColor(ChatColor.GOLD)
|
||||
.setTierColor(ChatColor.GOLD)
|
||||
.setHideIfUnowned(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
private ItemizedTrack track1(String id, String name, String desc)
|
||||
{
|
||||
return TrackBuilder.builder(id)
|
||||
.withShortName(name)
|
||||
.withDescription(desc)
|
||||
.setTierName(name)
|
||||
.withColor(ChatColor.GOLD)
|
||||
.setTierColor(ChatColor.GOLD)
|
||||
.setHideIfUnowned(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
private ItemizedTrack track(String id, String shortName, String longName, String tierName)
|
||||
{
|
||||
return TrackBuilder.builder(id)
|
||||
.withShortName(shortName)
|
||||
.withLongName(longName)
|
||||
.withDescription(tierName)
|
||||
.setTierName(tierName)
|
||||
.withColor(ChatColor.GOLD)
|
||||
.setTierColor(ChatColor.GOLD)
|
||||
.setHideIfUnowned(true)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class Bridges2017Track extends ItemizedTrack
|
||||
public Bridges2017Track()
|
||||
{
|
||||
super(
|
||||
"botb2017",
|
||||
"tournament-br-2017",
|
||||
ChatColor.GOLD,
|
||||
"BotB 2017",
|
||||
"2017 Bridges Champion",
|
||||
|
@ -15,7 +15,7 @@ public class TableFlipTrack extends Track
|
||||
|
||||
public TableFlipTrack()
|
||||
{
|
||||
super("tableflip", ChatColor.AQUA, "Tableflip", "Tableflip", "(╯°□°)╯ ︵ ┻━┻", true);
|
||||
super("tableflipanim", ChatColor.AQUA, "Tableflip", "Tableflip", "(╯°□°)╯ ︵ ┻━┻", true);
|
||||
special();
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
|
@ -0,0 +1,173 @@
|
||||
package mineplex.core.titles.tracks.custom;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import mineplex.core.titles.tracks.ItemizedTrack;
|
||||
import mineplex.core.titles.tracks.Track;
|
||||
import mineplex.core.titles.tracks.TrackFormat;
|
||||
import mineplex.core.titles.tracks.TrackTier;
|
||||
|
||||
public class TrackBuilder
|
||||
{
|
||||
private String _id;
|
||||
private String _shortName;
|
||||
private String _longName;
|
||||
private ChatColor _color;
|
||||
private String _desc;
|
||||
private boolean _hideIfUnowned;
|
||||
|
||||
private String _tierName;
|
||||
private String _tierDesc;
|
||||
private ChatColor _tierColor;
|
||||
private ChatColor _magicColor;
|
||||
|
||||
private int _ticks;
|
||||
private String[] _frames;
|
||||
|
||||
private TrackBuilder(String id)
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public TrackBuilder withShortName(String shortName)
|
||||
{
|
||||
Validate.notNull(shortName, "Short name cannot be null");
|
||||
this._shortName = shortName.length() > 16 ? shortName.substring(0, 16) : shortName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder withLongName(String longName)
|
||||
{
|
||||
Validate.notNull(longName, "Long name cannot be null");
|
||||
this._longName = longName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder withColor(ChatColor color)
|
||||
{
|
||||
Validate.notNull(color, "Color cannot be null");
|
||||
this._color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder withDescription(String desc)
|
||||
{
|
||||
Validate.notNull(desc, "Description cannot be null");
|
||||
this._desc = desc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder setHideIfUnowned(boolean hide)
|
||||
{
|
||||
this._hideIfUnowned = hide;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder setTierName(String tierName)
|
||||
{
|
||||
Validate.notNull(tierName, "Tier name cannot be null");
|
||||
this._tierName = tierName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder setTierDesc(String tierDesc)
|
||||
{
|
||||
Validate.notNull(tierDesc, "Tier desc cannot be null");
|
||||
this._tierDesc = tierDesc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder setTierColor(ChatColor tierColor)
|
||||
{
|
||||
Validate.notNull(tierColor, "Tier color cannot be null");
|
||||
this._tierColor = tierColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder setTierMagicColor(ChatColor magicColor)
|
||||
{
|
||||
Validate.notNull(magicColor, "Magic color cannot be null");
|
||||
this._magicColor = magicColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder setFrames(String... frames)
|
||||
{
|
||||
Validate.notNull(frames, "Frames cannot be null");
|
||||
if (frames.length == 0)
|
||||
return this;
|
||||
this._frames = frames;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackBuilder setTicks(int ticks)
|
||||
{
|
||||
this._ticks = ticks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T extends Track> T build()
|
||||
{
|
||||
Validate.notNull(_id, "ID cannot be null");
|
||||
Validate.notNull(_color, "Color cannot be null");
|
||||
Validate.notNull(_shortName, "Short name cannot be null");
|
||||
|
||||
if (_desc == null)
|
||||
_desc = _shortName;
|
||||
if (_longName == null)
|
||||
_longName = _shortName;
|
||||
if (_tierColor == null)
|
||||
_tierColor = _color;
|
||||
if (_tierName == null)
|
||||
_tierName = _shortName;
|
||||
if (_tierDesc == null)
|
||||
_tierDesc = _desc;
|
||||
|
||||
if (_frames == null)
|
||||
{
|
||||
return (T) new ItemizedTrack(_id, _color, _shortName, _longName, _desc, _hideIfUnowned)
|
||||
{
|
||||
ItemizedTrack init()
|
||||
{
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
_tierName,
|
||||
_tierDesc,
|
||||
this::owns,
|
||||
new TrackFormat(_tierColor, _magicColor)
|
||||
));
|
||||
return this;
|
||||
}
|
||||
}.init();
|
||||
}
|
||||
else
|
||||
{
|
||||
Validate.isTrue(_ticks >= 1, "Ticks must be >= 1");
|
||||
|
||||
return (T) new ItemizedTrack(_id, _color, _shortName, _longName, _desc, _hideIfUnowned)
|
||||
{
|
||||
ItemizedTrack init()
|
||||
{
|
||||
getRequirements()
|
||||
.addTier(new TrackTier(
|
||||
_tierName,
|
||||
_tierDesc,
|
||||
this::owns,
|
||||
new TrackFormat(_tierColor, _magicColor)
|
||||
.animated(_ticks, _frames)
|
||||
));
|
||||
return this;
|
||||
}
|
||||
}.init();
|
||||
}
|
||||
}
|
||||
|
||||
public static TrackBuilder builder(String id)
|
||||
{
|
||||
Validate.notNull(id, "ID cannot be null");
|
||||
Validate.isTrue(id.length() <= 32, "ID must not be longer than 32 characters");
|
||||
return new TrackBuilder(id);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user