mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +01:00
Added script signs (untested)
This commit is contained in:
parent
9e6ea22b39
commit
569ddf5a8a
@ -44,6 +44,7 @@ import io.github.dre2n.dungeonsxl.requirement.RequirementTypes;
|
|||||||
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
||||||
import io.github.dre2n.dungeonsxl.reward.RewardTypes;
|
import io.github.dre2n.dungeonsxl.reward.RewardTypes;
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSignTypes;
|
import io.github.dre2n.dungeonsxl.sign.DSignTypes;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.SignScripts;
|
||||||
import io.github.dre2n.dungeonsxl.task.AnnouncerTask;
|
import io.github.dre2n.dungeonsxl.task.AnnouncerTask;
|
||||||
import io.github.dre2n.dungeonsxl.task.LazyUpdateTask;
|
import io.github.dre2n.dungeonsxl.task.LazyUpdateTask;
|
||||||
import io.github.dre2n.dungeonsxl.task.SecureModeTask;
|
import io.github.dre2n.dungeonsxl.task.SecureModeTask;
|
||||||
@ -73,6 +74,7 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
public static File ANNOUNCERS;
|
public static File ANNOUNCERS;
|
||||||
public static File CLASSES;
|
public static File CLASSES;
|
||||||
public static File MOBS;
|
public static File MOBS;
|
||||||
|
public static File SIGNS;
|
||||||
|
|
||||||
private DataConfig dataConfig;
|
private DataConfig dataConfig;
|
||||||
private MainConfig mainConfig;
|
private MainConfig mainConfig;
|
||||||
@ -91,6 +93,7 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
private Announcers announcers;
|
private Announcers announcers;
|
||||||
private DClasses dClasses;
|
private DClasses dClasses;
|
||||||
private DMobTypes dMobTypes;
|
private DMobTypes dMobTypes;
|
||||||
|
private SignScripts signScripts;
|
||||||
|
|
||||||
private BukkitTask announcerTask;
|
private BukkitTask announcerTask;
|
||||||
private BukkitTask worldUnloadTask;
|
private BukkitTask worldUnloadTask;
|
||||||
@ -150,6 +153,7 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
loadAnnouncers(ANNOUNCERS);
|
loadAnnouncers(ANNOUNCERS);
|
||||||
loadDClasses(CLASSES);
|
loadDClasses(CLASSES);
|
||||||
loadDMobTypes(MOBS);
|
loadDMobTypes(MOBS);
|
||||||
|
loadSignScripts(SIGNS);
|
||||||
|
|
||||||
manager.registerEvents(new EntityListener(), this);
|
manager.registerEvents(new EntityListener(), this);
|
||||||
manager.registerEvents(new GUIListener(), this);
|
manager.registerEvents(new GUIListener(), this);
|
||||||
@ -242,6 +246,11 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
if (!MOBS.exists()) {
|
if (!MOBS.exists()) {
|
||||||
MOBS.mkdir();
|
MOBS.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SIGNS = new File(SCRIPTS, "signs");
|
||||||
|
if (!SIGNS.exists()) {
|
||||||
|
SIGNS.mkdir();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save and load
|
// Save and load
|
||||||
@ -543,6 +552,20 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
dMobTypes = new DMobTypes(file);
|
dMobTypes = new DMobTypes(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loaded instance of SignScripts
|
||||||
|
*/
|
||||||
|
public SignScripts getSignScripts() {
|
||||||
|
return signScripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of SignScripts
|
||||||
|
*/
|
||||||
|
public void loadSignScripts(File file) {
|
||||||
|
signScripts = new SignScripts(file);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the worldUnloadTask
|
* @return the worldUnloadTask
|
||||||
*/
|
*/
|
||||||
|
@ -32,9 +32,9 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
* @author Frank Baumann, Daniel Saukel
|
* @author Frank Baumann, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class ReloadCommand extends BRCommand {
|
public class ReloadCommand extends BRCommand {
|
||||||
|
|
||||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
public ReloadCommand() {
|
public ReloadCommand() {
|
||||||
setCommand("reload");
|
setCommand("reload");
|
||||||
setMinArgs(0);
|
setMinArgs(0);
|
||||||
@ -44,11 +44,11 @@ public class ReloadCommand extends BRCommand {
|
|||||||
setPlayerCommand(true);
|
setPlayerCommand(true);
|
||||||
setConsoleCommand(true);
|
setConsoleCommand(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
PluginManager plugins = Bukkit.getServer().getPluginManager();
|
PluginManager plugins = Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
|
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
|
||||||
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
|
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
|
||||||
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
|
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
|
||||||
@ -85,11 +85,12 @@ public class ReloadCommand extends BRCommand {
|
|||||||
plugin.loadAnnouncers(DungeonsXL.ANNOUNCERS);
|
plugin.loadAnnouncers(DungeonsXL.ANNOUNCERS);
|
||||||
plugin.loadDClasses(DungeonsXL.CLASSES);
|
plugin.loadDClasses(DungeonsXL.CLASSES);
|
||||||
plugin.loadDMobTypes(DungeonsXL.MOBS);
|
plugin.loadDMobTypes(DungeonsXL.MOBS);
|
||||||
|
plugin.loadSignScripts(DungeonsXL.SIGNS);
|
||||||
|
|
||||||
MessageUtil.sendPluginTag(sender, plugin);
|
MessageUtil.sendPluginTag(sender, plugin);
|
||||||
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_RELOAD_DONE.getMessage());
|
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_RELOAD_DONE.getMessage());
|
||||||
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_LOADED.getMessage(String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
|
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_LOADED.getMessage(String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
|
||||||
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_COMPATIBILITY.getMessage(String.valueOf(internals), vault, mythicMobs));
|
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_MAIN_COMPATIBILITY.getMessage(String.valueOf(internals), vault, mythicMobs));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package io.github.dre2n.dungeonsxl.game;
|
package io.github.dre2n.dungeonsxl.game;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -60,7 +61,7 @@ public class GameTypes {
|
|||||||
/**
|
/**
|
||||||
* @return the game type which has the enum value sign text in the second line of the sign
|
* @return the game type which has the enum value sign text in the second line of the sign
|
||||||
*/
|
*/
|
||||||
public GameType getBySign(Sign sign) {
|
public GameType getBySign(DSign sign) {
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
|
|
||||||
for (GameType type : types) {
|
for (GameType type : types) {
|
||||||
|
@ -47,7 +47,6 @@ public class BlockSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
if (!lines[1].isEmpty()) {
|
if (!lines[1].isEmpty()) {
|
||||||
String line1[] = lines[1].split(",");
|
String line1[] = lines[1].split(",");
|
||||||
Material offBlock = Material.matchMaterial(line1[0]);
|
Material offBlock = Material.matchMaterial(line1[0]);
|
||||||
|
@ -44,7 +44,6 @@ public class ChestSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String[] lines = getSign().getLines();
|
|
||||||
if (!lines[1].isEmpty()) {
|
if (!lines[1].isEmpty()) {
|
||||||
String[] attributes = lines[1].split(",");
|
String[] attributes = lines[1].split(",");
|
||||||
if (attributes.length >= 1) {
|
if (attributes.length >= 1) {
|
||||||
|
@ -40,7 +40,6 @@ public class ChunkUpdaterSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
Chunk chunk = getGameWorld().getWorld().getChunkAt(getSign().getBlock());
|
Chunk chunk = getGameWorld().getWorld().getChunkAt(getSign().getBlock());
|
||||||
|
|
||||||
if (!lines[1].isEmpty()) {
|
if (!lines[1].isEmpty()) {
|
||||||
|
@ -55,7 +55,6 @@ public class ClassesSign extends DSign {
|
|||||||
/* Actions */
|
/* Actions */
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
String[] lines = getSign().getLines();
|
|
||||||
return plugin.getDClasses().getByName(lines[1]) != null;
|
return plugin.getDClasses().getByName(lines[1]) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ public class CommandSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
if (lines[1].isEmpty() || lines[2].isEmpty()) {
|
if (lines[1].isEmpty() || lines[2].isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -70,7 +69,6 @@ public class CommandSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String[] lines = getSign().getLines();
|
|
||||||
String[] attributes = lines[2].split(",");
|
String[] attributes = lines[2].split(",");
|
||||||
|
|
||||||
command = lines[1];
|
command = lines[1];
|
||||||
|
@ -131,7 +131,6 @@ public class DMobSign extends DSign implements MobSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
if (lines[1].isEmpty() || lines[2].isEmpty()) {
|
if (lines[1].isEmpty() || lines[2].isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -151,7 +150,6 @@ public class DMobSign extends DSign implements MobSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
if (!lines[1].isEmpty() && !lines[2].isEmpty()) {
|
if (!lines[1].isEmpty() && !lines[2].isEmpty()) {
|
||||||
String mob = lines[1];
|
String mob = lines[1];
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
|
@ -37,13 +37,15 @@ public abstract class DSign {
|
|||||||
static DungeonsXL plugin = DungeonsXL.getInstance();
|
static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private Sign sign;
|
private Sign sign;
|
||||||
|
protected String[] lines;
|
||||||
private GameWorld gameWorld;
|
private GameWorld gameWorld;
|
||||||
|
|
||||||
// List of Triggers
|
// List of Triggers
|
||||||
private Set<Trigger> triggers = new HashSet<>();
|
private Set<Trigger> triggers = new HashSet<>();
|
||||||
|
|
||||||
public DSign(Sign sign, GameWorld gameWorld) {
|
public DSign(Sign sign, GameWorld gameWorld) {
|
||||||
this.setSign(sign);
|
this.sign = sign;
|
||||||
|
this.lines = sign.getLines();
|
||||||
this.gameWorld = gameWorld;
|
this.gameWorld = gameWorld;
|
||||||
|
|
||||||
// Check Trigger
|
// Check Trigger
|
||||||
@ -88,6 +90,21 @@ public abstract class DSign {
|
|||||||
this.sign = sign;
|
this.sign = sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sign lines
|
||||||
|
*/
|
||||||
|
public String[] getLines() {
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param lines
|
||||||
|
* the sign lines to set
|
||||||
|
*/
|
||||||
|
public void setLines(String[] lines) {
|
||||||
|
this.lines = lines;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the gameWorld
|
* @return the gameWorld
|
||||||
*/
|
*/
|
||||||
@ -169,7 +186,10 @@ public abstract class DSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static DSign create(Sign sign, GameWorld gameWorld) {
|
public static DSign create(Sign sign, GameWorld gameWorld) {
|
||||||
String[] lines = sign.getLines();
|
return create(sign, sign.getLines(), gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DSign create(Sign sign, String[] lines, GameWorld gameWorld) {
|
||||||
DSign dSign = null;
|
DSign dSign = null;
|
||||||
|
|
||||||
for (DSignType type : plugin.getDSigns().getDSigns()) {
|
for (DSignType type : plugin.getDSigns().getDSigns()) {
|
||||||
|
@ -42,6 +42,7 @@ public enum DSignTypeDefault implements DSignType {
|
|||||||
PLACE("Place", "place", false, PlaceSign.class),
|
PLACE("Place", "place", false, PlaceSign.class),
|
||||||
READY("Ready", "ready", true, ReadySign.class),
|
READY("Ready", "ready", true, ReadySign.class),
|
||||||
REDSTONE("Redstone", "redstone", false, RedstoneSign.class),
|
REDSTONE("Redstone", "redstone", false, RedstoneSign.class),
|
||||||
|
SCRIPT("Script", "script", false, ScriptSign.class),
|
||||||
SOUND_MESSAGE("SoundMSG", "soundmsg", false, SoundMessageSign.class),
|
SOUND_MESSAGE("SoundMSG", "soundmsg", false, SoundMessageSign.class),
|
||||||
START("Start", "start", true, StartSign.class),
|
START("Start", "start", true, StartSign.class),
|
||||||
TRIGGER("Trigger", "trigger", true, TriggerSign.class),
|
TRIGGER("Trigger", "trigger", true, TriggerSign.class),
|
||||||
|
@ -196,7 +196,6 @@ public class ExternalMobSign extends DSign implements MobSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
if (lines[1].isEmpty() || lines[2].isEmpty()) {
|
if (lines[1].isEmpty() || lines[2].isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -216,8 +215,6 @@ public class ExternalMobSign extends DSign implements MobSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
|
|
||||||
String mob = lines[1];
|
String mob = lines[1];
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
String[] attributes = lines[2].split(",");
|
String[] attributes = lines[2].split(",");
|
||||||
|
@ -44,7 +44,6 @@ public class FloorSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String[] lines = getSign().getLines();
|
|
||||||
if (!lines[1].isEmpty()) {
|
if (!lines[1].isEmpty()) {
|
||||||
floor = lines[1];
|
floor = lines[1];
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,6 @@ public class MessageSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
|
|
||||||
if (!lines[1].isEmpty()) {
|
if (!lines[1].isEmpty()) {
|
||||||
String msg = getGame().getRules().getMsg(NumberUtil.parseInt(lines[1]), true);
|
String msg = getGame().getRules().getMsg(NumberUtil.parseInt(lines[1]), true);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
|
@ -39,7 +39,6 @@ public class PlaceSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
getGameWorld().getPlaceableBlocks().add(new GamePlaceableBlock(getSign().getBlock(), lines[1], lines[2]));
|
getGameWorld().getPlaceableBlocks().add(new GamePlaceableBlock(getSign().getBlock(), lines[1], lines[2]));
|
||||||
getSign().getBlock().setType(Material.AIR);
|
getSign().getBlock().setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,8 @@ public class ReadySign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (plugin.getGameTypes().getBySign(getSign()) != null) {
|
if (plugin.getGameTypes().getBySign(this) != null) {
|
||||||
gameType = plugin.getGameTypes().getBySign(getSign());
|
gameType = plugin.getGameTypes().getBySign(this);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
gameType = GameTypeDefault.DEFAULT;
|
gameType = GameTypeDefault.DEFAULT;
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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.block.Sign;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class ScriptSign extends DSign {
|
||||||
|
|
||||||
|
private DSignType type = DSignTypeDefault.SCRIPT;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public ScriptSign(Sign sign, GameWorld gameWorld) {
|
||||||
|
super(sign, gameWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the script
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
return plugin.getSignScripts().getByName(lines[1]) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
SignScript script = plugin.getSignScripts().getByName(name);
|
||||||
|
for (String[] lines : script.getSigns()) {
|
||||||
|
getGameWorld().getDSigns().add(DSign.create(getSign(), lines, getGameWorld()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DSignType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* 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.NumberUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class SignScript {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private List<String[]> signs = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param file
|
||||||
|
* the script file
|
||||||
|
*/
|
||||||
|
public SignScript(File file) {
|
||||||
|
this(file.getName().substring(0, file.getName().length() - 4), YamlConfiguration.loadConfiguration(file));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* the name of the Announcer
|
||||||
|
* @param config
|
||||||
|
* the config that stores the information
|
||||||
|
*/
|
||||||
|
public SignScript(String name, FileConfiguration config) {
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (String key : config.getKeys(false)) {
|
||||||
|
int index = NumberUtil.parseInt(key);
|
||||||
|
String[] lines = config.getStringList(key).toArray(signs.get(i));
|
||||||
|
signs.set(index, lines);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the announcer
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the signs
|
||||||
|
*/
|
||||||
|
public List<String[]> getSigns() {
|
||||||
|
return signs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param index
|
||||||
|
* the index number
|
||||||
|
* @return the lines of the sign
|
||||||
|
*/
|
||||||
|
public String[] getLines(int index) {
|
||||||
|
return signs.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param index
|
||||||
|
* the index number
|
||||||
|
* @param lines
|
||||||
|
* the lines to set
|
||||||
|
*/
|
||||||
|
public void setLines(int index, String[] lines) {
|
||||||
|
signs.set(index, lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* 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.FileUtil;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class SignScripts {
|
||||||
|
|
||||||
|
private List<SignScript> scripts = new ArrayList<>();
|
||||||
|
|
||||||
|
public SignScripts(File file) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
for (File script : FileUtil.getFilesForFolder(file)) {
|
||||||
|
scripts.add(new SignScript(script));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the script that has the name
|
||||||
|
*/
|
||||||
|
public SignScript getByName(String name) {
|
||||||
|
for (SignScript script : scripts) {
|
||||||
|
if (script.getName().equalsIgnoreCase(name)) {
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the scripts
|
||||||
|
*/
|
||||||
|
public List<SignScript> getScripts() {
|
||||||
|
return scripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param script
|
||||||
|
* the SignScript to add
|
||||||
|
*/
|
||||||
|
public void addScript(SignScript script) {
|
||||||
|
scripts.add(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param script
|
||||||
|
* the SignScript to remove
|
||||||
|
*/
|
||||||
|
public void removeScript(SignScript script) {
|
||||||
|
scripts.remove(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -50,8 +50,6 @@ public class SoundMessageSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String lines[] = getSign().getLines();
|
|
||||||
|
|
||||||
if (!lines[1].isEmpty()) {
|
if (!lines[1].isEmpty()) {
|
||||||
String msg = getGame().getRules().getMsg(NumberUtil.parseInt(lines[1]), true);
|
String msg = getGame().getRules().getMsg(NumberUtil.parseInt(lines[1]), true);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
|
@ -75,7 +75,6 @@ public class WaveSign extends DSign {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
String[] lines = getSign().getLines();
|
|
||||||
if (!lines[1].isEmpty()) {
|
if (!lines[1].isEmpty()) {
|
||||||
mobCountIncreaseRate = NumberUtil.parseDouble(lines[1], 2);
|
mobCountIncreaseRate = NumberUtil.parseDouble(lines[1], 2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user