mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 22:17:17 +00:00
Added developer API and events
Added essentials migrator
This commit is contained in:
1 parent
f1a1df6858
commit
739359cbd6
63 files changed
+1699
-259
No files matched your search
@@ -6,6 +6,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* An object representing a Player's home in-game
|
||||
* @author William
|
||||
*/
|
||||
public class Home extends TeleportationPoint {
|
||||
|
||||
String name;
|
||||
@@ -15,6 +19,14 @@ public class Home extends TeleportationPoint {
|
||||
UUID ownerUUID;
|
||||
String ownerUsername;
|
||||
|
||||
/**
|
||||
* An object representing a Player's home in-game
|
||||
* @param location The Bukkit location of the home
|
||||
* @param server The Bungee server ID of the home
|
||||
* @param homeOwner The Player who owns the home
|
||||
* @param name The name of the home
|
||||
* @param isPublic Whether or not the home is public
|
||||
*/
|
||||
public Home(Location location, String server, Player homeOwner, String name, boolean isPublic) {
|
||||
super(location, server);
|
||||
this.name = name;
|
||||
@@ -24,6 +36,15 @@ public class Home extends TeleportationPoint {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object representing a Player's home in-game
|
||||
* @param teleportationPoint The position of the home
|
||||
* @param ownerUsername The username of the owner
|
||||
* @param ownerUUID The UUID of the owner
|
||||
* @param name The name of the home
|
||||
* @param description The description of the home
|
||||
* @param isPublic Whether or not the home is public
|
||||
*/
|
||||
public Home(TeleportationPoint teleportationPoint, String ownerUsername, String ownerUUID, String name, String description, boolean isPublic) {
|
||||
super(teleportationPoint.worldName, teleportationPoint.x, teleportationPoint.y, teleportationPoint.z, teleportationPoint.yaw, teleportationPoint.pitch, teleportationPoint.server);
|
||||
this.ownerUsername = ownerUsername;
|
||||
@@ -33,22 +54,42 @@ public class Home extends TeleportationPoint {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the Home is public
|
||||
* @return if the Home is public
|
||||
*/
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the privacy of the home
|
||||
* @param isPublic should the home be public?
|
||||
*/
|
||||
public void setPublic(boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the UUID of the Home's owner
|
||||
* @return the owner's UUID
|
||||
*/
|
||||
public UUID getOwnerUUID() {
|
||||
return ownerUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the username of the Home's owner
|
||||
* @return the owner's username
|
||||
*/
|
||||
public String getOwnerUsername() {
|
||||
return ownerUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Player who owns the home
|
||||
* @return the Player owner of the home
|
||||
*/
|
||||
public Player getOwner() {
|
||||
Player player = Bukkit.getPlayer(ownerUUID);
|
||||
if (player != null) {
|
||||
@@ -58,23 +99,43 @@ public class Home extends TeleportationPoint {
|
||||
}
|
||||
}
|
||||
|
||||
public void setOwner(Player p) {
|
||||
this.ownerUUID = p.getUniqueId();
|
||||
this.ownerUsername = p.getName();
|
||||
/**
|
||||
* Set the owner of the home
|
||||
* @param player The new owner of the home
|
||||
*/
|
||||
public void setOwner(Player player) {
|
||||
this.ownerUUID = player.getUniqueId();
|
||||
this.ownerUsername = player.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the home
|
||||
* @return the Home name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the home
|
||||
* @return the Home description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the home
|
||||
* @param name the new Home name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description of the home
|
||||
* @param description the new Home description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.name = description;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.william278.huskhomes2.Objects;
|
||||
|
||||
import me.william278.huskhomes2.Main;
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -35,8 +35,8 @@ public class RandomPoint extends TeleportationPoint {
|
||||
int negativeX;
|
||||
int negativeZ;
|
||||
|
||||
x = random.nextInt(Main.settings.getRtpRange());
|
||||
z = random.nextInt(Main.settings.getRtpRange());
|
||||
x = random.nextInt(HuskHomes.settings.getRtpRange());
|
||||
z = random.nextInt(HuskHomes.settings.getRtpRange());
|
||||
negativeX = random.nextInt(2);
|
||||
negativeZ = random.nextInt(2);
|
||||
|
||||
@@ -80,8 +80,8 @@ public class RandomPoint extends TeleportationPoint {
|
||||
}
|
||||
|
||||
public RandomPoint(Player player) {
|
||||
super(player.getLocation(), Main.settings.getServerID());
|
||||
setLocation(getRandomLocation(player.getWorld()), Main.settings.getServerID());
|
||||
super(player.getLocation(), HuskHomes.settings.getServerID());
|
||||
setLocation(getRandomLocation(player.getWorld()), HuskHomes.settings.getServerID());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.william278.huskhomes2.Objects;
|
||||
|
||||
import me.william278.huskhomes2.Integrations.economy;
|
||||
import me.william278.huskhomes2.Main;
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.dataManager;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.permissionHomeLimits;
|
||||
@@ -31,8 +31,8 @@ public class SetHomeConditions {
|
||||
conditionsNotMetReason = "error_set_home_invalid_characters";
|
||||
return;
|
||||
}
|
||||
if (Main.settings.doEconomy()) {
|
||||
double setHomeCost = Main.settings.setHomeCost;
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
double setHomeCost = HuskHomes.settings.setHomeCost;
|
||||
if (setHomeCost > 0) {
|
||||
int currentPlayerHomeSlots = dataManager.getPlayerHomeSlots(player);
|
||||
if (currentHomeCount > (currentPlayerHomeSlots - 1)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.william278.huskhomes2.Objects;
|
||||
|
||||
import me.william278.huskhomes2.Main;
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -45,6 +45,9 @@ public class Settings {
|
||||
double publicHomeCost;
|
||||
double rtpCost;
|
||||
|
||||
// Vanished player checks
|
||||
boolean checkVanishedPlayers;
|
||||
|
||||
// Time and maximum home settings
|
||||
int maximumHomes;
|
||||
int teleportRequestExpiryTime;
|
||||
@@ -89,7 +92,7 @@ public class Settings {
|
||||
this.doDynmap = configFile.getBoolean("dynmap_integration.enabled");
|
||||
|
||||
if (this.doDynmap) {
|
||||
PluginManager pluginManager = Main.getInstance().getServer().getPluginManager();
|
||||
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
||||
Plugin dynmap = pluginManager.getPlugin("dynmap");
|
||||
if (dynmap == null) {
|
||||
Bukkit.getLogger().warning("Dynmap integration was enabled in config, but the Dynmap plugin could not be found!");
|
||||
@@ -108,7 +111,7 @@ public class Settings {
|
||||
this.doEconomy = configFile.getBoolean("economy_integration.enabled");
|
||||
|
||||
if (this.doEconomy) {
|
||||
PluginManager pluginManager = Main.getInstance().getServer().getPluginManager();
|
||||
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
||||
Plugin vault = pluginManager.getPlugin("Vault");
|
||||
if (vault == null) {
|
||||
Bukkit.getLogger().warning("Economy integration was enabled in config, but the Vault plugin could not be found!");
|
||||
@@ -122,6 +125,8 @@ public class Settings {
|
||||
this.publicHomeCost = configFile.getDouble("economy_integration.costs.make_home_public");
|
||||
this.rtpCost = configFile.getDouble("economy_integration.costs.random_teleport");
|
||||
|
||||
this.checkVanishedPlayers = configFile.getBoolean("handle_vanished_players");
|
||||
|
||||
this.doSpawnCommand = configFile.getBoolean("spawn_command.enabled");
|
||||
this.doWarpCommand = configFile.getBoolean("enable_warp_command");
|
||||
|
||||
@@ -134,7 +139,7 @@ public class Settings {
|
||||
this.teleportWarmupTime = configFile.getInt("general.teleport_warmup_time");
|
||||
|
||||
} catch (Exception e) {
|
||||
Main.disablePlugin("An error occurred loading the HuskHomes config (" + e.getCause() + ")");
|
||||
HuskHomes.disablePlugin("An error occurred loading the HuskHomes config (" + e.getCause() + ")");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -183,6 +188,10 @@ public class Settings {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
public boolean isCheckVanishedPlayers() {
|
||||
return checkVanishedPlayers;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.william278.huskhomes2.Objects;
|
||||
|
||||
import me.william278.huskhomes2.Main;
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TeleportRequest {
|
||||
this.requestType = requestType.toLowerCase();
|
||||
}
|
||||
long currentUnixTime = Instant.now().getEpochSecond();
|
||||
requestExpiryTime = currentUnixTime + Main.settings.getTeleportRequestExpiryTime();
|
||||
requestExpiryTime = currentUnixTime + HuskHomes.settings.getTeleportRequestExpiryTime();
|
||||
}
|
||||
|
||||
public String getSenderName() {
|
||||
|
||||
@@ -4,6 +4,10 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
/**
|
||||
* @author William
|
||||
* HuskHomes' position representation object; represents an in-game location on a server
|
||||
*/
|
||||
public class TeleportationPoint {
|
||||
|
||||
String server;
|
||||
@@ -14,6 +18,11 @@ public class TeleportationPoint {
|
||||
float yaw;
|
||||
float pitch;
|
||||
|
||||
/**
|
||||
* Update the location of a TeleportationPoint
|
||||
* @param location a new Bukkit location
|
||||
* @param server a new Bungee server ID
|
||||
*/
|
||||
public void setLocation(Location location, String server) {
|
||||
worldName = location.getWorld().getName();
|
||||
x = location.getX();
|
||||
@@ -24,6 +33,11 @@ public class TeleportationPoint {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
/**
|
||||
* HuskHomes' position representation object; represents an in-game location on a server
|
||||
* @param location The Bukkit location
|
||||
* @param server The Bungee server ID which the location is on
|
||||
*/
|
||||
public TeleportationPoint(Location location, String server) {
|
||||
if (location.getWorld() == null) {
|
||||
throw new IllegalStateException("The location provided has an invalid world");
|
||||
@@ -31,6 +45,16 @@ public class TeleportationPoint {
|
||||
setLocation(location, server);
|
||||
}
|
||||
|
||||
/**
|
||||
* HuskHomes' position representation object; represents an in-game location on a server
|
||||
* @param worldName The name of the location's world
|
||||
* @param x The location's x-coordinate
|
||||
* @param y The location's y-coordinate
|
||||
* @param z The location's z-coordinate
|
||||
* @param yaw The location's yaw angle
|
||||
* @param pitch The location's pitch angle
|
||||
* @param server The Bungee server ID which the location is on
|
||||
*/
|
||||
public TeleportationPoint(String worldName, double x, double y, double z, float yaw, float pitch, String server) {
|
||||
this.server = server;
|
||||
this.worldName = worldName;
|
||||
@@ -41,14 +65,11 @@ public class TeleportationPoint {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public void updateLocation(Location location, String server) {
|
||||
setLocation(location, server);
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Bukkit location from a TeleportationPoint
|
||||
* @return the Bukkit location on the server from a TeleportationPoint
|
||||
* @throws IllegalStateException if the location is not valid on the server
|
||||
*/
|
||||
public Location getLocation() {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world != null) {
|
||||
@@ -58,26 +79,58 @@ public class TeleportationPoint {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the world from a TeleportationPoint
|
||||
* @return the name of the world the position is on from a TeleportationPoint
|
||||
*/
|
||||
public String getWorldName() {
|
||||
return worldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Bungee server ID from a TeleportationPoint
|
||||
* @return the TeleportationPoint's Bungee server ID
|
||||
*/
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the x-coordinate of a TeleportationPoint
|
||||
* @return the x-coordinate
|
||||
*/
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y-coordinate of a TeleportationPoint
|
||||
* @return the y-coordinate
|
||||
*/
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the z-coordinate of a TeleportationPoint
|
||||
* @return the z-coordinate
|
||||
*/
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the yaw angle of a TeleportationPoint
|
||||
* @return the yaw angle
|
||||
*/
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pitch angle of a TeleportationPoint
|
||||
* @return the pitch angle
|
||||
*/
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package me.william278.huskhomes2.Objects;
|
||||
|
||||
import me.william278.huskhomes2.Main;
|
||||
import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TimedTeleport {
|
||||
@@ -18,7 +17,7 @@ public class TimedTeleport {
|
||||
double initialTeleporterHealth;
|
||||
|
||||
int timeRemaining;
|
||||
final int warmupTime = Main.settings.getTeleportWarmupTime();
|
||||
final int warmupTime = HuskHomes.settings.getTeleportWarmupTime();
|
||||
|
||||
public TimedTeleport(Player teleporter, TeleportationPoint targetPoint) {
|
||||
this.teleporter = teleporter;
|
||||
|
||||
@@ -2,35 +2,67 @@ package me.william278.huskhomes2.Objects;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
* An object representing an in-game warp
|
||||
* @author William
|
||||
*/
|
||||
public class Warp extends TeleportationPoint {
|
||||
|
||||
String name;
|
||||
String description;
|
||||
|
||||
/**
|
||||
* An object representing an in-game warp
|
||||
* @param location the Bukkit location of the Warp
|
||||
* @param server The Bungee server ID of the Warp
|
||||
* @param name The name of the Warp
|
||||
*/
|
||||
public Warp(Location location, String server, String name) {
|
||||
super(location, server);
|
||||
this.name = name;
|
||||
this.description = "A publicly accessible warp";
|
||||
}
|
||||
|
||||
/**
|
||||
* An object representing an in-game warp
|
||||
* @param teleportationPoint The position of the Warp
|
||||
* @param name The name of the Warp
|
||||
* @param description The description of the Warp
|
||||
*/
|
||||
public Warp(TeleportationPoint teleportationPoint, String name, String description) {
|
||||
super(teleportationPoint.worldName, teleportationPoint.x, teleportationPoint.y, teleportationPoint.z, teleportationPoint.yaw, teleportationPoint.pitch, teleportationPoint.server);
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the Warp
|
||||
* @return the Warp's description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the Warp
|
||||
* @return the Warp's name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the Warp
|
||||
* @param name the new Warp name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description of the Warp
|
||||
* @param description the new Warp description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.name = description;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user