mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-03-09 21:29:05 +01:00
Add integration for BossShop; resolves #126
This commit is contained in:
parent
15ae32ae84
commit
6d543c22be
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerEscapeEvent;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import org.black_ixx.bossshop.BossShop;
|
||||
import org.black_ixx.bossshop.core.BSShop;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class BossShopSign extends DSign {
|
||||
|
||||
BossShop bossShop = (BossShop) Bukkit.getPluginManager().getPlugin("BossShop");
|
||||
|
||||
private DSignType type = DSignTypeDefault.BOSS_SHOP;
|
||||
|
||||
public BossShopSign(Sign sign, String[] lines, DGameWorld gameWorld) {
|
||||
super(sign, lines, gameWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
if (bossShop.getAPI().getShop(lines[1]) == null) {
|
||||
markAsErroneous();
|
||||
return;
|
||||
}
|
||||
|
||||
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.GREEN + lines[1]);
|
||||
getSign().setLine(2, ChatColor.GREEN + lines[2]);
|
||||
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
|
||||
getSign().update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPlayerTrigger(Player player) {
|
||||
openShop(player, lines[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DSignType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void openShop(Player player, String shopName) {
|
||||
BSShop shop = bossShop.getAPI().getShop(shopName);
|
||||
if (shop != null) {
|
||||
bossShop.getAPI().openShop(player, shop);
|
||||
} else {
|
||||
MessageUtil.sendMessage(player, ChatColor.RED + "Shop " + shopName + " not found...");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -25,6 +25,7 @@ public enum DSignTypeDefault implements DSignType {
|
||||
|
||||
BED("Bed", "bed", false, false, BedSign.class),
|
||||
BLOCK("Block", "block", false, true, BlockSign.class),
|
||||
BOSS_SHOP("BossShop", "bossshop", false, true, BossShopSign.class),
|
||||
CHECKPOINT("Checkpoint", "checkpoint", false, false, CheckpointSign.class),
|
||||
CHEST("Chest", "chest", false, false, ChestSign.class),
|
||||
CHUNK_UPDATER("ChunkUpdater", "chunkupdater", true, false, ChunkUpdaterSign.class),
|
||||
|
Loading…
Reference in New Issue
Block a user