diff --git a/src/main/java/mviper/plugin/hotels/bukkit/CommandListener.java b/src/main/java/mviper/plugin/hotels/bukkit/CommandListener.java
new file mode 100644
index 0000000..60882f7
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/bukkit/CommandListener.java
@@ -0,0 +1,77 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.bukkit;
+
+import mviper.plugin.hotels.core.commands.CommandDelegator;
+import mviper.plugin.hotels.core.exceptions.HotelsException;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.TabCompleter;
+import org.bukkit.entity.Player;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class CommandListener implements CommandExecutor, TabCompleter {
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+
+ try {
+ Player player = sender instanceof Player ? (Player) sender : null;
+
+ if (args.length == 0) {
+ CommandDelegator.delegate("", new String[0], player);
+ } else {
+ String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
+ CommandDelegator.delegate(args[0], subArgs, player);
+ }
+ } catch (HotelsException he) {
+ Messaging.send(he.getMessage(), sender);
+ if (he.isPrintCommandUsage() && he.getCommandUsage() != null) {
+ Messaging.send(he.getCommandUsage(), sender);
+ }
+ if (he.isPrintStackTrace()) {
+ he.printStackTrace();
+ }
+
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ Player player = sender instanceof Player ? (Player) sender : null;
+
+ if (args.length == 0) {
+ return new ArrayList<>();
+ } else if (args.length == 1) {
+ return CommandDelegator.getPrimaryCommandLabels();
+ } else {
+ String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
+ return CommandDelegator.tabComplete(args[0], subArgs, player);
+ }
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/bukkit/ConfigAdapter.java b/src/main/java/mviper/plugin/hotels/bukkit/ConfigAdapter.java
new file mode 100644
index 0000000..b09987c
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/bukkit/ConfigAdapter.java
@@ -0,0 +1,46 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.bukkit;
+
+import java.nio.file.Path;
+
+/**
+ * Handles loading and saving of YAML files
+ */
+public class ConfigAdapter {
+
+ //TODO implement methods
+
+ /**
+ * Extracts a yml file from resources to the plugin folder
+ * @param name The name of the file in the resources folder
+ */
+ void setupConfig(String name) {
+
+ }
+
+ HotelsConfiguration getConfig(Path path) {
+ return null;
+ }
+
+ void saveConfig(HotelsConfiguration config) {
+
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/bukkit/EconomyAdapter.java b/src/main/java/mviper/plugin/hotels/bukkit/EconomyAdapter.java
new file mode 100644
index 0000000..7da4894
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/bukkit/EconomyAdapter.java
@@ -0,0 +1,51 @@
+package mviper.plugin.hotels.bukkit;
+
+import mviper.plugin.hotels.core.exceptions.BruhMoment;
+import net.milkbowl.vault.economy.Economy;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.RegisteredServiceProvider;
+
+import java.math.BigDecimal;
+
+public class EconomyAdapter {
+
+ private Economy economy;
+
+ public void initialise() {
+ RegisteredServiceProvider registration =
+ Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
+
+ if (registration == null) {
+ throw new BruhMoment(); // TODO make and handle this exception properly
+ }
+
+ economy = registration.getProvider();
+ }
+
+ public String getCurrencyNameSingular() {
+ return economy.currencyNameSingular();
+ }
+
+ public String getCurrencyNamePlural() {
+ return economy.currencyNamePlural();
+ }
+
+ public BigDecimal getBalance(Player player) {
+ return BigDecimal.valueOf(economy.getBalance(player));
+ }
+
+ /**
+ * Attempts to withdraw amount from player account
+ * @param player Player whose account we will be acting on
+ * @param amount Amount to withdraw
+ * @return Whether we were able to withdraw amount
+ */
+ public boolean withdrawAmount(Player player, BigDecimal amount) {
+ return economy.withdrawPlayer(player, amount.doubleValue()).transactionSuccess();
+ }
+
+ public String formatCurrency(BigDecimal amount) {
+ return economy.format(amount.doubleValue());
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/bukkit/HotelsConfiguration.java b/src/main/java/mviper/plugin/hotels/bukkit/HotelsConfiguration.java
new file mode 100644
index 0000000..b8a0d53
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/bukkit/HotelsConfiguration.java
@@ -0,0 +1,164 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.bukkit;
+
+import org.bukkit.configuration.file.YamlConfiguration;
+import java.util.*;
+
+/**
+ * YAML Configuration handler
+ */
+public class HotelsConfiguration {
+ private final YamlConfiguration config;
+
+ public HotelsConfiguration(YamlConfiguration config) {
+ this.config = config;
+ }
+
+ public String getCurrentPath() {
+ return config.getCurrentPath();
+ }
+
+ public String getName() {
+ return config.getName();
+ }
+
+ public Set getKeys(boolean deep) {
+ return config.getKeys(deep);
+ }
+
+ public Map getValues(boolean deep) {
+ return config.getValues(deep);
+ }
+
+ public boolean contains(String path) {
+ return config.contains(path);
+ }
+
+ public boolean contains(String path, boolean ignoreDefault) {
+ return config.contains(path, ignoreDefault);
+ }
+
+ public boolean isSet(String path) {
+ return config.isSet(path);
+ }
+
+ public Object get(String path) {
+ return config.get(path);
+ }
+
+ public Object get(String path, Object def) {
+ return config.get(path, def);
+ }
+
+ public String getString(String path) {
+ return config.getString(path);
+ }
+
+ public String getString(String path, String def) {
+ return config.getString(path, def);
+ }
+
+ public int getInt(String path) {
+ return config.getInt(path);
+ }
+
+ public int getInt(String path, int def) {
+ return config.getInt(path, def);
+ }
+
+ public boolean getBoolean(String path) {
+ return config.getBoolean(path);
+ }
+
+ public boolean getBoolean(String path, boolean def) {
+ return config.getBoolean(path, def);
+ }
+
+ public double getDouble(String path) {
+ return config.getDouble(path);
+ }
+
+ public double getDouble(String path, double def) {
+ return config.getDouble(path, def);
+ }
+
+ public long getLong(String path) {
+ return config.getLong(path);
+ }
+
+ public long getLong(String path, long def) {
+ return config.getLong(path, def);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List getList(String path) {
+ return (List) config.getList(path);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List getList(String path, List def) {
+ return (List) config.getList(path, def);
+ }
+
+ public List getStringList(String path) {
+ return config.getStringList(path);
+ }
+
+ public List getIntegerList(String path) {
+ return config.getIntegerList(path);
+ }
+
+ public List getBooleanList(String path) {
+ return config.getBooleanList(path);
+ }
+
+ public List getDoubleList(String path) {
+ return config.getDoubleList(path);
+ }
+
+ public List getFloatList(String path) {
+ return config.getFloatList(path);
+ }
+
+ public List getLongList(String path) {
+ return config.getLongList(path);
+ }
+
+ public List getByteList(String path) {
+ return config.getByteList(path);
+ }
+
+ public List getCharacterList(String path) {
+ return config.getCharacterList(path);
+ }
+
+ public List getShortList(String path) {
+ return config.getShortList(path);
+ }
+
+ public T getObject(String path, Class clazz) {
+ return config.getObject(path, clazz);
+ }
+
+ public T getObject(String path, Class clazz, T def) {
+ return config.getObject(path, clazz, def);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/bukkit/HotelsMain.java b/src/main/java/mviper/plugin/hotels/bukkit/HotelsMain.java
new file mode 100644
index 0000000..968c84e
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/bukkit/HotelsMain.java
@@ -0,0 +1,70 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.bukkit;
+
+import mviper.plugin.hotels.core.database.HotelsQuery;
+import org.bukkit.command.PluginCommand;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.bstats.bukkit.Metrics;
+
+import java.util.concurrent.CompletableFuture;
+
+public class HotelsMain extends JavaPlugin {
+
+ @Override
+ public void onEnable() {
+ getLogger().info("Hotels v" + getDescription().getVersion() + " has been enabled");
+
+ // Initialize bstats
+ setupMetrics();
+
+ PluginCommand hotelsCommand = getCommand("hotels");
+ CommandListener commandListener = new CommandListener();
+ if (hotelsCommand != null) {
+ hotelsCommand.setExecutor(commandListener);
+ hotelsCommand.setTabCompleter(commandListener);
+ }
+
+ CompletableFuture.runAsync(this::loadJPA);
+ }
+
+ @Override
+ public void onDisable() {
+ unloadJPA();
+ getLogger().info("Hotels v" + getDescription().getVersion() + " has been disabled");
+ }
+
+ private void setupMetrics() {
+ Metrics metrics = new Metrics(this, 29264);
+ getLogger().info("bstats metrics initialized");
+ }
+
+ private void loadJPA() {
+ // For JPA classloader to work correctly
+ Thread.currentThread().setContextClassLoader(getClassLoader());
+ HotelsQuery.initialise();
+ getLogger().info("Loaded JPA Connection");
+ }
+
+ private void unloadJPA() {
+ HotelsQuery.closeEntityManagerFactory();
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/bukkit/Messaging.java b/src/main/java/mviper/plugin/hotels/bukkit/Messaging.java
new file mode 100644
index 0000000..0a3f9d2
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/bukkit/Messaging.java
@@ -0,0 +1,66 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.bukkit;
+
+import org.bukkit.Bukkit;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public final class Messaging {
+
+ private Messaging() {
+ // Utility class
+ }
+
+ /**
+ * Send a message to a player, or console if null
+ * @param message Message to send
+ * @param player Player the message should be sent to
+ */
+ public static void send(String message, Player player) {
+ if (player != null) {
+ player.sendMessage(message);
+ } else {
+ Bukkit.getLogger().info(message);
+ }
+ }
+
+ public static void send(String message, CommandSender sender) {
+ if (sender instanceof Player player) {
+ send(message, player);
+ } else {
+ send(message, (Player) null);
+ }
+ }
+
+ /**
+ * Sends a debug message to a player, if debug is enabled
+ * @param message Message to send
+ * @param player Player the message should be sent to
+ */
+ public static void debug(String message, Player player) {
+ //TODO if debug enabled
+ send(prependDebug(message), player);
+ }
+
+ private static String prependDebug(String message) {
+ return "[DEBUG] " + message;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/bukkit/Utilities.java b/src/main/java/mviper/plugin/hotels/bukkit/Utilities.java
new file mode 100644
index 0000000..f8f5193
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/bukkit/Utilities.java
@@ -0,0 +1,16 @@
+package mviper.plugin.hotels.bukkit;
+
+import org.bukkit.Bukkit;
+import java.util.UUID;
+
+public final class Utilities {
+
+ private Utilities() {
+ // Utility class
+ }
+
+ public static UUID worldNameToId(String name) {
+ org.bukkit.World world = Bukkit.getWorld(name);
+ return world != null ? world.getUID() : null;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/CommandDelegator.java b/src/main/java/mviper/plugin/hotels/core/commands/CommandDelegator.java
new file mode 100644
index 0000000..2099f7e
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/CommandDelegator.java
@@ -0,0 +1,145 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.commands;
+
+import com.google.common.collect.ImmutableSet;
+import mviper.plugin.hotels.bukkit.Messaging;
+import mviper.plugin.hotels.core.commands.arguments.HotelsCommandArgumentOptionality;
+import mviper.plugin.hotels.core.commands.subcommands.CreateHotelCommand;
+import mviper.plugin.hotels.core.commands.subcommands.HotelsHelpCommand;
+import mviper.plugin.hotels.core.commands.subcommands.ListAllHotelsCommand;
+import mviper.plugin.hotels.core.commands.subcommands.ListHotelsInWorldCommand;
+import mviper.plugin.hotels.core.exceptions.BruhMoment;
+import mviper.plugin.hotels.core.exceptions.HotelsException;
+import mviper.plugin.hotels.core.exceptions.NoPermissionException;
+import mviper.plugin.hotels.core.exceptions.NotEnoughArgumentsException;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Delegates hotels subcommands to correct handler class
+ */
+public final class CommandDelegator {
+
+ private static final Map> hotelsCommands = new HashMap<>();
+ private static final List primaryCommands = new ArrayList<>();
+
+ // primary alias of each subcommand
+ public static List getPrimaryCommandLabels() {
+ return new ArrayList<>(primaryCommands);
+ }
+
+ static {
+ // Various versions of the same command with different arguments are grouped together
+ Set> sets = ImmutableSet.of(
+ ImmutableSet.of(new ListHotelsInWorldCommand(), new ListAllHotelsCommand()), // sort by highest amount of args first
+ ImmutableSet.of(new CreateHotelCommand()),
+ ImmutableSet.of(new HotelsHelpCommand())
+ );
+
+ for (Set set : sets) {
+ HotelsCommand firstCommand = set.iterator().next();
+ String[] labels = firstCommand.getLabels();
+ primaryCommands.add(labels[0]);
+
+ for (String label : labels) {
+ hotelsCommands.put(label, set);
+ }
+ }
+ }
+
+ private CommandDelegator() {
+ // Utility class
+ }
+
+ public static void delegate(String subcommand, String[] args, Player player) {
+ Messaging.send("Subcommand: " + subcommand, player);
+
+ if (hotelsCommands.containsKey(subcommand)) {
+
+ Set hotelsCommandSet = hotelsCommands.get(subcommand);
+ //Go through this set in order, and only throw no permission error if none can be run
+
+ boolean ranSuccessfully = false;
+ HotelsException lastException = new BruhMoment();
+
+ if (hotelsCommandSet == null) {
+ throw lastException;
+ }
+
+ for (HotelsCommand hotelsCommand : hotelsCommandSet) {
+ try {
+ hotelsCommand.acceptAndExecute(args, player); //Try to run command
+ ranSuccessfully = true; //If it didn't go to catch clause, the command ran, so we can break here
+ break;
+ } catch (NotEnoughArgumentsException e) {
+ lastException = e; //Save last thrown exception, to show user most relevant error
+ } catch (NoPermissionException e) {
+ lastException = e;
+ }
+ }
+
+ if (!ranSuccessfully) {
+ throw lastException;
+ }
+ } else {
+ Messaging.send("Hotels subcommand not recognised!", player);
+ }
+ }
+
+ /**
+ * Provide suggestions for tab complete feature
+ */
+ public static List tabComplete(String subcommand, String[] args, Player player) {
+ List suggestions = new ArrayList<>();
+
+ if (!hotelsCommands.containsKey(subcommand)) {
+ return suggestions;
+ }
+
+ Set hotelsCommandSet = hotelsCommands.get(subcommand);
+ if (hotelsCommandSet == null) {
+ return suggestions;
+ }
+
+ for (HotelsCommand hotelsCommand : hotelsCommandSet) {
+ // match each provided argument as far as possible
+ var argument = hotelsCommand.nextMissingArgument(args);
+ if (argument == null) {
+ return suggestions;
+ }
+
+ return switch (argument.getOptionality()) {
+ case PLAYER_NAME -> Bukkit.getOnlinePlayers().stream()
+ .map(Player::getName)
+ .collect(Collectors.toList());
+ case WORLD_NAME -> Bukkit.getWorlds().stream()
+ .map(org.bukkit.World::getName)
+ .collect(Collectors.toList());
+ default -> suggestions;
+ };
+ }
+
+ return suggestions;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/HotelsCommand.java b/src/main/java/mviper/plugin/hotels/core/commands/HotelsCommand.java
new file mode 100644
index 0000000..e2f761f
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/HotelsCommand.java
@@ -0,0 +1,160 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.commands;
+
+import mviper.plugin.hotels.core.commands.arguments.HotelsCommandArgument;
+import mviper.plugin.hotels.core.commands.arguments.HotelsCommandArgumentOptionality;
+import mviper.plugin.hotels.core.exceptions.NoPermissionException;
+import mviper.plugin.hotels.core.exceptions.NotEnoughArgumentsException;
+import mviper.plugin.hotels.core.permissions.HotelsPermission;
+import org.bukkit.entity.Player;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * A subcommand of the /hotels command
+ */
+public abstract class HotelsCommand {
+ private final String[] labels;
+ private final Set arguments;
+ private final HotelsPermission permission;
+
+ public HotelsCommand(String[] labels, Set arguments, HotelsPermission permission) {
+ this.labels = labels;
+ this.arguments = arguments;
+ this.permission = permission;
+ }
+
+ /**
+ * Check if the player has permission to execute the command
+ * @param player Player executing the command
+ * @return Whether the player can execute this command
+ */
+ private boolean hasPermission(Player player) {
+ return permission.checkPermission(player);
+ }
+
+ /**
+ * Gets next argument the subcommand is expecting
+ */
+ public HotelsCommandArgument nextMissingArgument(String[] args) {
+ Iterator argumentsIterator = arguments.iterator();
+ HotelsCommandArgument argument = null;
+
+ for (int i = 0; i < args.length; i++) {
+ if (argumentsIterator.hasNext()) {
+ argument = argumentsIterator.next();
+ } else {
+ return null;
+ }
+ }
+
+ return argument;
+ }
+
+ /**
+ * Accepts subcommand arguments and sets them accordingly
+ * @param args The arguments for the subcommand, excluding the subcommand label itself
+ * @param player The player who sent the command, for inferring of optional arguments
+ */
+ private void acceptArguments(String[] args, Player player) {
+ Iterator argumentsIterator = arguments.iterator();
+ int argIndex = 0;
+
+ while (argumentsIterator.hasNext()) {
+ HotelsCommandArgument argument = argumentsIterator.next();
+
+ if (argIndex < args.length) {
+ argument.setValue(args[argIndex]);
+ argIndex++;
+ } else {
+ // Argument must be inferred from player
+ if (player == null) {
+ throw new NotEnoughArgumentsException(getUsage());
+ }
+
+ switch (argument.getOptionality()) {
+ case PLAYER_NAME -> argument.setValue(player.getName());
+ case WORLD_NAME -> argument.setValue(player.getWorld().getName());
+ default -> throw new NotEnoughArgumentsException(getUsage());
+ }
+ }
+ System.out.println("Args value " + argument.getValue());
+ }
+ }
+
+ /**
+ * Accepts subcommand arguments and executes the command
+ * @param args The arguments for the subcommand, excluding the subcommand label itself
+ * @param player The player who sent the command, for optional arguments inferring
+ */
+ public void acceptAndExecute(String[] args, Player player) {
+ acceptArguments(args, player);
+ if (hasPermission(player)) {
+ CompletableFuture.runAsync(() -> execute(player));
+ } else {
+ throw new NoPermissionException();
+ }
+ }
+
+ /**
+ * Execute the subcommand
+ */
+ public abstract void execute(Player player);
+
+ protected HotelsCommandArgument getArgument(int index) {
+ return arguments.toArray(new HotelsCommandArgument[0])[index];
+ }
+
+ public String getUsage() {
+ StringBuilder usageString = new StringBuilder("/ht ");
+
+ for (int i = 0; i < labels.length; i++) {
+ usageString.append(labels[i]);
+ if (labels.length > 1 && i < labels.length - 1) {
+ usageString.append("|");
+ }
+ }
+
+ for (HotelsCommandArgument arg : arguments) {
+ if (arg.getOptionality() == HotelsCommandArgumentOptionality.FALSE) {
+ usageString.append(" <").append(arg.getSuggestion()).append(">");
+ } else {
+ usageString.append(" [").append(arg.getSuggestion()).append("]");
+ }
+ }
+
+ return usageString.toString();
+ }
+
+ public String[] getLabels() {
+ return labels;
+ }
+
+ public Set getArguments() {
+ return arguments;
+ }
+
+ public HotelsPermission getPermission() {
+ return permission;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgument.java b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgument.java
new file mode 100644
index 0000000..14e3a55
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgument.java
@@ -0,0 +1,75 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.commands.arguments;
+
+/**
+ * Represents an argument to a subcommand of the /hotels command
+ */
+public class HotelsCommandArgument {
+ private final HotelsCommandArgumentOptionality optionality;
+ /**
+ * Label suggested if the command syntax is entered wrongly
+ */
+ private final String suggestion;
+
+ /**
+ * The input the user entered for this argument
+ */
+ private String value;
+
+ public HotelsCommandArgument(HotelsCommandArgumentOptionality optionality, String suggestion) {
+ this.optionality = optionality;
+ this.suggestion = suggestion;
+ }
+
+ /**
+ * Get the status, whether an input was given and the argument is optional
+ * @return The status, depending on the input and optionality
+ */
+ public HotelsCommandArgumentStatus getStatus() {
+ if (hasInput()) {
+ return HotelsCommandArgumentStatus.FULL;
+ } else if (optionality == HotelsCommandArgumentOptionality.TRUE) {
+ return HotelsCommandArgumentStatus.IGNORE;
+ } else {
+ return HotelsCommandArgumentStatus.EMPTY;
+ }
+ }
+
+ private boolean hasInput() {
+ return value != null && !value.isEmpty();
+ }
+
+ public HotelsCommandArgumentOptionality getOptionality() {
+ return optionality;
+ }
+
+ public String getSuggestion() {
+ return suggestion;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentOptionality.java b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentOptionality.java
new file mode 100644
index 0000000..b399c39
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentOptionality.java
@@ -0,0 +1,42 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.commands.arguments;
+
+/**
+ * Whether a HotelsCommandArgument is optional, and what kind of optionality
+ */
+public enum HotelsCommandArgumentOptionality {
+ /**
+ * The argument is optional
+ */
+ TRUE,
+ /**
+ * The argument is not optional
+ */
+ FALSE,
+ /**
+ * The argument is optional for player as it can be inferred
+ */
+ PLAYER_NAME,
+ /**
+ * The argument is optional for players as it can be inferred
+ */
+ WORLD_NAME
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentRequirements.java b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentRequirements.java
new file mode 100644
index 0000000..8969e0c
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentRequirements.java
@@ -0,0 +1,17 @@
+package mviper.plugin.hotels.core.commands.arguments;
+
+/**
+ * Defines certain requirements a hotels subcommand argument must meet before being run
+ * These include being owner or renter of the specified room or hotel etc.
+ */
+public class HotelsCommandArgumentRequirements {
+ private final HotelsCommandArgumentRequirementsEnum requirement;
+
+ public HotelsCommandArgumentRequirements(HotelsCommandArgumentRequirementsEnum requirement) {
+ this.requirement = requirement;
+ }
+
+ public HotelsCommandArgumentRequirementsEnum getRequirement() {
+ return requirement;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentRequirementsEnum.java b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentRequirementsEnum.java
new file mode 100644
index 0000000..f47bd02
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentRequirementsEnum.java
@@ -0,0 +1,5 @@
+package mviper.plugin.hotels.core.commands.arguments;
+
+public enum HotelsCommandArgumentRequirementsEnum {
+ OWNER, RENTER, HELPER, FRIEND
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentStatus.java b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentStatus.java
new file mode 100644
index 0000000..e2becae
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/arguments/HotelsCommandArgumentStatus.java
@@ -0,0 +1,38 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.commands.arguments;
+
+/**
+ * The current status of a HotelsCommandArgument
+ */
+public enum HotelsCommandArgumentStatus {
+ /**
+ * An input was given
+ */
+ FULL,
+ /**
+ * No input given, and it is required
+ */
+ EMPTY,
+ /**
+ * Input not given but not required
+ */
+ IGNORE
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/subcommands/CreateHotelCommand.java b/src/main/java/mviper/plugin/hotels/core/commands/subcommands/CreateHotelCommand.java
new file mode 100644
index 0000000..455bc58
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/subcommands/CreateHotelCommand.java
@@ -0,0 +1,78 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.commands.subcommands;
+
+import com.google.common.collect.ImmutableSet;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import mviper.plugin.hotels.core.commands.HotelsCommand;
+import mviper.plugin.hotels.core.commands.arguments.HotelsCommandArgument;
+import mviper.plugin.hotels.core.commands.arguments.HotelsCommandArgumentOptionality;
+import mviper.plugin.hotels.core.events.HotelCreateEvent;
+import mviper.plugin.hotels.core.exceptions.InvalidHotelException;
+import mviper.plugin.hotels.core.exceptions.PlayerOnlyException;
+import mviper.plugin.hotels.core.hotel.Hotel;
+import mviper.plugin.hotels.core.hotel.HotelOwner;
+import mviper.plugin.hotels.core.permissions.HotelsPermission;
+import mviper.plugin.hotels.core.regions.HotelRegion;
+import mviper.plugin.hotels.core.regions.RegionManager;
+import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+import org.bukkit.entity.Player;
+
+public class CreateHotelCommand extends HotelsCommand {
+
+ public CreateHotelCommand() {
+ super(
+ new String[]{"create", "c"},
+ ImmutableSet.of(new HotelsCommandArgument(HotelsCommandArgumentOptionality.FALSE, "name")),
+ new HotelsPermission("hotels.create")
+ );
+ }
+
+ @Override
+ public void execute(Player player) {
+ if (player == null) {
+ throw new PlayerOnlyException();
+ }
+
+ String hotelName = getArgument(0).getValue();
+ if (hotelName == null) {
+ throw new InvalidHotelException();
+ }
+
+ var world = player.getWorld();
+
+ player.sendMessage("Creating hotel " + hotelName);
+
+ // TODO PRECONDITIONS:
+ // player must have a region selected
+ // region must not intersect already existing hotel regions
+ // must not intersect regions with custom flag (no hotels)
+ // they must have enough money to create hotel, (money scaling with size of region?)
+ // must not own more than max hotels owned
+
+ HotelOwner hotelOwner = new HotelOwner(player.getUniqueId());
+ Hotel hotel = new Hotel(hotelOwner, world.getUID().toString(), hotelName);
+ String hotelId = hotel.getId().toString();
+ ProtectedRegion protectedRegion = RegionManager.getProtectedRegion(player, hotelId);
+ hotel.setHotelRegion(new HotelRegion(BukkitAdapter.adapt(world), hotelId, protectedRegion));
+
+ new HotelCreateEvent(hotel).call();
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/subcommands/HotelsHelpCommand.java b/src/main/java/mviper/plugin/hotels/core/commands/subcommands/HotelsHelpCommand.java
new file mode 100644
index 0000000..afcc410
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/subcommands/HotelsHelpCommand.java
@@ -0,0 +1,46 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.commands.subcommands;
+
+import mviper.plugin.hotels.bukkit.Messaging;
+import mviper.plugin.hotels.core.commands.CommandDelegator;
+import mviper.plugin.hotels.core.commands.HotelsCommand;
+import mviper.plugin.hotels.core.permissions.HotelsPermission;
+import org.bukkit.entity.Player;
+
+import java.util.Collections;
+
+public class HotelsHelpCommand extends HotelsCommand {
+
+ public HotelsHelpCommand() {
+ super(
+ new String[]{"help", ""},
+ Collections.emptySet(),
+ new HotelsPermission("hotels.help")
+ );
+ }
+
+ @Override
+ public void execute(Player player) {
+ for (String label : CommandDelegator.getPrimaryCommandLabels()) {
+ Messaging.send(label, player);
+ }
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/subcommands/ListAllHotelsCommand.java b/src/main/java/mviper/plugin/hotels/core/commands/subcommands/ListAllHotelsCommand.java
new file mode 100644
index 0000000..ea477ff
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/subcommands/ListAllHotelsCommand.java
@@ -0,0 +1,35 @@
+package mviper.plugin.hotels.core.commands.subcommands;
+
+import mviper.plugin.hotels.bukkit.Messaging;
+import mviper.plugin.hotels.core.commands.HotelsCommand;
+import mviper.plugin.hotels.core.database.HotelsQuery;
+import mviper.plugin.hotels.core.hotel.Hotel;
+import mviper.plugin.hotels.core.permissions.HotelsPermission;
+import org.bukkit.entity.Player;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+
+public class ListAllHotelsCommand extends HotelsCommand {
+
+ public ListAllHotelsCommand() {
+ super(
+ new String[]{"hotellist", "hlist", "list"},
+ new LinkedHashSet<>(),
+ new HotelsPermission("hotels.hotellist.all")
+ );
+ }
+
+ @Override
+ public void execute(Player player) {
+ List resultList = HotelsQuery.getAll(Hotel.class);
+
+ if (resultList.isEmpty()) {
+ Messaging.send("No hotels found at all!", player);
+ } else {
+ for (Hotel hotel : resultList) {
+ Messaging.send("Hotel: " + hotel.getHotelName(), player);
+ }
+ }
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/commands/subcommands/ListHotelsInWorldCommand.java b/src/main/java/mviper/plugin/hotels/core/commands/subcommands/ListHotelsInWorldCommand.java
new file mode 100644
index 0000000..439ca5e
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/commands/subcommands/ListHotelsInWorldCommand.java
@@ -0,0 +1,73 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.commands.subcommands;
+
+import com.google.common.collect.ImmutableSet;
+import mviper.plugin.hotels.bukkit.Messaging;
+import mviper.plugin.hotels.bukkit.Utilities;
+import mviper.plugin.hotels.core.commands.HotelsCommand;
+import mviper.plugin.hotels.core.commands.arguments.HotelsCommandArgument;
+import mviper.plugin.hotels.core.commands.arguments.HotelsCommandArgumentOptionality;
+import mviper.plugin.hotels.core.database.HotelsQuery;
+import mviper.plugin.hotels.core.exceptions.WorldNonExistentException;
+import mviper.plugin.hotels.core.hotel.Hotel;
+import mviper.plugin.hotels.core.permissions.HotelsPermission;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * Lists the hotels in all/given world(s)
+ */
+public class ListHotelsInWorldCommand extends HotelsCommand {
+
+ public ListHotelsInWorldCommand() {
+ super(
+ new String[]{"hotellist", "hlist", "list"},
+ ImmutableSet.of(new HotelsCommandArgument(HotelsCommandArgumentOptionality.WORLD_NAME, "world")),
+ new HotelsPermission("hotels.hotellist.world")
+ );
+ }
+
+ @Override
+ public void execute(Player player) {
+ String worldName = getArgument(0).getValue();
+ if (worldName == null) {
+ throw new WorldNonExistentException(getUsage());
+ }
+
+ UUID worldId = Utilities.worldNameToId(worldName);
+ if (worldId == null) {
+ throw new WorldNonExistentException(getUsage());
+ }
+
+ String queryString = "SELECT h FROM Hotel h WHERE hotelWorldId='" + worldId.toString() + "'";
+ List resultList = HotelsQuery.runSelectQuery(queryString, Hotel.class);
+
+ if (resultList.isEmpty()) {
+ Messaging.send("No hotels found in this world!", player);
+ } else {
+ for (Hotel hotel : resultList) {
+ Messaging.send("Hotel: " + hotel.getHotelName(), player); //TODO make pages when too many results
+ }
+ }
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/database/HotelsQuery.java b/src/main/java/mviper/plugin/hotels/core/database/HotelsQuery.java
new file mode 100644
index 0000000..58fe506
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/database/HotelsQuery.java
@@ -0,0 +1,59 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.database;
+
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
+import jakarta.persistence.Persistence;
+import java.util.List;
+
+public final class HotelsQuery {
+
+ private static EntityManagerFactory entityManagerFactory;
+
+ private HotelsQuery() {
+ // Utility class
+ }
+
+ public static void initialise() {
+ entityManagerFactory = Persistence.createEntityManagerFactory("HotelsPU");
+ }
+
+ public static EntityManager getEntityManager() {
+ return entityManagerFactory.createEntityManager();
+ }
+
+ public static void closeEntityManagerFactory() {
+ entityManagerFactory.close();
+ }
+
+ public static List getAll(Class clazz) {
+ String className = clazz.getSimpleName();
+ String queryString = "SELECT a FROM " + className + " a";
+ return runSelectQuery(queryString, clazz);
+ }
+
+ public static List runSelectQuery(String typedQuery, Class clazz) {
+ EntityManager entityManager = getEntityManager();
+ List resultList = entityManager.createQuery(typedQuery, clazz).getResultList();
+ entityManager.close();
+ return resultList;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/database/QueryTest.java b/src/main/java/mviper/plugin/hotels/core/database/QueryTest.java
new file mode 100644
index 0000000..f6bd661
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/database/QueryTest.java
@@ -0,0 +1,90 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.database;
+
+import mviper.plugin.hotels.core.exceptions.WorldNonExistentException;
+import mviper.plugin.hotels.core.hotel.Hotel;
+import mviper.plugin.hotels.core.hotel.HotelOwner;
+import org.bukkit.Bukkit;
+import org.bukkit.World;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityTransaction;
+import java.util.*;
+
+public final class QueryTest {
+
+ private QueryTest() {
+ // Utility class
+ }
+
+ public static List getAllHotels() {
+ return HotelsQuery.runSelectQuery("SELECT h FROM Hotel h", Hotel.class);
+ }
+
+ public static List getAllOwners() {
+ return HotelsQuery.runSelectQuery("SELECT o FROM HotelOwner o", HotelOwner.class);
+ }
+
+ public static void addOwner() {
+ HotelOwner owner = new HotelOwner(UUID.randomUUID());
+ EntityManager entityManager = HotelsQuery.getEntityManager();
+ EntityTransaction transaction = entityManager.getTransaction();
+
+ try {
+ transaction.begin();
+ entityManager.persist(owner);
+ transaction.commit();
+ } catch (Exception e) {
+ transaction.rollback();
+ e.printStackTrace();
+ }
+
+ entityManager.close();
+ }
+
+ public static void addHotel() {
+ HotelOwner owner = new HotelOwner(UUID.randomUUID());
+ World world = Bukkit.getWorld("world");
+ if (world == null) {
+ throw new WorldNonExistentException("test");
+ }
+
+ Hotel hotel = new Hotel(
+ owner,
+ world.getUID().toString(),
+ "Test"
+ );
+
+ EntityManager entityManager = HotelsQuery.getEntityManager();
+ EntityTransaction transaction = entityManager.getTransaction();
+
+ try {
+ transaction.begin();
+ entityManager.persist(owner);
+ entityManager.persist(hotel);
+ transaction.commit();
+ } catch (Exception e) {
+ transaction.rollback();
+ e.printStackTrace();
+ }
+
+ entityManager.close();
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/events/HotelCreateEvent.java b/src/main/java/mviper/plugin/hotels/core/events/HotelCreateEvent.java
new file mode 100644
index 0000000..841d0f0
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/events/HotelCreateEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.events;
+
+import mviper.plugin.hotels.core.hotel.Hotel;
+
+public class HotelCreateEvent extends HotelsEvent {
+ private Hotel hotel;
+
+ public HotelCreateEvent(Hotel hotel) {
+ this.hotel = hotel;
+ }
+
+ public Hotel getHotel() {
+ return hotel;
+ }
+
+ public void setHotel(Hotel hotel) {
+ this.hotel = hotel;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/events/HotelsEvent.java b/src/main/java/mviper/plugin/hotels/core/events/HotelsEvent.java
new file mode 100644
index 0000000..e519f83
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/events/HotelsEvent.java
@@ -0,0 +1,54 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.events;
+
+import org.bukkit.Bukkit;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class HotelsEvent extends Event implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+ private boolean cancelled = false;
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ public void call() {
+ Bukkit.getServer().getPluginManager().callEvent(this);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/BruhMoment.java b/src/main/java/mviper/plugin/hotels/core/exceptions/BruhMoment.java
new file mode 100644
index 0000000..0df7e7d
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/BruhMoment.java
@@ -0,0 +1,29 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+/**
+ * For when there shouldn't be an exception thrown
+ */
+public class BruhMoment extends HotelsException {
+ public BruhMoment() {
+ super("Unknown error has occurred", null, false, true);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/HotelsException.java b/src/main/java/mviper/plugin/hotels/core/exceptions/HotelsException.java
new file mode 100644
index 0000000..8e44acb
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/HotelsException.java
@@ -0,0 +1,54 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+public class HotelsException extends RuntimeException {
+ private final String commandUsage;
+ private final boolean printCommandUsage;
+ private final boolean printStackTrace;
+
+ public HotelsException(String message, String commandUsage, boolean printCommandUsage, boolean printStackTrace) {
+ super(message);
+ this.commandUsage = commandUsage;
+ this.printCommandUsage = printCommandUsage;
+ this.printStackTrace = printStackTrace;
+ }
+
+ public HotelsException(String message) {
+ this(message, null, true, false);
+ }
+
+ public HotelsException(String message, String commandUsage) {
+ this(message, commandUsage, true, false);
+ }
+
+ public String getCommandUsage() {
+ return commandUsage;
+ }
+
+ public boolean isPrintCommandUsage() {
+ return printCommandUsage;
+ }
+
+ public boolean isPrintStackTrace() {
+ return printStackTrace;
+ }
+}
+
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/InvalidHotelException.java b/src/main/java/mviper/plugin/hotels/core/exceptions/InvalidHotelException.java
new file mode 100644
index 0000000..7c0d407
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/InvalidHotelException.java
@@ -0,0 +1,26 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+public class InvalidHotelException extends HotelsException {
+ public InvalidHotelException() {
+ super("Specified hotel is not valid!");
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/InvalidRegionException.java b/src/main/java/mviper/plugin/hotels/core/exceptions/InvalidRegionException.java
new file mode 100644
index 0000000..068242c
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/InvalidRegionException.java
@@ -0,0 +1,26 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+public class InvalidRegionException extends HotelsException {
+ public InvalidRegionException() {
+ super("Region is not valid!", null, false, false);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/NoArgumentsException.java b/src/main/java/mviper/plugin/hotels/core/exceptions/NoArgumentsException.java
new file mode 100644
index 0000000..5eb4aa5
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/NoArgumentsException.java
@@ -0,0 +1,26 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+public class NoArgumentsException extends HotelsException {
+ public NoArgumentsException(String commandUsage) {
+ super("No arguments!", commandUsage);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/NoPermissionException.java b/src/main/java/mviper/plugin/hotels/core/exceptions/NoPermissionException.java
new file mode 100644
index 0000000..feea154
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/NoPermissionException.java
@@ -0,0 +1,26 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+public class NoPermissionException extends HotelsException {
+ public NoPermissionException() {
+ super("No permission!", null, false, false);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/NotEnoughArgumentsException.java b/src/main/java/mviper/plugin/hotels/core/exceptions/NotEnoughArgumentsException.java
new file mode 100644
index 0000000..19d5575
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/NotEnoughArgumentsException.java
@@ -0,0 +1,26 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+public class NotEnoughArgumentsException extends HotelsException {
+ public NotEnoughArgumentsException(String commandUsage) {
+ super("Not enough arguments!", commandUsage);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/PlayerOnlyException.java b/src/main/java/mviper/plugin/hotels/core/exceptions/PlayerOnlyException.java
new file mode 100644
index 0000000..762f862
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/PlayerOnlyException.java
@@ -0,0 +1,26 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+public class PlayerOnlyException extends HotelsException {
+ public PlayerOnlyException() {
+ super("This command can only be run by a player", null, false, false);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/WorldGuardException.java b/src/main/java/mviper/plugin/hotels/core/exceptions/WorldGuardException.java
new file mode 100644
index 0000000..fb92a5f
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/WorldGuardException.java
@@ -0,0 +1,26 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+public class WorldGuardException extends HotelsException {
+ public WorldGuardException() {
+ super("WorldGuard error!", null, true, true);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/exceptions/WorldNonExistentException.java b/src/main/java/mviper/plugin/hotels/core/exceptions/WorldNonExistentException.java
new file mode 100644
index 0000000..b186fc3
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/exceptions/WorldNonExistentException.java
@@ -0,0 +1,26 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.exceptions;
+
+public class WorldNonExistentException extends HotelsException {
+ public WorldNonExistentException(String commandUsage) {
+ super("Specified world does not exist!", commandUsage);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/homes/AbstractHome.java b/src/main/java/mviper/plugin/hotels/core/homes/AbstractHome.java
new file mode 100644
index 0000000..5dad1bc
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/homes/AbstractHome.java
@@ -0,0 +1,91 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.homes;
+
+import jakarta.persistence.Basic;
+import jakarta.persistence.MappedSuperclass;
+
+@MappedSuperclass
+public abstract class AbstractHome {
+
+ @Basic(optional = false)
+ private int x;
+
+ @Basic(optional = false)
+ private int y;
+
+ @Basic(optional = false)
+ private int z;
+
+ @Basic(optional = false)
+ private float pitch;
+
+ @Basic(optional = false)
+ private float yaw;
+
+ public AbstractHome(int x, int y, int z, float pitch, float yaw) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.pitch = pitch;
+ this.yaw = yaw;
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ this.x = x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ public void setY(int y) {
+ this.y = y;
+ }
+
+ public int getZ() {
+ return z;
+ }
+
+ public void setZ(int z) {
+ this.z = z;
+ }
+
+ public float getPitch() {
+ return pitch;
+ }
+
+ public void setPitch(float pitch) {
+ this.pitch = pitch;
+ }
+
+ public float getYaw() {
+ return yaw;
+ }
+
+ public void setYaw(float yaw) {
+ this.yaw = yaw;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/homes/HotelHome.java b/src/main/java/mviper/plugin/hotels/core/homes/HotelHome.java
new file mode 100644
index 0000000..4b7e4c8
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/homes/HotelHome.java
@@ -0,0 +1,50 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.homes;
+
+import mviper.plugin.hotels.core.hotel.Hotel;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.OneToOne;
+
+@Entity
+public class HotelHome extends AbstractHome {
+
+ @OneToOne(optional = false)
+ private final Hotel hotel;
+
+ @Id
+ private final String hotelId;
+
+ public HotelHome(Hotel hotel, int x, int y, int z, float pitch, float yaw) {
+ super(x, y, z, pitch, yaw);
+ this.hotel = hotel;
+ this.hotelId = hotel.getId().toString();
+ }
+
+ public Hotel getHotel() {
+ return hotel;
+ }
+
+ public String getHotelId() {
+ return hotelId;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/homes/RoomHome.java b/src/main/java/mviper/plugin/hotels/core/homes/RoomHome.java
new file mode 100644
index 0000000..a3d2f27
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/homes/RoomHome.java
@@ -0,0 +1,51 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.homes;
+
+import mviper.plugin.hotels.core.room.Room;
+import java.util.UUID;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.OneToOne;
+
+@Entity
+public class RoomHome extends AbstractHome {
+
+ @OneToOne(optional = false)
+ private final Room room;
+
+ @Id
+ private final UUID roomId;
+
+ public RoomHome(Room room, int x, int y, int z, float pitch, float yaw) {
+ super(x, y, z, pitch, yaw);
+ this.room = room;
+ this.roomId = room.getId();
+ }
+
+ public Room getRoom() {
+ return room;
+ }
+
+ public UUID getRoomId() {
+ return roomId;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/hotel/Hotel.java b/src/main/java/mviper/plugin/hotels/core/hotel/Hotel.java
new file mode 100644
index 0000000..43a6d2a
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/hotel/Hotel.java
@@ -0,0 +1,131 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.hotel;
+
+import mviper.plugin.hotels.core.homes.HotelHome;
+import mviper.plugin.hotels.core.regions.HotelRegion;
+import mviper.plugin.hotels.core.room.Room;
+import java.util.*;
+import jakarta.persistence.*;
+
+/**
+ * Represents a Hotel object
+ */
+@Entity
+public class Hotel {
+ @Id
+ @GeneratedValue
+ private UUID id;
+
+ @ManyToOne(optional = false)
+ private HotelOwner hotelOwner;
+
+ @Basic(optional = false)
+ private String hotelWorldId;
+
+ @Basic(optional = false)
+ private String hotelName;
+
+ @Transient
+ private HotelRegion hotelRegion;
+
+ @ManyToMany
+ private Set hotelHelpers = new HashSet<>();
+
+ @OneToMany
+ private Set hotelRooms = new HashSet<>();
+
+ @OneToOne
+ private HotelHome hotelHome;
+
+ public Hotel() {
+ }
+
+ public Hotel(HotelOwner hotelOwner, String hotelWorldId, String hotelName) {
+ this.hotelOwner = hotelOwner;
+ this.hotelWorldId = hotelWorldId;
+ this.hotelName = hotelName;
+ }
+
+ // Getters and Setters
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public HotelOwner getHotelOwner() {
+ return hotelOwner;
+ }
+
+ public void setHotelOwner(HotelOwner hotelOwner) {
+ this.hotelOwner = hotelOwner;
+ }
+
+ public String getHotelWorldId() {
+ return hotelWorldId;
+ }
+
+ public void setHotelWorldId(String hotelWorldId) {
+ this.hotelWorldId = hotelWorldId;
+ }
+
+ public String getHotelName() {
+ return hotelName;
+ }
+
+ public void setHotelName(String hotelName) {
+ this.hotelName = hotelName;
+ }
+
+ public HotelRegion getHotelRegion() {
+ return hotelRegion;
+ }
+
+ public void setHotelRegion(HotelRegion hotelRegion) {
+ this.hotelRegion = hotelRegion;
+ }
+
+ public Set getHotelHelpers() {
+ return hotelHelpers;
+ }
+
+ public void setHotelHelpers(Set hotelHelpers) {
+ this.hotelHelpers = hotelHelpers;
+ }
+
+ public Set getHotelRooms() {
+ return hotelRooms;
+ }
+
+ public void setHotelRooms(Set hotelRooms) {
+ this.hotelRooms = hotelRooms;
+ }
+
+ public HotelHome getHotelHome() {
+ return hotelHome;
+ }
+
+ public void setHotelHome(HotelHome hotelHome) {
+ this.hotelHome = hotelHome;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/hotel/HotelHelper.java b/src/main/java/mviper/plugin/hotels/core/hotel/HotelHelper.java
new file mode 100644
index 0000000..8c8c2f8
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/hotel/HotelHelper.java
@@ -0,0 +1,59 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.hotel;
+
+import java.util.*;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.ManyToMany;
+
+/**
+ * Represents a hotel helper, who can build in a hotel region but cannot administer it
+ */
+@Entity
+public class HotelHelper {
+ @Id
+ private final UUID playerId;
+
+ @ManyToMany
+ private final Set hotels;
+
+ public HotelHelper(UUID playerId, Set hotels) {
+ this.playerId = playerId;
+ this.hotels = hotels;
+ }
+
+ public UUID getPlayerId() {
+ return playerId;
+ }
+
+ public Set getHotels() {
+ return hotels;
+ }
+
+ public boolean add(Hotel hotel) {
+ return hotels.add(hotel);
+ }
+
+ public boolean remove(Hotel hotel) {
+ return hotels.remove(hotel);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/hotel/HotelOwner.java b/src/main/java/mviper/plugin/hotels/core/hotel/HotelOwner.java
new file mode 100644
index 0000000..eaa1bdc
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/hotel/HotelOwner.java
@@ -0,0 +1,66 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.hotel;
+
+import java.util.*;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.OneToMany;
+
+/**
+ * Represents the owner of a hotel
+ */
+@Entity
+public class HotelOwner {
+ @Id
+ private UUID playerId;
+
+ @OneToMany
+ private Set hotels = new HashSet<>();
+
+ public HotelOwner() {
+ }
+
+ public HotelOwner(UUID playerId) {
+ this.playerId = playerId;
+ }
+
+ public HotelOwner(UUID playerId, Set hotels) {
+ this.playerId = playerId;
+ this.hotels = hotels;
+ }
+
+ public UUID getPlayerId() {
+ return playerId;
+ }
+
+ public void setPlayerId(UUID playerId) {
+ this.playerId = playerId;
+ }
+
+ public Set getHotels() {
+ return hotels;
+ }
+
+ public void setHotels(Set hotels) {
+ this.hotels = hotels;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/permissions/HotelsPermission.java b/src/main/java/mviper/plugin/hotels/core/permissions/HotelsPermission.java
new file mode 100644
index 0000000..efaa299
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/permissions/HotelsPermission.java
@@ -0,0 +1,43 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2020 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package mviper.plugin.hotels.core.permissions;
+
+import org.bukkit.entity.Player;
+
+/**
+ * Represents a checkable Hotels permission
+ */
+public class HotelsPermission {
+ private final String permission;
+
+ public HotelsPermission(String permission) {
+ this.permission = permission;
+ }
+
+ public boolean checkPermission(Player player) {
+ return player == null || player.hasPermission(permission);
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ //TODO must include ways to check that player is owner of hotel and thus can run certain commands etc.
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/regions/AbstractRegion.java b/src/main/java/mviper/plugin/hotels/core/regions/AbstractRegion.java
new file mode 100644
index 0000000..9eee418
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/regions/AbstractRegion.java
@@ -0,0 +1,88 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.regions;
+
+import com.sk89q.worldedit.world.World;
+import com.sk89q.worldguard.domains.DefaultDomain;
+import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+import mviper.plugin.hotels.core.regions.RegionManager;
+import java.util.UUID;
+
+/**
+ * Provides an abstraction for interfacing Hotel's classes with WorldGuard regions
+ */
+public abstract class AbstractRegion {
+ private final World world;
+ private final String id;
+ private final ProtectedRegion region;
+
+ /**
+ * For already existing regions
+ * @param id The UUID of the object representing the region, i.e. a Hotel UUID
+ */
+ public AbstractRegion(World world, String id) {
+ this.world = world;
+ this.id = id;
+ this.region = RegionManager.getRegion(world, RegionManager.REGION_PREFIX + id);
+ }
+
+ public AbstractRegion(World world, String id, ProtectedRegion region) {
+ this.world = world;
+ this.id = id;
+ this.region = region;
+ }
+
+ private DefaultDomain getMembers() {
+ return region.getMembers();
+ }
+
+ private DefaultDomain getOwners() {
+ return region.getOwners();
+ }
+
+ public void addMember(UUID playerId) {
+ getMembers().addPlayer(playerId);
+ }
+
+ public void removeMember(UUID playerId) {
+ getMembers().removePlayer(playerId);
+ }
+
+ public void addOwner(UUID playerId) {
+ getOwners().addPlayer(playerId);
+ }
+
+ public void removeOwner(UUID playerId) {
+ getOwners().removePlayer(playerId);
+ }
+
+ public World getWorld() {
+ return world;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public ProtectedRegion getRegion() {
+ return region;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/regions/HotelRegion.java b/src/main/java/mviper/plugin/hotels/core/regions/HotelRegion.java
new file mode 100644
index 0000000..80fb6a2
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/regions/HotelRegion.java
@@ -0,0 +1,40 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.regions;
+
+import com.sk89q.worldedit.world.World;
+import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+
+/**
+ * Provides an abstraction for manipulating a hotel's region
+ */
+public class HotelRegion extends AbstractRegion {
+
+ public HotelRegion(World world, String id, ProtectedRegion region) {
+ super(world, id, region);
+ }
+
+ public HotelRegion(World world, String id) {
+ super(world, id);
+ }
+}
+
+//TODO this must not actually try to get the region but rather represent it
diff --git a/src/main/java/mviper/plugin/hotels/core/regions/RegionManager.java b/src/main/java/mviper/plugin/hotels/core/regions/RegionManager.java
new file mode 100644
index 0000000..e08ef6f
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/regions/RegionManager.java
@@ -0,0 +1,105 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.regions;
+
+import com.sk89q.worldedit.bukkit.WorldEditPlugin;
+import com.sk89q.worldedit.regions.CuboidRegion;
+import com.sk89q.worldedit.regions.Polygonal2DRegion;
+import com.sk89q.worldedit.regions.Region;
+import com.sk89q.worldedit.world.World;
+import com.sk89q.worldguard.WorldGuard;
+import com.sk89q.worldguard.protection.managers.RemovalStrategy;
+import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
+import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
+import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+import mviper.plugin.hotels.core.exceptions.InvalidRegionException;
+import mviper.plugin.hotels.core.exceptions.WorldGuardException;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+
+public final class RegionManager {
+
+ public static final String REGION_PREFIX = "HOTELS_";
+
+ private static final WorldGuard WG_INSTANCE = WorldGuard.getInstance();
+ private static final com.sk89q.worldguard.protection.regions.RegionContainer REGION_CONTAINER =
+ WG_INSTANCE.getPlatform().getRegionContainer();
+ private static final WorldEditPlugin worldEditPlugin =
+ (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
+
+ private RegionManager() {
+ // Utility class
+ }
+
+ private static com.sk89q.worldguard.protection.managers.RegionManager getRegionManager(World world) {
+ com.sk89q.worldguard.protection.managers.RegionManager rm = REGION_CONTAINER.get(world);
+ if (rm == null) {
+ throw new WorldGuardException();
+ }
+ return rm;
+ }
+
+ public static ProtectedRegion getRegion(World world, String id) {
+ ProtectedRegion region = getRegionManager(world).getRegion(id);
+ if (region == null) {
+ throw new InvalidRegionException();
+ }
+ return region;
+ }
+
+ public static void addRegion(World world, ProtectedRegion region) {
+ getRegionManager(world).addRegion(region);
+ }
+
+ public static void removeRegion(World world, String id) {
+ getRegionManager(world).removeRegion(id, RemovalStrategy.UNSET_PARENT_IN_CHILDREN);
+ }
+
+ /**
+ * Get a Protected Region from a player's selection
+ * @param id The UUID of the region's object, i.e. a Hotel UUID
+ */
+ public static ProtectedRegion getProtectedRegion(Player player, String id) {
+ Region selection = getSelection(player);
+ return toProtectedRegion(selection, id);
+ }
+
+ public static ProtectedRegion toProtectedRegion(Region region, String id) {
+ if (region instanceof CuboidRegion cuboidRegion) {
+ return new ProtectedCuboidRegion(REGION_PREFIX + id,
+ cuboidRegion.getMinimumPoint(), cuboidRegion.getMaximumPoint());
+ } else if (region instanceof Polygonal2DRegion polygonRegion) {
+ return new ProtectedPolygonalRegion(id, polygonRegion.getPoints(),
+ polygonRegion.getMinimumY(), polygonRegion.getMaximumY());
+ } else {
+ throw new InvalidRegionException();
+ }
+ }
+
+ // WorldEdit
+ private static Region getSelection(Player player) {
+ try {
+ return worldEditPlugin.getSession(player).getClipboard().getClipboard().getRegion();
+ } catch (com.sk89q.worldedit.EmptyClipboardException e) {
+ throw new InvalidRegionException();
+ }
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/regions/RoomRegion.java b/src/main/java/mviper/plugin/hotels/core/regions/RoomRegion.java
new file mode 100644
index 0000000..dc01be7
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/regions/RoomRegion.java
@@ -0,0 +1,33 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.regions;
+
+import com.sk89q.worldedit.world.World;
+
+/**
+ * Provides an abstraction for manipulating a room's region
+ */
+public class RoomRegion extends AbstractRegion {
+
+ public RoomRegion(World world, String id) {
+ super(world, id);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/room/Room.java b/src/main/java/mviper/plugin/hotels/core/room/Room.java
new file mode 100644
index 0000000..ca9c325
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/room/Room.java
@@ -0,0 +1,187 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.room;
+
+import mviper.plugin.hotels.core.homes.RoomHome;
+import mviper.plugin.hotels.core.hotel.Hotel;
+import mviper.plugin.hotels.core.regions.RoomRegion;
+import java.time.LocalDateTime;
+import java.util.*;
+import jakarta.persistence.*;
+
+/**
+ * Represents a room in a hotel
+ */
+@Entity
+public class Room {
+ @Id
+ private UUID id;
+
+ @ManyToOne(optional = false)
+ private Hotel hotel;
+
+ @Basic(optional = false)
+ private int roomNumber;
+
+ @Basic(optional = false)
+ private long rentTime; // in minutes
+
+ @Basic(optional = false)
+ private double cost;
+
+ @Basic(optional = false)
+ private boolean isRoomReset;
+
+ @ManyToOne
+ private RoomRenter renter;
+
+ @OneToMany
+ private Set roomFriends = new HashSet<>();
+
+ @OneToOne
+ private RoomHome roomHome;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ private LocalDateTime expiryInstant;
+
+ @Transient
+ private RoomRegion region;
+
+ public Room() {
+ }
+
+ public Room(UUID id, Hotel hotel, int roomNumber, long rentTime, double cost,
+ boolean isRoomReset, RoomRenter renter, Set roomFriends,
+ RoomHome roomHome, LocalDateTime expiryInstant, RoomRegion region) {
+ this.id = id;
+ this.hotel = hotel;
+ this.roomNumber = roomNumber;
+ this.rentTime = rentTime;
+ this.cost = cost;
+ this.isRoomReset = isRoomReset;
+ this.renter = renter;
+ this.roomFriends = roomFriends != null ? roomFriends : new HashSet<>();
+ this.roomHome = roomHome;
+ this.expiryInstant = expiryInstant;
+ this.region = region;
+ }
+
+ public Set getRoomFriends() {
+ return roomFriends;
+ }
+
+ public boolean addFriend(RoomFriend roomFriend) {
+ return roomFriends.add(roomFriend);
+ }
+
+ public boolean removeFriend(RoomFriend roomFriend) {
+ return roomFriends.remove(roomFriend);
+ }
+
+ public void clearFriends() {
+ roomFriends.clear();
+ }
+
+ // Getters and Setters
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public Hotel getHotel() {
+ return hotel;
+ }
+
+ public void setHotel(Hotel hotel) {
+ this.hotel = hotel;
+ }
+
+ public int getRoomNumber() {
+ return roomNumber;
+ }
+
+ public void setRoomNumber(int roomNumber) {
+ this.roomNumber = roomNumber;
+ }
+
+ public long getRentTime() {
+ return rentTime;
+ }
+
+ public void setRentTime(long rentTime) {
+ this.rentTime = rentTime;
+ }
+
+ public double getCost() {
+ return cost;
+ }
+
+ public void setCost(double cost) {
+ this.cost = cost;
+ }
+
+ public boolean isRoomReset() {
+ return isRoomReset;
+ }
+
+ public void setRoomReset(boolean roomReset) {
+ isRoomReset = roomReset;
+ }
+
+ public RoomRenter getRenter() {
+ return renter;
+ }
+
+ public void setRenter(RoomRenter renter) {
+ this.renter = renter;
+ }
+
+ public void setRoomFriends(Set roomFriends) {
+ this.roomFriends = roomFriends;
+ }
+
+ public RoomHome getRoomHome() {
+ return roomHome;
+ }
+
+ public void setRoomHome(RoomHome roomHome) {
+ this.roomHome = roomHome;
+ }
+
+ public LocalDateTime getExpiryInstant() {
+ return expiryInstant;
+ }
+
+ public void setExpiryInstant(LocalDateTime expiryInstant) {
+ this.expiryInstant = expiryInstant;
+ }
+
+ public RoomRegion getRegion() {
+ return region;
+ }
+
+ public void setRegion(RoomRegion region) {
+ this.region = region;
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/room/RoomFriend.java b/src/main/java/mviper/plugin/hotels/core/room/RoomFriend.java
new file mode 100644
index 0000000..b787b66
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/room/RoomFriend.java
@@ -0,0 +1,59 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.room;
+
+import java.util.*;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.ManyToMany;
+
+/**
+ * Represents a friend, who can use a room but not administer it
+ */
+@Entity
+public class RoomFriend {
+ @Id
+ private final UUID playerId;
+
+ @ManyToMany
+ private final Set rooms;
+
+ public RoomFriend(UUID playerId, Set rooms) {
+ this.playerId = playerId;
+ this.rooms = rooms;
+ }
+
+ public UUID getPlayerId() {
+ return playerId;
+ }
+
+ public Set getRooms() {
+ return rooms;
+ }
+
+ public boolean add(Room room) {
+ return rooms.add(room);
+ }
+
+ public boolean remove(Room room) {
+ return rooms.remove(room);
+ }
+}
diff --git a/src/main/java/mviper/plugin/hotels/core/room/RoomRenter.java b/src/main/java/mviper/plugin/hotels/core/room/RoomRenter.java
new file mode 100644
index 0000000..d002a35
--- /dev/null
+++ b/src/main/java/mviper/plugin/hotels/core/room/RoomRenter.java
@@ -0,0 +1,59 @@
+/*
+ * Hotels Bukkit Plugin
+ * Copyright (C) 2019 mviper
+ * Full licence text can be found in LICENCE file
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package mviper.plugin.hotels.core.room;
+
+import java.util.*;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.OneToMany;
+
+/**
+ * Represents the renter of a room in a hotel
+ */
+@Entity
+public class RoomRenter {
+ @Id
+ private final UUID playerId;
+
+ @OneToMany
+ private final Set rooms;
+
+ public RoomRenter(UUID playerId, Set rooms) {
+ this.playerId = playerId;
+ this.rooms = rooms;
+ }
+
+ public UUID getPlayerId() {
+ return playerId;
+ }
+
+ public Set getRooms() {
+ return rooms;
+ }
+
+ public boolean add(Room room) {
+ return rooms.add(room);
+ }
+
+ public boolean remove(Room room) {
+ return rooms.remove(room);
+ }
+}
diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..ab7b3b5
--- /dev/null
+++ b/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+ org.hibernate.jpa.HibernatePersistenceProvider
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
new file mode 100644
index 0000000..dc69e7a
--- /dev/null
+++ b/src/main/resources/config.yml
@@ -0,0 +1,89 @@
+# Hotels Plugin Configuration
+# Version: 2.0.0
+# For Minecraft 1.21.x
+
+# Database settings
+database:
+ # Database type: h2, mysql, postgresql
+ type: h2
+ # H2 database file location (relative to plugin folder)
+ h2-file: database
+ # MySQL/PostgreSQL settings (if using external database)
+ host: localhost
+ port: 3306
+ database: hotels
+ username: root
+ password: ""
+ # Connection pool settings
+ pool:
+ maximum-pool-size: 10
+ minimum-idle: 2
+ connection-timeout: 30000
+
+# Economy settings
+economy:
+ # Enable economy integration (requires Vault)
+ enabled: true
+ # Default currency symbol
+ currency-symbol: "$"
+
+# Hotel settings
+hotels:
+ # Maximum number of hotels per player
+ max-hotels-per-player: 5
+ # Maximum number of rooms per hotel
+ max-rooms-per-hotel: 50
+ # Minimum distance between hotels (in blocks)
+ min-hotel-distance: 100
+ # Allow hotel creation in all worlds
+ allow-all-worlds: true
+ # Worlds where hotels are allowed (if allow-all-worlds is false)
+ allowed-worlds:
+ - world
+ - world_nether
+ - world_the_end
+
+# Room settings
+rooms:
+ # Default rent duration in days
+ default-rent-duration: 7
+ # Maximum rent duration in days
+ max-rent-duration: 30
+ # Minimum rent price
+ min-rent-price: 10.0
+ # Maximum rent price
+ max-rent-price: 10000.0
+ # Allow room friends
+ allow-friends: true
+ # Maximum number of friends per room
+ max-friends-per-room: 5
+
+# Region settings
+regions:
+ # Minimum region size (blocks)
+ min-region-size: 16
+ # Maximum region size (blocks)
+ max-region-size: 10000
+ # Require WorldGuard region for hotel creation
+ require-worldguard: true
+
+# Permission settings
+permissions:
+ # Use permission-based limits (overrides default limits)
+ use-permission-limits: true
+
+# Messages
+messages:
+ # Message prefix
+ prefix: "&8[&6Hotels&8]&r "
+ # Enable colored messages
+ colored-messages: true
+
+# Debug mode
+debug: false
+
+# Auto-save interval (in minutes, 0 to disable)
+auto-save-interval: 5
+
+# Language (en, de, es, fr)
+language: en
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..4714f3e
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,66 @@
+main: mviper.plugin.hotels.bukkit.HotelsMain
+name: Hotels
+version: ${project.version}
+author: M_Viper
+description: Allows the making of hotels and renting of rooms
+website: https://github.com/mviper/hotels
+load: POSTWORLD
+api-version: 1.21
+
+depend: [Vault, WorldEdit, WorldGuard]
+
+commands:
+ Hotels:
+ description: Hotels's main command
+ aliases: [ht]
+ usage: /hotels [args]
+ permission: hotels.use
+
+permissions:
+ hotels.*:
+ description: Gives access to all Hotels commands
+ children:
+ hotels.use: true
+ hotels.admin: true
+ hotels.create: true
+ hotels.delete: true
+ hotels.list: true
+ hotels.rent: true
+ hotels.manage: true
+
+ hotels.use:
+ description: Allows using basic Hotels commands
+ default: true
+
+ hotels.admin:
+ description: Gives access to all admin commands
+ default: op
+ children:
+ hotels.create: true
+ hotels.delete: true
+ hotels.manage: true
+ hotels.bypass: true
+
+ hotels.create:
+ description: Allows creating hotels
+ default: op
+
+ hotels.delete:
+ description: Allows deleting hotels
+ default: op
+
+ hotels.list:
+ description: Allows listing hotels
+ default: true
+
+ hotels.rent:
+ description: Allows renting rooms
+ default: true
+
+ hotels.manage:
+ description: Allows managing own hotels
+ default: op
+
+ hotels.bypass:
+ description: Bypasses all restrictions
+ default: op