Moved onUpdate() to DSign

This commit is contained in:
Sn0wStorm 2013-04-13 15:18:18 +02:00
parent dfc102fdf8
commit 9d34c0154a
8 changed files with 63 additions and 120 deletions

View File

@ -91,7 +91,19 @@ public abstract class DSign {
}
public void onDisable(){
}
public void onUpdate(int type,boolean powered){
setPowered(type, powered);
if(isPowered()){
if(!isDistanceTrigger){
onTrigger();
}
} else {
onDisable();
}
}

View File

@ -12,8 +12,8 @@ public class SIGNBlock extends DSign{
//Variables
private boolean initialized;
private boolean active;
private int offBlock = 0;
private int onBlock = 0;
private int offBlockId = 0;
private int onBlockId = 0;
public SIGNBlock(Sign sign, GameWorld gworld) {
super(sign, gworld);
@ -29,34 +29,25 @@ public class SIGNBlock extends DSign{
@Override
public void onInit() {
String lines[] = sign.getLines();
offBlock = p.parseInt(lines[1]);
onBlock = p.parseInt(lines[2]);
sign.getBlock().setTypeId(offBlock);
offBlockId = p.parseInt(lines[1]);
onBlockId = p.parseInt(lines[2]);
sign.getBlock().setTypeId(offBlockId);
initialized = true;
}
@Override
public void onUpdate(int type,boolean powered) {
if(initialized){
setPowered(type,powered);
if(isPowered()){
if(!isDistanceTrigger()){
onTrigger();
}
} else {
active = false;
sign.getBlock().setTypeId(offBlock);
}
public void onTrigger() {
if(initialized && !active){
sign.getBlock().setTypeId(onBlockId);
active = true;
}
}
@Override
public void onTrigger() {
if(initialized){
if(!active){
sign.getBlock().setTypeId(onBlock);
active = true;
}
public void onDisable() {
if(initialized && active){
sign.getBlock().setTypeId(offBlockId);
active = false;
}
}

View File

@ -33,18 +33,6 @@ public class SIGNCheckpoint extends DSign{
initialized = true;
}
@Override
public void onUpdate(int type,boolean powered) {
if(initialized){
setPowered(type,powered);
if(!isDistanceTrigger()){
if(isPowered()){
onTrigger();
}
}
}
}
@Override
public void onTrigger() {
if(initialized){

View File

@ -60,35 +60,26 @@ public class SIGNMob extends DSign{
}
@Override
public void onUpdate(int type,boolean powered) {
if(initialized){
setPowered(type,powered);
if(isPowered()){
if(!isDistanceTrigger()){
onTrigger();
}
} else {
killTask();
interval = 0;
active = false;
}
public void onTrigger() {
if(initialized && !active){
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = p.getServer().getScheduler().scheduleSyncRepeatingTask(p, scheduler, 0L, 20L);
active = true;
}
}
@Override
public void onTrigger() {
if(initialized){
if(!active){
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = p.getServer().getScheduler().scheduleSyncRepeatingTask(p, scheduler, 0L, 20L);
active = true;
}
public void onDisable() {
if(initialized && active){
killTask();
interval = 0;
active = false;
}
}
public void killTask(){
public void killTask() {
if(initialized && active){
if(taskId != -1){
p.getServer().getScheduler().cancelTask(taskId);

View File

@ -43,18 +43,6 @@ public class SIGNMsg extends DSign{
initialized = true;
}
@Override
public void onUpdate(int type,boolean powered) {
if(initialized){
setPowered(type,powered);
if(!isDistanceTrigger()){
if(isPowered()){
onTrigger();
}
}
}
}
@Override
public void onTrigger() {
if(initialized){

View File

@ -22,9 +22,6 @@ public class SIGNRedstone extends DSign{
@Override
public boolean check() {
if(isRedstoneTrigger()){
return false;
}
return true;
}
@ -38,27 +35,18 @@ public class SIGNRedstone extends DSign{
}
@Override
public void onUpdate(int type, boolean powered) {
if(initialized){
setPowered(type, powered);
if(isPowered()){
if(!isDistanceTrigger()){
onTrigger();
}
} else {
active = false;
block.setTypeId(0);
}
public void onTrigger() {
if(initialized && !active){
block.setTypeId(152);
active = true;
}
}
@Override
public void onTrigger() {
if(initialized){
if(!active){
block.setTypeId(152);
active = true;
}
public void onDisable() {
if(initialized && active){
block.setTypeId(0);
active = false;
}
}

View File

@ -48,18 +48,6 @@ public class SIGNSoundMsg extends DSign{
initialized = true;
}
@Override
public void onUpdate(int type,boolean powered) {
if(initialized){
setPowered(type,powered);
if(!isDistanceTrigger()){
if(isPowered()){
onTrigger();
}
}
}
}
@Override
public void onTrigger() {
if(initialized){

View File

@ -66,24 +66,6 @@ public class SIGNTrigger extends DSign{
initialized = true;
}
@Override
public void onUpdate(int type,boolean powered) {
if(initialized){
setPowered(type,powered);
if(!isDistanceTrigger() || !isPowered()){
for(DSign dsign : this.gworld.dSigns){
if(dsign != null){
if(dsign.isSignTrigger()){
if(triggerId == dsign.getStId()){
dsign.onUpdate(1,isPowered());
}
}
}
}
}
}
}
@Override
public void onTrigger() {
if(initialized){
@ -98,7 +80,22 @@ public class SIGNTrigger extends DSign{
}
}
}
@Override
public void onDisable() {
if(initialized){
for(DSign dsign : this.gworld.dSigns){
if(dsign != null){
if(dsign.isSignTrigger()){
if(triggerId == dsign.getStId()){
dsign.onUpdate(1,false);
}
}
}
}
}
}
@Override
public String getPermissions() {
return buildPermissions;