Moved code to objects
This commit is contained in:
parent
884184006c
commit
b593a22568
@ -1,8 +1,10 @@
|
|||||||
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
||||||
|
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -21,6 +23,26 @@ public class LinkedBeaconTeleporterBlock extends LinkedBeaconTeleporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LinkedBeaconTeleporterItem break_(BlockBreakEvent e){
|
||||||
|
// Dont drop anything
|
||||||
|
e.setDropItems(false);
|
||||||
|
e.setExpToDrop(0);
|
||||||
|
|
||||||
|
LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.breakLbtBlock(this);
|
||||||
|
|
||||||
|
Location loc = this.block().getLocation();
|
||||||
|
|
||||||
|
// Drop custom-item
|
||||||
|
if(e.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
|
loc.getWorld().dropItemNaturally(
|
||||||
|
loc.add(0.5, 0, 0.5),
|
||||||
|
lbtItem.item()
|
||||||
|
);
|
||||||
|
|
||||||
|
return lbtItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Conversion methods
|
// Conversion methods
|
||||||
public static LinkedBeaconTeleporterBlock getFromLocation(Location loc){
|
public static LinkedBeaconTeleporterBlock getFromLocation(Location loc){
|
||||||
return Main.lbtManager.getLbtBlockFromLocation(loc);
|
return Main.lbtManager.getLbtBlockFromLocation(loc);
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
||||||
|
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@ -35,6 +38,12 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LinkedBeaconTeleporterBlock place(BlockPlaceEvent e){
|
||||||
|
LinkedBeaconTeleporterBlock lbtBlock = Main.lbtManager.placeLbtItem(this, e.getBlock());
|
||||||
|
return lbtBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Conversion methods
|
// Conversion methods
|
||||||
public static LinkedBeaconTeleporterItem getFromItemStack(ItemStack itemStack){
|
public static LinkedBeaconTeleporterItem getFromItemStack(ItemStack itemStack){
|
||||||
return Main.lbtManager.getLbtItemFromItemStack(itemStack);
|
return Main.lbtManager.getLbtItemFromItemStack(itemStack);
|
||||||
|
@ -26,18 +26,7 @@ public class OnBlockBreak implements Listener {
|
|||||||
// Ignore if not found
|
// Ignore if not found
|
||||||
if(lbtBlock == null) return;
|
if(lbtBlock == null) return;
|
||||||
|
|
||||||
LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.breakLbtBlock(lbtBlock);
|
LinkedBeaconTeleporterItem lbtItem = lbtBlock.break_(e);
|
||||||
|
|
||||||
// Dont drop anything
|
|
||||||
e.setDropItems(false);
|
|
||||||
e.setExpToDrop(0);
|
|
||||||
|
|
||||||
// Drop custom-item
|
|
||||||
if(e.getPlayer().getGameMode() != GameMode.CREATIVE)
|
|
||||||
lbtBlock.block().getLocation().getWorld().dropItemNaturally(
|
|
||||||
lbtBlock.block().getLocation(),
|
|
||||||
lbtItem.item()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,7 @@ public class OnBlockPlace implements Listener {
|
|||||||
// Ignore if not found
|
// Ignore if not found
|
||||||
if(lbtItem == null) return;
|
if(lbtItem == null) return;
|
||||||
|
|
||||||
Block block = e.getBlock();
|
LinkedBeaconTeleporterBlock lbtBlock = lbtItem.place(e);
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = Main.lbtManager.placeLbtItem(lbtItem, block);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user