Skip to content

Commit

Permalink
Release (#689)
Browse files Browse the repository at this point in the history
New features:
- Added {prefix} support to all messages
- Added unformatted player names for kill and bed destroy message
- Added unbreakable to mellee weapons #245
- Addded Elytra auto equip #663
- add toggle for halloween special (#632)
- Added Placeholders to upgrade message #668

For developers:
- add sidebar init event
- exposed sidebar to the API

- fix team identifier length (Sidebar kick issue (#682, #666 )
- Fix Moneys reward team-support on Solo & update variables names
- Bug fixes and placeholder adjustments (#685)
- Fixed command error when lobby location is not set
- Fixed spanish translation error #599
- Fixed spanish translation error #599
- Netherite armor support in 1.16+ #657
- Wins placeholder not in lobby sidebar #658
- Sidebar Title animation not working #660
- Player levels showing numbers #661
- Fixed In-game arena Scoreboard lines in the wrong spot #662
- NPE when clicking outside of shop inventory #664
- Added Placeholders to upgrade message #668
- Fixed players can collect drops during respawn #669

---------

Co-authored-by: Tom Keuper <tomkeuper@live.nl>
Co-authored-by: Yuri <84080587+Xxyuri2005xX@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 26, 2023
1 parent 767a050 commit f71953d
Show file tree
Hide file tree
Showing 45 changed files with 797 additions and 728 deletions.
10 changes: 10 additions & 0 deletions bedwars-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<id>commons-repo</id>
<url>https://repo.fusesource.com/nexus/content/repositories/releases-3rd-party/</url>
</repository>
<repository>
<id>andrei-prod</id>
<url>https://repo.andrei1058.dev/releases</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -42,6 +46,12 @@
<version>1.16.3-R0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- SIDEBAR LIB -->
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-base</artifactId>
<version>23.2</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.andrei1058.bedwars.api.server.RestoreAdapter;
import com.andrei1058.bedwars.api.server.ServerType;
import com.andrei1058.bedwars.api.server.VersionSupport;
import com.andrei1058.bedwars.api.sidebar.ISidebarService;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -493,4 +494,6 @@ interface ScoreboardUtil {
*/
void givePlayerScoreboard(Player player, boolean delay);
}

ISidebarService getScoreboardManager();
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ public interface IBuyItem {
boolean isPermanent();

void setPermanent(boolean permanent);

boolean isUnbreakable();

void setUnbreakable(boolean permanent);
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class ConfigPath {
public static final String GENERAL_CONFIGURATION_BUNGEE_OPTION_BWP_TIME_OUT = "bungee-settings.bwp-time-out";

public static final String GENERAL_CONFIGURATION_ALLOW_FIRE_EXTINGUISH = "allow-fire-extinguish";
public static final String GENERAL_CONFIGURATION_ENABLE_HALLOWEEN = "enable-halloween-feature";

public static final String GENERAL_CONFIGURATION_LOBBY_ITEMS_PATH = "lobby-items";
public static final String GENERAL_CONFIGURATION_EXPERIMENTAL_TEAM_ASSIGNER = "use-experimental-team-assigner";
Expand Down Expand Up @@ -297,6 +298,7 @@ public class ConfigPath {
public static final String SHOP_CATEGORY_CONTENT_CONTENT_SLOT = "content-settings.content-slot";
public static final String SHOP_CATEGORY_CONTENT_IS_PERMANENT = "content-settings.is-permanent";
public static final String SHOP_CATEGORY_CONTENT_IS_DOWNGRADABLE = "content-settings.is-downgradable";
public static final String SHOP_CATEGORY_CONTENT_IS_UNBREAKABLE = "content-settings.is-unbreakable";
public static final String SHOP_CATEGORY_CONTENT_WEIGHT = "content-settings.weight";
public static final String SHOP_CATEGORY_CONTENT_CONTENT_TIERS = "content-tiers";
public static final String SHOP_CATEGORY_CONTENT_PATH = ".category-content";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.andrei1058.bedwars.api.events.sidebar;

import com.andrei1058.bedwars.api.sidebar.ISidebar;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class PlayerSidebarInitEvent extends Event implements Cancellable {

private static final HandlerList HANDLERS = new HandlerList();
private boolean cancelled = false;

private Player player;
private ISidebar sidebar;

public PlayerSidebarInitEvent(Player player, ISidebar sidebar) {
this.player = player;
this.sidebar = sidebar;
}

public HandlerList getHandlers() {
return HANDLERS;
}

public static HandlerList getHandlerList() {
return HANDLERS;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}

public Player getPlayer() {
return player;
}

public void setPlayer(Player player) {
this.player = player;
}

public ISidebar getSidebar() {
return sidebar;
}

public void setSidebar(ISidebar sidebar) {
this.sidebar = sidebar;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class Language extends ConfigManager {

private final String iso;
private String prefix = "";
private static String prefixStatic = "";
private static final HashMap<UUID, Language> langByPlayer = new HashMap<>();
private static final List<Language> languages = new ArrayList<>();
private static Language defaultLanguage;
Expand All @@ -53,6 +54,9 @@ public Language(Plugin plugin, String iso) {
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public void setPrefixStatic(String prefix) {
this.prefixStatic = prefix;
}

/**
* Get scoreboard strings.
Expand Down Expand Up @@ -89,7 +93,7 @@ public String getLangName() {
*/
public static String getMsg(Player p, String path) {
if (p == null) return getDefaultLanguage().m(path);
return langByPlayer.getOrDefault(p.getUniqueId(), getDefaultLanguage()).m(path);
return langByPlayer.getOrDefault(p.getUniqueId(), getDefaultLanguage()).m(path).replace("{prefix}", (prefixStatic == null? "":prefixStatic));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.andrei1058.bedwars.api.configuration.ConfigPath;

@SuppressWarnings("WeakerAccess")
@Deprecated
public class Messages {

public static String PREFIX = "prefix";
Expand Down Expand Up @@ -330,7 +329,7 @@ public class Messages {
public static String UPGRADES_TRAP_SLOT_ITEM_LORE1_PATH = "upgrades-trap-slot-item-lore1-";
public static String UPGRADES_TRAP_SLOT_ITEM_LORE2_PATH = "upgrades-trap-slot-item-lore2-";
public static String UPGRADES_UPGRADE_TIER_ITEM_NAME = "upgrades-upgrade-name-{name}-{tier}";
public static String UPGRADES_UPGRADE_TIER_ITEM_LORE = "upgrades-upgrade-lore-{name}-{tier}";
public static String UPGRADES_UPGRADE_TIER_ITEM_LORE = "upgrades-upgrade-lore-{name}";
public static String UPGRADES_BASE_TRAP_ITEM_NAME_PATH = "upgrades-base-trap-name-";
public static String UPGRADES_BASE_TRAP_ITEM_LORE_PATH = "upgrades-base-trap-lore-";
public static String UPGRADES_TRAP_CUSTOM_TITLE = "upgrades-base-trap-title-";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,26 @@ public boolean isPlayerHead(String material, int data) {
*/
public abstract Material materialGoldenLeggings();

/**
* Get netherite helmet material
*/
public abstract Material materialNetheriteHelmet();

/**
* Get netherite chest plate
*/
public abstract Material materialNetheriteChestPlate();

/**
* Get netherite leggings
*/
public abstract Material materialNetheriteLeggings();

/**
* Get elytra - supports: 1.12.2+
*/
public abstract Material materialElytra();

/**
* Cake material
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.andrei1058.bedwars.api.sidebar;

import com.andrei1058.bedwars.api.arena.IArena;
import com.andrei1058.spigot.sidebar.PlaceholderProvider;
import com.andrei1058.spigot.sidebar.Sidebar;
import com.andrei1058.spigot.sidebar.SidebarLine;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public interface ISidebar {

/**
* Sidebar holder.
*/
Player getPlayer();

/**
* Coincides with the arena where the player is on.
*/
@Nullable
IArena getArena();

/**
* Get sidebar lib handle.
*/
Sidebar getHandle();

/**
* Set sidebar content.
*/
void setContent(List<String> titleArray, List<String> lineArray, @Nullable IArena arena);

/**
* Convert an animated string to an object.
*/
SidebarLine normalizeTitle(@Nullable List<String> titleArray);

/**
* Convert string lines to string objects.
*/
@NotNull List<SidebarLine> normalizeLines(@NotNull List<String> lineArray);

/**
* Will update tab prefix and suffix for the given player on current sidebar.
*
* @param player format given player on current holder's sidebar.
* @param skipStateCheck will skip checking if tab formatting is disabled.
*/
void giveUpdateTabFormat(@NotNull Player player, boolean skipStateCheck);


/**
* @return true if tab formatting is disabled for current sidebar/ arena stage
*/
boolean isTabFormattingDisabled();

/**
* Register a placeholder that is not going to be removed trough game state changes.
*/
boolean registerPersistentPlaceholder(PlaceholderProvider placeholderProvider);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.andrei1058.bedwars.api.sidebar;

import com.andrei1058.bedwars.api.arena.IArena;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* BedWars scoreboard manager.
*/
public interface ISidebarService {

/**
* Send player scoreboard based on conditions.
*/
void giveSidebar(@NotNull Player player, @Nullable IArena arena, boolean delay);

/**
* Remove a player scoreboard.
*/
void remove(@NotNull Player player);

/**
* Refresh title on all scoreboards.
*/
void refreshTitles();

/**
* Refresh placeholders on all sidebars.
*/
void refreshPlaceholders();

/**
* Refresh placeholders for sidebars in a given arena;
*/
void refreshPlaceholders(IArena arena);

/**
* Refresh all tab-list header and footer strings for every sidebar.
*/
void refreshTabList();

/**
* Refresh player healths.
*/
void refreshHealth();

@Nullable
ISidebar getSidebar(@NotNull Player player);

}
6 changes: 6 additions & 0 deletions bedwars-plugin/src/main/java/com/andrei1058/bedwars/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.andrei1058.bedwars.api.server.RestoreAdapter;
import com.andrei1058.bedwars.api.server.ServerType;
import com.andrei1058.bedwars.api.server.VersionSupport;
import com.andrei1058.bedwars.api.sidebar.ISidebarService;
import com.andrei1058.bedwars.arena.Arena;
import com.andrei1058.bedwars.arena.SetupSession;
import com.andrei1058.bedwars.commands.bedwars.MainCommand;
Expand Down Expand Up @@ -435,4 +436,9 @@ public ScoreboardUtil getScoreboardUtil() {
public boolean isShuttingDown() {
return BedWars.isShuttingDown();
}

@Override
public ISidebarService getScoreboardManager() {
return SidebarService.getInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,10 @@ public void onEnable() {

registerEvents(new ScoreboardListener());

// Halloween Special
HalloweenSpecial.init();
if (config.getBoolean(ConfigPath.GENERAL_CONFIGURATION_ENABLE_HALLOWEEN)) {
// Halloween Special
HalloweenSpecial.init();
}

SpoilPlayerTNTFeature.init();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ public class Misc {
public static void moveToLobbyOrKick(Player p, @Nullable IArena arena, boolean notAbandon) {
if (getServerType() != ServerType.BUNGEE) {
if (!p.getWorld().getName().equalsIgnoreCase(config.getLobbyWorldName())) {
p.teleport(config.getConfigLoc("lobbyLoc"));
Location loc = config.getConfigLoc("lobbyLoc");
if (loc != null){ // Can happen when location is not set in config
p.teleport(loc);
} else {
forceKick(p, arena, notAbandon);
return;
}
if (arena != null) {
if (arena.isSpectator(p)) {
arena.removeSpectator(p, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,15 @@ public void respawnMember(@NotNull Player p) {
}
PaperSupport.teleportC(p, getSpawn(), PlayerTeleportEvent.TeleportCause.PLUGIN);
p.setVelocity(new Vector(0, 0, 0));
getArena().getRespawnSessions().remove(p);
p.removePotionEffect(PotionEffectType.INVISIBILITY);
nms.setCollide(p, arena, true);
p.setAllowFlight(false);
p.setFlying(false);
p.setHealth(20);

Bukkit.getScheduler().runTaskLater(plugin, ()-> {
getArena().getRespawnSessions().remove(p); //Fixes https://github.com/andrei1058/BedWars1058/issues/669

for (Player inGame : arena.getPlayers()){
if (inGame.equals(p)) continue;
BedWars.nms.spigotShowPlayer(p, inGame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public MainConfig(Plugin plugin, String name) {
yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_DISABLED_LANGUAGES, Collections.singletonList("your language iso here"));
yml.addDefault("storeLink", "https://www.spigotmc.org/resources/authors/39904/");
yml.addDefault("lobbyServer", "hub");
yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_ENABLE_HALLOWEEN, true);
yml.addDefault(ConfigPath.GENERAL_CHAT_GLOBAL, yml.get("globalChat", false));
yml.addDefault(ConfigPath.GENERAL_CHAT_FORMATTING, yml.get("formatChat", true));
yml.addDefault("debug", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,15 @@ public boolean isPermanent() {
public void setPermanent(boolean permanent) {

}

@Override
public boolean isUnbreakable() {
return false;
}

@Override
public void setUnbreakable(boolean unbreakable) {

}
}
}
Loading

0 comments on commit f71953d

Please sign in to comment.