mirror of
https://github.com/songoda/EpicBuckets.git
synced 2024-09-27 13:02:54 +02:00
Update 1.2
Added downwards gen for gravity affected blocks using Vertical genbucket (infused later), default faces working
This commit is contained in:
parent
e154bc9d8c
commit
dd62791948
14
pom.xml
14
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicBuckets</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>1.1</version>
|
||||
<version>1.2</version>
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
@ -86,8 +86,12 @@
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.inv</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.acf</shadedPattern>
|
||||
<pattern>co.aikar.timings.lib</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.acf.timings</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.commands</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.acf.commands</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>de.tr7zw.itemnbtapi</pattern>
|
||||
@ -117,7 +121,7 @@
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>3_aikar</id>
|
||||
<id>33_aikar</id>
|
||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
@ -134,7 +138,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>acf-paper</artifactId>
|
||||
<artifactId>acf-bukkit</artifactId>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbuckets;
|
||||
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import co.aikar.commands.BukkitCommandManager;
|
||||
import com.songoda.epicbuckets.command.CommandGenbucket;
|
||||
import com.songoda.epicbuckets.file.ConfigManager;
|
||||
import com.songoda.epicbuckets.genbucket.GenbucketManager;
|
||||
@ -26,7 +26,7 @@ public class EpicBuckets extends ExtendedJavaPlugin {
|
||||
private Debugger debugger;
|
||||
private GenbucketManager genbucketManager;
|
||||
private Economy econ;
|
||||
private PaperCommandManager commandManager;
|
||||
private BukkitCommandManager commandManager;
|
||||
private InventoryManager inventoryManager;
|
||||
|
||||
private Locale locale;
|
||||
@ -46,6 +46,8 @@ public class EpicBuckets extends ExtendedJavaPlugin {
|
||||
|
||||
saveDefaultConfig();
|
||||
|
||||
Locale.init(this);
|
||||
Locale.saveDefaultLocale("en_US");
|
||||
this.locale = Locale.getLocale(getConfig().getString("Locale", "en_US"));
|
||||
|
||||
debugger = new Debugger();
|
||||
@ -53,7 +55,7 @@ public class EpicBuckets extends ExtendedJavaPlugin {
|
||||
shopManager = new ShopManager();
|
||||
configManager.setup();
|
||||
genbucketManager = new GenbucketManager();
|
||||
commandManager = new PaperCommandManager(this);
|
||||
commandManager = new BukkitCommandManager(this);
|
||||
|
||||
inventoryManager = new InventoryManager(this);
|
||||
inventoryManager.init();
|
||||
@ -64,9 +66,6 @@ public class EpicBuckets extends ExtendedJavaPlugin {
|
||||
|
||||
setupEconomy();
|
||||
|
||||
Locale.init(this);
|
||||
Locale.saveDefaultLocale("en_US");
|
||||
|
||||
console.sendMessage(ChatUtil.colorString("&a============================="));
|
||||
}
|
||||
|
||||
|
@ -110,8 +110,8 @@ public class ConfigManager {
|
||||
genbucketLogicalFaces = new HashMap<>();
|
||||
|
||||
epicBuckets.getConfig().getConfigurationSection("VALID-FACES").getKeys(false).forEach(s -> {
|
||||
genbucketDefaultFace.put(GenbucketType.valueOf(s), BlockFace.valueOf(epicBuckets.getConfig().getString("VALID-FACES" + s + "DEFAULT")));
|
||||
genbucketValidFaces.put(GenbucketType.valueOf(s), epicBuckets.getConfig().getStringList("VALID-FACES" + s + "WHITELIST").stream().map(s1 -> BlockFace.valueOf(s1)).collect(Collectors.toList()));
|
||||
genbucketDefaultFace.put(GenbucketType.valueOf(s), BlockFace.valueOf(epicBuckets.getConfig().getString("VALID-FACES." + s + ".DEFAULT")));
|
||||
genbucketValidFaces.put(GenbucketType.valueOf(s), epicBuckets.getConfig().getStringList("VALID-FACES." + s + ".WHITELIST").stream().map(s1 -> BlockFace.valueOf(s1)).collect(Collectors.toList()));
|
||||
});
|
||||
|
||||
genbucketLogicalFaces.put(GenbucketType.HORIZONTAL, new ArrayList<>(Arrays.asList(BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH)));
|
||||
|
@ -5,6 +5,7 @@ import com.songoda.epicbuckets.shop.SubShop;
|
||||
import com.songoda.epicbuckets.util.XMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -26,6 +27,7 @@ public abstract class Genbucket {
|
||||
private UUID genUUID;
|
||||
private Location playerLocation;
|
||||
private BukkitTask generation;
|
||||
private boolean isGravityGen;
|
||||
|
||||
public Genbucket(GenbucketType genbucketType, Block clickedBlock, BlockFace blockFace, SubShop s, Player owner) {
|
||||
epicBuckets = EpicBuckets.getInstance();
|
||||
@ -35,8 +37,10 @@ public abstract class Genbucket {
|
||||
this.blockFace = blockFace;
|
||||
this.clickedBlock = clickedBlock;
|
||||
this.currentBlock = clickedBlock;
|
||||
this.sourceBlock = clickedBlock.getRelative(blockFace);
|
||||
this.subShop = s;
|
||||
this.playerLocation = owner.getLocation();
|
||||
isGravityGen = s.getGenItem().getType().hasGravity();
|
||||
}
|
||||
|
||||
public abstract void generate();
|
||||
@ -73,7 +77,8 @@ public abstract class Genbucket {
|
||||
if (!isValidBlockFace()) return false;
|
||||
if (!epicBuckets.getConfigManager().getLogicalFacesForGenbucket(getGenbucketType()).contains(getBlockFace())) {
|
||||
blockFace = epicBuckets.getConfigManager().getDefaultFaceForGenbucket(genbucketType);
|
||||
sourceBlock = clickedBlock.getRelative(blockFace);
|
||||
clickedBlock = sourceBlock.getRelative(getBlockFace().getOppositeFace());
|
||||
currentBlock = clickedBlock;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -88,7 +93,21 @@ public abstract class Genbucket {
|
||||
|
||||
protected boolean isBelowVoid(int moved) {
|
||||
if (blockFace != BlockFace.DOWN) return false;
|
||||
return clickedBlock.getRelative(0, -moved, 0).getLocation().getBlockY() == 0;
|
||||
return sourceBlock.getRelative(0, -moved, 0).getLocation().getBlockY() < 0;
|
||||
}
|
||||
|
||||
protected boolean gravityGen(int moved) {
|
||||
Block b = getNextBlock();
|
||||
if (isBelowVoid(moved + 1)) return false;
|
||||
if (b.getRelative(getBlockFace()).getType() != Material.AIR) {
|
||||
if (b.getRelative(getBlockFace()).getType() != XMaterial.COBBLESTONE.parseMaterial()) {
|
||||
b.setType(getGenItem().getType());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
b.getRelative(getBlockFace()).setType(XMaterial.COBBLESTONE.parseMaterial());
|
||||
b.setType(getGenItem().getType());
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Block getNextBlock(int moved, BlockFace blockFace) {
|
||||
@ -130,4 +149,8 @@ public abstract class Genbucket {
|
||||
return blockFace;
|
||||
}
|
||||
|
||||
protected boolean isGravityGen() {
|
||||
return isGravityGen && getBlockFace() == BlockFace.DOWN;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,13 @@ public class Vertical extends Genbucket {
|
||||
BukkitRunnable runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isBelowVoid(blocksPlaced) || blocksPlaced >= epicBuckets.getConfigManager().getMaxVerticalHeight() || !placeGen(getNextBlock())) {
|
||||
if (isGravityGen()) {
|
||||
if (!gravityGen(blocksPlaced)) {
|
||||
epicBuckets.getGenbucketManager().unregisterGenbucketForPlayer(getOwner(), getGenUUID());
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
} else if (isBelowVoid(blocksPlaced + 1) || blocksPlaced >= epicBuckets.getConfigManager().getMaxVerticalHeight() || !placeGen(getNextBlock())) {
|
||||
epicBuckets.getGenbucketManager().unregisterGenbucketForPlayer(getOwner(), getGenUUID());
|
||||
cancel();
|
||||
return;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicbuckets.listener;
|
||||
|
||||
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.genbucket.Genbucket;
|
||||
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||
@ -18,12 +19,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class GenbucketPlaceListener implements Listener {
|
||||
|
||||
private EpicBuckets epicBuckets;
|
||||
|
||||
public GenbucketPlaceListener() {
|
||||
epicBuckets = EpicBuckets.getInstance();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void emptyBucket(PlayerBucketEmptyEvent e) {
|
||||
NBTItem nbtItem = new NBTItem(e.getItemStack());
|
||||
@ -44,19 +39,19 @@ public class GenbucketPlaceListener implements Listener {
|
||||
e.setCancelled(true);
|
||||
|
||||
if (!e.getPlayer().hasPermission("genbucket.place")) {
|
||||
e.getPlayer().sendMessage(epicBuckets.getLocale().getMessage("event.place.nothere"));
|
||||
e.getPlayer().sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.place.nothere"));
|
||||
return;
|
||||
}
|
||||
if (epicBuckets.getConfigManager().isGenbucketsDisabled()) {
|
||||
e.getPlayer().sendMessage(epicBuckets.getLocale().getMessage("event.genbucket.disabled"));
|
||||
if (EpicBuckets.getInstance().getConfigManager().isGenbucketsDisabled()) {
|
||||
e.getPlayer().sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.genbucket.disabled"));
|
||||
return;
|
||||
}
|
||||
if (!epicBuckets.getGenbucketManager().canRegisterNewGenbucket(e.getPlayer())) {
|
||||
e.getPlayer().sendMessage(epicBuckets.getLocale().getMessage("event.place.wait"));
|
||||
if (!EpicBuckets.getInstance().getGenbucketManager().canRegisterNewGenbucket(e.getPlayer())) {
|
||||
e.getPlayer().sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.place.wait"));
|
||||
return;
|
||||
}
|
||||
if (!epicBuckets.getGenbucketManager().canPlaceGenbucket(e.getPlayer(), e.getClickedBlock().getLocation())) {
|
||||
e.getPlayer().sendMessage(epicBuckets.getLocale().getMessage("event.place.nothere"));
|
||||
if (!EpicBuckets.getInstance().getGenbucketManager().canPlaceGenbucket(e.getPlayer(), e.getClickedBlock().getLocation())) {
|
||||
e.getPlayer().sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.place.nothere"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -64,28 +59,28 @@ public class GenbucketPlaceListener implements Listener {
|
||||
|
||||
switch(GenbucketType.valueOf(nbtItem.getString("Type"))) {
|
||||
case PSUEDO:
|
||||
genbucket = new PsuedoVertical(e.getPlayer(), e.getClickedBlock(), e.getBlockFace(), epicBuckets.getShopManager().getShop(nbtItem.getString("Shop")).getSubShop(nbtItem.getString("SubShop")));
|
||||
genbucket = new PsuedoVertical(e.getPlayer(), e.getClickedBlock(), e.getBlockFace(), EpicBuckets.getInstance().getShopManager().getShop(nbtItem.getString("Shop")).getSubShop(nbtItem.getString("SubShop")));
|
||||
break;
|
||||
case INFUSED:
|
||||
genbucket = new Infused(e.getPlayer(), e.getClickedBlock(), e.getBlockFace(), epicBuckets.getShopManager().getShop(nbtItem.getString("Shop")).getSubShop(nbtItem.getString("SubShop")));
|
||||
genbucket = new Infused(e.getPlayer(), e.getClickedBlock(), e.getBlockFace(), EpicBuckets.getInstance().getShopManager().getShop(nbtItem.getString("Shop")).getSubShop(nbtItem.getString("SubShop")));
|
||||
break;
|
||||
case VERTICAL:
|
||||
genbucket = new Vertical(e.getPlayer(), e.getClickedBlock(), e.getBlockFace(), epicBuckets.getShopManager().getShop(nbtItem.getString("Shop")).getSubShop(nbtItem.getString("SubShop")));
|
||||
genbucket = new Vertical(e.getPlayer(), e.getClickedBlock(), e.getBlockFace(), EpicBuckets.getInstance().getShopManager().getShop(nbtItem.getString("Shop")).getSubShop(nbtItem.getString("SubShop")));
|
||||
break;
|
||||
case HORIZONTAL:
|
||||
genbucket = new Horizontal(e.getPlayer(), e.getClickedBlock(), e.getBlockFace(), epicBuckets.getShopManager().getShop(nbtItem.getString("Shop")).getSubShop(nbtItem.getString("SubShop")));
|
||||
genbucket = new Horizontal(e.getPlayer(), e.getClickedBlock(), e.getBlockFace(), EpicBuckets.getInstance().getShopManager().getShop(nbtItem.getString("Shop")).getSubShop(nbtItem.getString("SubShop")));
|
||||
}
|
||||
|
||||
if (!genbucket.calculateBlockFace()) {
|
||||
e.getPlayer().sendMessage(epicBuckets.getLocale().getMessage("event.genbucket.placedwrong").replace("%genbucket%", genbucket.getGenbucketType().name.toUpperCase() + " genbucket"));
|
||||
e.getPlayer().sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.genbucket.placedwrong").replace("%genbucket%", genbucket.getGenbucketType().name.toUpperCase() + " genbucket"));
|
||||
return;
|
||||
}
|
||||
if (genbucket.getGenbucketType() == GenbucketType.PSUEDO && !epicBuckets.getConfigManager().getPsuedoMaterials().contains(XMaterial.requestXMaterial(e.getClickedBlock().getType().name(), e.getClickedBlock().getData()))) {
|
||||
e.getPlayer().sendMessage(epicBuckets.getLocale().getMessage("event.genbucket.wrongmaterialpsuedo"));
|
||||
if (genbucket.getGenbucketType() == GenbucketType.PSUEDO && !EpicBuckets.getInstance().getConfigManager().getPsuedoMaterials().contains(XMaterial.requestXMaterial(e.getClickedBlock().getType().name(), e.getClickedBlock().getData()))) {
|
||||
e.getPlayer().sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.genbucket.wrongmaterialpsuedo"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getPlayer().getGameMode() != GameMode.CREATIVE || !epicBuckets.getConfigManager().isUnlimitedGenbuckets()) {
|
||||
if (e.getPlayer().getGameMode() != GameMode.CREATIVE || !EpicBuckets.getInstance().getConfigManager().isUnlimitedGenbuckets()) {
|
||||
if (e.getItem().getAmount() > 1) {
|
||||
e.getItem().setAmount(e.getItem().getAmount() - 1);
|
||||
} else {
|
||||
@ -93,8 +88,8 @@ public class GenbucketPlaceListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
epicBuckets.getGenbucketManager().registerGenbucketForPlayer(e.getPlayer(), genbucket);
|
||||
epicBuckets.getGenbucketManager().notifyAdmins(e.getPlayer(), genbucket);
|
||||
EpicBuckets.getInstance().getGenbucketManager().registerGenbucketForPlayer(e.getPlayer(), genbucket);
|
||||
EpicBuckets.getInstance().getGenbucketManager().notifyAdmins(e.getPlayer(), genbucket);
|
||||
genbucket.generate();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user