mirror of
https://github.com/songoda/EpicBuckets.git
synced 2024-11-13 05:45:16 +01:00
Command alias added + source block break addon
This commit is contained in:
parent
0c53dbf2a1
commit
e154bc9d8c
@ -9,7 +9,7 @@ import com.songoda.epicbuckets.util.ChatUtil;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("epicbuckets|eb")
|
||||
@CommandAlias("epicbuckets|eb|genbucket")
|
||||
public class CommandGenbucket extends BaseCommand {
|
||||
|
||||
private EpicBuckets epicBuckets;
|
||||
@ -30,11 +30,11 @@ public class CommandGenbucket extends BaseCommand {
|
||||
@CatchUnknown @Default
|
||||
public void doHelp(CommandSender sender) {
|
||||
sender.sendMessage(ChatUtil.colorString("&3&lEpicBuckets"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets|eb help: &7shows this help"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets|eb reload: &7reloads the config"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets|eb shop: &7opens up the genbucket shop"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets|eb admin toggle: &7toggle your status to receive genbucket placement notifications"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets|eb admin panel: &7opens up the panel with all active genbuckets"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets help: &7shows this help"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets reload: &7reloads the config"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets shop: &7opens up the genbucket shop"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets admin toggle: &7toggle your status to receive genbucket placement notifications"));
|
||||
sender.sendMessage(ChatUtil.colorString("&f/epicbuckets admin panel: &7opens up the panel with all active genbuckets"));
|
||||
}
|
||||
|
||||
@Subcommand("shop")
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -19,10 +20,12 @@ public abstract class Genbucket {
|
||||
private GenbucketType genbucketType;
|
||||
private BlockFace blockFace;
|
||||
private Block clickedBlock;
|
||||
private Block sourceBlock;
|
||||
private Block currentBlock;
|
||||
private SubShop subShop;
|
||||
private UUID genUUID;
|
||||
private Location playerLocation;
|
||||
private BukkitTask generation;
|
||||
|
||||
public Genbucket(GenbucketType genbucketType, Block clickedBlock, BlockFace blockFace, SubShop s, Player owner) {
|
||||
epicBuckets = EpicBuckets.getInstance();
|
||||
@ -38,6 +41,10 @@ public abstract class Genbucket {
|
||||
|
||||
public abstract void generate();
|
||||
|
||||
public Block getSourceBlock() {
|
||||
return sourceBlock;
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
return owner;
|
||||
}
|
||||
@ -66,10 +73,19 @@ public abstract class Genbucket {
|
||||
if (!isValidBlockFace()) return false;
|
||||
if (!epicBuckets.getConfigManager().getLogicalFacesForGenbucket(getGenbucketType()).contains(getBlockFace())) {
|
||||
blockFace = epicBuckets.getConfigManager().getDefaultFaceForGenbucket(genbucketType);
|
||||
sourceBlock = clickedBlock.getRelative(blockFace);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public BukkitTask getGeneration() {
|
||||
return generation;
|
||||
}
|
||||
|
||||
public void setGeneration(BukkitTask task) {
|
||||
generation = task;
|
||||
}
|
||||
|
||||
protected boolean isBelowVoid(int moved) {
|
||||
if (blockFace != BlockFace.DOWN) return false;
|
||||
return clickedBlock.getRelative(0, -moved, 0).getLocation().getBlockY() == 0;
|
||||
|
@ -19,7 +19,7 @@ public class Horizontal extends Genbucket {
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
new BukkitRunnable() {
|
||||
BukkitRunnable runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (blocksPlaced >= epicBuckets.getConfigManager().getMaxHorizontalLength() || !placeGen(getNextBlock())) {
|
||||
@ -29,6 +29,7 @@ public class Horizontal extends Genbucket {
|
||||
}
|
||||
blocksPlaced++;
|
||||
}
|
||||
}.runTaskTimer(EpicBuckets.getInstance(), 0, epicBuckets.getConfigManager().getDelay());
|
||||
};
|
||||
setGeneration(runnable.runTaskTimer(EpicBuckets.getInstance(), 0, epicBuckets.getConfigManager().getDelay()));
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class Infused extends Genbucket {
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
new BukkitRunnable() {
|
||||
BukkitRunnable runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if ((!side1 && !side2) || blocksPlaced >= epicBuckets.getConfigManager().getMaxVerticalHeight()) {
|
||||
@ -37,6 +37,7 @@ public class Infused extends Genbucket {
|
||||
}
|
||||
blocksPlaced++;
|
||||
}
|
||||
}.runTaskTimer(EpicBuckets.getInstance(), 0, epicBuckets.getConfigManager().getDelay());
|
||||
};
|
||||
setGeneration(runnable.runTaskTimer(EpicBuckets.getInstance(), 0, epicBuckets.getConfigManager().getDelay()));
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class PsuedoVertical extends Genbucket {
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
new BukkitRunnable() {
|
||||
BukkitRunnable runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isBelowVoid(blocksUp) || blocksUp >= epicBuckets.getConfigManager().getMaxVerticalHeight()) {
|
||||
@ -30,6 +30,7 @@ public class PsuedoVertical extends Genbucket {
|
||||
fixHole(getNextBlock());
|
||||
blocksUp++;
|
||||
}
|
||||
}.runTaskTimer(EpicBuckets.getInstance(), 0, epicBuckets.getConfigManager().getDelay());
|
||||
};
|
||||
setGeneration(runnable.runTaskTimer(EpicBuckets.getInstance(), 0, epicBuckets.getConfigManager().getDelay()));
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class Vertical extends Genbucket {
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
new BukkitRunnable() {
|
||||
BukkitRunnable runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isBelowVoid(blocksPlaced) || blocksPlaced >= epicBuckets.getConfigManager().getMaxVerticalHeight() || !placeGen(getNextBlock())) {
|
||||
@ -29,6 +29,7 @@ public class Vertical extends Genbucket {
|
||||
}
|
||||
blocksPlaced++;
|
||||
}
|
||||
}.runTaskTimer(EpicBuckets.getInstance(), 0, epicBuckets.getConfigManager().getDelay());
|
||||
};
|
||||
setGeneration(runnable.runTaskTimer(EpicBuckets.getInstance(), 0, epicBuckets.getConfigManager().getDelay()));
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import com.songoda.epicbuckets.genbucket.types.PsuedoVertical;
|
||||
import com.songoda.epicbuckets.genbucket.types.Vertical;
|
||||
import com.songoda.epicbuckets.util.XMaterial;
|
||||
import de.tr7zw.itemnbtapi.NBTItem;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -77,7 +76,7 @@ public class GenbucketPlaceListener implements Listener {
|
||||
genbucket = new Horizontal(e.getPlayer(), e.getClickedBlock(), e.getBlockFace(), epicBuckets.getShopManager().getShop(nbtItem.getString("Shop")).getSubShop(nbtItem.getString("SubShop")));
|
||||
}
|
||||
|
||||
if (!genbucket.isValidBlockFace()) {
|
||||
if (!genbucket.calculateBlockFace()) {
|
||||
e.getPlayer().sendMessage(epicBuckets.getLocale().getMessage("event.genbucket.placedwrong").replace("%genbucket%", genbucket.getGenbucketType().name.toUpperCase() + " genbucket"));
|
||||
return;
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.songoda.epicbuckets.listener;
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class SourceBlockBreakListener implements Listener {
|
||||
|
||||
private EpicBuckets epicBuckets;
|
||||
|
||||
public SourceBlockBreakListener() {
|
||||
epicBuckets = EpicBuckets.getInstance();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
epicBuckets.getGenbucketManager().getActiveGens().forEach((uuid, genbuckets) -> {
|
||||
if (genbuckets.size() > 0) {
|
||||
genbuckets.forEach(genbucket -> {
|
||||
if (genbucket.getSourceBlock().getLocation() == e.getBlock().getLocation()) {
|
||||
genbucket.getGeneration().cancel();
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user