mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Load and trigger signs correctly in games
This commit is contained in:
parent
293dc75f0e
commit
51cccb3afb
@ -61,6 +61,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -164,6 +165,20 @@ public class DGameWorld extends DInstanceWorld implements GameWorld {
|
||||
classes = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DungeonSign createDungeonSign(Sign sign, String[] lines) {
|
||||
DungeonSign dSign = super.createDungeonSign(sign, lines);
|
||||
|
||||
if (dSign.isOnDungeonInit()) {
|
||||
dSign.initialize();
|
||||
}
|
||||
if (!dSign.isErroneous() && dSign.isSetToAir()) {
|
||||
dSign.setToAir();
|
||||
}
|
||||
|
||||
return dSign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the placeableBlocks
|
||||
*/
|
||||
@ -369,10 +384,18 @@ public class DGameWorld extends DInstanceWorld implements GameWorld {
|
||||
isPlaying = true;
|
||||
|
||||
for (DungeonSign sign : getDungeonSigns()) {
|
||||
if (sign != null) {
|
||||
if (!sign.isOnDungeonInit()) {
|
||||
sign.initialize();
|
||||
if (sign == null || sign.isOnDungeonInit()) {
|
||||
continue;
|
||||
}
|
||||
sign.initialize();
|
||||
if (sign.isErroneous()) {
|
||||
continue;
|
||||
}
|
||||
if (sign.isSetToAir()) {
|
||||
sign.setToAir();
|
||||
}
|
||||
if (!sign.hasTriggers()) {
|
||||
sign.trigger(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,12 +406,6 @@ public class DGameWorld extends DInstanceWorld implements GameWorld {
|
||||
for (Trigger trigger : getTriggers(TriggerTypeDefault.FORTUNE)) {
|
||||
((FortuneTrigger) trigger).onTrigger();
|
||||
}
|
||||
|
||||
for (DungeonSign sign : getDungeonSigns()) {
|
||||
if (sign != null && !sign.isErroneous() && !sign.hasTriggers()) {
|
||||
sign.trigger(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,6 +118,7 @@ public abstract class DInstanceWorld implements InstanceWorld {
|
||||
DungeonSign dSign = (DungeonSign) constructor.newInstance(plugin, sign, lines, this);
|
||||
signs.put(sign.getBlock(), dSign);
|
||||
return dSign;
|
||||
|
||||
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
|
||||
| IllegalArgumentException | InvocationTargetException exception) {
|
||||
MessageUtil.log(plugin, "&4Could not create a dungeon sign of the type \"" + type
|
||||
|
@ -26,6 +26,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Collection;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,9 @@ public class SignData {
|
||||
int z = os.readInt();
|
||||
|
||||
Block block = instance.getWorld().getBlockAt(x, y, z);
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
BlockState state = block.getState();
|
||||
if (state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
String[] lines = sign.getLines();
|
||||
instance.createDungeonSign(sign, lines);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user