mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Holographic Displays integration; resolves #4
This commit is contained in:
parent
c7695f815e
commit
df843c95ef
5
pom.xml
5
pom.xml
@ -105,6 +105,11 @@
|
||||
<version>2.0.18-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.filoghost</groupId>
|
||||
<artifactId>holographicdisplaysapi</artifactId>
|
||||
<version>2.1.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
@ -33,6 +33,7 @@ public enum DSignTypeDefault implements DSignType {
|
||||
END("End", "end", false, EndSign.class),
|
||||
EXTERNAL_MOB("ExternalMob", "mob", false, ExternalMobSign.class),
|
||||
FLOOR("Floor", "floor", false, FloorSign.class),
|
||||
HOLOGRAM("Hologram", "hologram", true, HologramSign.class),
|
||||
INTERACT("Interact", "interact", true, InteractSign.class),
|
||||
LEAVE("Leave", "leave", true, LeaveSign.class),
|
||||
LIVES_MODIFIER("Lives", "lives", false, LivesModifierSign.class),
|
||||
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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 com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||
import io.github.dre2n.commons.compatibility.Version;
|
||||
import io.github.dre2n.commons.util.EnumUtil;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.itemsxl.util.commons.util.NumberUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class HologramSign extends DSign {
|
||||
|
||||
private DSignType type = DSignTypeDefault.HOLOGRAM;
|
||||
|
||||
private Hologram hologram;
|
||||
|
||||
public HologramSign(Sign sign, String[] lines, GameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onInit() {
|
||||
getSign().setType(Material.AIR);
|
||||
|
||||
String[] holoLines = lines[1].split("/");
|
||||
Location location = getSign().getLocation();
|
||||
location = location.add(0, NumberUtil.parseDouble(lines[2]), 0);
|
||||
|
||||
hologram = HologramsAPI.createHologram(plugin, location);
|
||||
for (String line : holoLines) {
|
||||
if (line.startsWith("Item:")) {
|
||||
String id = line.replace("Item:", "");
|
||||
ItemStack item;
|
||||
|
||||
if (Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
||||
item = plugin.getCaliburnAPI().getItems().getById(id).toItemStack(1);
|
||||
|
||||
} else if (EnumUtil.isValidEnum(Material.class, id)) {
|
||||
item = new ItemStack(Material.valueOf(id));
|
||||
|
||||
} else {
|
||||
item = new ItemStack(NumberUtil.parseInt(id));
|
||||
}
|
||||
|
||||
hologram.appendItemLine(item);
|
||||
|
||||
} else {
|
||||
hologram.appendTextLine(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DSignType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user