Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DONE] Small but helpful additions & fixes #916

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/compile_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment:
name: development
url: https://repo.andrei1058.dev
# environment:
# name: development
# url: https://repo.andrei1058.dev
steps:
- uses: actions/checkout@v3
- name: Set up JDK
Expand All @@ -32,4 +32,4 @@ jobs:
mvn versions:set -DnewVersion=$UPDATE_VERSION-SNAPSHOT
mvn versions:update-child-modules
mvn clean install -s ci_settings.xml
echo "UPDATE_VERSION=$UPDATE_VERSION" >> $GITHUB_ENV
echo "UPDATE_VERSION=$UPDATE_VERSION" >> $GITHUB_ENV
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
environment:
name: production
url: https://repo.andrei1058.com
url: https://repo.andrei1058.dev
steps:
- uses: actions/checkout@v3
- name: Set up JDK
Expand Down Expand Up @@ -44,4 +44,4 @@ jobs:
with:
generate_release_notes: true
name: ${{env.UPDATE_VERSION}}
tag_name: ${{env.UPDATE_VERSION}}
tag_name: ${{env.UPDATE_VERSION}}
3 changes: 1 addition & 2 deletions .github/workflows/deploy_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- develop

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -30,4 +29,4 @@ jobs:
mvn versions:set -DnewVersion=$UPDATE_VERSION-SNAPSHOT
mvn versions:update-child-modules
mvn clean deploy -s ci_settings.xml
echo "UPDATE_VERSION=$UPDATE_VERSION" >> $GITHUB_ENV
echo "UPDATE_VERSION=$UPDATE_VERSION" >> $GITHUB_ENV
2 changes: 1 addition & 1 deletion bedwars-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>BedWars1058</artifactId>
<groupId>com.andrei1058.bedwars</groupId>
<version>23.10.1-SNAPSHOT</version>
<version>23.12.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bedwars-api</artifactId>
Expand Down
44 changes: 33 additions & 11 deletions bedwars-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>BedWars1058</artifactId>
<groupId>com.andrei1058.bedwars</groupId>
<version>23.10.1-SNAPSHOT</version>
<version>23.12.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bedwars-plugin</artifactId>
Expand Down Expand Up @@ -192,6 +192,16 @@
<artifactId>versionsupport_v1_20_R2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.andrei1058.bedwars</groupId>
<artifactId>versionsupport_v1_20_R3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.andrei1058.bedwars</groupId>
<artifactId>versionsupport_v1_20_R4</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.andrei1058.bedwars</groupId>
<artifactId>versionsupport-common</artifactId>
Expand Down Expand Up @@ -247,61 +257,73 @@
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-base</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_8_R3</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_12_R1</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_16_R1</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_17_R1</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_18_R2</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_19_R2</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_19_R3</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_20_R1</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_20_R2</artifactId>
<version>23.10</version>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_20_R3</artifactId>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_20_R4</artifactId>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<!-- End of Sidebar LIB-->
Expand Down
14 changes: 13 additions & 1 deletion bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class BedWars extends JavaPlugin {

private static ServerType serverType = ServerType.MULTIARENA;
public static boolean debug = true, autoscale = false;
public static String mainCmd = "bw", link = "https://www.spigotmc.org/resources/50942/";
public static String mainCmd = "bw", link = "https://www.spigotmc.org/resources/97320/";
public static ConfigManager signs, generators;
public static MainConfig config;
public static ShopManager shop;
Expand Down Expand Up @@ -516,6 +516,9 @@ public void onEnable() {

// TNT Spoil Feature
SpoilPlayerTNTFeature.init();

// Warn user if current server version support is deprecated
this.performDeprecationCheck();
}

/**
Expand Down Expand Up @@ -753,6 +756,15 @@ public static void setParty(Party party) {
BedWars.party = party;
}

public void performDeprecationCheck() {
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
if (Arrays.stream(nms.getClass().getAnnotations()).anyMatch(annotation -> annotation instanceof Deprecated)) {
this.getLogger().warning("Support for "+getServerVersion()+" is scheduled for removal. " +
"Please consider upgrading your server software to a newer Minecraft version.");
}
});
}

@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
return new VoidChunkGenerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,12 @@ public void removePlayer(@NotNull Player p, boolean disconnect) {
Language lang = Language.getPlayerLanguage(inGame);
inGame.sendMessage(event.getMessage().apply(inGame)
.replace("{PlayerTeamName}", team.getDisplayName(lang))
.replace("{PlayerColor}", team.getColor().chat().toString()).replace("{PlayerName}", p.getDisplayName())
.replace("{PlayerColor}", team.getColor().chat().toString())
.replace("{PlayerName}", p.getDisplayName())
.replace("{PlayerNameUnformatted}", p.getName())
.replace("{KillerColor}", killerTeam.getColor().chat().toString())
.replace("{KillerName}", lastDamager.getDisplayName())
.replace("{KillerNameUnformatted}", lastDamager.getName())
.replace("{KillerTeamName}", killerTeam.getDisplayName(lang)));
}
}
Expand All @@ -873,9 +876,12 @@ public void removePlayer(@NotNull Player p, boolean disconnect) {
Language lang = Language.getPlayerLanguage(inGame);
inGame.sendMessage(event.getMessage().apply(inGame)
.replace("{PlayerTeamName}", team.getDisplayName(lang))
.replace("{PlayerColor}", team.getColor().chat().toString()).replace("{PlayerName}", p.getDisplayName())
.replace("{PlayerColor}", team.getColor().chat().toString())
.replace("{PlayerName}", p.getDisplayName())
.replace("{PlayerNameUnformatted}", p.getName())
.replace("{KillerColor}", killerTeam.getColor().chat().toString())
.replace("{KillerName}", lastDamager.getDisplayName())
.replace("{KillerNameUnformatted}", lastDamager.getName())
.replace("{KillerTeamName}", killerTeam.getDisplayName(lang)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package com.andrei1058.bedwars.commands.party;

import com.andrei1058.bedwars.api.language.Messages;
import com.andrei1058.bedwars.support.papi.SupportPAPI;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
Expand All @@ -43,7 +44,7 @@ public PartyCommand(String name) {
}

//owner, target
private static HashMap<UUID, UUID> partySessionRequest = new HashMap<>();
private static final HashMap<UUID, UUID> partySessionRequest = new HashMap<>();

@Override
public boolean execute(CommandSender s, String c, String[] args) {
Expand All @@ -63,19 +64,20 @@ public boolean execute(CommandSender s, String c, String[] args) {
p.sendMessage(getMsg(p, Messages.COMMAND_PARTY_INSUFFICIENT_PERMISSIONS));
return true;
}
if (Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline()) {
if (p == Bukkit.getPlayer(args[1])) {
Player invited = Bukkit.getPlayer(args[1]);
if (invited != null && invited.isOnline()) {
if (p == invited) {
p.sendMessage(getMsg(p, Messages.COMMAND_PARTY_INVITE_DENIED_CANNOT_INVITE_YOURSELF));
return true;
}
p.sendMessage(getMsg(p, Messages.COMMAND_PARTY_INVITE_SENT).replace("{playername}", p.getName()).replace("{player}", args[1]));
p.sendMessage(SupportPAPI.getSupportPAPI().replace(p, getMsg(p, Messages.COMMAND_PARTY_INVITE_SENT).replace("{playername}", p.getName()).replace("{player}", invited.getName())));
TextComponent tc = new TextComponent(getMsg(p, Messages.COMMAND_PARTY_INVITE_SENT_TARGET_RECEIVE_MSG).replace("{player}", p.getName()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/party accept " + p.getName()));
Bukkit.getPlayer(args[1]).spigot().sendMessage(tc);
invited.spigot().sendMessage(tc);
if (partySessionRequest.containsKey(p.getUniqueId())) {
partySessionRequest.replace(p.getUniqueId(), Bukkit.getPlayer(args[1]).getUniqueId());
partySessionRequest.replace(p.getUniqueId(), invited.getUniqueId());
} else {
partySessionRequest.put(p.getUniqueId(), Bukkit.getPlayer(args[1]).getUniqueId());
partySessionRequest.put(p.getUniqueId(), invited.getUniqueId());
}
} else {
p.sendMessage(getMsg(p, Messages.COMMAND_PARTY_INVITE_DENIED_PLAYER_OFFLINE).replace("{player}", args[1]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public MainConfig(Plugin plugin, String name) {
yml.addDefault(ConfigPath.GENERAL_TNT_JUMP_DAMAGE_OTHERS, 10);

// tnd block blast resistance
yml.addDefault(ConfigPath.GENERAL_TNT_PROTECTION_END_STONE_BLAST, 12f);
// on 1.8.8 it has to be around 69, on 1.20 and 1.18 it works fine with 12 (tested)
yml.addDefault(ConfigPath.GENERAL_TNT_PROTECTION_END_STONE_BLAST, BedWars.nms.getVersion() == 0 ? 69f : 12f);
yml.addDefault(ConfigPath.GENERAL_TNT_PROTECTION_GLASS_BLAST, 300f);
yml.addDefault(ConfigPath.GENERAL_TNT_RAY_BLOCKED_BY_GLASS, true);

Expand Down Expand Up @@ -382,6 +383,7 @@ public MainConfig(Plugin plugin, String name) {
try {
Bukkit.spigot().getConfig().save("spigot.yml");
} catch (IOException e) {
//noinspection CallToPrintStackTrace
e.printStackTrace();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class MetricsManager {
private final Metrics metrics;

private MetricsManager(BedWars plugin) {
metrics = new Metrics(plugin, 97320);
metrics = new Metrics(plugin, 1885);

// base metrics
metrics.addCustomChart(new SimplePie("server_type", () -> BedWars.getServerType().toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public SidebarLine normalizeTitle(@Nullable List<String> titleArray) {
for (String line : lineArray) {
// convert old placeholders
line = line.replace("{server_ip}", "{serverIp}");
String scoreLine = null;

// generic team placeholder {team}
if (null != arena) {
Expand All @@ -148,9 +149,14 @@ public SidebarLine normalizeTitle(@Nullable List<String> titleArray) {
line = genericTeamFormat
.replace("{TeamLetter}", teamLetter)
.replace("{TeamColor}", team.getColor().chat().toString())
.replace("{TeamName}", teamName)
.replace("{TeamStatus}", "{Team" + team.getName() + "Status}");
.replace("{TeamName}", teamName);

if (line.contains("{TeamStatus}") && getAPI().getVersionSupport().getVersion() >= 10) {
line = line.replace("{TeamStatus}", "");
scoreLine = "{Team" + team.getName() + "Status}";
} else {
line = line.replace("{TeamStatus}", "{Team" + team.getName() + "Status}");
}
} else {
// skip line
continue;
Expand Down Expand Up @@ -223,12 +229,7 @@ public SidebarLine normalizeTitle(@Nullable List<String> titleArray) {
if (divided.length > 1) {
sidebarLine = normalizeTitle(Arrays.asList(divided));
} else {
sidebarLine = new SidebarLine() {
@Override
public @NotNull String getLine() {
return finalTemp;
}
};
sidebarLine = new BwSidebarLine(finalTemp, scoreLine);
}

lines.add(sidebarLine);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.andrei1058.bedwars.sidebar;

import com.andrei1058.spigot.sidebar.ScoredLine;
import com.andrei1058.spigot.sidebar.SidebarLine;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class BwSidebarLine extends SidebarLine implements ScoredLine {

public final String content;
public final String score;

public BwSidebarLine(String content, @Nullable String score) {
this.content = content;
this.score = score == null ? "" : score;
}
@Override
public String getScore() {
return score;
}

@Override
public @NotNull String getLine() {
return content;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static boolean init(JavaPlugin plugin) {
}
Bukkit.getScheduler().runTaskTimer(plugin, new RefreshPlaceholdersTask(), 1L, placeholdersRefreshInterval);
}
MetricsManager.appendPie("sb_placeholder_refresh_interval", () -> String.valueOf(playerListRefreshInterval));
MetricsManager.appendPie("sb_placeholder_refresh_interval", () -> String.valueOf(placeholdersRefreshInterval));

int titleRefreshInterval = config.getInt(ConfigPath.SB_CONFIG_SIDEBAR_TITLE_REFRESH_INTERVAL);
if (titleRefreshInterval < 1) {
Expand Down
Loading