Skip to content

Commit

Permalink
Added arena display name
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Apr 1, 2024
1 parent 337dbb8 commit db96eb1
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/main/java/me/lrxh/practice/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public enum Locale {
PING_YOUR("PING.YOUR"),
PING_OTHERS("PING.OTHERS"),
QUEUE_LEAVE_RANKED("QUEUE.LEAVE_RANKED"),
QUEUE_RANGE_INCREMENT("QUEUE.RANGE_INCREMENT"),
MATCH_GIVE_KIT("MATCH.GIVE_KIT"),
MATCH_ENDERPEARL_COOLDOWN("MATCH.ENDERPEARL_COOLDOWN"),
MATCH_ENDERPEARL_COOLDOWN_EXPIRED("MATCH.ENDERPEARL_COOLDOWN_EXPIRED"),
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/me/lrxh/practice/arena/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Arena extends Cuboid {
private static final List<Arena> arenas = new ArrayList<>();

protected String name;
protected String displayName;
protected Location spawnA;
protected Location spawnB;
protected boolean active;
Expand Down Expand Up @@ -77,6 +78,9 @@ public static void init() {
arena.setBedB(LocationUtil.deserialize(configuration.getString(path + ".bedB")));
}

String displayName = configuration.getString(path + ".displayName");
arena.setDisplayName(displayName);

if (configuration.contains(path + ".kits")) {
for (String kitName : configuration.getStringList(path + ".kits")) {
arena.getKits().add(kitName);
Expand Down
23 changes: 19 additions & 4 deletions src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void help3(Player player) {
player.sendMessage(CC.translate("&7* &c/arena list &7- &fList all arenas"));
player.sendMessage(CC.translate("&7* &c/arena setspawn &7<arena> &7<a/b> &7- &fSet arena spawns"));
player.sendMessage(CC.translate("&7* &c/arena tp &7<arena> &7- &fTeleport arena"));
player.sendMessage(CC.translate("&7* &c/arena setDisplayName &7<arena> &7<value> &7- &fSet arena display name"));
player.sendMessage(CC.translate("&7&m-----------------------------------------"));
}

Expand Down Expand Up @@ -111,7 +112,20 @@ public void create(Player player, String arenaName, ArenaType arenaType) {
}


@Subcommand("remove")
@Subcommand("setDisplayName")
@CommandCompletion("@arenas")
@Syntax("<arena> <value>")
public void setDisplayName(Player player, String arenaName, String value) {
if (checkArena(arenaName)) {
player.sendMessage(CC.translate("&4ERROR - &cArena doesn't exists!"));
return;
}
Arena arena = Arena.getByName(arenaName);
arena.setDisplayName(value);

player.sendMessage(CC.GREEN + "Successfully set " + arena.getDisplayName() + " display name!");
}

@CommandCompletion("@arenas")
@Syntax("<arena>")
public void remove(Player player, String arenaName) {
Expand All @@ -122,9 +136,10 @@ public void remove(Player player, String arenaName) {
Arena arena = Arena.getByName(arenaName);
arena.delete();

player.sendMessage(CC.GREEN + "Deleted arena " + arena.getName());
player.sendMessage(CC.GREEN + "Deleted arena " + arena.getDisplayName());
}


@Subcommand("wand")
public void wand(Player player) {
if (player.getInventory().first(Selection.SELECTION_WAND) != -1) {
Expand Down Expand Up @@ -259,7 +274,7 @@ public void tp(Player player, String arenaName) {
if (arena == null) return;

player.teleport(arena.getSpawnA());
player.sendMessage(CC.GREEN + "Teleported to arena " + arena.getName());
player.sendMessage(CC.GREEN + "Teleported to arena " + arena.getDisplayName());
}

@Subcommand("generate")
Expand Down Expand Up @@ -380,7 +395,7 @@ public void setBedSpawn(Player player, String arenaName, SpawnType pos) {
}

arena.save();
player.sendMessage(CC.GREEN + "Updated bed " + pos + " for arena " + arena.getName());
player.sendMessage(CC.GREEN + "Updated bed " + pos + " for arena " + arena.getDisplayName());
}

private boolean checkArena(String arena) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/me/lrxh/practice/arena/impl/SharedArena.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void save() {
FileConfiguration configuration = Practice.getInstance().getArenasConfig().getConfiguration();
configuration.set(path, null);
configuration.set(path + ".type", getType().name());
configuration.set(path + ".displayName", displayName);
configuration.set(path + ".spawnA", LocationUtil.serialize(spawnA));
configuration.set(path + ".spawnB", LocationUtil.serialize(spawnB));
configuration.set(path + ".cuboid.location1", LocationUtil.serialize(getLowerCorner()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void save() {
configuration.set(path, null);
configuration.set(path + ".type", getType().name());
configuration.set(path + ".spawnA", LocationUtil.serialize(spawnA));
configuration.set(path + ".displayName", displayName);
configuration.set(path + ".spawnB", LocationUtil.serialize(spawnB));
configuration.set(path + ".bedA", LocationUtil.serialize(bedA));
configuration.set(path + ".bedB", LocationUtil.serialize(bedB));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public void execute(Player sender, String targetName) {
return;
}

if (sender.getUniqueId().equals(target.getUniqueId())) {
sender.sendMessage(CC.RED + "You cannot duel yourself.");
return;
}
// if (sender.getUniqueId().equals(target.getUniqueId())) {
// sender.sendMessage(CC.RED + "You cannot duel yourself.");
// return;
// }

Profile senderProfile = Profile.getByUuid(sender.getUniqueId());
Profile targetProfile = Profile.getByUuid(target.getUniqueId());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/lrxh/practice/duel/DuelProcedure.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public void send() {

if (party) {
sender.sendMessage(Locale.DUEL_SENT_PARTY.format(target, kit.getName(), target.getName(),
targetProfile.getParty().getPlayers().size(), arena.getName()));
targetProfile.getParty().getPlayers().size(), arena.getDisplayName()));

for (String msg : Locale.DUEL_RECEIVED_PARTY.formatLines(sender, kit.getName(), sender.getName(),
senderProfile.getParty().getPlayers().size(), arena.getName())) {
senderProfile.getParty().getPlayers().size(), arena.getDisplayName())) {
if (msg.contains("%CLICKABLE%")) {
ChatComponentBuilder builder = new ChatComponentBuilder(Locale.DUEL_RECEIVED_CLICKABLE.format(target,
sender.getName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private static class SelectArenaButton extends Button {
@Override
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.PAPER)
.name(Practice.getInstance().getMenusConfig().getString("DUEL.ARENA-SELECTOR.ARENA-NAME").replace("<arena>", arena.getName()))
.name(Practice.getInstance().getMenusConfig().getString("DUEL.ARENA-SELECTOR.ARENA-NAME").replace("<arena>", arena.getDisplayName()))
.clearFlags()
.build();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/lrxh/practice/match/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void start() {
arena.setActive(true);

// Send arena message
sendMessage(Locale.MATCH_PLAYING_ARENA.format(arena.getName()));
sendMessage(Locale.MATCH_PLAYING_ARENA.format(arena.getDisplayName()));

// Setup players
for (GameParticipant<MatchGamePlayer> gameParticipant : getParticipants()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/lrxh/practice/profile/hotbar/Hotbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void init() {
HotbarItem hotbarItem = HotbarItem.KIT_SELECTION;
ItemBuilder builder = new ItemBuilder(Material.ENCHANTED_BOOK);
builder.durability(0);
builder.name("&7» &a&l%KIT% &7«");
builder.name("&e%KIT%");
builder.lore("");
builder.clearFlags();
items.put(hotbarItem, builder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public void request() {
return;
}

for (String line : Locale.REMATCH_SENT_REQUEST.formatLines(sender, target.getName(), arena.getName())) {
for (String line : Locale.REMATCH_SENT_REQUEST.formatLines(sender, target.getName(), arena.getDisplayName())) {
sender.sendMessage(line);
}

List<BaseComponent[]> components = new ArrayList<>();

for (String line : Locale.REMATCH_RECEIVED_REQUEST.formatLines(sender, sender.getName(), arena.getName())) {
for (String line : Locale.REMATCH_RECEIVED_REQUEST.formatLines(sender, sender.getName(), arena.getDisplayName())) {
BaseComponent[] lineComponents = new ChatComponentBuilder("")
.parse(line)
.attachToEachPart(ChatHelper.hover(Locale.REMATCH_RECEIVED_REQUEST_HOVER.format(target)))
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/me/lrxh/practice/queue/QueueProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ public void tickRange() {

if (ticked >= 50) {
ticked = 0;

if (queue.isRanked()) {
Player player = Bukkit.getPlayer(playerUuid);

if (player != null) {
player.sendMessage(Locale.QUEUE_RANGE_INCREMENT.format(player, queue.getQueueName(), getMinRange(),
getMaxRange()));
}
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/me/lrxh/practice/util/CC.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public class CC {
public static char CIRCLE = '●';
public static char DOUBLE_ARROW_RIGHT = '»';
public static char DOUBLE_ARROW_LEFT = '«';
public static String STAR = StringEscapeUtils.unescapeJava("\u2606");
public static String CHECKMARK = StringEscapeUtils.unescapeJava("\u2713");
public static String X = StringEscapeUtils.unescapeJava("\u2717");
public static String LUNAR = StringEscapeUtils.unescapeJava("\u272A");
public static String LINE = StringEscapeUtils.unescapeJava("\u2503");
public static String STAR = StringEscapeUtils.unescapeJava("");
public static String CHECKMARK = StringEscapeUtils.unescapeJava("");
public static String X = StringEscapeUtils.unescapeJava("");
public static String LUNAR = StringEscapeUtils.unescapeJava("");
public static String LINE = StringEscapeUtils.unescapeJava("");

public static String translate(String in) {
return ChatColor.translateAlternateColorCodes('&', in);
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ QUEUE:
LEAVE_UNRANKED: '&cYou have been removed from queue.'
JOIN_RANKED: '&aYou are now queued for &aRanked {0}. &7[{1} ELO]'
LEAVE_RANKED: '&cYou have been removed from queue.'
RANGE_INCREMENT: '&eSearching in ELO range &7[{1} -> {2}]&e...'
RANKED-ERROR-MESSAGE: '&cYou cannot join ranked queues with less than 10 unranked 1v1 wins. You need {0} more wins!'
MATCH:
START:
Expand Down

0 comments on commit db96eb1

Please sign in to comment.