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 health display as 0 when game starts (#379)
- Updated boxing counter (#389)
- Fixed potion effects still active when a new round starts
- Allow TNT placement above build limit (#389)
- Fixed message error which displays the not in lobby players (#395)
  • Loading branch information
GoodestEnglish committed Jul 2, 2023
1 parent 3d42840 commit f01a288
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 22 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.20-BETA-" + getGitHash()
version = "1.1.21-BETA-" + getGitHash()

processResources {
def props = [version: version]
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/rip/diamond/practice/EdenPlaceholder.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ public String translate(Player player, String str) {
int solo_y = opponent.getHits();
int soloDifference = solo_x - solo_y;

boolean selfComboing = self.getCombo() > 1;
boolean opponentComboing = opponent.getCombo() > 1;

str = str
.replace("{match-solo-opponent}", opponent.getUsername())
.replace("{match-solo-winner}", match.getState() == MatchState.ENDING ? match.getWinningPlayers().get(0).getUsername() : "")
.replace("{match-solo-loser}", match.getState() == MatchState.ENDING ? match.getTeams().stream().filter(team -> team != match.getWinningTeam()).map(team -> team.getLeader().getUsername()).findFirst().orElse(""): "")
.replace("{match-solo-boxing-difference-text}", soloDifference == 0 ? Language.SCOREBOARD_BOXING_COUNTER_NO_COMBO.toString() : Language.SCOREBOARD_BOXING_COUNTER_TEXT_SOLO.toString())
.replace("{match-solo-boxing-difference-text}", selfComboing || opponentComboing ? Language.SCOREBOARD_BOXING_COUNTER_TEXT_SOLO.toString(selfComboing ? CC.GREEN : CC.RED, selfComboing ? self.getCombo() : opponent.getCombo()) : Language.SCOREBOARD_BOXING_COUNTER_NO_COMBO.toString())
.replace("{match-solo-boxing-difference}", Math.abs(soloDifference) + "")
.replace("{match-solo-boxing-difference-number}", soloDifference + "")
.replace("{match-solo-boxing-difference-symbol}", soloDifference == 0 ? "" : soloDifference > 0 ? "+" : "-")
Expand All @@ -124,14 +127,17 @@ public String translate(Player player, String str) {
int teams_y = opponentTeam.getHits();
int teamsDifference = teams_x - teams_y;

boolean xComboing = team.getCombo() > 1;
boolean yComboing = opponentTeam.getCombo() > 1;

str = str
.replace("{match-team-self-alive}", team.getAliveCount() + "")
.replace("{match-team-self-size}", team.getTeamPlayers().size() + "")
.replace("{match-team-opponent-alive}", opponentTeam.getAliveCount() + "")
.replace("{match-team-opponent-size}", opponentTeam.getTeamPlayers().size() + "")
.replace("{match-team-winner}", match.getState() == MatchState.ENDING ? match.getWinningTeam() == null ? "" : match.getWinningTeam().getLeader().getUsername() : "")
.replace("{match-team-loser}", match.getState() == MatchState.ENDING ? match.getWinningTeam() == null ? "" : match.getTeams().stream().filter(t -> match.getWinningTeam() != t).map(t -> t.getLeader().getUsername()).findFirst().orElse("") : "")
.replace("{match-team-boxing-difference-text}", teamsDifference == 0 ? Language.SCOREBOARD_BOXING_COUNTER_NO_COMBO.toString() : Language.SCOREBOARD_BOXING_COUNTER_TEXT_TEAM.toString())
.replace("{match-team-boxing-difference-text}", xComboing || yComboing ? Language.SCOREBOARD_BOXING_COUNTER_TEXT_TEAM.toString(xComboing ? CC.GREEN : CC.RED, xComboing ? team.getCombo() : opponentTeam.getCombo()) : Language.SCOREBOARD_BOXING_COUNTER_NO_COMBO.toString())
.replace("{match-team-boxing-difference}", Math.abs(teamsDifference) + "")
.replace("{match-team-boxing-difference-number}", teamsDifference + "")
.replace("{match-team-boxing-difference-symbol}", teamsDifference == 0 ? "" : teamsDifference > 0 ? "+" : "-")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rip/diamond/practice/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public enum Config {
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),
MATCH_INSTANT_GAPPLE_EFFECTS("match.instant-gapple-effects", true),
MATCH_OUTSIDE_CUBOID_INSTANT_DEATH("match.outside-cuboid-instant-death", true),
MATCH_REMOVE_CACTUS_SUGAR_CANE_PHYSICS("match.remove-cactus-sugar-cane-physics", true),
MATCH_DEATH_LIGHTNING("match.death-lightning", true),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rip/diamond/practice/config/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ 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;
return "";
}
if (Util.isNull(str)) {
return path;
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/rip/diamond/practice/debug/TestCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import rip.diamond.practice.events.EdenEvent;
import rip.diamond.practice.profile.PlayerProfile;
import rip.diamond.practice.util.Common;
import rip.diamond.practice.util.command.Command;
import rip.diamond.practice.util.command.CommandArgs;
Expand All @@ -12,11 +13,12 @@ public class TestCommand extends Command {

@CommandArgs(name = "test", permission = "eden.command.test", async = true)
public void execute(CommandArguments command) {
Player sender = command.getPlayer();
Player player = command.getPlayer();
PlayerProfile profile = PlayerProfile.get(player);
String[] args = command.getArgs();

if (args[0].equalsIgnoreCase("1")) {
sender.setFoodLevel(10);
player.setHealth(Double.parseDouble(args[1]));
return;
} else if (args[0].equalsIgnoreCase("2")) {
Bukkit.getPlayer("GoodestEnglish").performCommand("party create");
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/rip/diamond/practice/match/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityWeather;
import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -118,6 +119,7 @@ public void start() {
//Create the health display under NameTag, if needed
if (kit.getGameRules().isShowHealth()) {
plugin.getScoreboardHandler().getScoreboard(player).registerHealthObjective();
player.setHealth(player.getMaxHealth() - 0.001); //Fix for health display as 0 - #379
}

//Set up the knockback
Expand Down Expand Up @@ -359,10 +361,14 @@ public boolean canEnd() {
}

public boolean isProtected(Location location, boolean isPlacing) {
return isProtected(location, isPlacing, null);
}

public boolean isProtected(Location location, boolean isPlacing, Block block) {
if (location.getBlockY() >= arenaDetail.getArena().getBuildMax() || location.getBlockY() <= arenaDetail.getArena().getYLimit()) {
return true;
}
if (!arenaDetail.getCuboid().contains(location)) {
if (!arenaDetail.getCuboid().contains(location) && (block.getType() != Material.TNT && Config.MATCH_TNT_ENABLED.toBoolean())) { //Allow TNT placing above build limit
return true;
}
if (kit.getGameRules().isSpleef()) {
Expand All @@ -380,7 +386,7 @@ public boolean isProtected(Location location, boolean isPlacing) {
return false;
}
if (kit.getGameRules().isPortalGoal()) {
long count = Util.getBlocksAroundCenter(location, arenaDetail.getArena().getPortalProtectionRadius()).stream().filter(block -> block.getType() == Material.ENDER_PORTAL).count();
long count = Util.getBlocksAroundCenter(location, arenaDetail.getArena().getPortalProtectionRadius()).stream().filter(b -> b.getType() == Material.ENDER_PORTAL).count();
if (count > 0) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ public void onPlace(BlockPlaceEvent event) {
event.setCancelled(true);
return;
}
if (match.isProtected(block.getLocation(), true)) {
if (match.isProtected(block.getLocation(), true, block)) {
event.setCancelled(true);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package rip.diamond.practice.match.task;

import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.github.paperspigot.Title;
import rip.diamond.practice.config.Config;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/rip/diamond/practice/match/team/TeamPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ public void respawn(Match match) {
return;
}
kitLoadout.apply(match, getPlayer());
getPlayer().setHealth(getPlayer().getMaxHealth()); //A fix for https://github.com/RealGoodestEnglish/Eden/issues/11 - Restore health each time when respawn
lastHitDamager = null; //A fix for https://github.com/RealGoodestEnglish/Eden/issues/11 - Prevent kill spam (https://www.youtube.com/watch?v=oD6k0rrNVTk)
getPlayer().setHealth(getPlayer().getMaxHealth()); //A fix for #11 - Restore health each time when respawn
getPlayer().getActivePotionEffects().clear(); //A fix for #389 - Remove effects like absorption when score
lastHitDamager = null; //A fix for #11 - Prevent kill spam (https://www.youtube.com/watch?v=oD6k0rrNVTk)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,12 @@ else if (args[0].equalsIgnoreCase("list")) {
Language.PARTY_DISABLED_PARTY_INVITE.sendMessage(player);
return;
}

Party party = Party.getByPlayer(player);
if (party == null) {
party = new Party(player, Config.PARTY_DEFAULT_MAX_SIZE.toInteger());
}

if (!party.getLeader().getUniqueID().equals(player.getUniqueId())) {
Language.PARTY_ONLY_LEADER.sendMessage(player);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void startPartyEvent(Player leader, KitMatchType matchType, Kit kit, Aren
return;
}

List<PartyMember> notInLobbyPlayers = new ArrayList<>();
party.getAllPartyMembers().stream().filter(partyMember -> PlayerProfile.get(partyMember.getPlayer()).getPlayerState() != PlayerState.IN_LOBBY).forEach(notInLobbyPlayers::add);
List<String> notInLobbyPlayers = new ArrayList<>();
party.getAllPartyMembers().stream().filter(partyMember -> PlayerProfile.get(partyMember.getPlayer()).getPlayerState() != PlayerState.IN_LOBBY).forEach(pm -> notInLobbyPlayers.add(pm.getUsername()));
if (!notInLobbyPlayers.isEmpty()) {
Language.PARTY_START_PARTY_FIGHT_PLAYERS_NOT_IN_LOBBY.sendMessage(leader, StringUtils.join(notInLobbyPlayers, ", "));
return;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rip/diamond/practice/util/BasicConfigFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public String getString(String path) {
if (this.configuration.contains(path)) {
return ChatColor.translateAlternateColorCodes('&', this.configuration.getString(path));
}
return "null";
return path;
}

public List<String> getStringList(String path) {
Expand All @@ -69,7 +69,7 @@ public List<String> getStringList(String path) {
}
return strings;
}
return Collections.singletonList("null");
return Collections.singletonList(path);
}

public void load() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rip/diamond/practice/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class Util {

public static boolean isNull(String str) {
return str == null || str.equalsIgnoreCase("null");
return str == null || str.equalsIgnoreCase("null") || str.equalsIgnoreCase("");
}

public static boolean isNotNull(String str) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ match:
## This option will give a 'Play Again' item to match players when a match is ended, like Minemen Club
allow-requeue: true
## When player consume a golden apple, should the system gives normal effects to the player (which contains instantly regenerate to full health, saturation and absorption hearts), or just regenerate to full health?
## Default is false which only set the player health to full, no effects are given
instant-gapple-effects: false
## If false, then system will only set the player health to full, no effects are given
instant-gapple-effects: true
## When player is outside the cuboid (which uses arena min/max), should player receive a instant death damage?
outside-cuboid-instant-death: true
## Should Eden remove cactus and sugar cane's physics?
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/language-tw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ scoreboard:
title: "&b戰鬥練習"
boxing-counter:
no-combo: "&f沒有連擊"
text: "{match-solo-boxing-difference-color}{match-solo-boxing-difference} 連擊"
text-solo: "{match-solo-boxing-difference-color}{match-solo-boxing-combo} 連擊"
text-team: "{match-team-boxing-difference-color}{match-team-boxing-combo} 連擊"
loading:
- "&7&m----------------------"
- "&c你的資料正在加載中..."
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ scoreboard:
title: "&bPractice"
boxing-counter:
no-combo: "&fNo Combo"
text-solo: "{match-solo-boxing-difference-color}{match-solo-boxing-difference} Combo"
text-team: "{match-team-boxing-difference-color}{match-team-boxing-difference} Combo"
text-solo: "{0}{1} Combo"
text-team: "{0}{1} Combo"
loading:
- "&7&m----------------------"
- "&cYour data is loading..."
Expand Down

0 comments on commit f01a288

Please sign in to comment.