Skip to content

Commit

Permalink
Merge pull request #80 from AlpsBTE/78-one-world
Browse files Browse the repository at this point in the history
Implementation of One- and City Plot Worlds
  • Loading branch information
LordTuxn authored Jul 15, 2022
2 parents 0b87dad + 583832e commit 8b32ec7
Show file tree
Hide file tree
Showing 60 changed files with 1,924 additions and 765 deletions.
12 changes: 10 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@
<dependency>
<groupId>com.fastasyncworldedit</groupId>
<artifactId>FAWE-Core</artifactId>
<version>1.17-93</version>
<version>1.12</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fastasyncworldedit</groupId>
<artifactId>FAWE-Bukkit</artifactId>
<version>1.17-93</version>
<version>1.12</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand All @@ -122,6 +122,14 @@
<scope>compile</scope>
</dependency>

<!-- ParticleNativeAPI -->
<dependency>
<groupId>com.github.fierioziy.particlenativeapi</groupId>
<artifactId>ParticleNativeAPI-plugin</artifactId>
<version>3.2.0</version>
<scope>provided</scope>
</dependency>

<!-- Canvas Menu Builder -->
<dependency>
<groupId>com.github.IPVP-MC</groupId>
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/alpsbte/plotsystem/PlotSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public void onEnable() {

PlotManager.checkPlotsForLastActivity();
PlotManager.syncPlotSchematicFiles();
PlotManager.startTimer();

try {
new PacketListener();
Expand Down Expand Up @@ -309,10 +310,25 @@ public static boolean isHolographicDisplaysEnabled() {
return plugin.getServer().getPluginManager().isPluginEnabled("HolographicDisplays");
}

/**
* @return True if ParticleNativeAPI is present
*/
public static boolean isParticleNativeAPIEnabled() {
return plugin.getServer().getPluginManager().isPluginEnabled("ParticleNativeAPI");
}

public static boolean isMultiverseInventoriesEnabled() {
return plugin.getServer().getPluginManager().isPluginEnabled("Multiverse-Inventories");
}

/**
* @param worldName Name of the world
* @return Config path for the world
*/
public static String getMultiverseInventoriesConfigPath(String worldName) {
return PlotSystem.DependencyManager.isMultiverseInventoriesEnabled() ? Bukkit.getPluginManager().getPlugin("Multiverse-Inventories").getDataFolder() + "/worlds/" + worldName : "";
}

/**
* @return Multiverse-Core instance
*/
Expand All @@ -334,6 +350,14 @@ public static WorldGuardPlugin getWorldGuard() {
return WorldGuardPlugin.inst();
}

/**
* @param worldName Name of the world
* @return Config path for the world
*/
public static String getWorldGuardConfigPath(String worldName) {
return Bukkit.getPluginManager().getPlugin("WorldGuard").getDataFolder() + "/worlds/" + worldName;
}

/**
* @return Protocol Lib Instance
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String s, String[] a
player.sendMessage(Utils.getErrorMessageFormat(LangUtil.get(sender, LangPaths.Message.Error.PLAYER_NOT_FOUND)));
}
} else {
new PlayerPlotsMenu(player, new Builder(player.getUniqueId()));
new PlayerPlotsMenu(player, Builder.byUUID(player.getUniqueId()));
}
} catch (SQLException ex) {
sender.sendMessage(Utils.getErrorMessageFormat(LangUtil.get(sender, LangPaths.Message.Error.ERROR_OCCURRED)));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/alpsbte/plotsystem/commands/CMD_Tpll.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@

package com.alpsbte.plotsystem.commands;

import com.alpsbte.plotsystem.core.system.Builder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
import com.alpsbte.plotsystem.utils.Utils;
import com.alpsbte.plotsystem.utils.conversion.CoordinateConversion;
import com.alpsbte.plotsystem.utils.conversion.projection.OutOfProjectionBoundsException;
import com.alpsbte.plotsystem.utils.enums.Status;
import com.alpsbte.plotsystem.utils.io.language.LangPaths;
import com.alpsbte.plotsystem.utils.io.language.LangUtil;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -88,7 +90,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String s, String[] a
double[] terraCoords = CoordinateConversion.convertFromGeo(lon, lat);

// Get plot, that the player is in
Plot plot = PlotManager.getPlotByWorld(playerWorld);
Plot plot = PlotManager.getCurrentPlot(Builder.byUUID(player.getUniqueId()), Status.unfinished, Status.unreviewed);

// Convert terra coordinates to plot relative coordinates
CompletableFuture<double[]> plotCoords = PlotManager.convertTerraToPlotXZ(plot, terraCoords);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.alpsbte.plotsystem.commands.BaseCommand;
import com.alpsbte.plotsystem.commands.SubCommand;
import com.alpsbte.plotsystem.core.system.Builder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
import com.alpsbte.plotsystem.core.system.plot.PlotHandler;
Expand Down Expand Up @@ -58,7 +59,7 @@ public void onCommand(CommandSender sender, String[] args) {
return;
}
} else if (getPlayer(sender) != null && PlotManager.isPlotWorld(getPlayer(sender).getWorld())) {
plot = PlotManager.getPlotByWorld(getPlayer(sender).getWorld());
plot = PlotManager.getCurrentPlot(Builder.byUUID(getPlayer(sender).getUniqueId()), Status.unfinished);
} else {
sendInfo(sender);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
import com.alpsbte.plotsystem.commands.BaseCommand;
import com.alpsbte.plotsystem.commands.SubCommand;
import com.alpsbte.plotsystem.core.menus.FeedbackMenu;
import com.alpsbte.plotsystem.core.system.Builder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
import com.alpsbte.plotsystem.utils.Utils;
import com.alpsbte.plotsystem.utils.enums.Status;
import com.alpsbte.plotsystem.utils.io.language.LangPaths;
import com.alpsbte.plotsystem.utils.io.language.LangUtil;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -59,7 +61,7 @@ public void onCommand(CommandSender sender, String[] args) {
return;
}
} else if (PlotManager.isPlotWorld(getPlayer(sender).getWorld())) {
plot = PlotManager.getPlotByWorld(getPlayer(sender).getWorld());
plot = PlotManager.getCurrentPlot(Builder.byUUID(getPlayer(sender).getUniqueId()), Status.completed);
} else {
sendInfo(sender);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@

import com.alpsbte.plotsystem.commands.BaseCommand;
import com.alpsbte.plotsystem.commands.SubCommand;
import com.alpsbte.plotsystem.core.system.Builder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.core.system.plot.PlotHandler;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
import com.alpsbte.plotsystem.utils.Utils;
import com.alpsbte.plotsystem.utils.enums.Status;
import com.alpsbte.plotsystem.utils.io.language.LangPaths;
import com.alpsbte.plotsystem.utils.io.language.LangUtil;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -57,7 +59,7 @@ public void onCommand(CommandSender sender, String[] args) {
sender.sendMessage(Utils.getErrorMessageFormat(LangUtil.get(sender, LangPaths.Message.Error.PLOT_DOES_NOT_EXIST)));
}
} else if (PlotManager.isPlotWorld(getPlayer(sender).getWorld())) {
PlotHandler.sendLinkMessages(PlotManager.getPlotByWorld(getPlayer(sender).getWorld()), getPlayer(sender));
PlotHandler.sendLinkMessages(PlotManager.getCurrentPlot(Builder.byUUID(getPlayer(sender).getUniqueId()), Status.unfinished, Status.unreviewed), getPlayer(sender));
} else {
sendInfo(sender);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import com.alpsbte.plotsystem.commands.BaseCommand;
import com.alpsbte.plotsystem.commands.SubCommand;
import com.alpsbte.plotsystem.core.menus.FeedbackMenu;
import com.alpsbte.plotsystem.core.menus.PlotMemberMenu;
import com.alpsbte.plotsystem.core.system.Builder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
import com.alpsbte.plotsystem.utils.Utils;
import com.alpsbte.plotsystem.utils.enums.Status;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -37,7 +38,7 @@ public void onCommand(CommandSender sender, String[] args) {
}
} else if (PlotManager.isPlotWorld(getPlayer(sender).getWorld())) {
//plot members
plot = PlotManager.getPlotByWorld(getPlayer(sender).getWorld());
plot = PlotManager.getCurrentPlot(Builder.byUUID(getPlayer(sender).getUniqueId()), Status.unfinished, Status.unreviewed);
} else {
sendInfo(sender);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.alpsbte.plotsystem.commands.BaseCommand;
import com.alpsbte.plotsystem.commands.SubCommand;
import com.alpsbte.plotsystem.core.system.Builder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.core.system.plot.PlotHandler;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
Expand Down Expand Up @@ -58,7 +59,7 @@ public void onCommand(CommandSender sender, String[] args) {
return;
}
} else if (getPlayer(sender) != null && PlotManager.isPlotWorld(getPlayer(sender).getWorld())) {
plot = PlotManager.getPlotByWorld(getPlayer(sender).getWorld());
plot = PlotManager.getCurrentPlot(Builder.byUUID(getPlayer(sender).getUniqueId()));
} else {
sendInfo(sender);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void onCommand(CommandSender sender, String[] args) {
plot.getWorld().teleportPlayer(getPlayer(sender));
} else {
if (sender.hasPermission("plotsystem.admin") && PlotManager.plotExists(plotID)) {
new DefaultPlotGenerator(new Plot(plotID), new Builder(getPlayer(sender).getUniqueId()));
new DefaultPlotGenerator(new Plot(plotID), Builder.byUUID(getPlayer(sender).getUniqueId()));
} else {
sender.sendMessage(Utils.getErrorMessageFormat(LangUtil.get(sender, LangPaths.Message.Error.PLOT_DOES_NOT_EXIST)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.alpsbte.plotsystem.commands.BaseCommand;
import com.alpsbte.plotsystem.commands.SubCommand;
import com.alpsbte.plotsystem.core.system.Builder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.core.system.plot.PlotHandler;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
Expand Down Expand Up @@ -58,7 +59,7 @@ public void onCommand(CommandSender sender, String[] args) {
return;
}
} else if (getPlayer(sender) != null && PlotManager.isPlotWorld(getPlayer(sender).getWorld())) {
plot = PlotManager.getPlotByWorld(getPlayer(sender).getWorld());
plot = PlotManager.getCurrentPlot(Builder.byUUID(getPlayer(sender).getUniqueId()), Status.unreviewed);
} else {
sendInfo(sender);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

import com.alpsbte.plotsystem.PlotSystem;
import com.alpsbte.plotsystem.commands.BaseCommand;
import com.alpsbte.plotsystem.utils.enums.Status;
import com.alpsbte.plotsystem.utils.io.config.ConfigPaths;
import com.alpsbte.plotsystem.core.system.Builder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
import com.alpsbte.plotsystem.utils.Utils;
Expand Down Expand Up @@ -56,7 +58,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String s, String[] a
return true;
}
} else if (getPlayer(sender) != null && PlotManager.isPlotWorld(getPlayer(sender).getWorld())) {
plot = PlotManager.getPlotByWorld(getPlayer(sender).getWorld());
plot = PlotManager.getCurrentPlot(Builder.byUUID(getPlayer(sender).getUniqueId()), Status.unfinished, Status.unreviewed);
} else {
sendInfo(sender);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.alpsbte.plotsystem.commands.BaseCommand;
import com.alpsbte.plotsystem.core.menus.ReviewMenu;
import com.alpsbte.plotsystem.core.menus.ReviewPlotMenu;
import com.alpsbte.plotsystem.core.system.Builder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
import com.alpsbte.plotsystem.utils.Utils;
import com.alpsbte.plotsystem.utils.enums.Status;
Expand All @@ -48,11 +50,10 @@ public boolean onCommand(CommandSender sender, Command cmd, String s, String[] a
if (getPlayer(sender) != null) {
try {
Player player = (Player) sender;
if (PlotManager.isPlotWorld(player.getWorld()) && PlotManager.getPlotByWorld(player.getWorld()).getStatus() == Status.unreviewed) {
new ReviewPlotMenu(player, PlotManager.getPlotByWorld(player.getWorld()));
} else {
new ReviewMenu(player);
}
Plot plot = PlotManager.getCurrentPlot(Builder.byUUID(player.getUniqueId()), Status.unreviewed);
if (plot != null && plot.getStatus() == Status.unreviewed) {
new ReviewPlotMenu(player, plot);
} else new ReviewMenu(player);
} catch (SQLException ex) {
sender.sendMessage(Utils.getErrorMessageFormat(LangUtil.get(sender, LangPaths.Message.Error.ERROR_OCCURRED)));
Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
Expand Down
29 changes: 11 additions & 18 deletions src/main/java/com/alpsbte/plotsystem/core/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package com.alpsbte.plotsystem.core;

import com.alpsbte.plotsystem.PlotSystem;
import com.alpsbte.plotsystem.core.system.plot.world.PlotWorld;
import com.alpsbte.plotsystem.utils.io.config.ConfigPaths;
import com.alpsbte.plotsystem.core.system.plot.PlotManager;
import com.alpsbte.plotsystem.core.menus.CompanionMenu;
Expand Down Expand Up @@ -101,7 +102,7 @@ public void onPlayerJoinEvent(PlayerJoinEvent event) {

// Check if player has changed his name
try {
Builder builder = new Builder(event.getPlayer().getUniqueId());
Builder builder = Builder.byUUID(event.getPlayer().getUniqueId());
if (!builder.getName().equals(event.getPlayer().getName())) {
DatabaseConnection.createStatement("UPDATE plotsystem_builders SET name = ? WHERE uuid = ?")
.setValue(event.getPlayer().getName()).setValue(event.getPlayer().getUniqueId().toString()).executeUpdate();
Expand All @@ -112,7 +113,7 @@ public void onPlayerJoinEvent(PlayerJoinEvent event) {

// Informing player about new feedback
try {
List<Plot> plots = PlotManager.getPlots(new Builder(event.getPlayer().getUniqueId()), Status.completed, Status.unfinished);
List<Plot> plots = PlotManager.getPlots(Builder.byUUID(event.getPlayer().getUniqueId()), Status.completed, Status.unfinished);
List<Plot> reviewedPlots = new ArrayList<>();

for(Plot plot : plots) {
Expand All @@ -132,7 +133,7 @@ public void onPlayerJoinEvent(PlayerJoinEvent event) {

// Informing player about unfinished plots
try {
List<Plot> plots = PlotManager.getPlots(new Builder(event.getPlayer().getUniqueId()), Status.unfinished);
List<Plot> plots = PlotManager.getPlots(Builder.byUUID(event.getPlayer().getUniqueId()), Status.unfinished);
if(plots.size() >= 1) {
PlotHandler.sendUnfinishedPlotReminderMessage(plots, event.getPlayer());
event.getPlayer().sendMessage("");
Expand Down Expand Up @@ -196,36 +197,28 @@ public void onPlayerInteractEvent(PlayerInteractEvent event) {
@EventHandler
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) throws SQLException {
if (event.getRightClicked().getType().equals(EntityType.PLAYER)) {
event.getPlayer().performCommand("plots " + new Builder(event.getRightClicked().getUniqueId()).getName());
event.getPlayer().performCommand("plots " + Builder.byUUID(event.getRightClicked().getUniqueId()).getName());
}
}

@EventHandler
public void onPlayerQuitEvent(PlayerQuitEvent event) {
final World w = event.getPlayer().getWorld();

Bukkit.getScheduler().scheduleSyncDelayedTask(PlotSystem.getPlugin(), () -> {
if(PlotManager.isPlotWorld(w)) {
try {
PlotManager.getPlotByWorld(w).getWorld().unloadWorld(false);
} catch (SQLException ex) {
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
}
DefaultPlotGenerator.playerPlotGenerationHistory.remove(event.getPlayer().getUniqueId());
try { PlotWorld.getPlotWorldByName(w.getName()).unloadWorld(false);
} catch (SQLException ex) { Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex); }
}
DefaultPlotGenerator.playerPlotGenerationHistory.remove(event.getPlayer().getUniqueId());
PlotManager.clearCache(event.getPlayer().getUniqueId());
}, 60L);
}

@EventHandler
public void onPlayerTeleportEvent(PlayerTeleportEvent event) throws SQLException {
if(PlotManager.isPlotWorld(event.getPlayer().getWorld()) && !event.getFrom().getWorld().equals(event.getTo().getWorld())) {
PlotManager.getPlotByWorld(event.getFrom().getWorld()).getWorld().unloadWorld(false);
}
}

@EventHandler
public void onPlayerChangedWorldEvent(PlayerChangedWorldEvent event) throws SQLException {
if (PlotManager.isPlotWorld(event.getFrom())) {
PlotManager.getPlotByWorld(event.getFrom()).getWorld().unloadWorld(false);
PlotWorld.getPlotWorldByName(event.getFrom().getName()).unloadWorld(false);
}

if (PlotManager.isPlotWorld(event.getPlayer().getWorld())) {
Expand Down
Loading

0 comments on commit 8b32ec7

Please sign in to comment.