mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-05 02:09:48 +01:00
Added warp / destination signs
This commit is contained in:
parent
4a6c450097
commit
973297b2cc
@ -29,6 +29,7 @@ public enum DSignTypeDefault implements DSignType {
|
||||
CHUNK_UPDATER("ChunkUpdater", "chunkupdater", true, ChunkUpdaterSign.class),
|
||||
CLASSES("Classes", "classes", true, ClassesSign.class),
|
||||
COMMAND("CMD", "cmd", false, CommandSign.class),
|
||||
DESTINATION("Destination", "warp", false, DestinationSign.class),
|
||||
DROP("Drop", "drop", false, DropSign.class),
|
||||
END("End", "end", false, EndSign.class),
|
||||
EXTERNAL_MOB("ExternalMob", "mob", false, ExternalMobSign.class),
|
||||
@ -49,7 +50,8 @@ public enum DSignTypeDefault implements DSignType {
|
||||
START("Start", "start", true, StartSign.class),
|
||||
TELEPORT("Teleport", "teleport", false, TeleportSign.class),
|
||||
TRIGGER("Trigger", "trigger", true, TriggerSign.class),
|
||||
WAVE("Wave", "wave", false, WaveSign.class);
|
||||
WAVE("Wave", "wave", false, WaveSign.class),
|
||||
WARP("Warp", "warp", false, WarpSign.class);
|
||||
|
||||
private String name;
|
||||
private String buildPermission;
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 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 io.github.dre2n.dungeonsxl.sign;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||
*/
|
||||
public class DestinationSign extends DSign {
|
||||
|
||||
private DSignType type = DSignTypeDefault.DESTINATION;
|
||||
|
||||
private String id;
|
||||
|
||||
public DestinationSign(Sign sign, String[] lines, GameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the ID of the destination sign
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
@Override
|
||||
public boolean check() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
id = lines[1];
|
||||
getSign().getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DSignType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
114
src/main/java/io/github/dre2n/dungeonsxl/sign/WarpSign.java
Normal file
114
src/main/java/io/github/dre2n/dungeonsxl/sign/WarpSign.java
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 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 io.github.dre2n.dungeonsxl.sign;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.itemsxl.util.commons.util.playerutil.PlayerUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||
*/
|
||||
public class WarpSign extends DSign {
|
||||
|
||||
private DSignType type = DSignTypeDefault.WARP;
|
||||
|
||||
private String destination;
|
||||
|
||||
public WarpSign(Sign sign, String[] lines, GameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the destination sign
|
||||
*/
|
||||
public DestinationSign getDestinationSign() {
|
||||
for (DSign dSign : getGameWorld().getDSigns()) {
|
||||
if (dSign.getType() == DSignTypeDefault.DESTINATION) {
|
||||
if (((DestinationSign) dSign).getId().equals(destination)) {
|
||||
return (DestinationSign) dSign;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the destination
|
||||
*/
|
||||
public Location getDestination() {
|
||||
if (getDestinationSign() != null) {
|
||||
return getDestinationSign().getSign().getLocation();
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the ID of the destination sign
|
||||
*/
|
||||
public void setDestination(String id) {
|
||||
destination = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
destination = lines[1];
|
||||
|
||||
if (!getTriggers().isEmpty()) {
|
||||
getSign().getBlock().setType(Material.AIR);
|
||||
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, ChatColor.DARK_GREEN + "Warp");
|
||||
getSign().setLine(2, "");
|
||||
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||
getSign().update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPlayerTrigger(Player player) {
|
||||
PlayerUtil.secureTeleport(player, getDestination());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DSignType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user