mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-25 03:55:22 +01:00
Formatting
Changed SIGNRedstone from invisible torch to visible block Signed-off-by: Grafe <flingelfrank@hotmail.com>
This commit is contained in:
parent
c8b706610b
commit
dfc102fdf8
@ -170,12 +170,6 @@ public class GameWorld {
|
||||
|
||||
public void delete(){
|
||||
gworlds.remove(this);
|
||||
|
||||
for(DSign sign:dSigns){
|
||||
if(sign != null){
|
||||
sign.killTask();
|
||||
}
|
||||
}
|
||||
p.getServer().unloadWorld(this.world,true);
|
||||
File dir = new File("DXL_Game_"+this.id);
|
||||
p.removeDirectory(dir);
|
||||
|
@ -25,7 +25,6 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import com.dre.dungeonsxl.DGSign;
|
||||
import com.dre.dungeonsxl.signs.DSign;
|
||||
import com.dre.dungeonsxl.DGroup;
|
||||
import com.dre.dungeonsxl.DLootInventory;
|
||||
import com.dre.dungeonsxl.DPlayer;
|
||||
@ -45,7 +44,6 @@ public class PlayerListener implements Listener{
|
||||
Player player = event.getPlayer();
|
||||
Block clickedBlock=event.getClickedBlock();
|
||||
|
||||
|
||||
if(clickedBlock!=null){
|
||||
//Block Enderchests
|
||||
if(GameWorld.get(player.getWorld())!=null || EditWorld.get(player.getWorld())!=null){
|
||||
@ -69,20 +67,6 @@ public class PlayerListener implements Listener{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Block invisible Redstone signs
|
||||
GameWorld gworld = GameWorld.get(player.getWorld());
|
||||
if(!gworld.untouchable.isEmpty()){
|
||||
if(event.getAction()==Action.RIGHT_CLICK_BLOCK){
|
||||
if(gworld.untouchable.contains(clickedBlock)){
|
||||
for(DSign sign:gworld.dSigns){
|
||||
if(sign!=null){
|
||||
sign.onDiscover();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,19 +91,10 @@ public abstract class DSign {
|
||||
|
||||
}
|
||||
|
||||
public void onDiscover(){
|
||||
|
||||
}
|
||||
|
||||
public void onUpdate(int type,boolean powered){
|
||||
|
||||
}
|
||||
|
||||
public void killTask(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static DSign create(Sign sign, GameWorld gworld){
|
||||
String[] lines = sign.getLines();
|
||||
DSign dSign = null;
|
||||
@ -152,12 +143,12 @@ public abstract class DSign {
|
||||
}
|
||||
|
||||
|
||||
//Getter anb Setter
|
||||
public void setPowered(int type,boolean powered) {
|
||||
//Getter and Setter
|
||||
public void setPowered(int type, boolean powered) {
|
||||
isPowered[type] = powered;
|
||||
}
|
||||
|
||||
public boolean isPowered() { //0=Redstone 1=Sign
|
||||
public boolean isPowered() {//0=Redstone 1=Sign
|
||||
if( (isPowered[0]||!isRedstoneTrigger()) && (isPowered[1]||!isSignTrigger()) ){
|
||||
return true;
|
||||
} else {
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.dre.dungeonsxl.signs;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.dre.dungeonsxl.game.GameWorld;
|
||||
|
||||
public class SIGNBlock extends DSign{
|
||||
@ -14,11 +12,9 @@ public class SIGNBlock extends DSign{
|
||||
//Variables
|
||||
private boolean initialized;
|
||||
private boolean active;
|
||||
private byte side;
|
||||
private int offBlock = 0;
|
||||
private int onBlock = 0;
|
||||
|
||||
|
||||
public SIGNBlock(Sign sign, GameWorld gworld) {
|
||||
super(sign, gworld);
|
||||
}
|
||||
@ -54,7 +50,6 @@ public class SIGNBlock extends DSign{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
if(initialized){
|
||||
|
@ -27,7 +27,7 @@ public class SIGNMob extends DSign{
|
||||
private int amount = 1;
|
||||
private boolean initialized;
|
||||
private boolean active;
|
||||
private int id = -1;
|
||||
private int taskId = -1;
|
||||
|
||||
public SIGNMob(Sign sign, GameWorld gworld) {
|
||||
super(sign, gworld);
|
||||
@ -81,19 +81,18 @@ public class SIGNMob extends DSign{
|
||||
if(!active){
|
||||
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
|
||||
|
||||
id = p.getServer().getScheduler().scheduleSyncRepeatingTask(p, scheduler, 0L, 20L);
|
||||
taskId = p.getServer().getScheduler().scheduleSyncRepeatingTask(p, scheduler, 0L, 20L);
|
||||
|
||||
active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killTask(){
|
||||
if(initialized && active){
|
||||
if(id != -1){
|
||||
p.getServer().getScheduler().cancelTask(id);
|
||||
id = -1;
|
||||
if(taskId != -1){
|
||||
p.getServer().getScheduler().cancelTask(taskId);
|
||||
taskId = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,6 +108,9 @@ public class SIGNMob extends DSign{
|
||||
public void run() {
|
||||
if(sign.interval<=0){
|
||||
World world = sign.sign.getWorld();
|
||||
GameWorld gworld = GameWorld.get(world);
|
||||
|
||||
if(gworld != null){
|
||||
|
||||
//Check normal mobs
|
||||
if(EntityType.fromName(sign.mob)!=null){
|
||||
@ -145,6 +147,9 @@ public class SIGNMob extends DSign{
|
||||
}
|
||||
|
||||
sign.interval = sign.maxinterval;
|
||||
} else {
|
||||
sign.killTask();
|
||||
}
|
||||
}
|
||||
sign.interval--;
|
||||
}
|
||||
|
@ -1,13 +1,8 @@
|
||||
package com.dre.dungeonsxl.signs;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import com.dre.dungeonsxl.P;
|
||||
import com.dre.dungeonsxl.DPlayer;
|
||||
import com.dre.dungeonsxl.game.GameWorld;
|
||||
|
||||
public class SIGNRedstone extends DSign{
|
||||
@ -19,8 +14,7 @@ public class SIGNRedstone extends DSign{
|
||||
//Variables
|
||||
private boolean initialized;
|
||||
private boolean active;
|
||||
private byte side;
|
||||
private BukkitTask task = null;
|
||||
private Block block;
|
||||
|
||||
public SIGNRedstone(Sign sign, GameWorld gworld) {
|
||||
super(sign, gworld);
|
||||
@ -37,80 +31,33 @@ public class SIGNRedstone extends DSign{
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
if(sign.getBlock().getType() == Material.WALL_SIGN){
|
||||
switch(sign.getData().getData()){
|
||||
case 5:
|
||||
side = 0x1; //west
|
||||
break;
|
||||
case 4:
|
||||
side = 0x2; //east
|
||||
break;
|
||||
case 3:
|
||||
side = 0x3; //north
|
||||
break;
|
||||
case 2:
|
||||
side = 0x4; //south
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
side = 0x5; //up
|
||||
}
|
||||
gworld.untouchable.add(sign.getBlock().getRelative(BlockFace.DOWN));
|
||||
gworld.untouchable.add(sign.getBlock().getRelative(BlockFace.UP));
|
||||
gworld.untouchable.add(sign.getBlock().getRelative(BlockFace.WEST));
|
||||
gworld.untouchable.add(sign.getBlock().getRelative(BlockFace.EAST));
|
||||
gworld.untouchable.add(sign.getBlock().getRelative(BlockFace.NORTH));
|
||||
gworld.untouchable.add(sign.getBlock().getRelative(BlockFace.SOUTH));
|
||||
sign.getBlock().setTypeId(0);
|
||||
this.block = sign.getBlock();
|
||||
this.block.setTypeId(0);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(int type,boolean powered) {
|
||||
public void onUpdate(int type, boolean powered) {
|
||||
if(initialized){
|
||||
setPowered(type,powered);
|
||||
setPowered(type, powered);
|
||||
if(isPowered()){
|
||||
if(!isDistanceTrigger()){
|
||||
onTrigger();
|
||||
}
|
||||
} else {
|
||||
killTask();
|
||||
active = false;
|
||||
sign.getBlock().setTypeId(0);
|
||||
block.setTypeId(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDiscover(){
|
||||
if(initialized && active){
|
||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(p, new DiscoveryTask(), 1);
|
||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(p, new DiscoveryTask(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killTask(){
|
||||
if(initialized && active){
|
||||
if(task != null){
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
if(initialized){
|
||||
if(!active){
|
||||
sign.getBlock().setData(side);
|
||||
sign.getBlock().setTypeId(76);
|
||||
block.setTypeId(152);
|
||||
active = true;
|
||||
if(task == null){
|
||||
task = P.p.getServer().getScheduler().runTaskTimer(p, new DiscoveryTask(), 1, 60);
|
||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(p, new DiscoveryTask(), 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,22 +71,5 @@ public class SIGNRedstone extends DSign{
|
||||
public boolean isOnDungeonInit() {
|
||||
return onDungeonInit;
|
||||
}
|
||||
|
||||
public class DiscoveryTask implements Runnable {
|
||||
|
||||
public DiscoveryTask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(initialized && active){
|
||||
for(DPlayer dplayer:DPlayer.players){
|
||||
if(!dplayer.isEditing){
|
||||
dplayer.player.sendBlockChange(sign.getBlock().getLocation(),0,(byte)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user