mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 19:55:48 +00:00
Did the requested changes
This commit is contained in:
parent
207cb35dda
commit
f1aa8a08d0
@ -7,8 +7,11 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -63,8 +66,10 @@ public class ClimbingPick extends SimpleSlimefunItem<ItemUseHandler> implements
|
|||||||
materialSpeedsDef.put(Material.DIORITE.name(), 0.6D);
|
materialSpeedsDef.put(Material.DIORITE.name(), 0.6D);
|
||||||
materialSpeedsDef.put(Material.GRANITE.name(), 0.6D);
|
materialSpeedsDef.put(Material.GRANITE.name(), 0.6D);
|
||||||
materialSpeedsDef.put(Material.ANDESITE.name(), 0.6D);
|
materialSpeedsDef.put(Material.ANDESITE.name(), 0.6D);
|
||||||
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) materialSpeedsDef.put(Material.BLACKSTONE.name(), 0.6D);
|
|
||||||
materialSpeedsDef.put(Material.NETHERRACK.name(), 0.6D);
|
materialSpeedsDef.put(Material.NETHERRACK.name(), 0.6D);
|
||||||
|
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
|
||||||
|
materialSpeedsDef.put(Material.BLACKSTONE.name(), 0.6D);
|
||||||
|
}
|
||||||
|
|
||||||
addItemSetting(materialSpeeds);
|
addItemSetting(materialSpeeds);
|
||||||
}
|
}
|
||||||
@ -80,7 +85,8 @@ public class ClimbingPick extends SimpleSlimefunItem<ItemUseHandler> implements
|
|||||||
@Override
|
@Override
|
||||||
public ItemUseHandler getItemHandler() {
|
public ItemUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
if (e.getClickedBlock().isPresent()) {
|
if (!e.getClickedBlock().isPresent()) return;
|
||||||
|
|
||||||
Block block = e.getClickedBlock().get();
|
Block block = e.getClickedBlock().get();
|
||||||
ItemStack item = e.getItem();
|
ItemStack item = e.getItem();
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
@ -95,19 +101,26 @@ public class ClimbingPick extends SimpleSlimefunItem<ItemUseHandler> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
Material mat = block.getType();
|
Material mat = block.getType();
|
||||||
if (materialSpeeds.getValue().containsKey(mat.name())) {
|
Double launch = materialSpeeds.getValue().get(mat.name());
|
||||||
double launch = materialSpeeds.getValue().get(mat.name());
|
if (launch != null) {
|
||||||
if (item.getEnchantments().containsKey(Enchantment.DIG_SPEED)) {
|
Integer efficiencyLevel = item.getEnchantments().get(Enchantment.DIG_SPEED);
|
||||||
launch += (item.getEnchantmentLevel(Enchantment.DIG_SPEED) * 0.2);
|
if (efficiencyLevel != null){
|
||||||
|
launch += (efficiencyLevel * 0.2);
|
||||||
}
|
}
|
||||||
velocity = velocity.setY(velocity.getY() + launch);
|
velocity = velocity.setY(velocity.getY() + launch);
|
||||||
}
|
|
||||||
|
|
||||||
users.add(p.getUniqueId());
|
users.add(p.getUniqueId());
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance, () -> users.remove(p.getUniqueId()), 4L);
|
Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance, () -> users.remove(p.getUniqueId()), 4L);
|
||||||
|
}
|
||||||
|
|
||||||
ClimbingPickLaunchEvent event = new ClimbingPickLaunchEvent(p, velocity, item);
|
ClimbingPickLaunchEvent event = new ClimbingPickLaunchEvent(p, velocity, item);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
p.setVelocity(event.getVelocity());
|
||||||
|
p.playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 1F);
|
||||||
|
|
||||||
|
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||||
|
((ClimbingPick) SlimefunItem.getByItem(e.getItem())).damageItem(p, e.getItem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
||||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The special event listener for {@link ClimbingPick}.
|
|
||||||
* This is made like this to allow addons to add more materials to climbing pick.
|
|
||||||
*
|
|
||||||
* @author Linox
|
|
||||||
*
|
|
||||||
* @see ClimbingPick
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ClimbingPickListener implements Listener {
|
|
||||||
|
|
||||||
public ClimbingPickListener(SlimefunPlugin plugin) {
|
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onLaunch(ClimbingPickLaunchEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
|
|
||||||
p.setVelocity(e.getVelocity());
|
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 1F);
|
|
||||||
|
|
||||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
|
||||||
((ClimbingPick) SlimefunItem.getByItem(e.getItem())).damageItem(p, e.getItem());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,6 @@ import java.util.Set;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ClimbingPickListener;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -238,7 +237,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
new WitherListener(this);
|
new WitherListener(this);
|
||||||
new IronGolemListener(this);
|
new IronGolemListener(this);
|
||||||
new PlayerInteractEntityListener(this);
|
new PlayerInteractEntityListener(this);
|
||||||
new ClimbingPickListener(this);
|
|
||||||
|
|
||||||
new MobDropListener(this, (BasicCircuitBoard) SlimefunItems.BASIC_CIRCUIT_BOARD.getItem());
|
new MobDropListener(this, (BasicCircuitBoard) SlimefunItems.BASIC_CIRCUIT_BOARD.getItem());
|
||||||
|
|
||||||
|
@ -53,11 +53,11 @@ public class TestClimbingPick implements SlimefunItemTest<ClimbingPick> {
|
|||||||
for (BlockFace face : BlockFace.values()) {
|
for (BlockFace face : BlockFace.values()) {
|
||||||
BlockMock block1 = new BlockMock(Material.STONE);
|
BlockMock block1 = new BlockMock(Material.STONE);
|
||||||
simulateRightClickBlock(player, pick, block1, face);
|
simulateRightClickBlock(player, pick, block1, face);
|
||||||
server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class);
|
server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class, e -> !e.isCancelled());
|
||||||
|
|
||||||
BlockMock block2 = new BlockMock(Material.DIRT);
|
BlockMock block2 = new BlockMock(Material.DIRT);
|
||||||
simulateRightClickBlock(player, pick, block2, face);
|
simulateRightClickBlock(player, pick, block2, face);
|
||||||
server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class);
|
server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class, ClimbingPickLaunchEvent::isCancelled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user