Skip to content

Commit

Permalink
Merge pull request #121 from Plugily-Projects/development
Browse files Browse the repository at this point in the history
4.6.1
  • Loading branch information
Tigerpanzer02 authored Aug 4, 2021
2 parents 7e7791b + a47fc3a commit 9e72f18
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ deploy webhooks to print changelog successfully

That's all, matcher will stop when detects next line started with `###` match

### 4.6.1 (03.08.2021 - 04.08.2021)
* Fixed NoSuchFieldError as COMMAND spawn reason was added in 1.17
* Fixed 1.17.1 startup issue

### 4.6.0 (15.04.2021 - 03.08.2021)
* Added forcestart item
* Added 1.17 support
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<groupId>plugily.projects</groupId>
<artifactId>villagedefense</artifactId>
<version>4.6.0</version>
<version>4.6.1</version>
<name>VillageDefense</name>

<properties>
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/plugily/projects/villagedefense/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,6 @@ private boolean validateIfPluginShouldStart() {
getServer().getPluginManager().disablePlugin(this);
return false;
}
if(ServerVersion.Version.isCurrentEqual(ServerVersion.Version.v1_17_R1)) {
MessageUtils.thisVersionIsNotSupported();
Debugger.sendConsoleMsg("&cYour server version is not supported by Village Defense!");
Debugger.sendConsoleMsg("&cSadly, we must shut off. Maybe you consider changing your server version?");
Debugger.sendConsoleMsg("&cWe only support the latest build of 1.17! Use a newer version!");
forceDisable = true;
getServer().getPluginManager().disablePlugin(this);
return false;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,11 @@ public List<Location> getVillagerSpawns() {
}

public void addVillagerSpawn(Location location) {
spawnPoints.getOrDefault(SpawnPoint.VILLAGER, new ArrayList<>()).add(location);
getVillagerSpawns().add(location);
}

public void addZombieSpawn(Location location) {
spawnPoints.getOrDefault(SpawnPoint.ZOMBIE, new ArrayList<>()).add(location);
getZombieSpawns().add(location);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,13 @@ public static void startWave(@NotNull Arena arena) {
}
VersionUtils.sendTitles(player, title, subTitle, fadeIn, stay, fadeOut);
plugin.getRewardsHandler().performReward(player, arena, Reward.RewardType.START_WAVE);

String msg = plugin.getChatManager().formatMessage(arena, plugin.getChatManager().colorMessage(Messages.WAVE_STARTED), wave);
if (!msg.isEmpty()) {
player.sendMessage(msg);
}
}

plugin.getChatManager().broadcastMessage(arena, plugin.getChatManager().formatMessage(arena, plugin.getChatManager().colorMessage(Messages.WAVE_STARTED), wave));
Debugger.debug("[{0}] Wave start event finished took {1}ms", arena.getId(), System.currentTimeMillis() - start);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static void bringDeathPlayersBack(Arena arena) {
}

User user = plugin.getUserManager().getUser(player);
if(!plugin.getConfigPreferences().getOption(ConfigPreferences.Option.INGAME_JOIN_RESPAWN) && user.isPermanentSpectator()) {
if(user.isPermanentSpectator() && !plugin.getConfigPreferences().getOption(ConfigPreferences.Option.INGAME_JOIN_RESPAWN)) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ default int getPriority() {

@Override
default int compareTo(EnemySpawner spawner) {
int compareValue = Integer.compare(this.getPriority(), spawner.getPriority());
int compareValue = Integer.compare(getPriority(), spawner.getPriority());
if (compareValue == 0) {
compareValue = this.getName().compareTo(spawner.getName());
return getName().compareTo(spawner.getName());
}
return compareValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package plugily.projects.villagedefense.arena.states;

import org.bukkit.entity.Player;
import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
import plugily.projects.villagedefense.ConfigPreferences;
import plugily.projects.villagedefense.Main;
import plugily.projects.villagedefense.api.StatsStorage;
import plugily.projects.villagedefense.arena.Arena;
Expand Down Expand Up @@ -51,7 +49,7 @@ public void handleCall(Arena arena) {
int timer = arena.getTimer();

if(timer <= 0) {
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1) && plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BOSSBAR_ENABLED)) {
if(arena.getGameBar() != null) {
arena.getGameBar().setTitle(plugin.getChatManager().colorMessage(Messages.BOSSBAR_GAME_ENDED));
}

Expand All @@ -67,8 +65,12 @@ public void handleCall(Arena arena) {
user.setStat(StatsStorage.StatisticType.ORBS, 0);
arena.getScoreboardManager().removeScoreboard(user);
plugin.getRewardsHandler().performReward(player, arena, Reward.RewardType.END_GAME);

String msg = Messages.COMMANDS_TELEPORTED_TO_THE_LOBBY.getMessage();
if (!msg.isEmpty()) {
player.sendMessage(plugin.getChatManager().getPrefix() + msg);
}
}
plugin.getChatManager().broadcast(arena, Messages.COMMANDS_TELEPORTED_TO_THE_LOBBY);

arena.setArenaState(ArenaState.RESTARTING);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package plugily.projects.villagedefense.arena.states;

import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
import plugily.projects.villagedefense.ConfigPreferences;
import plugily.projects.villagedefense.Main;
import plugily.projects.villagedefense.arena.Arena;
import plugily.projects.villagedefense.arena.ArenaManager;
Expand Down Expand Up @@ -77,15 +75,15 @@ public void handleCall(Arena arena) {

private void bossBarUpdate(Arena arena) {
if(arena.getOption(ArenaOption.BAR_TOGGLE_VALUE) > 5) {
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1) && plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BOSSBAR_ENABLED)) {
if(arena.getGameBar() != null) {
arena.getGameBar().setTitle(plugin.getChatManager().colorMessage(Messages.BOSSBAR_IN_GAME_WAVE).replace("%wave%", Integer.toString(arena.getWave())));
}
arena.addOptionValue(ArenaOption.BAR_TOGGLE_VALUE, 1);
if(arena.getOption(ArenaOption.BAR_TOGGLE_VALUE) > 10) {
arena.setOptionValue(ArenaOption.BAR_TOGGLE_VALUE, 0);
}
} else {
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1) && plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BOSSBAR_ENABLED)) {
if(arena.getGameBar() != null) {
arena.getGameBar().setTitle(plugin.getChatManager().colorMessage(Messages.BOSSBAR_IN_GAME_INFO).replace("%wave%", Integer.toString(arena.getWave())));
}
arena.addOptionValue(ArenaOption.BAR_TOGGLE_VALUE, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
import plugily.projects.villagedefense.ConfigPreferences;
import plugily.projects.villagedefense.Main;
Expand Down Expand Up @@ -64,7 +63,7 @@ public void handleCall(Arena arena) {
ArenaManager.joinAttempt(player, ArenaRegistry.getArenas().get(ArenaRegistry.getBungeeArena()));
}
}
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1) && plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BOSSBAR_ENABLED)) {
if(arena.getGameBar() != null) {
arena.getGameBar().setTitle(plugin.getChatManager().colorMessage(Messages.BOSSBAR_WAITING_FOR_PLAYERS));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
import plugily.projects.villagedefense.ConfigPreferences;
import plugily.projects.villagedefense.Main;
import plugily.projects.villagedefense.api.StatsStorage;
import plugily.projects.villagedefense.api.event.game.VillageGameStartEvent;
Expand All @@ -48,23 +46,25 @@ public void init(Main plugin) {
@Override
public void handleCall(Arena arena) {
double startWaiting = plugin.getConfig().getDouble("Starting-Waiting-Time", 60);
boolean bossBarEnabled = ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1) && plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BOSSBAR_ENABLED);
int timer = arena.getTimer();

if(bossBarEnabled) {
if(arena.getGameBar() != null) {
arena.getGameBar().setTitle(plugin.getChatManager().colorMessage(Messages.BOSSBAR_STARTING_IN).replace("%time%", Integer.toString(timer)));
arena.getGameBar().setProgress(timer / startWaiting);
}
for(Player player : arena.getPlayers()) {
player.setExp((float) (timer / startWaiting));
player.setLevel(timer);
}
if(!arena.isForceStart() && arena.getPlayers().size() < arena.getMinimumPlayers()) {
if(bossBarEnabled) {

int minPlayers = arena.getMinimumPlayers();

if(!arena.isForceStart() && arena.getPlayers().size() < minPlayers) {
if(arena.getGameBar() != null) {
arena.getGameBar().setTitle(plugin.getChatManager().colorMessage(Messages.BOSSBAR_WAITING_FOR_PLAYERS));
arena.getGameBar().setProgress(1.0);
}
plugin.getChatManager().broadcastMessage(arena, plugin.getChatManager().formatMessage(arena, plugin.getChatManager().colorMessage(Messages.LOBBY_MESSAGES_WAITING_FOR_PLAYERS), arena.getMinimumPlayers()));
plugin.getChatManager().broadcastMessage(arena, plugin.getChatManager().formatMessage(arena, plugin.getChatManager().colorMessage(Messages.LOBBY_MESSAGES_WAITING_FOR_PLAYERS), minPlayers));
arena.setArenaState(ArenaState.WAITING_FOR_PLAYERS);
Bukkit.getPluginManager().callEvent(new VillageGameStartEvent(arena));
arena.setTimer(15);
Expand All @@ -78,24 +78,28 @@ public void handleCall(Arena arena) {
arena.spawnVillagers();
Bukkit.getPluginManager().callEvent(new VillageGameStartEvent(arena));
arena.setArenaState(ArenaState.IN_GAME);
if(bossBarEnabled) {
if(arena.getGameBar() != null) {
arena.getGameBar().setProgress(1.0);
}
arena.setTimer(5);

org.bukkit.Location arenaLoc = arena.getStartLocation();
int orbsStartingAmount = plugin.getConfig().getInt("Orbs-Starting-Amount", 20);

for(Player player : arena.getPlayers()) {
player.teleport(arena.getStartLocation());
player.teleport(arenaLoc);
player.setExp(0);
player.setLevel(0);
player.getInventory().clear();
player.setGameMode(GameMode.SURVIVAL);
User user = plugin.getUserManager().getUser(player);
user.setStat(StatsStorage.StatisticType.ORBS, plugin.getConfig().getInt("Orbs-Starting-Amount", 20));
user.setStat(StatsStorage.StatisticType.ORBS, orbsStartingAmount);
user.getKit().giveKitItems(player);
player.updateInventory();
plugin.getUserManager().addExperience(player, 10);
arena.setTimer(plugin.getConfig().getInt("Cooldown-Before-Next-Wave", 25));
player.sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage(Messages.LOBBY_MESSAGES_GAME_STARTED));
}
arena.setTimer(plugin.getConfig().getInt("Cooldown-Before-Next-Wave", 25));
arena.setFighting(false);
}
if(arena.isForceStart()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package plugily.projects.villagedefense.arena.states;

import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
import plugily.projects.villagedefense.ConfigPreferences;
import plugily.projects.villagedefense.Main;
import plugily.projects.villagedefense.arena.Arena;
import plugily.projects.villagedefense.arena.ArenaState;
Expand Down Expand Up @@ -50,7 +48,7 @@ public void handleCall(Arena arena) {
return;
}
} else {
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1) && plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BOSSBAR_ENABLED)) {
if(arena.getGameBar() != null) {
arena.getGameBar().setTitle(plugin.getChatManager().colorMessage(Messages.BOSSBAR_WAITING_FOR_PLAYERS));
}
plugin.getChatManager().broadcast(arena, Messages.LOBBY_MESSAGES_ENOUGH_PLAYERS_TO_START);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerExpChangeEvent;
import org.bukkit.inventory.ItemStack;

import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
import plugily.projects.commonsbox.minecraft.compat.events.api.CBPlayerInteractEntityEvent;
import plugily.projects.commonsbox.minecraft.compat.events.api.CBPlayerInteractEvent;
Expand Down Expand Up @@ -101,10 +103,15 @@ public Events(Main plugin) {

@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM
|| (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17_R1) && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.COMMAND)) {
return;
}

for(Arena arena : ArenaRegistry.getArenas()) {
Location startLoc = arena.getStartLocation();

if(startLoc != null && event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.CUSTOM && event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.COMMAND && event.getEntity().getWorld().equals(startLoc.getWorld())
if(startLoc != null && event.getEntity().getWorld().equals(startLoc.getWorld())
&& event.getEntity().getLocation().distance(startLoc) < 150) {
event.setCancelled(true);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,13 @@ public void broadcastMessage(Arena arena, String message) {

public String formatMessage(Arena arena, String message, int integer) {
String returnString = message;
returnString = StringUtils.replace(returnString, "%ARENANAME%", arena.getMapName());
returnString = StringUtils.replace(returnString, "%NUMBER%", Integer.toString(integer));
returnString = colorRawMessage(formatPlaceholders(returnString, arena));
return returnString;
}

public String formatMessage(Arena arena, String message, Player player) {
String returnString = message;
returnString = StringUtils.replace(returnString, "%ARENANAME%", arena.getMapName());
returnString = StringUtils.replace(returnString, "%PLAYER%", player.getName());
returnString = colorRawMessage(formatPlaceholders(returnString, arena));
if(plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
Expand Down

0 comments on commit 9e72f18

Please sign in to comment.