Formatting

Changed SIGNRedstone from invisible torch to visible block

Signed-off-by: Grafe <flingelfrank@hotmail.com>
This commit is contained in:
Grafe 2013-04-12 23:27:32 +02:00
parent c8b706610b
commit dfc102fdf8
6 changed files with 56 additions and 157 deletions

View File

@ -170,12 +170,6 @@ public class GameWorld {
public void delete(){ public void delete(){
gworlds.remove(this); gworlds.remove(this);
for(DSign sign:dSigns){
if(sign != null){
sign.killTask();
}
}
p.getServer().unloadWorld(this.world,true); p.getServer().unloadWorld(this.world,true);
File dir = new File("DXL_Game_"+this.id); File dir = new File("DXL_Game_"+this.id);
p.removeDirectory(dir); p.removeDirectory(dir);

View File

@ -25,7 +25,6 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.dre.dungeonsxl.DGSign; import com.dre.dungeonsxl.DGSign;
import com.dre.dungeonsxl.signs.DSign;
import com.dre.dungeonsxl.DGroup; import com.dre.dungeonsxl.DGroup;
import com.dre.dungeonsxl.DLootInventory; import com.dre.dungeonsxl.DLootInventory;
import com.dre.dungeonsxl.DPlayer; import com.dre.dungeonsxl.DPlayer;
@ -45,7 +44,6 @@ public class PlayerListener implements Listener{
Player player = event.getPlayer(); Player player = event.getPlayer();
Block clickedBlock=event.getClickedBlock(); Block clickedBlock=event.getClickedBlock();
if(clickedBlock!=null){ if(clickedBlock!=null){
//Block Enderchests //Block Enderchests
if(GameWorld.get(player.getWorld())!=null || EditWorld.get(player.getWorld())!=null){ 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();
}
}
}
}
}
} }
} }

View File

@ -91,19 +91,10 @@ public abstract class DSign {
} }
public void onDiscover(){
}
public void onUpdate(int type,boolean powered){ public void onUpdate(int type,boolean powered){
} }
public void killTask(){
}
public static DSign create(Sign sign, GameWorld gworld){ public static DSign create(Sign sign, GameWorld gworld){
String[] lines = sign.getLines(); String[] lines = sign.getLines();
DSign dSign = null; DSign dSign = null;
@ -152,7 +143,7 @@ public abstract class DSign {
} }
//Getter anb Setter //Getter and Setter
public void setPowered(int type, boolean powered) { public void setPowered(int type, boolean powered) {
isPowered[type] = powered; isPowered[type] = powered;
} }

View File

@ -1,8 +1,6 @@
package com.dre.dungeonsxl.signs; package com.dre.dungeonsxl.signs;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.block.Block;
import com.dre.dungeonsxl.game.GameWorld; import com.dre.dungeonsxl.game.GameWorld;
public class SIGNBlock extends DSign{ public class SIGNBlock extends DSign{
@ -14,11 +12,9 @@ public class SIGNBlock extends DSign{
//Variables //Variables
private boolean initialized; private boolean initialized;
private boolean active; private boolean active;
private byte side;
private int offBlock = 0; private int offBlock = 0;
private int onBlock = 0; private int onBlock = 0;
public SIGNBlock(Sign sign, GameWorld gworld) { public SIGNBlock(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
} }
@ -54,7 +50,6 @@ public class SIGNBlock extends DSign{
} }
} }
@Override @Override
public void onTrigger() { public void onTrigger() {
if(initialized){ if(initialized){

View File

@ -27,7 +27,7 @@ public class SIGNMob extends DSign{
private int amount = 1; private int amount = 1;
private boolean initialized; private boolean initialized;
private boolean active; private boolean active;
private int id = -1; private int taskId = -1;
public SIGNMob(Sign sign, GameWorld gworld) { public SIGNMob(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
@ -81,19 +81,18 @@ public class SIGNMob extends DSign{
if(!active){ if(!active){
MobSpawnScheduler scheduler = new MobSpawnScheduler(this); 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; active = true;
} }
} }
} }
@Override
public void killTask(){ public void killTask(){
if(initialized && active){ if(initialized && active){
if(id != -1){ if(taskId != -1){
p.getServer().getScheduler().cancelTask(id); p.getServer().getScheduler().cancelTask(taskId);
id = -1; taskId = -1;
} }
} }
} }
@ -109,6 +108,9 @@ public class SIGNMob extends DSign{
public void run() { public void run() {
if(sign.interval<=0){ if(sign.interval<=0){
World world = sign.sign.getWorld(); World world = sign.sign.getWorld();
GameWorld gworld = GameWorld.get(world);
if(gworld != null){
//Check normal mobs //Check normal mobs
if(EntityType.fromName(sign.mob)!=null){ if(EntityType.fromName(sign.mob)!=null){
@ -145,6 +147,9 @@ public class SIGNMob extends DSign{
} }
sign.interval = sign.maxinterval; sign.interval = sign.maxinterval;
} else {
sign.killTask();
}
} }
sign.interval--; sign.interval--;
} }

View File

@ -1,13 +1,8 @@
package com.dre.dungeonsxl.signs; package com.dre.dungeonsxl.signs;
import org.bukkit.block.Sign;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.Sign;
import org.bukkit.scheduler.BukkitTask;
import com.dre.dungeonsxl.P;
import com.dre.dungeonsxl.DPlayer;
import com.dre.dungeonsxl.game.GameWorld; import com.dre.dungeonsxl.game.GameWorld;
public class SIGNRedstone extends DSign{ public class SIGNRedstone extends DSign{
@ -19,8 +14,7 @@ public class SIGNRedstone extends DSign{
//Variables //Variables
private boolean initialized; private boolean initialized;
private boolean active; private boolean active;
private byte side; private Block block;
private BukkitTask task = null;
public SIGNRedstone(Sign sign, GameWorld gworld) { public SIGNRedstone(Sign sign, GameWorld gworld) {
super(sign, gworld); super(sign, gworld);
@ -37,31 +31,9 @@ public class SIGNRedstone extends DSign{
@Override @Override
public void onInit() { public void onInit() {
if(sign.getBlock().getType() == Material.WALL_SIGN){ this.block = sign.getBlock();
switch(sign.getData().getData()){ this.block.setTypeId(0);
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);
initialized = true; initialized = true;
} }
@ -74,43 +46,18 @@ public class SIGNRedstone extends DSign{
onTrigger(); onTrigger();
} }
} else { } else {
killTask();
active = false; 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 @Override
public void onTrigger() { public void onTrigger() {
if(initialized){ if(initialized){
if(!active){ if(!active){
sign.getBlock().setData(side); block.setTypeId(152);
sign.getBlock().setTypeId(76);
active = true; 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() { public boolean isOnDungeonInit() {
return onDungeonInit; 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);
}
}
}
}
}
} }