mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixed Auto-Disenchanter exploit using mcMMO's "super ability" tools
This commit is contained in:
parent
0262830ef5
commit
4b43cd6eaa
@ -43,6 +43,7 @@
|
||||
* Fixed #3177
|
||||
* Fixed unbreakable Flint and Steel still being damaged in Ignition Chambers
|
||||
* Fixed #2677
|
||||
* Fixed Auto-Disenchanter exploit using mcMMO's "super ability" tools
|
||||
|
||||
## Release Candidate 26 (20 Jul 2021)
|
||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#26
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.inventory.meta.Repairable;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.AutoDisenchantEvent;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
@ -79,9 +80,8 @@ public class AutoDisenchanter extends AbstractEnchantmentMachine {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ParametersAreNonnullByDefault
|
||||
private MachineRecipe disenchant(BlockMenu menu, ItemStack item, ItemStack book) {
|
||||
private @Nullable MachineRecipe disenchant(BlockMenu menu, ItemStack item, ItemStack book) {
|
||||
Map<Enchantment, Integer> enchantments = new HashMap<>();
|
||||
|
||||
// Find enchantments
|
||||
|
@ -11,14 +11,18 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import dev.lone.itemsadder.api.ItemsAdder;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager;
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter;
|
||||
|
||||
import dev.lone.itemsadder.api.ItemsAdder;
|
||||
|
||||
/**
|
||||
* This Service holds all interactions and hooks with third-party {@link Plugin Plugins}
|
||||
@ -223,8 +227,7 @@ public class IntegrationsManager {
|
||||
*
|
||||
* @return Our instanceof of the {@link ProtectionManager}
|
||||
*/
|
||||
@Nonnull
|
||||
public ProtectionManager getProtectionManager() {
|
||||
public @Nonnull ProtectionManager getProtectionManager() {
|
||||
return protectionManager;
|
||||
}
|
||||
|
||||
@ -264,6 +267,25 @@ public class IntegrationsManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes any temporary enchantments from the given {@link ItemStack}.
|
||||
* Some plugins apply enchantments for a short amount of time and remove it later.
|
||||
* We don't want these items to be exploited using an {@link AutoDisenchanter} for example,
|
||||
* so we want to be able to strip those temporary enchantments in advance.
|
||||
*
|
||||
* @param item
|
||||
* The {@link ItemStack}
|
||||
*/
|
||||
public void removeTemporaryEnchantments(@Nonnull ItemStack item) {
|
||||
if (isMcMMOInstalled) {
|
||||
try {
|
||||
SkillUtils.removeAbilityBuff(item);
|
||||
} catch (Exception | LinkageError x) {
|
||||
logError("mcMMO", x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlaceholderAPIInstalled() {
|
||||
return isPlaceholderAPIInstalled;
|
||||
}
|
||||
|
@ -9,10 +9,13 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.AutoDisenchantEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
@ -52,6 +55,15 @@ class McMMOIntegration implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onAutoDisenchant(AutoDisenchantEvent e) {
|
||||
try {
|
||||
SkillUtils.removeAbilityBuff(e.getItem());
|
||||
} catch (Exception | LinkageError x) {
|
||||
SlimefunPlugin.getIntegrations().logError("mcMMO", x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks if an {@link ItemStack} can be salvaged or not.
|
||||
* We basically don't want players to salvage any {@link SlimefunItem} unless
|
||||
|
Loading…
Reference in New Issue
Block a user