This commit is contained in:
Matheus 2024-06-14 12:31:36 -04:00
parent b0209dcd12
commit e64c943506
14 changed files with 131 additions and 45 deletions

View File

@ -42,6 +42,7 @@ import land.battle.practice.util.CC;
import land.battle.practice.util.timer.TimerManager;
import land.battle.practice.util.timer.impl.EnderpearlTimer;
import land.battle.practice.vote.VoteManager;
import land.battle.practice.vote.commands.RateCommand;
import lombok.Getter;
import lombok.Setter;
import me.lucko.helper.Commands;
@ -271,7 +272,8 @@ public class Practice extends ExtendedJavaPlugin {
new FollowCommand(),
new TournamentCommand(),
new ServerSettingsCommand(),
new SetSpawnCommand()
new SetSpawnCommand(),
new RateCommand()
).forEach(acfCommandProcessor::registerCommand);
}

View File

@ -119,7 +119,7 @@ public class PlayerListener implements Listener {
this.plugin.getPlayerManager().createPlayerData(event);
}
private final String centeredTitle = StringUtil.getCentered(CC.GOLD + CC.BOLD + "NA Practice");
private final String centeredTitle = StringUtil.getCentered(CC.GOLD + CC.BOLD + "Practice");
private final String centeredSubTitle = StringUtil.getCentered(CC.GRAY + "Click one of the swords to start fighting!");
@EventHandler

View File

