Skip to content

Commit

Permalink
Release 0.11.2 (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowdashlabs authored Feb 24, 2023
2 parents d123d10 + 478ca84 commit 69b5ceb
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 53 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish_to_nexus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3.1.0
- name: Set up JDK 18
- uses: actions/checkout@v3.3.0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 18
distribution: adopt
java-version: 17
- name: Build with Gradle
run: ./gradlew --build-cache build
- name: Test with Gradle
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3.1.0
- name: Set up JDK 18
- uses: actions/checkout@v3.3.0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 18
distribution: adopt
java-version: 17
- name: Build with Gradle
run: ./gradlew --build-cache build
- name: Test with Gradle
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Remove config
/config/

gradle.properties

.gradle
**/build/
!src/**/build/
Expand Down
20 changes: 15 additions & 5 deletions BloodNight-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ plugins {

dependencies {
implementation(project(":BloodNight-api"))
implementation("de.eldoria", "eldo-util", "1.10.2")
implementation("net.kyori", "adventure-platform-bukkit", "4.1.2")
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.9.1")
implementation("de.eldoria", "eldo-util", "1.10.2-SNAPSHOT")
implementation("net.kyori", "adventure-platform-bukkit", "4.2.0")
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.9.2")
testImplementation("junit", "junit", "4.13.2")
testImplementation("org.mockito", "mockito-core", "4.8.0")
compileOnly("io.lumine", "Mythic-Dist", "5.1.4")
testImplementation("org.mockito", "mockito-core", "4.9.0")
compileOnly("io.lumine", "Mythic-Dist", "5.2.1")
compileOnly("me.clip", "placeholderapi", "2.11.2")
compileOnly("com.onarandombox.multiversecore", "Multiverse-Core", "4.3.1")
compileOnly("se.hyperver.hyperverse", "Core", "0.10.0")
Expand Down Expand Up @@ -80,4 +80,14 @@ tasks {
build{
dependsOn(shadowJar)
}

register<Copy>("copyToServer") {
val path = project.property("targetDir") ?: "";
if (path.toString().isEmpty()) {
println("targetDir is not set in gradle properties")
return@register
}
from(shadowJar)
destinationDir = File(path.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private void sendMobListPage(World world, CommandSender
localizer().getMessage("manageMob.title",
Replacement.create("TYPE", mobGroup.getKey()),
Replacement.create("WORLD", world.getName())),
"/bloodNight manageMob " + mobGroup.getKey() + " " + ArgumentUtils.escapeWorldName(world) + " page {page}");
"/bloodnight manageMob " + mobGroup.getKey() + " " + ArgumentUtils.escapeWorldName(world) + " page {page}");

bukkitAudiences.sender(sender).sendMessage(Identity.nil(), component);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private void sendWorldPage(World world, CommandSender sender, int p) {
}
return builder.build();
}, localizer().getMessage("nightSelection.title.menu"),
"/bloodNight nightSelection " + ArgumentUtils.escapeWorldName(world) + " page {page}");
"/bloodnight nightSelection " + ArgumentUtils.escapeWorldName(world) + " page {page}");
bukkitAudiences.sender(sender).sendMessage(page);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void sendWorldPage(World world, CommandSender sender, int page) {
.build();
},
localizer().getMessage("manageWorlds.title"),
"/bloodNight manageWorlds " + ArgumentUtils.escapeWorldName(world) + " page {page}");
"/bloodnight manageWorlds " + ArgumentUtils.escapeWorldName(world) + " page {page}");

