Skip to content

Commit

Permalink
v1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
byteful committed Jun 17, 2023
1 parent 0fa4ab4 commit 48007e1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repositories {
dependencies {
implementation 'de.tr7zw:item-nbt-api:2.11.2'
implementation 'com.github.Redempt:RedLib:6.5.2'
implementation 'com.github.cryptomorin:XSeries:9.3.1'
implementation 'com.github.cryptomorin:XSeries:9.4.0'
implementation 'com.github.Revxrsal.Lamp:common:3.1.5'
implementation 'com.github.Revxrsal.Lamp:bukkit:3.1.5'
implementation 'com.github.Sven65:Item-Names:1.0.0'
Expand All @@ -48,7 +48,7 @@ dependencies {
}

group = 'me.byteful.plugin'
version = '1.3.3'
version = '1.3.4'
description = 'LevelTools'
java.sourceCompatibility = JavaVersion.VERSION_1_8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import redempt.redlib.blockdata.DataBlock;

import java.util.Objects;
import java.util.stream.Stream;
import java.util.Set;
import java.util.stream.Collectors;

public class BlockEventListener extends XPListener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
Expand All @@ -35,16 +36,16 @@ public void onBlockBreak(BlockBreakEvent e) {
}
}

final String type = LevelToolsPlugin.getInstance().getConfig().getString("block_list_type", "blacklist");
final Stream<Material> stream = LevelToolsPlugin.getInstance().getConfig().getStringList("block_list").stream().map(Material::getMaterial).filter(Objects::nonNull);
final String type = LevelToolsPlugin.getInstance().getConfig().getString("block_list_type", "blacklist");
final Set<Material> blocks = LevelToolsPlugin.getInstance().getConfig().getStringList("block_list").stream().map(Material::getMaterial).filter(Objects::nonNull).collect(Collectors.toSet());

if (type != null && type.equalsIgnoreCase("whitelist") && stream.noneMatch(material -> block.getType() == material)) {
return;
}
if (type != null && type.equalsIgnoreCase("whitelist") && !blocks.contains(block.getType())) {
return;
}

if (type != null && type.equalsIgnoreCase("blacklist") && stream.anyMatch(material -> block.getType() == material)) {
return;
}
if (type != null && type.equalsIgnoreCase("blacklist") && blocks.contains(block.getType())) {
return;
}

if (!LevelToolsUtil.isAxe(hand.getType()) && !LevelToolsUtil.isPickaxe(hand.getType()) && !LevelToolsUtil.isShovel(hand.getType())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import org.bukkit.inventory.ItemStack;

import java.util.Objects;
import java.util.stream.Stream;
import java.util.Set;
import java.util.stream.Collectors;

public class EntityEventListener extends XPListener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
Expand All @@ -23,22 +24,22 @@ public void onEntityKillEntity(EntityDeathEvent e) {

final ItemStack hand = LevelToolsUtil.getHand(killer);

final String ltype = LevelToolsPlugin.getInstance().getConfig().getString("entity_list_type", "blacklist");
final Stream<EntityType> stream = LevelToolsPlugin.getInstance().getConfig().getStringList("entity_list").stream().map(str -> {
try {
return EntityType.valueOf(str);
} catch (Exception ignored) {
return null;
final String ltype = LevelToolsPlugin.getInstance().getConfig().getString("entity_list_type", "blacklist");
final Set<EntityType> entities = LevelToolsPlugin.getInstance().getConfig().getStringList("entity_list").stream().map(str -> {
try {
return EntityType.valueOf(str);
} catch (Exception ignored) {
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toSet());

if (ltype != null && ltype.equalsIgnoreCase("whitelist") && !entities.contains(e.getEntityType())) {
return;
}
}).filter(Objects::nonNull);

if (ltype != null && ltype.equalsIgnoreCase("whitelist") && stream.noneMatch(type -> e.getEntityType() == type)) {
return;
}

if (ltype != null && ltype.equalsIgnoreCase("blacklist") && stream.anyMatch(type -> e.getEntityType() == type)) {
return;
}
if (ltype != null && ltype.equalsIgnoreCase("blacklist") && entities.contains(e.getEntityType())) {
return;
}

if (!LevelToolsUtil.isSword(hand.getType()) && !LevelToolsUtil.isProjectileShooter(hand.getType())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ protected void handle(LevelToolsItem tool, Player player, double modifier) {
double newXp = LevelToolsUtil.round(tool.getXp() + modifier, 1);

final LevelToolsXPIncreaseEvent xpEvent = new LevelToolsXPIncreaseEvent(tool, player, newXp, false);

Bukkit.getPluginManager().callEvent(xpEvent);

if (xpEvent.isCancelled()) {
Expand All @@ -53,6 +52,7 @@ protected void handle(LevelToolsItem tool, Player player, double modifier) {
}

final LevelToolsLevelIncreaseEvent levelEvent = new LevelToolsLevelIncreaseEvent(tool, player, newLevel, false);
Bukkit.getPluginManager().callEvent(levelEvent);

if (levelEvent.isCancelled()) {
return;
Expand Down

0 comments on commit 48007e1

Please sign in to comment.