3
0
Fork 0

Fixed messages file, added data saving and some more fixes.

This commit is contained in:
stijnb1234 2020-04-18 09:53:19 +02:00
parent b487444b65
commit 0c16981ef6
10 changed files with 172 additions and 127 deletions

View file

@ -26,6 +26,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Objects;
@ -156,13 +157,25 @@ public final class ThemeParkPlus extends JavaPlugin {
Logger.logError("Couldn't find classes for Lamp & Gate util. The plugin won't work as intended.", true);
}
Logger.logInfo("Loading data...", true);
try {
data.load();
} catch (SQLException e) {
e.printStackTrace();
Logger.logError("Couldn't load data! Something went wrong.", true);
}
Logger.logInfo("Plugin enabled!", true);
Logger.logInfo("-------------------------------", true);
}
@Override
public void onDisable() {
Logger.logInfo("Saving data to data file...", true);
data.save();
if (getSConfig().getFile().getBoolean("DiscordWebhook.Enabled")) {
Logger.logInfo("Breaking discord connection...", true);
webhookClient.close();
}
Logger.logInfo("Plugin disabled!", true);

View file

@ -18,15 +18,6 @@ public class Gate {
private boolean isDirectional = false;
private WalkingDirection direction;
/**
* Constructor for a normal gate.
*
* @param loc The gate location
*/
public Gate(Location loc) {
this.loc = loc;
}
/**
* Constructor for a directional gate.
*

View file

@ -4,6 +4,7 @@ import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import nl.sbdeveloper.themeparkplus.api.PlusAPI;
import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection;
import nl.sbdeveloper.themeparkplus.api.objects.Gate;
import nl.sbdeveloper.themeparkplus.util.ConfigUtil;
import nl.sbdeveloper.themeparkplus.util.Cuboid;
import nl.sbdeveloper.themeparkplus.util.LGUtil;
import org.bukkit.Bukkit;
@ -14,8 +15,11 @@ import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
public class TPPCMD implements CommandExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
@ -25,13 +29,13 @@ public class TPPCMD implements CommandExecutor {
return infoCommand(sender);
} else if (args[0].equalsIgnoreCase("opengate") && args.length == 5) {
if (!sender.hasPermission("tpp.opengate")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
return openGate(sender, args, 0, null);
} else if (args[0].equalsIgnoreCase("opengate") && args.length == 6) {
if (!sender.hasPermission("tpp.opengate")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
@ -44,13 +48,13 @@ public class TPPCMD implements CommandExecutor {
return openGate(sender, args, 0, dir);
} catch (Exception ex2) {
sender.sendMessage(ChatColor.RED + "Unknown direction or amount.");
sender.sendMessage(ConfigUtil.getMessage("Gates.UnknownDirAndAmount"));
return true;
}
}
} else if (args[0].equalsIgnoreCase("opengate") && args.length == 7) {
if (!sender.hasPermission("tpp.opengate")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
@ -60,7 +64,7 @@ public class TPPCMD implements CommandExecutor {
try {
amount = Integer.parseInt(args[5]);
} catch (NumberFormatException ex) {
sender.sendMessage(ChatColor.RED + "Unknown amount.");
sender.sendMessage(ConfigUtil.getMessage("General.IncorrectAmount"));
ex.printStackTrace();
return true;
}
@ -68,27 +72,27 @@ public class TPPCMD implements CommandExecutor {
try {
dir = WalkingDirection.valueOf(args[6]);
} catch (Exception ex2) {
sender.sendMessage(ChatColor.RED + "Unknown direction.");
sender.sendMessage(ConfigUtil.getMessage("Gates.UnknownDir"));
return true;
}
return openGate(sender, args, amount, dir);
} else if (args[0].equalsIgnoreCase("closegate") && args.length == 5) {
if (!sender.hasPermission("tpp.closegate")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
return closeGate(sender, args);
} else if (args[0].equalsIgnoreCase("lampon") && args.length == 5) {
if (!sender.hasPermission("tpp.lampon")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
return lampTurnOnCommand(sender, args, 0);
} else if (args[0].equalsIgnoreCase("lampon") && args.length == 6) {
if (!sender.hasPermission("tpp.lampon")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
@ -96,26 +100,26 @@ public class TPPCMD implements CommandExecutor {
try {
amount = Integer.parseInt(args[5]);
} catch (NumberFormatException ex) {
sender.sendMessage(ChatColor.RED + "Unknown amount.");
sender.sendMessage(ConfigUtil.getMessage("General.IncorrectAmount"));
return true;
}
return lampTurnOnCommand(sender, args, amount);
} else if (args[0].equalsIgnoreCase("lampoff") && args.length == 5) {
if (!sender.hasPermission("tpp.lampoff")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
return lampTurnOffCommand(sender, args);
} else if (args[0].equalsIgnoreCase("lampson") && args.length == 8) {
if (!sender.hasPermission("tpp.lampson")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
return lampsTurnOnCommand(sender, args, 0);
} else if (args[0].equalsIgnoreCase("lampson") && args.length == 9) {
if (!sender.hasPermission("tpp.lampson")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
@ -123,14 +127,14 @@ public class TPPCMD implements CommandExecutor {
try {
amount = Integer.parseInt(args[8]);
} catch (NumberFormatException ex) {
sender.sendMessage(ChatColor.RED + "Unknown amount.");
sender.sendMessage(ConfigUtil.getMessage("General.IncorrectAmount"));
return true;
}
return lampsTurnOnCommand(sender, args, amount);
} else if (args[0].equalsIgnoreCase("lampsoff") && args.length == 8) {
if (!sender.hasPermission("tpp.lampsoff")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do this.");
sender.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return true;
}
return lampsTurnOffCommand(sender, args);
@ -188,7 +192,7 @@ public class TPPCMD implements CommandExecutor {
Block b = loc.getBlock();
if (LGUtil.isOpenable(b)) {
if (LGUtil.isOpen(b)) {
sender.sendMessage(ChatColor.RED + "That gate is already opened!");
sender.sendMessage(ConfigUtil.getMessage("Gates.AlreadyOpen"));
return true;
}
if (gate != null && gate.isDirectional()) {
@ -197,14 +201,14 @@ public class TPPCMD implements CommandExecutor {
LGUtil.openGate(b);
}
} else {
sender.sendMessage(ChatColor.RED + "That block is not a gate.");
sender.sendMessage(ConfigUtil.getMessage("Gates.NoGate"));
return true;
}
if (amount != 0) {
sender.sendMessage(ChatColor.GREEN + "Gate opened for " + amount + " players!");
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Gates.Opened"));
} else {
sender.sendMessage(ChatColor.GREEN + "Gate opened!");
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Gates.OpenedAmount", Collections.singletonMap("%amount%", String.valueOf(amount))));
}
return true;
}
@ -224,16 +228,16 @@ public class TPPCMD implements CommandExecutor {
}
if (!LGUtil.isOpen(b)) {
sender.sendMessage(ChatColor.RED + "That gate is already closed!");
sender.sendMessage(ConfigUtil.getMessage("Gates.AlreadyClosed"));
return true;
}
LGUtil.closeGate(b);
} else {
sender.sendMessage(ChatColor.RED + "That block is not a gate.");
sender.sendMessage(ConfigUtil.getMessage("Gates.NoGate"));
return true;
}
sender.sendMessage(ChatColor.GREEN + "Gate closed!");
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Gates.Closed"));
return true;
}
@ -247,19 +251,19 @@ public class TPPCMD implements CommandExecutor {
if (secOn == 0) {
if (!LGUtil.zetLampAan(block)) {
sender.sendMessage(ChatColor.RED + "Couldn't turn the lamp on. Maybe it's not a lamp, or it's already on.");
sender.sendMessage(ConfigUtil.getMessage("Lamps.ErrorOn"));
return true;
}
sender.sendMessage(ChatColor.GREEN + "Lamp turned on!");
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamps.TurnedOn"));
} else {
if (!LGUtil.zetLampAan(block)) {
sender.sendMessage(ChatColor.RED + "Couldn't turn the lamp on. Maybe it's not a lamp, or it's already on.");
sender.sendMessage(ConfigUtil.getMessage("Lamps.ErrorOn"));
return true;
}
Bukkit.getScheduler().runTaskLater(ThemeParkPlus.getInstance(), () -> LGUtil.zetLampUit(block), secOn * 20);
sender.sendMessage(ChatColor.GREEN + "Lamp turned on for " + secOn + " second(s)!");
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamps.TurnedOnSec", Collections.singletonMap("%sec%", String.valueOf(secOn))));
}
return true;
}
@ -272,11 +276,11 @@ public class TPPCMD implements CommandExecutor {
Location loc = new Location(bworld, bx, by, bz);
if (!LGUtil.zetLampUit(loc.getBlock())) {
sender.sendMessage(ChatColor.RED + "Couldn't turn the lamp off. Maybe it's not a lamp, or it's already off.");
sender.sendMessage(ConfigUtil.getMessage("Lamps.ErrorOn"));
return true;
}
sender.sendMessage(ChatColor.GREEN + "Lamp turned off!");
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamps.TurnedOff"));
return true;
}
@ -300,7 +304,7 @@ public class TPPCMD implements CommandExecutor {
Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlus.getInstance(), () -> cub.getBlocks().forEach(block -> {
if (block.getType().name().contains("REDSTONE_LAMP")) Bukkit.getScheduler().runTask(ThemeParkPlus.getInstance(), () -> LGUtil.zetLampAan(block));
}));
sender.sendMessage(ChatColor.GREEN + "Lamps in region turned on!");
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamps.TurnedOn"));
} else {
Bukkit.getScheduler().runTaskAsynchronously(ThemeParkPlus.getInstance(), () -> cub.getBlocks().forEach(block -> {
if (block.getType().name().contains("REDSTONE_LAMP")) Bukkit.getScheduler().runTask(ThemeParkPlus.getInstance(), () -> LGUtil.zetLampAan(block));
@ -309,7 +313,7 @@ public class TPPCMD implements CommandExecutor {
Bukkit.getScheduler().runTaskLaterAsynchronously(ThemeParkPlus.getInstance(), () -> cub.getBlocks().forEach(block -> {
if (block.getType().name().contains("REDSTONE_LAMP")) Bukkit.getScheduler().runTask(ThemeParkPlus.getInstance(), () -> LGUtil.zetLampUit(block));
}), secOn * 20);
sender.sendMessage(ChatColor.GREEN + "Lamps in region turned on for " + secOn + " seconds!");
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamps.TurnedOnSec", Collections.singletonMap("%sec%", String.valueOf(secOn))));
}
return true;
}
@ -334,7 +338,7 @@ public class TPPCMD implements CommandExecutor {
if (block.getType().name().contains("REDSTONE_LAMP")) Bukkit.getScheduler().runTask(ThemeParkPlus.getInstance(), () -> LGUtil.zetLampUit(block));
}));
sender.sendMessage(ChatColor.GREEN + "Lamps in region turned off!");
if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamps.TurnedOff"));
return true;
}
}

View file

@ -3,6 +3,7 @@ package nl.sbdeveloper.themeparkplus.listeners;
import nl.sbdeveloper.themeparkplus.api.PlusAPI;
import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection;
import nl.sbdeveloper.themeparkplus.api.objects.Gate;
import nl.sbdeveloper.themeparkplus.util.ConfigUtil;
import nl.sbdeveloper.themeparkplus.util.DirectionUtil;
import nl.sbdeveloper.themeparkplus.util.LGUtil;
import org.bukkit.ChatColor;
@ -46,7 +47,7 @@ public class DirectionalGateListener implements Listener {
if (loopdir == null) return;
if (loopdir.getBlockFace() != gate.getDirection().getBlockFace()) {
e.getPlayer().teleport(oldLoc);
e.getPlayer().sendMessage(ChatColor.RED + "You can't walk in that direction.");
e.getPlayer().sendMessage(ConfigUtil.getMessage("Gates.WrongDir"));
return;
}

View file

@ -25,6 +25,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
public class FastpassListeners implements Listener {
@EventHandler
@ -33,21 +35,28 @@ public class FastpassListeners implements Listener {
String[] lines = e.getLines();
if (!p.hasPermission("tpp.fastpass.create")) {
p.sendMessage(ChatColor.RED + "You don't have the permission to do this.");
p.sendMessage(ConfigUtil.getMessage("General.NoPermission"));
return;
}
if (!API.isAttraction(e.getLine(2))) {
p.sendMessage(ChatColor.RED + e.getLine(2) + " is not an existing ride.");
p.sendMessage(ConfigUtil.getMessage("Fastpass.UnknownRide", Collections.singletonMap("ridename", e.getLine(2))));
return;
}
String mLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1"));
String mLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2"));
String sLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1"));
String sLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2"));
if (lines[0].equalsIgnoreCase("[ThemeParkPlus]") && lines[1].equalsIgnoreCase("Machine") && !lines[2].isEmpty() && !lines[3].isEmpty()) {
e.setLine(0, ChatColor.GRAY + "[" + ChatColor.GOLD + "ThemeParkPlus" + ChatColor.GRAY + "]");
e.setLine(1, ChatColor.BLUE + "Machine");
e.setLine(0, mLineOne);
e.setLine(1, mLineTwo);
} else if (lines[0].equalsIgnoreCase("[ThemeParkPlus]") && lines[1].equalsIgnoreCase("Scanner") && !lines[2].isEmpty() && !lines[3].isEmpty()) {
e.setLine(0, ChatColor.GRAY + "[" + ChatColor.GOLD + "ThemeParkPlus" + ChatColor.GRAY + "]");
e.setLine(1, ChatColor.RED + "Scanner");
e.setLine(0, sLineOne);
e.setLine(1, sLineTwo);
} else {
p.sendMessage(ConfigUtil.getMessage("Fastpass.IncorrectSign"));
}
}
@ -55,8 +64,16 @@ public class FastpassListeners implements Listener {
public void onSignClick(PlayerInteractEvent e) {
if (e.getClickedBlock() == null || e.getAction() != Action.RIGHT_CLICK_BLOCK || !(e.getClickedBlock().getState() instanceof Sign) || e.getHand() != EquipmentSlot.HAND) return;
String mLineOne = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1")));
String mLineTwo = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2")));
String sLineOne = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1")));
String sLineTwo = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2")));
String ticketName = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.Item.DisplayName"));
Sign sign = (Sign) e.getClickedBlock().getState();
if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase("Machine")) {
if (!ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(mLineOne) && !ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(sLineOne)) return;
if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(mLineTwo)) {
//Buy a ticket
String attID = sign.getLine(2);
if (!API.isAttraction(attID)) return;
@ -74,8 +91,9 @@ public class FastpassListeners implements Listener {
if (ticket == null) return;
ItemMeta meta = ticket.getItemMeta();
if (meta == null) return;
meta.setDisplayName(ChatColor.GOLD + "Fasspass Ticket");
meta.setLore(Collections.singletonList(ChatColor.GOLD + "For: " + ConfigUtil.makecolored(att.getName())));
meta.setDisplayName(ticketName);
List<String> ticketLores = ConfigUtil.getLore("Fastpass.Item.Lore", Collections.singletonMap("%ridename", att.getName()));
meta.setLore(ticketLores);
ticket.setItemMeta(meta);
NBTItem item = new NBTItem(ticket);
@ -84,7 +102,7 @@ public class FastpassListeners implements Listener {
ticket = item.getItem();
if (ThemeParkPlus.getEconomy().getBalance(e.getPlayer()) < price) {
e.getPlayer().sendMessage(ChatColor.RED + "You can't pay this fastpass ticket.");
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.NotEnoughMoney"));
return;
}
@ -92,7 +110,7 @@ public class FastpassListeners implements Listener {
if (content == null || content.getType() == null || content.getType() == Material.AIR) continue;
NBTItem nbtContent = new NBTItem(content);
if (content.getType() == XMaterial.PAPER.parseMaterial() && content.hasItemMeta() && nbtContent.hasKey("RideID") && nbtContent.getString("RideID").equalsIgnoreCase(attID)) {
e.getPlayer().sendMessage(ChatColor.RED + "You already have a ticket for this ride.");
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.AlreadyHaveTicket"));
return;
}
}
@ -101,11 +119,14 @@ public class FastpassListeners implements Listener {
e.getPlayer().getInventory().addItem(ticket);
e.getPlayer().updateInventory();
e.getPlayer().sendMessage(ChatColor.GREEN + "Bought a Fastpass ticket for " + ConfigUtil.makecolored(att.getName()) + ChatColor.GREEN + ". You paid €" + String.format("%.2f", price) + " for it!");
} else if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase("Scanner")) {
HashMap<String, String> vars = new HashMap<>();
vars.put("%ridename%", att.getName());
vars.put("%price%", String.format("%.2f", price));
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.Bought", vars));
} else if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(sLineTwo)) {
//Scan a ticket
if (!API.isAttraction(sign.getLine(2))) {
e.getPlayer().sendMessage(ChatColor.RED + "This sign is incorrect! The attraction doesn't exists.");
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.UnknownRide", Collections.singletonMap("%ridename%", sign.getLine(2))));
return;
}
Attraction att = API.getAttraction(sign.getLine(2));
@ -114,12 +135,12 @@ public class FastpassListeners implements Listener {
NBTItem nbtContent = new NBTItem(content);
if (content.getType() == Material.AIR
|| !content.hasItemMeta() || !nbtContent.hasKey("RideID")) {
e.getPlayer().sendMessage(ChatColor.RED + "You need a fastpass ticket to go through the fastpass line.");
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.NoTicket"));
return;
}
if (att.getStatus() != Status.OPEN && att.getStatus() != Status.ACTIVE) {
e.getPlayer().sendMessage(ChatColor.RED + "This attraction is closed.");
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.RideClosed"));
return;
}
@ -140,9 +161,9 @@ public class FastpassListeners implements Listener {
}
e.getPlayer().getInventory().remove(e.getPlayer().getInventory().getItemInMainHand());
e.getPlayer().updateInventory();
e.getPlayer().sendMessage(ChatColor.GREEN + "Successfully redeemed your fastpass ticket!");
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.Redeemed"));
} catch (NumberFormatException | ArrayIndexOutOfBoundsException ex) {
e.getPlayer().sendMessage(ChatColor.RED + "This sign is incorrect!");
e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.IncorrectSign"));
}
}
}

View file

@ -7,7 +7,6 @@ import me.paradoxpixel.themepark.api.event.attraction.StatusChangeEvent;
import me.paradoxpixel.themepark.attraction.status.StatusManager;
import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import nl.sbdeveloper.themeparkplus.util.ConfigUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

View file

@ -1,11 +1,54 @@
package nl.sbdeveloper.themeparkplus.util;
import nl.sbdeveloper.themeparkplus.ThemeParkPlus;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ConfigUtil {
@NotNull
public static String makecolored(String str) {
return ChatColor.translateAlternateColorCodes('&', str);
}
@NotNull
public static List<String> getLore(String path, Map<String, String> vars) {
ArrayList<String> response = new ArrayList<>();
for (String str : ThemeParkPlus.getSConfig().getFile().getStringList(path)) {
for (Map.Entry<String, String> entry : vars.entrySet()) {
str = str.replaceAll(entry.getKey(), entry.getValue());
}
response.add(makecolored(str));
}
return response;
}
@NotNull
public static String getMessage(String path) {
return getMessage(path, new HashMap<>());
}
@NotNull
public static String getMessage(String path, Map<String, String> vars) {
String message = ThemeParkPlus.getMessages().getFile().getString(path);
if (message == null) return "";
for (Map.Entry<String, String> entry : vars.entrySet()) {
message = message.replaceAll(entry.getKey(), entry.getValue());
}
return makecolored(message);
}
public static boolean sendConsole(CommandSender sender) {
if (sender instanceof ConsoleCommandSender) {
return ThemeParkPlus.getSConfig().getFile().getBoolean("MessageInConsole");
} else {
return true;
}
}
}

View file

@ -25,15 +25,4 @@ public class DirectionUtil {
}
return null;
}
public static boolean isGoodDirection(WalkingDirection current, WalkingDirection good) {
if (current == WalkingDirection.EAST && good == WalkingDirection.EAST) {
return true;
} else if (current == WalkingDirection.NORTH && good == WalkingDirection.NORTH) {
return true;
} else if (current == WalkingDirection.SOUTH && good == WalkingDirection.SOUTH) {
return true;
} else return current == WalkingDirection.WEST && good == WalkingDirection.WEST;
}
}

View file

@ -1,14 +1,18 @@
License: 'TP-ABC-ABC'
License: 'TPABCD-1234-ABCD-1234SBD'
AntiFreerun:
Enabled: false
MessageInConsole: true
Fastpass:
ItemName: '&6ThemeParkTicket'
Item:
DisplayName: '&6Fastpass Ticket'
Lore:
- '&6For: %ridename%'
MachineSign:
Row1: "&3[ThemePark]"
Row1: "&8[&6ThemeParkPlus&8]"
Row2: "&bMachine"
ControlSign:
Row1: "&3[ThemePark]"
Row2: "&bControl"
ScannerSign:
Row1: "&8[&6ThemeParkPlus&8]"
Row2: "&bScanner"
DiscordWebhook:
Enabled: false
WebhookURL: ""
@ -23,11 +27,4 @@ DiscordWebhook:
CONSTRUCTION: 0xAAAAAA
MALFUNCTION: 0xAA00AA
ACTIVE: 0x55FF55
INACTIVE: 0xAA0000
WaitingRows:
MinutesPerWaitingPerson: 2
Sign:
Row1: "&3[ThemePark]"
Row2: "&bWaitingrow"
Row3: "%AttractionName%"
Row4: "%WaitTime% min."
INACTIVE: 0xAA0000

View file

@ -1,45 +1,32 @@
General:
OnlyForPlayers: "&cOnly players can run this command!"
NoPermission: "&cYou don't have the permission to do this!"
NoPermission: '&cYou don''t have the permission to do this.'
IncorrectAmount: '&cThis amount is incorrect.'
Gates:
Open:
ChooseDirection: "&cYou have to choose between: NORTH, EAST, SOUTH and WEST"
AlreadyOpen: "&cThat gate is already opened!"
Opened: "&aThat gate is now open!"
OpenedPlayers: "&aThat gate is now open! A maximum of %COUNT% %SINGMULTI:visitor:visitors% can now walk through it!"
Close:
AlreadyClosed: "&cThat gate is already closed!"
Closed: "&aThat gate is now closed!"
NoGate: "&cThat block is not a gate!"
NoGateConsole: "&cThe gate on the location %LocationXYZ% in the world %World% couldn't be find! It's now removed of the data!"
InvalidDirection: "&cYou can't walk through that gate in this direction!"
Lamps:
TurnOn:
NoLampOrAlreadyOn: "&cCouldn't turn that lamp on! Maybe it's already on, or it's not a redstone lamp."
IncorrectNumber: "&cThe number of seconds isn't correct! Give a number please."
TurnedOn: "&aThat lamp is succesfully turned on!"
TurnedOnSeconds: "&fThat lamp is succesfully turned on for %COUNT% %SINGMULTI:second:seconds%!"
TurnOff:
NoLampOrAlreadyOff: "&cCouldn't turn that lamp off! Maybe it's already off, or it's not a redstone lamp."
TurnedOff: "&aThat lamp is succesfully turned off!"
WrongDir: '&cYou can''t walk through this gate in that direction.'
UnknownDir: '&cThis direction is unknown. Choose between: NORTH, SOUTH, EAST, WEST'
UnknownDirAndAmount: '&cThis direction and amount are incorrect.'
AlreadyOpen: '&cThis gate is already opened.'
AlreadyClosed: '&cThis gate is already closed.'
NoGate: '&cThis block is not a gate.'
Opened: '&aThe gate is opened!'
OpenedAmount: '&aThe gate is opened for &f%amount% &aplayer(s)!'
Closed: '&aThe gate is closed!'
Fastpass:
NotEnoughMoney: "&cYou don't have enough money for this Fastpass ticket!"
AlreadyHasOne: "&cYou've already got a Fastpass ticket for this ride!"
MoneyWithdrawed: "&aA amount of $%MoneyAmount%,- is taken of your account!"
WrongLocation: "&cThat sign contains wrong coordinates!"
Expired: "&cYour fastpass ticket is already expired!"
NotOpen: "&cThat ride is not open!"
YouNeedATicket: "&cYou need a (correct) ticket to use the FastPass row!"
Succes: "&aHave fun in this ride!"
Malfunction:
ReasonQuestion: "&aPlease type the reason of the malfunction! (Type STOP to set it to Unknown)"
Reported: "&aThe malfunction has been reported to the Technical Service!"
Fixed: "&aThe malfunction has succesfully been removed!"
NotAllowedToChange: "&cYou can't change the status if a ride has a malfunction!"
WaitingRows:
WrongLocation: "&cA waitingrow sign (from the attraction %AttractionID%) couldn't be found! It will be deleted."
WrongAttraction: "&cThat attraction doesn't exists!"
ForgotSelection: "&cYou forgot to select a region! Please select a point one (left) and point two (right) with a STICK."
PosOneSelected: "&aSuccesfully selected position one!"
PosTwoSelected: "&aSuccesfully selected position two!"
SignCreated: "&aYou've succesfully created a WaitingRow sign!"
IncorrectSign: '&cThis sign is incorrect. Please read the wiki for more information.'
UnknownRide: '&cThe ride %ridename% &cdoes''nt exists.'
NotEnoughMoney: '&cYou can''t pay this ticket.'
AlreadyHaveTicket: '&cYou''ve already got a ticket for this ride.'
Bought: '&aYou''ve successfully bought a ticket for the ride %ridename%&a. You''ve paid &f%price% &afor it.'
NoTicket: '&cYou need a fastpass ticket to go through the fastpass line.'
RideClosed: '&cThis ride is closed.'
Redeemed: '&aSuccessfully redeemed your fastpass ticket!'
Lamp:
ErrorOn: '&cCouldn''t turn the lamp on. Maybe it''s not a lamp, or it''s already on.'
ErrorOff: '&cCouldn''t turn the lamp off. Maybe it''s not a lamp, or it''s already off.'
TurnedOn: '&aLamp turned on!'
TurnedOnSec: '&aLamp turned on for &f%sec% &asecond(s)!'
TurnedOff: '&aLamp turned off!'
Lamps:
TurnedOn: '&aLamps in region turned on!'
TurnedOnSec: '&aLamps in region turned on for &f%sec% &asecond(s)!'
TurnedOff: '&aLamps in region turned off!'