Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
Changes and Fixes
Browse files Browse the repository at this point in the history
- Fixed 'null' message still being sent (#382)
- 'null' title will now not going to be sent (#384)
- Added lobby teleportation when player is in lobby and player y coordinate is under 0 (#364)
- Fixed hunger never change because of the saturation level (#389)
- Removed `removeSnowBlockWhenSnowballHit` from kit gamerules. Use `spleef` instead (#338)
- Try to fix spectator cannot fly when lobby and arena world are separated. (Untested)
- Added option to set required wins to queue ranked (#312)
  • Loading branch information
GoodestEnglish committed Jun 28, 2023
1 parent 8595586 commit 1b8a69d
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'rip.diamond'
version = "1.1.19-BETA-" + getGitHash()
version = "1.1.20-BETA-" + getGitHash()

processResources {
def props = [version: version]
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/rip/diamond/practice/Eden.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
import rip.diamond.practice.leaderboard.LeaderboardManager;
import rip.diamond.practice.leaderboard.command.ReloadLeaderboardCommand;
import rip.diamond.practice.lobby.LobbyManager;
import rip.diamond.practice.lobby.LobbyMovementHandler;
import rip.diamond.practice.match.Match;
import rip.diamond.practice.match.MatchMovementHandler;
import rip.diamond.practice.match.command.*;
import rip.diamond.practice.match.listener.MatchListener;
import rip.diamond.practice.match.listener.SpectateListener;
Expand Down Expand Up @@ -228,6 +230,9 @@ private void loadGeneral() {
DuelRequest.init();
leaderboardManager.init();

new LobbyMovementHandler(this);
new MatchMovementHandler();

this.entityHider = new EntityHider(this, EntityHider.Policy.BLACKLIST).init();
this.scoreboardHandler = new SconeyHandler(this, new ScoreboardAdapter());
this.cache = new EdenCache();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/rip/diamond/practice/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public enum Config {
PARTY_DEFAULT_MAX_SIZE("party.default-max-size", 30),
//Lobby
LOBBY_DISPLAY_PLAYERS("lobby.display-players", true),
//Queue
QUEUE_RANKED_REQUIRED_WINS("queue.ranked-required-wins", 10),
//Match
MATCH_ALLOW_REQUEUE("match.allow-requeue", true),
MATCH_INSTANT_GAPPLE_EFFECTS("match.instant-gapple-effects", false),
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/rip/diamond/practice/config/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,6 @@ public enum Language {
KIT_GAME_RULES_HYPIXELUHC_DESCRIPTION("kit.game-rules.hypixelUHC.description"),
KIT_GAME_RULES_SPLEEF_RULES("kit.game-rules.spleef.rules"),
KIT_GAME_RULES_SPLEEF_DESCRIPTION("kit.game-rules.spleef.description"),
KIT_GAME_RULES_REMOVE_SNOW_BLOCK_WHEN_SNOWBALL_HIT_RULES("kit.game-rules.spleef.rules"),
KIT_GAME_RULES_REMOVE_SNOW_BLOCK_WHEN_SNOWBALL_HIT_DESCRIPTION("kit.game-rules.spleef.description"),
KIT_GAME_RULES_HEALTH_REGENERATION_RULES("kit.game-rules.health-regeneration.rules"),
KIT_GAME_RULES_HEALTH_REGENERATION_DESCRIPTION("kit.game-rules.health-regeneration.description"),
KIT_GAME_RULES_SHOW_HEALTH_RULES("kit.game-rules.show-health.rules"),
Expand Down Expand Up @@ -647,6 +645,7 @@ public enum Language {
QUEUE_ERROR_NOT_FOUND_QUEUE_PROFILE("queue.error-not-found-queue-profile"),
QUEUE_WRONG_STATE("queue.wrong-state"),
QUEUE_ERROR_KIT_DATA_NOT_FOUND("queue.error-kit-data-not-found"),
QUEUE_ERROR_NOT_ENOUGH_WINS("queue.error-not-enough-wins"),
QUEUE_SUCCESS_JOIN("queue.success-join"),
QUEUE_SUCCESS_QUIT("queue.success-quit"),
BUTTON_BACK_NAME("button.back.name"),
Expand Down Expand Up @@ -685,13 +684,13 @@ public String toString(Object... replacements) {

public String toString(Player player, Object... replacements) {
String str = Eden.INSTANCE.getLanguageFile().getString(path);
if (str.equalsIgnoreCase("null")) {
return null;
}
if (Util.isNull(str)) {
return path;
}
str = translate(str, player);
if (str == null) {
return null;
}
for (int i = 0; i < replacements.length; i++) {
String replacement = convert(replacements[i]);
str = str.replace("{" + i + "}", replacement);
Expand Down Expand Up @@ -727,7 +726,11 @@ public List<String> toStringList(Player player, Object... replacements) {
}

public void sendMessage(Player player, Object... replacements) {
Common.sendMessage(player, toString(player, replacements));
String msg = toString(player, replacements);
if (msg == null) {
return;
}
Common.sendMessage(player, msg);
}

public void sendListOfMessage(Player player, Object... replacements) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rip/diamond/practice/debug/TestCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public void execute(CommandArguments command) {
String[] args = command.getArgs();

if (args[0].equalsIgnoreCase("1")) {
EdenEvent.getOnGoingEvent().countdown(2);
Common.sendMessage(sender, "done 1");
sender.setFoodLevel(10);
return;
} else if (args[0].equalsIgnoreCase("2")) {
Bukkit.getPlayer("GoodestEnglish").performCommand("party create");
Bukkit.getPlayer("Fauzh").performCommand("party join GoodestEnglish");
Bukkit.getPlayer("DragonL").performCommand("party join GoodestEnglish");
return;
}


Expand Down
2 changes: 0 additions & 2 deletions src/main/java/rip/diamond/practice/kits/KitGameRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class KitGameRules implements Cloneable {
@Getter private boolean projectileOnly = false;
@Getter private boolean hypixelUHC = false;
@Getter private boolean spleef = false;
@Getter private boolean removeSnowBlockWhenSnowballHit = true;
@Getter private boolean healthRegeneration = true;
@Getter private boolean showHealth = true;
@Getter private boolean foodLevelChange = true;
Expand Down Expand Up @@ -94,7 +93,6 @@ public enum Readable {
projectileOnly(Language.KIT_GAME_RULES_PROJECTILE_ONLY_RULES.toString(), Language.KIT_GAME_RULES_PROJECTILE_ONLY_DESCRIPTION.toString()),
hypixelUHC(Language.KIT_GAME_RULES_HYPIXELUHC_RULES.toString(), Language.KIT_GAME_RULES_HYPIXELUHC_DESCRIPTION.toString()),
spleef(Language.KIT_GAME_RULES_SPLEEF_RULES.toString(), Language.KIT_GAME_RULES_SPLEEF_DESCRIPTION.toString()),
removeSnowBlockWhenSnowballHit(Language.KIT_GAME_RULES_REMOVE_SNOW_BLOCK_WHEN_SNOWBALL_HIT_RULES.toString(), Language.KIT_GAME_RULES_REMOVE_SNOW_BLOCK_WHEN_SNOWBALL_HIT_DESCRIPTION.toString()),
healthRegeneration(Language.KIT_GAME_RULES_HEALTH_REGENERATION_RULES.toString(), Language.KIT_GAME_RULES_HEALTH_REGENERATION_DESCRIPTION.toString()),
showHealth(Language.KIT_GAME_RULES_SHOW_HEALTH_RULES.toString(), Language.KIT_GAME_RULES_SHOW_HEALTH_DESCRIPTION.toString()),
foodLevelChange(Language.KIT_GAME_RULES_FOOD_LEVEL_CHANGE_RULES.toString(), Language.KIT_GAME_RULES_FOOD_LEVEL_CHANGE_DESCRIPTION.toString()),
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/rip/diamond/practice/lobby/LobbyMovementHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package rip.diamond.practice.lobby;

import rip.diamond.practice.Eden;
import rip.diamond.practice.profile.PlayerProfile;
import rip.diamond.practice.profile.PlayerState;

public class LobbyMovementHandler {

public LobbyMovementHandler(Eden plugin) {
Eden.INSTANCE.getSpigotAPI().getMovementHandler().injectLocationUpdate((player, from, to) -> {
PlayerProfile profile = PlayerProfile.get(player);

if (profile != null && (profile.getPlayerState() == PlayerState.IN_LOBBY || profile.getPlayerState() == PlayerState.IN_QUEUE) && player.getLocation().getY() < 0) {
plugin.getLobbyManager().teleport(player);
}
});
}

}
3 changes: 1 addition & 2 deletions src/main/java/rip/diamond/practice/match/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import rip.diamond.practice.event.MatchStartEvent;
import rip.diamond.practice.event.MatchStateChangeEvent;
import rip.diamond.practice.kits.Kit;
import rip.diamond.practice.lobby.LobbyMovementHandler;
import rip.diamond.practice.match.task.*;
import rip.diamond.practice.match.team.Team;
import rip.diamond.practice.match.team.TeamColor;
Expand Down Expand Up @@ -63,8 +64,6 @@ public static void init() {
new MatchClearItemTask();
new MatchPostMatchInventoriesClearTask();
new ProfileCooldownTask();

new MatchMovementHandler();
}

public Match(ArenaDetail arenaDetail, Kit kit, List<Team> teams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ public void onProjectileHit(ProjectileHitEvent event) {

if (event.getEntityType() == EntityType.SNOWBALL) {
Location location = event.getEntity().getLocation().clone().add(0, -1, 0);
if (location.getBlock().getType() == Material.SNOW_BLOCK && match.getKit().getGameRules().isRemoveSnowBlockWhenSnowballHit()) {
if (location.getBlock().getType() == Material.SNOW_BLOCK && match.getKit().getGameRules().isSpleef()) {
location.getBlock().setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import rip.diamond.practice.match.Match;
import rip.diamond.practice.profile.PlayerProfile;
import rip.diamond.practice.profile.PlayerState;
import rip.diamond.practice.util.Tasks;
import rip.diamond.practice.util.Util;

public class SpectateListener implements Listener {
Expand Down Expand Up @@ -163,8 +164,10 @@ public void onChangeWorld(PlayerChangedWorldEvent event) {
PlayerProfile profile = PlayerProfile.get(player);

if (profile.getPlayerState() == PlayerState.IN_SPECTATING) {
player.setAllowFlight(true);
player.setFlying(true);
Tasks.runLater(() -> {
player.setAllowFlight(true);
player.setFlying(true);
}, 2L);
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/rip/diamond/practice/queue/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import lombok.Getter;
import org.bukkit.entity.Player;
import rip.diamond.practice.Eden;
import rip.diamond.practice.config.Config;
import rip.diamond.practice.config.Language;
import rip.diamond.practice.kits.Kit;
import rip.diamond.practice.party.Party;
import rip.diamond.practice.profile.PlayerProfile;
import rip.diamond.practice.profile.PlayerState;
import rip.diamond.practice.profile.data.ProfileKitData;
import rip.diamond.practice.queue.task.QueueTask;

import java.util.HashMap;
Expand Down Expand Up @@ -52,6 +54,15 @@ public static void joinQueue(Player player, Kit kit, QueueType queueType) {
return;
}

if (queueType == QueueType.RANKED) {
int required = Config.QUEUE_RANKED_REQUIRED_WINS.toInteger();
int wins = profile.getKitData().values().stream().mapToInt(ProfileKitData::getUnrankedWon).sum();
if (wins < required) {
Language.QUEUE_ERROR_NOT_ENOUGH_WINS.sendMessage(player, required, wins);
return;
}
}

QueueProfile qProfile = new QueueProfile(player.getUniqueId(), kit, profile.getKitData().get(kit.getName()).getElo(), queueType);
players.put(player.getUniqueId(), qProfile);
profile.setPlayerState(PlayerState.IN_QUEUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ public void execute(CommandArguments command) {
return;
}
QueueType queueType = QueueType.valueOf(args[0].toUpperCase());

if (queueType == QueueType.RANKED) {
// TODO: 21/6/2023 https://github.com/diamond-rip/Eden/issues/312 #4
}

Kit kit = Kit.getByName(args[1]);
if (kit == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rip/diamond/practice/util/PlayerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void reset(Player player, boolean resetHeldSlot) {
return;
}
player.setHealth(20.0D);
player.setSaturation(20.0F);
player.setSaturation(0.0F);
player.setFallDistance(0.0F);
player.setFoodLevel(20);
player.setFireTicks(0);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/rip/diamond/practice/util/TitleSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
public class TitleSender {

public static void sendTitle(Player player, String text, PacketPlayOutTitle.EnumTitleAction titleAction, int fadeInTime, int showTime, int fadeOutTime) {
if (Util.isNull(text)) {
return;
}
IChatBaseComponent chatTitle = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC.translate(text) + "\",color:" + ChatColor.GOLD.name().toLowerCase() + "}");

PacketPlayOutTitle title = new PacketPlayOutTitle(titleAction, chatTitle);
Expand All @@ -21,6 +24,9 @@ public static void sendTitle(Player player, String text, PacketPlayOutTitle.Enum
}

public static void sendActionBar(Player p, String text) {
if (Util.isNull(text)) {
return;
}
CraftPlayer cp = (CraftPlayer) p;
IChatBaseComponent cbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC.translate(text) + "\"}");
PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc, (byte) 2);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ party:
lobby:
## Should player allow to see other players?
display-players: false
queue:
## How many wins should a player have to have access to queue ranked matches?
ranked-required-wins: 10
match:
## This option will give a 'Play Again' item to match players when a match is ended, like Minemen Club
allow-requeue: true
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/language-tw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -918,9 +918,6 @@ kit:
spleef:
rules: "鏟雪"
description: "設置該職業是否允許破壞雪地和沙子"
remove-snow-block-when-snowball-hit:
rules: "移除雪地"
description: "設置該職業是否在雪球碰觸雪地的時候移除雪地"
health-regeneration:
rules: "血量回復"
description: "設置該職業是否允許血量自動回復"
Expand Down Expand Up @@ -1477,6 +1474,7 @@ queue:
error-not-found-queue-profile: "&c錯誤: 未能成功找到 QueueProfile"
wrong-state: "&c無法在此情況下加入隊列"
error-kit-data-not-found: "&c無法加入隊列, 請重新登入伺服器"
error-not-enough-wins: "&c你需要 {0} 場勝利場數才能匹配排位賽, 你現在有 {1} 勝利場數"
success-join: "&f你已被加進了 &b{0} &f的等候隊列"
success-quit: "&f你已退出 &b{0} &f的等候隊列"
button:
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,6 @@ kit:
spleef:
rules: "Spleef"
description: "Setting for match to allow breaking snow and sand"
remove-snow-block-when-snowball-hit:
rules: "Remove Snow Block When Snowball Hit"
description: "Setting for snow block removal when snowball hit it"
health-regeneration:
rules: "Health Regeneration"
description: "Setting for match to allow auto regeneration"
Expand Down Expand Up @@ -1421,6 +1418,7 @@ queue:
error-not-found-queue-profile: "&cError: Cannot find QueueProfile"
wrong-state: "&cCannot join a queue in the current state"
error-kit-data-not-found: "&cCannot join a queue, please rejoin"
error-not-enough-wins: "&cYou need at least {0} wins to queue ranked. You now have {1} wins."
success-join: "&fYou have joined &b{0} &f's game queue"
success-quit: "&fYou have left &b{0} &f's game queue"
button:
Expand Down

0 comments on commit 1b8a69d

Please sign in to comment.