@ -34,8 +34,8 @@ public class ItemManager {
public ItemManager() {
this.spawnItems =
new ItemStack[] {
ItemUtil.createItem(Material.IRON_SWORD, CC.GOLD + "Join Unranked Matchmaking" + CC.GRAY + " (Right Click)"),
ItemUtil.createItem(Material.DIAMOND_SWORD, CC.GOLD + "Join Ranked Matchmaking" + CC.GRAY + " (Right Click)"),
ItemUtil.createItem(Material.IRON_SWORD, CC.GOLD + "Play Unranked" + CC.GRAY + " (Right Click)"),
ItemUtil.createItem(Material.DIAMOND_SWORD, CC.GOLD + "Play Ranked" + CC.GRAY + " (Right Click)"),
ItemUtil.createItem(Material.NETHER_STAR, CC.GOLD + "Create a Party" + CC.GRAY + " (Right Click)"),
null,
ItemUtil.createItem(Material.GOLD_INGOT, CC.GOLD + "Shop" + CC.GRAY + " (Right Click)"),
@ -45,8 +45,8 @@ public class ItemManager {
ItemUtil.createItem(Material.REDSTONE_COMPARATOR, CC.GOLD + "Settings" + CC.GRAY + " (Right Click)")
};
this.holandaItems = new ItemStack[] {
ItemUtil.createItem(Material.IRON_SWORD, CC.GOLD + "Join Unranked Matchmaking" + CC.GRAY + " (Right Click)"),
ItemUtil.createItem(Material.DIAMOND_SWORD, CC.GOLD + "Join Ranked Matchmaking" + CC.GRAY + " (Right Click)"),
ItemUtil.createItem(Material.IRON_SWORD, CC.GOLD + "Play Unranked" + CC.GRAY + " (Right Click)"),
ItemUtil.createItem(Material.DIAMOND_SWORD, CC.GOLD + "Play Ranked" + CC.GRAY + " (Right Click)"),
null,
null,
ItemUtil.createItem(Material.NETHER_STAR, CC.GOLD + "Create a Party" + CC.GRAY + " (Right Click)"),

View File

@ -271,13 +271,10 @@ public class MatchManager {
playerData.setPlayerState(PlayerState.SPECTATING);
PlayerUtil.clearPlayer(player);
final CraftPlayer playerCp = (CraftPlayer) player;
final EntityPlayer playerEp = playerCp.getHandle();
playerEp.getDataWatcher().watch(6, 0.0F);
player.setFireTicks(0);
match.addRunnable(this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, () -> {
match.getTeams().forEach(team -> team.streamAlivePlayers().forEach(member -> Practice.getInstance().getEntityHider().hideEntity(member, player)));
@ -286,6 +283,7 @@ public class MatchManager {
player.getActivePotionEffects().stream().map(PotionEffect::getType).forEach(player::removePotionEffect);
player.setWalkSpeed(0.2F);
player.setAllowFlight(true);
for (int i = 0; i < 5; i++) PlayerUtil.clearPlayer(player);
}, 20L));
if (match.isRedRover()) {
@ -313,6 +311,7 @@ public class MatchManager {
public void addSpectator(Player player, PlayerData playerData, Player target, Match targetMatch) {
this.spectators.put(player.getUniqueId(), targetMatch.getMatchId());
for (int i = 0; i < 5; i++) PlayerUtil.clearPlayer(player);
if (targetMatch.getMatchState() != MatchState.ENDING) {
if (!targetMatch.haveSpectated(player.getUniqueId())) {

View File

@ -1,5 +1,6 @@
package land.battle.practice.match.snapshot;
import com.cryptomorin.xseries.XMaterial;
import com.solexgames.core.util.Color;
import com.solexgames.core.util.PlayerUtil;
import com.solexgames.core.util.builder.ItemBuilder;
@ -67,8 +68,9 @@ public class InventorySnapshot extends Menu {
this.food = player.getFoodLevel();
final List<String> potionEffectStrings = new ArrayList<>();
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
if (player.getActivePotionEffects().isEmpty()) {
potionEffectStrings.add(CC.translate("&cNone"));
} else for (PotionEffect potionEffect : player.getActivePotionEffects()) {
final String romanNumeral = MathUtil.convertToRomanNumeral(potionEffect.getAmplifier() + 1);
final String effectName = StringUtil.toNiceString(potionEffect.getType().getName().toLowerCase());
final String duration = MathUtil.convertTicksToMinutes(potionEffect.getDuration());
@ -104,7 +106,7 @@ public class InventorySnapshot extends Menu {
this.potCount = (int) Arrays.stream(contents).filter(Objects::nonNull).map(ItemStack::getDurability).filter(d -> d == 16421).count();
this.buttonMap.put(49, new ItemBuilder(Material.POTION)
.setDisplayName(CC.AQUA + "Potion Statistics")
.setDisplayName(CC.GOLD + "Potion Statistics")
.setDurability(16421)
.setAmount(this.potCount)
.addLore(
@ -126,7 +128,7 @@ public class InventorySnapshot extends Menu {
final double roundedHealth = Math.round(health / 2.0 * 2.0) / 2.0;
this.buttonMap.put(47, new ItemBuilder(Material.SPECKLED_MELON)
.setDisplayName(CC.GRAY + "Health: " + CC.AQUA + roundedHealth)
.setDisplayName(CC.GRAY + "Health: " + CC.GOLD + roundedHealth)
.setAmount((int) roundedHealth)
.toButton()
);
@ -134,7 +136,7 @@ public class InventorySnapshot extends Menu {
final double roundedFood = Math.round(health / 2.0 * 2.0) / 2.0;
this.buttonMap.put(48, new ItemBuilder(Material.COOKED_BEEF)
.setDisplayName(CC.GRAY + "Hunger: " + CC.AQUA + roundedFood)
.setDisplayName(CC.GRAY + "Hunger: " + CC.GOLD + roundedFood)
.setAmount((int) roundedFood)
.toButton()
);
@ -144,8 +146,14 @@ public class InventorySnapshot extends Menu {
final int ping = PlayerUtil.getPing(player);
this.buttonMap.put(50, new ItemBuilder(Material.PAPER)
.setDisplayName(CC.AQUA + "Match Statistics")
this.buttonMap.put(50, new ItemBuilder(Material.BREWING_STAND_ITEM)
.setDisplayName(CC.GOLD + "Potion Effects")
.addLore(potionEffectStrings)
.toButton()
);
this.buttonMap.put(51, new ItemBuilder(Material.PAPER)
.setDisplayName(CC.GOLD + "Match Statistics")
.addLore(
CC.GRAY + "Longest Combo: " + CC.WHITE + playerData.getLongestCombo() + " hit" + (playerData.getLongestCombo() > 1 ? "s" : ""),
CC.GRAY + "Total Hits: " + CC.WHITE + playerData.getHits() + " hit" + (playerData.getHits() > 1 ? "s" : ""),
@ -155,6 +163,8 @@ public class InventorySnapshot extends Menu {
)
.toButton()
);
buttonMap.put(52, (new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseMaterial())).setDurability(15).setDisplayName(" ").toButton());
buttonMap.put(46, (new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseMaterial())).setDurability(15).setDisplayName(" ").toButton());
if (!match.isParty()) {
for (int i = 0; i < 2; i++) {

View File

@ -91,8 +91,13 @@ public class JoinQueueMenu extends Menu {
lore.add("&7In Queue: &f" + getQueued(queue));
lore.add("&7In Fights: &f" + getFighting(queue));
lore.add(" ");
lore.add("&6&lDaily Winstreaks:");
lore.addAll(LeaderboardUpdateRunnable.KIT_SPECIFIC_WIN_STREAK_LORE_SHORT.getOrDefault(this.queue, Collections.emptyList()));
if (queueType == QueueType.UNRANKED) {
lore.add("&6&lDaily Winstreaks:");
lore.addAll(LeaderboardUpdateRunnable.KIT_SPECIFIC_WIN_STREAK_LORE_SHORT.getOrDefault(this.queue, Collections.emptyList()));
} else if (queueType == QueueType.RANKED) {
lore.add("&6&lTop ELO:");
lore.addAll(LeaderboardUpdateRunnable.KIT_SPECIFIC_LEADERBOARD_LORE_SHORT.getOrDefault(this.queue, Collections.emptyList()));
}
lore.add(" ");
lore.add(CC.YELLOW + "[Click to join queue]");

View File

@ -1,5 +1,6 @@
package land.battle.practice.message.impl;
import land.battle.practice.Practice;
import land.battle.practice.message.KillMessage;
import land.battle.practice.util.CC;
import org.bukkit.entity.Player;
@ -23,11 +24,19 @@ public class DefaultDeathMessage implements KillMessage {
@Override
public String getFormatted(Player player, Player other, boolean otherPlayerExists) {
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " foi morto.";
}
if (!Practice.getInstance().isHolanda()) {
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " foi morto.";
}
return CC.RED + player.getName() + CC.GRAY + " foi morto por " + CC.GREEN + other.getName() + CC.GRAY + ".";
return CC.RED + player.getName() + CC.GRAY + " foi morto por " + CC.GREEN + other.getName() + CC.GRAY + ".";
} else {
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " died.";
}
return CC.RED + player.getName() + CC.GRAY + " was killed by " + CC.GREEN + other.getName() + CC.GRAY + ".";
}
}
@Override

View File

@ -1,5 +1,6 @@
package land.battle.practice.message.impl;
import land.battle.practice.Practice;
import land.battle.practice.message.KillMessage;
import land.battle.practice.util.CC;
import org.bukkit.entity.Player;
@ -24,26 +25,40 @@ public class GamerKillMessages implements KillMessage {
public String getFormatted(Player player, Player other, boolean otherPlayerExists) {
final String randomMessage = CC.YELLOW + this.getMessages().get(ThreadLocalRandom.current().nextInt(this.getMessages().size())) + CC.GRAY;
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + ".";
}
if (!Practice.getInstance().isHolanda()) {
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + ".";
}
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + " por " + CC.GREEN + other.getName() + CC.GRAY + ".";
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + " por " + CC.GREEN + other.getName() + CC.GRAY + ".";
} else {
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " was " + randomMessage + ".";
}
return CC.RED + player.getName() + CC.GRAY + " was " + randomMessage + " by " + CC.GREEN + other.getName() + CC.GRAY + ".";
}
}
@Override
public List<String> getMessages() {
return Arrays.asList(
return !Practice.getInstance().isHolanda() ? Arrays.asList(
"destruido", "enrolado",
"enfiado em um armario", "espancado"
) : Arrays.asList(
"destroyed", "rolled",
"shoved into a locker", "clapped"
);
}
@Override
public List<String> getDescription() {
return Arrays.asList(
return !Practice.getInstance().isHolanda() ? Arrays.asList(
CC.GRAY + "Irrite seus oponentes",
CC.GRAY + "usando frases levemente toxicas."
) : Arrays.asList(
CC.GRAY + "Trigger your opponents",
CC.GRAY + "using slightly toxic phrases."
);
}
}

View File

@ -1,5 +1,6 @@
package land.battle.practice.message.impl;
import land.battle.practice.Practice;
import land.battle.practice.message.KillMessage;
import land.battle.practice.util.CC;
import org.bukkit.entity.Player;
@ -24,26 +25,40 @@ public class KitchenKillMessages implements KillMessage {
public String getFormatted(Player player, Player other, boolean otherPlayerExists) {
final String randomMessage = CC.YELLOW + this.getMessages().get(ThreadLocalRandom.current().nextInt(this.getMessages().size())) + CC.GRAY;
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + ".";
}
if (!Practice.getInstance().isHolanda()) {
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + ".";
}
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + " por " + CC.GREEN + other.getName() + CC.GRAY + ".";
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + " por " + CC.GREEN + other.getName() + CC.GRAY + ".";
} else {
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " was " + randomMessage + ".";
}
return CC.RED + player.getName() + CC.GRAY + " was " + randomMessage + " by " + CC.GREEN + other.getName() + CC.GRAY + ".";
}
}
@Override
public List<String> getMessages() {
return Arrays.asList(
return !Practice.getInstance().isHolanda() ? Arrays.asList(
"assado lentamente", "marinado",
"cozido no vapor", "frito"
) : Arrays.asList(
"slow roasted", "marinated",
"steamed", "deep fried"
);
}
@Override
public List<String> getDescription() {
return Arrays.asList(
return !Practice.getInstance().isHolanda() ? Arrays.asList(
CC.GRAY + "frases e termos comuns",
CC.GRAY + "usados na cozinha."
) : Arrays.asList(
CC.GRAY + "Common phrases and terms",
CC.GRAY + "used in the kitchen."
);
}
}

View File

@ -1,5 +1,6 @@
package land.battle.practice.message.impl;
import land.battle.practice.Practice;
import land.battle.practice.message.KillMessage;
import land.battle.practice.util.CC;
import org.bukkit.entity.Player;
@ -25,29 +26,47 @@ public class NerdyKillMessages implements KillMessage {
public String getFormatted(Player player, Player other, boolean otherPlayerExists) {
final String randomMessage = CC.YELLOW + this.getMessages().get(ThreadLocalRandom.current().nextInt(this.getMessages().size())) + CC.GRAY;
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + ".";
}
if (!Practice.getInstance().isHolanda()) {
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + ".";
}
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + " por " + CC.GREEN + other.getName() + CC.GRAY + ".";
return CC.RED + player.getName() + CC.GRAY + " foi " + randomMessage + " por " + CC.GREEN + other.getName() + CC.GRAY + ".";
} else {
if (!otherPlayerExists) {
return CC.RED + player.getName() + CC.GRAY + " was " + randomMessage + ".";
}
return CC.RED + player.getName() + CC.GRAY + " was " + randomMessage + " by " + CC.GREEN + other.getName() + CC.GRAY + ".";
}
}
@Override
public List<String> getMessages() {
return Arrays.asList(
return !Practice.getInstance().isHolanda() ? Arrays.asList(
"deletado",
"crashado",
"dedurado",
"hackeado",
"superaquecido"
) : Arrays.asList(
"ALT+F4'd",
"deleted",
"crashed",
"ratted",
"hacked",
"over-heated"
);
}
@Override
public List<String> getDescription() {
return Arrays.asList(
return !Practice.getInstance().isHolanda() ? Arrays.asList(
CC.GRAY + "termos nerds de informatica",
CC.GRAY + "para irritar seu oponente."
) : Arrays.asList(
CC.GRAY + "Nerdy computer terms",
CC.GRAY + "to trigger your opponents."
);
}
}

View File

@ -33,6 +33,7 @@ public class LeaderboardUpdateRunnable implements Runnable {
public static final List<String> GLOBAL_ELO_LEADERBOARD_LORE = new ArrayList<>();
public static final Map<Kit, List<String>> KIT_SPECIFIC_LEADERBOARD_LORE = new HashMap<>();
public static final Map<Kit, List<String>> KIT_SPECIFIC_LEADERBOARD_LORE_SHORT = new HashMap<>();
public static final Map<Kit, List<String>> KIT_SPECIFIC_WIN_STREAK_LORE = new HashMap<>();
public static final Map<Kit, List<String>> KIT_SPECIFIC_WIN_STREAK_LORE_SHORT = new HashMap<>();
@ -72,6 +73,8 @@ public class LeaderboardUpdateRunnable implements Runnable {
final AtomicInteger integer = new AtomicInteger();
final List<String> loreEloShort = new ArrayList<>();
sortedUuids.forEach(uuid -> {
if (integer.get() != 10) {
final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first();
@ -82,6 +85,12 @@ public class LeaderboardUpdateRunnable implements Runnable {
}
});
if (lore.size() >= 3) {
IntStream.range(0, 3).forEach(i -> loreEloShort.add(" " + lore.get(i)));
}
LeaderboardUpdateRunnable.KIT_SPECIFIC_LEADERBOARD_LORE_SHORT.put(kit, loreEloShort);
LeaderboardUpdateRunnable.KIT_SPECIFIC_LEADERBOARD_LORE.put(kit, lore);
final List<String> loreForKillStreaks = new ArrayList<>();

View File

@ -28,9 +28,9 @@ public class SpawnBoardAdapter implements PlayerStateAdapter {
final PotPlayer potPlayer = CorePlugin.getInstance().getPlayerManager().getPlayer(player);
final RankedDivision rankedDivision = RankedDivision.getByGlobalElo(playerData.getGlobalElo());
if (!Practice.getInstance().isHolanda()) {
stringList.add(CC.GRAY + "Online: " + CC.AQUA + Bukkit.getOnlinePlayers().size());
stringList.add(CC.GRAY + "In Fights: " + CC.AQUA + StatusCache.getInstance().getFighting());
stringList.add(CC.GRAY + "Division: " + CC.BLUE + rankedDivision.getFancyName());
stringList.add(CC.WHITE + "Online: " + CC.GOLD + Bukkit.getOnlinePlayers().size());
stringList.add(CC.WHITE + "In Fights: " + CC.GOLD + StatusCache.getInstance().getFighting());
stringList.add(CC.WHITE + "Division: " + CC.BLUE + rankedDivision.getFancyName());
} else {
stringList.add(CC.WHITE + "Online: " + CC.GOLD + Bukkit.getOnlinePlayers().size());
stringList.add(CC.WHITE + "In Fights: " + CC.GOLD + StatusCache.getInstance().getFighting());

View File

@ -114,7 +114,11 @@ public final class PlayerUtil {
}
public static void clearPlayer(Player player) {
respawnPlayer(player);
clearPlayer(player, false);
}
public static void clearPlayer(Player player, boolean respawn) {
if (respawn) respawnPlayer(player);
player.setHealth(20.0D);
player.setFoodLevel(20);
player.setSaturation(12.8F);

View File

@ -25,7 +25,6 @@ public class RateCommand extends BaseCommand {
@Default
@Syntax("<vote>")
@CommandCompletion("@unvanished")
public void onDefault(Player player, String v) {
final PlayerData playerData = Practice.getInstance().getPlayerManager()
.getPlayerData(player.getUniqueId());