bukkitAudiences.sender(sender).sendMessage(Identity.nil(), component);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.Setter;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -31,6 +32,7 @@ public class GeneralSettings implements ConfigurationSerializable {
private boolean spawnerDropSuppression = true;
private boolean ignoreSpawnerMobs = false;
private List<String> blockedCommands = new ArrayList<>();
private List<EntityType> noVanillaDropIncrease = new ArrayList<>();

public GeneralSettings(Map<String, Object> objectMap) {
TypeResolvingMap map = SerializationUtil.mapOf(objectMap);
Expand All @@ -39,6 +41,7 @@ public GeneralSettings(Map<String, Object> objectMap) {
broadcastLevel = map.getValueOrDefault("broadcastLevel", broadcastLevel, BroadcastLevel.class);
broadcastMethod = map.getValueOrDefault("broadcastMethod", broadcastMethod, BroadcastMethod.class);
messageMethod = map.getValueOrDefault("messageMethod", messageMethod, BroadcastMethod.class);
noVanillaDropIncrease = map.getValueOrDefault("noVanillaDropIncrease", noVanillaDropIncrease, EntityType.class);
mobTick = map.getValueOrDefault("mobTick", mobTick);
joinWorldWarning = map.getValueOrDefault("joinWorldWarning", joinWorldWarning);
blindness = map.getValueOrDefault("blindness", blindness);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public class PlayerDeathActions extends DeathActions {
* Should support the {@code {player}} placeholder.
*/
private List<String> deathCommands = new ArrayList<>();
/**
* Commands which will be executed when a player respawns after death.
* <p>
* Should support the {@code {player}} placeholder.
*/
private List<String> respawnCommands = new ArrayList<>();
/**
* Probability of the player to lose and not drop its inventory.
*/
Expand All @@ -36,6 +42,7 @@ public PlayerDeathActions(Map<String, Object> objectMap) {
super(objectMap);
TypeResolvingMap map = SerializationUtil.mapOf(objectMap);
deathCommands = map.getValueOrDefault("deathCommands", deathCommands);
respawnCommands = map.getValueOrDefault("respawnCommands", respawnCommands);
loseInvProbability = map.getValueOrDefault("loseInvProbability", loseInvProbability);
loseExpProbability = map.getValueOrDefault("loseExpProbability", loseExpProbability);
respawnEffects = map.getMap("respawnEffects", (key, potionEffectSettings) -> PotionEffectType.getByName(key));
Expand All @@ -48,6 +55,7 @@ public PlayerDeathActions() {
public @NotNull Map<String, Object> serialize() {
return SerializationUtil.newBuilder(super.serialize())
.add("deathCommands", deathCommands)
.add("respawnCommands", respawnCommands)
.add("loseInvProbability", loseInvProbability)
.add("loseExpProbability", loseExpProbability)
.addMap("respawnEffects", respawnEffects,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@Getter
@SerializableAs("bloodNightDrop")
public class Drop implements ConfigurationSerializable {
private static final NamespacedKey WEIGHT_KEY = BloodNight.getNamespacedKey("dropWeight");
private static final NamespacedKey WEIGHT_KEY = BloodNight.getNamespacedKey("dropweight");
private final ItemStack item;
private final int weight;

Expand Down Expand Up @@ -69,23 +69,19 @@ public static ItemStack removeWeight(ItemStack item) {
Pattern weight = getRegexWeight();
ItemMeta itemMeta = item.hasItemMeta() ? item.getItemMeta() : Bukkit.getItemFactory().getItemMeta(item.getType());
List<String> lore = itemMeta.hasLore() ? itemMeta.getLore() : new ArrayList<>();
if (lore.isEmpty()) {
return item;
}
Matcher matcher = weight.matcher(lore.get(lore.size() - 1));
if (matcher.find()) {
lore.remove(lore.size() - 1);
} else {
return item;
if (!lore.isEmpty()) {
Matcher matcher = weight.matcher(lore.get(lore.size() - 1));
if (matcher.find()) {
lore.remove(lore.size() - 1);
}
}
ItemStack newItem = item.clone();
itemMeta.setLore(lore);
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
var container = itemMeta.getPersistentDataContainer();
if (container.has(WEIGHT_KEY, PersistentDataType.INTEGER)) {
container.remove(WEIGHT_KEY);
}
newItem.setItemMeta(itemMeta);
return newItem;
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
return item;
}

public static int getWeightFromItemStack(ItemStack item) {
Expand Down Expand Up @@ -133,6 +129,12 @@ public ItemStack getWeightedItem() {
}

public ItemStack getItem() {
ItemMeta itemMeta = item.hasItemMeta() ? item.getItemMeta() : Bukkit.getItemFactory().getItemMeta(item.getType());
var container = itemMeta.getPersistentDataContainer();
if (container.has(WEIGHT_KEY, PersistentDataType.INTEGER)) {
container.remove(WEIGHT_KEY);
}
item.setItemMeta(itemMeta);
return item.clone();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public List<ItemStack> getDrops(List<Drop> totalDrops, int minDrops, int dropAmo
for (Drop drop : totalDrops) {
currentWeight += drop.getWeight();
if (currentWeight < goal) continue;
result.add(new ItemStack(drop.getItem().clone()));
result.add(drop.getItem());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void lateInit() {
}

private void registerListener() {
nightManager = new NightManager(configuration);
nightManager = new NightManager(this, configuration);
nightManager.runTaskTimer(this, 5, 1);
mobManager = new MobManager(nightManager, configuration);
inventoryListener = new InventoryListener(configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,20 @@ public void onEntityKill(EntityDeathEvent event) {
} else {
BloodNight.logger().config("No mob found for " + specialMob.get() + " in group ");
}
} else {
} else if(!configuration.getGeneralSettings().getNoVanillaDropIncrease().contains(entity.getType())){
// If it is a vanilla mob just increase the drops.
VanillaDropMode dropMode = vanillaMobSettings.getVanillaDropMode();
switch (dropMode) {
case VANILLA:
for (ItemStack drop : event.getDrops()) {
if (isPickedUp(drop)) continue;
drop.setAmount((int) (drop.getAmount() * vanillaMobSettings.getDropMultiplier()));
drop.setAmount(Math.min(drop.getMaxStackSize(), (int) (drop.getAmount() * vanillaMobSettings.getDropMultiplier())));
}
break;
case COMBINE:
for (ItemStack drop : event.getDrops()) {
if (isPickedUp(drop)) continue;
drop.setAmount((int) (drop.getAmount() * vanillaMobSettings.getDropMultiplier()));
drop.setAmount(Math.min(drop.getMaxStackSize(), (int) (drop.getAmount() * vanillaMobSettings.getDropMultiplier())));
}
event.getDrops().addAll(mobSettings.getDrops(vanillaMobSettings.getExtraDrops()));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.*;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
Expand All @@ -41,6 +42,7 @@

public class NightManager extends BukkitRunnable implements Listener {

private final Plugin plugin;
private final Configuration configuration;
/**
* A set containing all world where a blood night is active.
Expand All @@ -60,7 +62,8 @@ public class NightManager extends BukkitRunnable implements Listener {

private boolean initialized = false;

public NightManager(Configuration configuration) {
public NightManager(Plugin plugin, Configuration configuration) {
this.plugin = plugin;
this.configuration = configuration;
this.localizer = ILocalizer.getPluginLocalizer(BloodNight.class);
this.messageSender = MessageSender.getPluginMessageSender(BloodNight.class);
Expand Down Expand Up @@ -297,6 +300,7 @@ public void onBedEnter(PlayerBedEnterEvent event) {

@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
if (!isBloodNightActive(event.getEntity().getWorld())) return;
PlayerDeathActions actions = configuration.getWorldSettings(event.getEntity().getWorld())
.getDeathActionSettings()
.getPlayerDeathActions();
Expand All @@ -311,25 +315,32 @@ public void onPlayerDeath(PlayerDeathEvent event) {
event.setDroppedExp(0);
}

for (String deathCommand : actions.getDeathCommands()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), deathCommand.replace("{player}", event.getEntity().getName()));
}
EldoUtilities.getDelayedActions().schedule(() -> {
for (String deathCommand : actions.getDeathCommands()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), deathCommand.replace("{player}", event.getEntity().getName()));
}
}, 1);
}

@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if (!isBloodNightActive(player.getWorld())) {
return;
}

PlayerDeathActions actions = configuration.getWorldSettings(player.getWorld())
.getDeathActionSettings()
.getPlayerDeathActions();
if (!isBloodNightActive(player.getWorld()) || event.isBedSpawn() || event.isAnchorSpawn()) {
return;
}

EldoUtilities.getDelayedActions().schedule(() -> {
for (PotionEffectSettings value : actions.getRespawnEffects().values()) {
player.addPotionEffect(new PotionEffect(value.getEffectType(), value.getDuration() * 20, 1, false));
}

for (String respawnCommand : actions.getRespawnCommands()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), respawnCommand.replace("{player}", event.getPlayer().getName()));
}
}, 1);
}

Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import de.chojo.PublishData

plugins {
java
id("de.chojo.publishdata") version "1.0.8"
id("de.chojo.publishdata") version "1.0.9"
}

group = "de.eldoria"
version = "0.11.1"
version = "0.11.2"

subprojects {
apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ repositories {

dependencies {
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
compileOnly("org.projectlombok:lombok:1.18.24")
compileOnly("org.jetbrains:annotations:23.0.0")
annotationProcessor("org.projectlombok:lombok:1.18.24")
compileOnly("org.projectlombok:lombok:1.18.26")
compileOnly("org.jetbrains:annotations:24.0.0")
annotationProcessor("org.projectlombok:lombok:1.18.26")
}

version = rootProject.version
Expand All @@ -30,7 +30,7 @@ java {
withSourcesJar()
withJavadocJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(16))
languageVersion.set(JavaLanguageVersion.of(17))
}
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 69b5ceb

Please sign in to comment.