mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Merge floor and end sign
This commit is contained in:
parent
405550b9c4
commit
b517e5e52f
@ -48,7 +48,8 @@ public enum DSignTypeDefault implements DSignType {
|
||||
@Deprecated
|
||||
EXTERNAL_MOB("ExternalMob", "mob", false, false, MobSign.class),
|
||||
FLAG("Flag", "flag", false, false, FlagSign.class),
|
||||
FLOOR("Floor", "floor", false, true, FloorSign.class),
|
||||
@Deprecated
|
||||
FLOOR("Floor", "end", false, true, EndSign.class),
|
||||
HOLOGRAM("Hologram", "hologram", true, false, HologramSign.class),
|
||||
INTERACT("Interact", "interact", true, true, InteractSign.class),
|
||||
LEAVE("Leave", "leave", true, true, LeaveSign.class),
|
||||
|
@ -18,9 +18,11 @@ package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.dungeon.Dungeon;
|
||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
||||
import de.erethon.dungeonsxl.trigger.InteractTrigger;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import de.erethon.dungeonsxl.world.DResourceWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -32,10 +34,26 @@ public class EndSign extends DSign {
|
||||
|
||||
private DSignType type = DSignTypeDefault.END;
|
||||
|
||||
private DResourceWorld floor;
|
||||
|
||||
public EndSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the next floor
|
||||
*/
|
||||
public DResourceWorld getFloor() {
|
||||
return floor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param floor the floor to set
|
||||
*/
|
||||
public void setFloor(DResourceWorld floor) {
|
||||
this.floor = floor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
return true;
|
||||
@ -43,6 +61,10 @@ public class EndSign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
if (!lines[1].isEmpty()) {
|
||||
floor = plugin.getDWorlds().getResourceByName(lines[1]);
|
||||
}
|
||||
|
||||
if (!getTriggers().isEmpty()) {
|
||||
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
||||
return;
|
||||
@ -55,8 +77,17 @@ public class EndSign extends DSign {
|
||||
}
|
||||
|
||||
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||
getSign().setLine(1, DMessage.SIGN_END.getMessage());
|
||||
getSign().setLine(2, "");
|
||||
Dungeon dungeon = getGame().getDungeon();
|
||||
if (dungeon.isMultiFloor() && !getGame().getUnplayedFloors().isEmpty() && getGameWorld().getResource() != dungeon.getConfig().getEndFloor()) {
|
||||
getSign().setLine(1, DMessage.SIGN_FLOOR_1.getMessage());
|
||||
if (floor == null) {
|
||||
getSign().setLine(2, DMessage.SIGN_FLOOR_2.getMessage());
|
||||
} else {
|
||||
getSign().setLine(2, ChatColor.DARK_GREEN + floor.getName().replace("_", " "));
|
||||
}
|
||||
} else {
|
||||
getSign().setLine(1, DMessage.SIGN_END.getMessage());
|
||||
}
|
||||
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||
getSign().update();
|
||||
}
|
||||
@ -72,7 +103,7 @@ public class EndSign extends DSign {
|
||||
return true;
|
||||
}
|
||||
|
||||
dPlayer.finish();
|
||||
dPlayer.finishFloor(floor);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2018 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.erethon.dungeonsxl.sign;
|
||||
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
||||
import de.erethon.dungeonsxl.trigger.InteractTrigger;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import de.erethon.dungeonsxl.world.DResourceWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||
*/
|
||||
public class FloorSign extends DSign {
|
||||
|
||||
private DSignType type = DSignTypeDefault.FLOOR;
|
||||
|
||||
private DResourceWorld floor;
|
||||
|
||||
public FloorSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the next floor
|
||||
*/
|
||||
public DResourceWorld getFloor() {
|
||||
return floor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param floor the floor to set
|
||||
*/
|
||||
public void setFloor(DResourceWorld floor) {
|
||||
this.floor = floor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
if (!lines[1].isEmpty()) {
|
||||
floor = plugin.getDWorlds().getResourceByName(lines[1]);
|
||||
}
|
||||
|
||||
if (!getTriggers().isEmpty()) {
|
||||
getSign().getBlock().setType(VanillaItem.AIR.getMaterial());
|
||||
return;
|
||||
}
|
||||
|
||||
InteractTrigger trigger = InteractTrigger.getOrCreate(0, getSign().getBlock(), getGameWorld());
|
||||
if (trigger != null) {
|
||||
trigger.addListener(this);
|
||||
addTrigger(trigger);
|
||||
}
|
||||
|
||||
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
|
||||
getSign().setLine(1, DMessage.SIGN_FLOOR_1.getMessage());
|
||||
if (floor == null) {
|
||||
getSign().setLine(2, DMessage.SIGN_FLOOR_2.getMessage());
|
||||
} else {
|
||||
getSign().setLine(2, ChatColor.DARK_GREEN + floor.getName().replaceAll("_", " "));
|
||||
}
|
||||
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||
getSign().update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPlayerTrigger(Player player) {
|
||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||
if (dPlayer == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dPlayer.isFinished()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
dPlayer.finishFloor(floor);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
||||
dPlayer.finishFloor(floor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DSignType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user