mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Added developer API and events
Added essentials migrator
This commit is contained in:
1 parent
f1a1df6858
commit
739359cbd6
63 files changed
+1687
-247
No files matched your search
@@ -0,0 +1,125 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
|
import me.william278.huskhomes2.dataManager;
|
||||||
|
import me.william278.huskhomes2.teleportManager;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The HuskHomes API
|
||||||
|
* Only use methods/events found within the API package
|
||||||
|
*/
|
||||||
|
public class HuskHomesAPI {
|
||||||
|
|
||||||
|
public HuskHomesAPI() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a Home set by a player, or NULL if it does not exist
|
||||||
|
@param player A player
|
||||||
|
@param homeName Name of the player's home you wish to retrieve
|
||||||
|
@return the player's Home, or NULL if it does not exist
|
||||||
|
@see Home
|
||||||
|
*/
|
||||||
|
public Home getHome(Player player, String homeName) {
|
||||||
|
return getHome(player.getName(), homeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a Home set by a player, or NULL if it does not exist
|
||||||
|
@param ownerUsername Username of the player
|
||||||
|
@param homeName Name of the player's home you wish to retrieve
|
||||||
|
@return the player's Home, or NULL if it does not exist
|
||||||
|
@see Home
|
||||||
|
*/
|
||||||
|
public Home getHome(String ownerUsername, String homeName) {
|
||||||
|
return dataManager.getHome(ownerUsername, homeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a Warp set on the server, or NULL if it does not exist
|
||||||
|
@param warpName Name of the warp
|
||||||
|
@return a Warp, or NULL if it does not exist
|
||||||
|
@see Warp
|
||||||
|
*/
|
||||||
|
public Warp getWarp(String warpName) {
|
||||||
|
return dataManager.getWarp(warpName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns an ArrayList of homes set by a Player
|
||||||
|
@param player A Player
|
||||||
|
@return an ArrayList of Homes
|
||||||
|
@see Home
|
||||||
|
*/
|
||||||
|
public ArrayList<Home> getHomes(Player player) {
|
||||||
|
return dataManager.getPlayerHomes(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns an ArrayList of homes set by a player
|
||||||
|
@param ownerUsername Username of the player who's homes you want to get
|
||||||
|
@return an ArrayList of Homes
|
||||||
|
@see Home
|
||||||
|
*/
|
||||||
|
public ArrayList<Home> getHomes(String ownerUsername) {
|
||||||
|
return dataManager.getPlayerHomes(ownerUsername);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns how many Homes a given Player has set
|
||||||
|
* @param player the Player being checked
|
||||||
|
* @return an integer of how many homes a player has set
|
||||||
|
* @see Home
|
||||||
|
*/
|
||||||
|
public int getHomeCount(Player player) {
|
||||||
|
return getHomes(player).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns an ArrayList of all the public homes set
|
||||||
|
@return an ArrayList of Homes
|
||||||
|
@see Home
|
||||||
|
*/
|
||||||
|
public ArrayList<Home> getPublicHomes() {
|
||||||
|
return dataManager.getPublicHomes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns how many public Homes there are
|
||||||
|
* @return an integer of how many public homes there are
|
||||||
|
* @see Home
|
||||||
|
*/
|
||||||
|
public int getPublicHomeCount() {
|
||||||
|
return getPublicHomes().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns an ArrayList of all the warps set
|
||||||
|
@return an ArrayList of Warps
|
||||||
|
@see Warp
|
||||||
|
*/
|
||||||
|
public ArrayList<Warp> getWarps() {
|
||||||
|
return dataManager.getWarps();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns how many Warps have been set
|
||||||
|
* @return an integer of how many warps have been set
|
||||||
|
* @see Warp
|
||||||
|
*/
|
||||||
|
public int getWarpCount() {
|
||||||
|
return getWarps().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current spawn position as a TeleportationPoint
|
||||||
|
* @return the spawn position as a TeleportationPoint
|
||||||
|
*/
|
||||||
|
public TeleportationPoint getSpawnPosition() {
|
||||||
|
return teleportManager.spawnLocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player changes the description of a home.
|
||||||
|
*/
|
||||||
|
public class PlayerChangeHomeDescriptionEvent extends PlayerHomeUpdateEvent {
|
||||||
|
|
||||||
|
private final String oldDescription;
|
||||||
|
private final String newDescription;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player changes the description of a home.
|
||||||
|
* @param player The Player who is changing the home's description
|
||||||
|
* @param home The Home being changed
|
||||||
|
* @param newDescription The new description being set
|
||||||
|
* @see PlayerHomeUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerChangeHomeDescriptionEvent(Player player, Home home, String newDescription) {
|
||||||
|
super(player, home);
|
||||||
|
this.oldDescription = home.getDescription();
|
||||||
|
this.newDescription = newDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the old description of the home
|
||||||
|
* @return the old description String
|
||||||
|
*/
|
||||||
|
public String getOldDescription() {
|
||||||
|
return oldDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the new description being set to the home
|
||||||
|
* @return the new description String
|
||||||
|
*/
|
||||||
|
public String getNewDescription() {
|
||||||
|
return newDescription;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
An event, fired when a player changes the description of a warp.
|
||||||
|
*/
|
||||||
|
public class PlayerChangeWarpDescriptionEvent extends PlayerWarpUpdateEvent {
|
||||||
|
private final String oldDescription;
|
||||||
|
private final String newDescription;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player changes the description of a warp.
|
||||||
|
* @param player The Player who is changing the warp's description
|
||||||
|
* @param warp The Warp being changed
|
||||||
|
* @param newDescription The new description being set
|
||||||
|
* @see PlayerWarpUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerChangeWarpDescriptionEvent(Player player, Warp warp, String newDescription) {
|
||||||
|
super(player, warp);
|
||||||
|
this.oldDescription = warp.getDescription();
|
||||||
|
this.newDescription = newDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the old description of the home
|
||||||
|
* @return the old description String
|
||||||
|
*/
|
||||||
|
public String getOldDescription() {
|
||||||
|
return oldDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the new description being set to the home
|
||||||
|
* @return the new description String
|
||||||
|
*/
|
||||||
|
public String getNewDescription() {
|
||||||
|
return newDescription;
|
||||||
|
}}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player deletes a home
|
||||||
|
*/
|
||||||
|
public class PlayerDeleteHomeEvent extends PlayerHomeUpdateEvent {
|
||||||
|
/**
|
||||||
|
* An event, fired when a player deletes a home
|
||||||
|
* @param player The Player who is deleting the home
|
||||||
|
* @param home The Home being deleted
|
||||||
|
* @see PlayerHomeUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerDeleteHomeEvent(Player player, Home home) {
|
||||||
|
super(player, home);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player deletes a warp
|
||||||
|
*/
|
||||||
|
public class PlayerDeleteWarpEvent extends PlayerWarpUpdateEvent {
|
||||||
|
/**
|
||||||
|
* An event, fired when a player deletes a warp
|
||||||
|
* @param player The Player who is deleting the warp
|
||||||
|
* @param warp The Warp being deleted
|
||||||
|
* @see PlayerWarpUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerDeleteWarpEvent(Player player, Warp warp) {
|
||||||
|
super(player, warp);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a home is updated
|
||||||
|
* Fires when a player renames a Home, updates its' location, changes its' name, changes whether or not it is public/private.
|
||||||
|
* Also fires when it is deleted
|
||||||
|
*/
|
||||||
|
public class PlayerHomeUpdateEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private final Home home;
|
||||||
|
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
private boolean isCancelled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a home is updated
|
||||||
|
* Fires when a player renames a Home, updates its' location, changes its' name, changes whether or not it is public/private, or when it is deleted
|
||||||
|
* Does not fire when a player sets a Home
|
||||||
|
*
|
||||||
|
* @param player The Player who is updating the Home
|
||||||
|
* @param home The Home being changed
|
||||||
|
*/
|
||||||
|
public PlayerHomeUpdateEvent(Player player, Home home) {
|
||||||
|
this.player = player;
|
||||||
|
this.home = home;
|
||||||
|
this.isCancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return isCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.isCancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Player involved in this event
|
||||||
|
*
|
||||||
|
* @return the Player who updated the home
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Player involved in this event
|
||||||
|
*
|
||||||
|
* @return the Home being updated
|
||||||
|
*/
|
||||||
|
public Home getHome() {
|
||||||
|
return home;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player makes a home private
|
||||||
|
*/
|
||||||
|
public class PlayerMakeHomePrivateEvent extends PlayerHomeUpdateEvent {
|
||||||
|
/**
|
||||||
|
* An event, fired when a player makes a home private
|
||||||
|
* @param player The Player who is making the Home private
|
||||||
|
* @param home The Home being changed
|
||||||
|
* @see PlayerHomeUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerMakeHomePrivateEvent(Player player, Home home) {
|
||||||
|
super(player, home);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player makes a home public
|
||||||
|
*/
|
||||||
|
public class PlayerMakeHomePublicEvent extends PlayerHomeUpdateEvent {
|
||||||
|
/**
|
||||||
|
* An event, fired when a player makes a home public
|
||||||
|
* @param player The Player who is making the Home public
|
||||||
|
* @param home The Home being changed
|
||||||
|
* @see PlayerHomeUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerMakeHomePublicEvent(Player player, Home home) {
|
||||||
|
super(player, home);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player edits a Warp to change it's location
|
||||||
|
*/
|
||||||
|
public class PlayerRelocateHomeEvent extends PlayerHomeUpdateEvent {
|
||||||
|
|
||||||
|
final TeleportationPoint oldTeleportationPoint;
|
||||||
|
final TeleportationPoint newTeleportationPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player relocates a home
|
||||||
|
* @param player The Player who is relocating the Home
|
||||||
|
* @param home The Home being moved
|
||||||
|
* @param newTeleportationPoint The new teleportation position of the Home
|
||||||
|
* @see PlayerWarpUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerRelocateHomeEvent(Player player, Home home, TeleportationPoint newTeleportationPoint) {
|
||||||
|
super(player, home);
|
||||||
|
this.oldTeleportationPoint = home;
|
||||||
|
this.newTeleportationPoint = newTeleportationPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the teleportation position of the Home before it is updated
|
||||||
|
* @return the pre-update teleportation position
|
||||||
|
*/
|
||||||
|
public TeleportationPoint getOldTeleportationPoint() {
|
||||||
|
return oldTeleportationPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the updated teleportation position of the Home
|
||||||
|
* @return the updated teleportation position
|
||||||
|
*/
|
||||||
|
public TeleportationPoint getNewTeleportationPoint() {
|
||||||
|
return newTeleportationPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player edits a Warp to change it's location
|
||||||
|
*/
|
||||||
|
public class PlayerRelocateWarpEvent extends PlayerWarpUpdateEvent {
|
||||||
|
|
||||||
|
final TeleportationPoint oldTeleportationPoint;
|
||||||
|
final TeleportationPoint newTeleportationPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player relocates a warp
|
||||||
|
* @param player The Player who is relocating the Warp
|
||||||
|
* @param warp The Warp being moved
|
||||||
|
* @param newTeleportationPoint The new teleportation position of the Warp
|
||||||
|
* @see PlayerWarpUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerRelocateWarpEvent(Player player, Warp warp, TeleportationPoint newTeleportationPoint) {
|
||||||
|
super(player, warp);
|
||||||
|
this.oldTeleportationPoint = warp;
|
||||||
|
this.newTeleportationPoint = newTeleportationPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the teleportation position of the Warp before it is updated
|
||||||
|
* @return the pre-update teleportation position
|
||||||
|
*/
|
||||||
|
public TeleportationPoint getOldTeleportationPoint() {
|
||||||
|
return oldTeleportationPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the updated teleportation position of the Warp
|
||||||
|
* @return the updated teleportation position
|
||||||
|
*/
|
||||||
|
public TeleportationPoint getNewTeleportationPoint() {
|
||||||
|
return newTeleportationPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player renames a home
|
||||||
|
*/
|
||||||
|
public class PlayerRenameHomeEvent extends PlayerHomeUpdateEvent {
|
||||||
|
|
||||||
|
private final String oldName;
|
||||||
|
private final String newName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player changes the name of a home
|
||||||
|
* @param player The Player who is changing the Home's name
|
||||||
|
* @param home The Home being changed
|
||||||
|
* @param newName The new name of the home
|
||||||
|
* @see PlayerHomeUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerRenameHomeEvent(Player player, Home home, String newName) {
|
||||||
|
super(player, home);
|
||||||
|
this.oldName = home.getName();
|
||||||
|
this.newName = newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the Home pre-update
|
||||||
|
* @return the name of the Home before it is updated
|
||||||
|
*/
|
||||||
|
public String getOldName() {
|
||||||
|
return oldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the changed name of the Home
|
||||||
|
* @return the new name of the Home
|
||||||
|
*/
|
||||||
|
public String getNewName() {
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player renames a warp
|
||||||
|
*/
|
||||||
|
public class PlayerRenameWarpEvent extends PlayerWarpUpdateEvent {
|
||||||
|
private final String oldName;
|
||||||
|
private final String newName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player changes the name of a warp
|
||||||
|
* @param player The Player who is changing the Warp's name
|
||||||
|
* @param warp The Warp being changed
|
||||||
|
* @param newName The new name of the warp
|
||||||
|
* @see PlayerWarpUpdateEvent
|
||||||
|
*/
|
||||||
|
public PlayerRenameWarpEvent(Player player, Warp warp, String newName) {
|
||||||
|
super(player, warp);
|
||||||
|
this.oldName = warp.getName();
|
||||||
|
this.newName = newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the Warp pre-update
|
||||||
|
* @return the name of the Warp before it is updated
|
||||||
|
*/
|
||||||
|
public String getOldName() {
|
||||||
|
return oldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the changed name of the Warp
|
||||||
|
* @return the new name of the Warp
|
||||||
|
*/
|
||||||
|
public String getNewName() {
|
||||||
|
return newName;
|
||||||
|
}}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player sets a new home
|
||||||
|
*/
|
||||||
|
public class PlayerSetHomeEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private Player player;
|
||||||
|
private Home home;
|
||||||
|
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
private boolean isCancelled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player sets a Home
|
||||||
|
* @param player the Player setting the Home
|
||||||
|
* @param home the Home being set
|
||||||
|
*/
|
||||||
|
public PlayerSetHomeEvent(Player player, Home home) {
|
||||||
|
this.player = player;
|
||||||
|
this.home = home;
|
||||||
|
this.isCancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return isCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.isCancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player involved in this event
|
||||||
|
* @return the Player who is setting the home
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Home being set
|
||||||
|
* @return the Home being set
|
||||||
|
*/
|
||||||
|
public Home getHome() {
|
||||||
|
return home;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a player sets a new warp
|
||||||
|
*/
|
||||||
|
public class PlayerSetWarpEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private final Warp warp;
|
||||||
|
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
private boolean isCancelled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a Player sets a Warp
|
||||||
|
* @param player the Player setting the warp
|
||||||
|
* @param warp the Warp being set
|
||||||
|
*/
|
||||||
|
public PlayerSetWarpEvent(Player player, Warp warp) {
|
||||||
|
this.player = player;
|
||||||
|
this.warp = warp;
|
||||||
|
this.isCancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return isCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.isCancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Player involved in this event
|
||||||
|
* @return the Player who is setting the warp
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Warp being set
|
||||||
|
* @return the Warp that is being set
|
||||||
|
*/
|
||||||
|
public Warp getWarp() {
|
||||||
|
return warp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package me.william278.huskhomes2.API;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a warp is updated
|
||||||
|
* Fires when a player renames a Warp, updates its' location or changes its' name.
|
||||||
|
* Also fires when a warp is deleted
|
||||||
|
*/
|
||||||
|
public class PlayerWarpUpdateEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private final Warp warp;
|
||||||
|
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
private boolean isCancelled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event, fired when a Warp is updated.
|
||||||
|
* Fires when a player renames a Warp, updates its' location, changes its' name or when it is deleted.
|
||||||
|
* Does not fire when a player sets a Warp.
|
||||||
|
* @param player The Player who is updating the Warp
|
||||||
|
* @param warp The Warp being changed
|
||||||
|
*/
|
||||||
|
public PlayerWarpUpdateEvent(Player player, Warp warp) {
|
||||||
|
this.player = player;
|
||||||
|
this.warp = warp;
|
||||||
|
this.isCancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return isCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.isCancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Player involved in this event
|
||||||
|
* @return the Player who updated the Warp
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Warp being updated
|
||||||
|
* @return the Warp being updated
|
||||||
|
*/
|
||||||
|
public Warp getWarp() {
|
||||||
|
return warp;
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package me.william278.huskhomes2.Commands.TabCompleters;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class editHomeTabCompleter implements TabCompleter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (!p.hasPermission("huskhomes.edithome")) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
if (args.length == 1) {
|
||||||
|
final List<String> tabCompletions = new ArrayList<>();
|
||||||
|
StringUtil.copyPartialMatches(args[0], homeTabCompleter.homeTabCache.get(p.getUniqueId()), tabCompletions);
|
||||||
|
Collections.sort(tabCompletions);
|
||||||
|
return tabCompletions;
|
||||||
|
} else if (args.length == 2) {
|
||||||
|
List<String> editHomeOptions = new ArrayList<>();
|
||||||
|
editHomeOptions.add("rename");
|
||||||
|
editHomeOptions.add("location");
|
||||||
|
editHomeOptions.add("description");
|
||||||
|
if (sender.hasPermission("huskhomes.edithome.public")) {
|
||||||
|
editHomeOptions.add("public");
|
||||||
|
editHomeOptions.add("private");
|
||||||
|
}
|
||||||
|
return editHomeOptions;
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
package me.william278.huskhomes2.Commands.TabCompleters;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class editWarpTabCompleter implements TabCompleter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (!p.hasPermission("huskhomes.editwarp")) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
if (args.length == 1) {
|
||||||
|
final List<String> tabCompletions = new ArrayList<>();
|
||||||
|
StringUtil.copyPartialMatches(args[0], warpTabCompleter.warpsTabCache, tabCompletions);
|
||||||
|
Collections.sort(tabCompletions);
|
||||||
|
return tabCompletions;
|
||||||
|
} else if (args.length == 2) {
|
||||||
|
List<String> editWarpOptions = new ArrayList<>();
|
||||||
|
editWarpOptions.add("rename");
|
||||||
|
editWarpOptions.add("location");
|
||||||
|
editWarpOptions.add("description");
|
||||||
|
return editWarpOptions;
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package me.william278.huskhomes2.Commands.TabCompleters;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class emptyTabCompleter implements TabCompleter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package me.william278.huskhomes2.Commands.TabCompleters;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import me.william278.huskhomes2.dataManager;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class homeTabCompleter implements TabCompleter {
|
||||||
|
|
||||||
|
// This HashMap stores a cache of a player's homes that is displayed when a user presses TAB.
|
||||||
|
// Owner UUID, Home Name
|
||||||
|
public static HashMap<UUID, ArrayList<String>> homeTabCache = new HashMap<>();
|
||||||
|
|
||||||
|
// This method updates a player's home cache.
|
||||||
|
public static void updatePlayerHomeCache(Player p) {
|
||||||
|
UUID uuid = p.getUniqueId();
|
||||||
|
ArrayList<Home> playerHomes = dataManager.getPlayerHomes(p.getName());
|
||||||
|
ArrayList<String> homeNames = new ArrayList<>();
|
||||||
|
for (Home home : playerHomes) {
|
||||||
|
homeNames.add(home.getName());
|
||||||
|
}
|
||||||
|
homeTabCache.put(uuid, homeNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (!sender.hasPermission("huskhomes.home")) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
if (args.length == 1) {
|
||||||
|
final List<String> tabCompletions = new ArrayList<>();
|
||||||
|
|
||||||
|
StringUtil.copyPartialMatches(args[0], homeTabCache.get(p.getUniqueId()), tabCompletions);
|
||||||
|
|
||||||
|
Collections.sort(tabCompletions);
|
||||||
|
|
||||||
|
return tabCompletions;
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package me.william278.huskhomes2.Commands.TabCompleters;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Integrations.vanishChecker;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class playerTabCompleter implements TabCompleter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
ArrayList<String> players = new ArrayList<>();
|
||||||
|
if (args.length == 0 || args.length == 1) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (!vanishChecker.isVanished(p) && !(p.getName().equals(sender.getName()))) {
|
||||||
|
players.add(p.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final List<String> tabCompletions = new ArrayList<>();
|
||||||
|
StringUtil.copyPartialMatches(args[0], players, tabCompletions);
|
||||||
|
Collections.sort(tabCompletions);
|
||||||
|
return tabCompletions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package me.william278.huskhomes2.Commands.TabCompleters;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import me.william278.huskhomes2.dataManager;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class publicHomeTabCompleter implements TabCompleter {
|
||||||
|
|
||||||
|
// Cached HashMap of public homes
|
||||||
|
// HomeName, OwnerName
|
||||||
|
public static final HashMap<String,String> publicHomeTabCache = new HashMap<>();
|
||||||
|
|
||||||
|
// Updates the public home cache
|
||||||
|
public static void updatePublicHomeTabCache() {
|
||||||
|
publicHomeTabCache.clear();
|
||||||
|
for (Home home : dataManager.getPublicHomes()) {
|
||||||
|
publicHomeTabCache.put(home.getName(), home.getOwnerUsername());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
if (!sender.hasPermission("huskhomes.publichome")) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
if (args.length == 1) {
|
||||||
|
final List<String> sortedHomeNames = new ArrayList<>();
|
||||||
|
StringUtil.copyPartialMatches(args[0], publicHomeTabCache.keySet(), sortedHomeNames);
|
||||||
|
Collections.sort(sortedHomeNames);
|
||||||
|
|
||||||
|
final List<String> finalCompletions = new ArrayList<>();
|
||||||
|
for (String homeName : sortedHomeNames) {
|
||||||
|
finalCompletions.add(publicHomeTabCache.get(homeName) + "." + homeName);
|
||||||
|
}
|
||||||
|
return finalCompletions;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package me.william278.huskhomes2.Commands.TabCompleters;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
|
import me.william278.huskhomes2.dataManager;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class warpTabCompleter implements TabCompleter {
|
||||||
|
|
||||||
|
// Cached HashMap of warps
|
||||||
|
public static final HashSet<String> warpsTabCache = new HashSet<>();
|
||||||
|
|
||||||
|
// Updates the public home cache
|
||||||
|
public static void updateWarpsTabCache() {
|
||||||
|
warpsTabCache.clear();
|
||||||
|
for (Warp warp : dataManager.getWarps()) {
|
||||||
|
warpsTabCache.add(warp.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
if (!sender.hasPermission("huskhomes.warp")) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
if (args.length == 1) {
|
||||||
|
final List<String> tabCompletions = new ArrayList<>();
|
||||||
|
|
||||||
|
StringUtil.copyPartialMatches(args[0], warpsTabCache, tabCompletions);
|
||||||
|
|
||||||
|
Collections.sort(tabCompletions);
|
||||||
|
|
||||||
|
return tabCompletions;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
package me.william278.huskhomes2.Commands;
|
package me.william278.huskhomes2.Commands;
|
||||||
|
|
||||||
import me.william278.huskhomes2.*;
|
import me.william278.huskhomes2.*;
|
||||||
|
import me.william278.huskhomes2.API.*;
|
||||||
|
import me.william278.huskhomes2.Commands.TabCompleters.homeTabCompleter;
|
||||||
|
import me.william278.huskhomes2.Commands.TabCompleters.publicHomeTabCompleter;
|
||||||
import me.william278.huskhomes2.Integrations.dynamicMap;
|
import me.william278.huskhomes2.Integrations.dynamicMap;
|
||||||
import me.william278.huskhomes2.Integrations.economy;
|
import me.william278.huskhomes2.Integrations.economy;
|
||||||
import me.william278.huskhomes2.Objects.Home;
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@@ -23,24 +27,32 @@ public class editHomeCommand implements CommandExecutor {
|
|||||||
switch (args[1]) {
|
switch (args[1]) {
|
||||||
case "location":
|
case "location":
|
||||||
Location newLocation = p.getLocation();
|
Location newLocation = p.getLocation();
|
||||||
|
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
||||||
|
|
||||||
// Remove old marker if on dynmap
|
// Remove old marker if on dynmap
|
||||||
Home locationMovedHome = dataManager.getHome(p.getName(), homeName);
|
Home locationMovedHome = dataManager.getHome(p.getName(), homeName);
|
||||||
if (locationMovedHome.isPublic() && Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
dynamicMap.removeDynamicMapMarker(homeName, p.getName());
|
dynamicMap.removeDynamicMapMarker(homeName, p.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerRelocateHomeEvent relocateHomeEvent = new PlayerRelocateHomeEvent(p, locationMovedHome, newTeleportLocation);
|
||||||
|
if (relocateHomeEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
dataManager.updateHomeLocation(p.getName(), homeName, newLocation);
|
dataManager.updateHomeLocation(p.getName(), homeName, newLocation);
|
||||||
messageManager.sendMessage(p, "edit_home_update_location", homeName);
|
messageManager.sendMessage(p, "edit_home_update_location", homeName);
|
||||||
|
|
||||||
// Add new updated marker if using dynmap
|
// Add new updated marker if using dynmap
|
||||||
locationMovedHome.setLocation(newLocation, Main.settings.getServerID());
|
locationMovedHome.setLocation(newLocation, HuskHomes.settings.getServerID());
|
||||||
if (locationMovedHome.isPublic() && Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
dynamicMap.addDynamicMapMarker(locationMovedHome);
|
dynamicMap.addDynamicMapMarker(locationMovedHome);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "description":
|
case "description":
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
|
Home descriptionChangedHome = dataManager.getHome(p.getName(), homeName);
|
||||||
|
|
||||||
// Get the new description
|
// Get the new description
|
||||||
StringBuilder newDescription = new StringBuilder();
|
StringBuilder newDescription = new StringBuilder();
|
||||||
for (int i = 2; i < args.length; i++) {
|
for (int i = 2; i < args.length; i++) {
|
||||||
@@ -51,25 +63,27 @@ public class editHomeCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String newDescriptionString = newDescription.toString();
|
String newDescriptionString = newDescription.toString();
|
||||||
|
PlayerChangeHomeDescriptionEvent changeHomeDescriptionEvent = new PlayerChangeHomeDescriptionEvent(p, descriptionChangedHome, newDescriptionString);
|
||||||
|
if (changeHomeDescriptionEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// Check the description is valid
|
// Check the description is valid
|
||||||
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
||||||
messageManager.sendMessage(p, "error_edit_home_invalid_description");
|
messageManager.sendMessage(p, "error_edit_home_invalid_description");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove old marker if on dynmap
|
// Remove old marker if on the Dynmap
|
||||||
Home descriptionChangedHome = dataManager.getHome(p.getName(), homeName);
|
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
if (descriptionChangedHome.isPublic() && Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
|
||||||
dynamicMap.removeDynamicMapMarker(homeName, p.getName());
|
dynamicMap.removeDynamicMapMarker(homeName, p.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update description
|
// Update description
|
||||||
dataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString);
|
dataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString);
|
||||||
|
|
||||||
// Add new marker if on dynmap
|
// Add new marker if using Dynmap
|
||||||
descriptionChangedHome.setDescription(newDescriptionString);
|
descriptionChangedHome.setDescription(newDescriptionString);
|
||||||
if (descriptionChangedHome.isPublic() && Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
dynamicMap.addDynamicMapMarker(descriptionChangedHome);
|
dynamicMap.addDynamicMapMarker(descriptionChangedHome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,14 +109,24 @@ public class editHomeCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Home renamedHome = dataManager.getHome(p.getName(), homeName);
|
Home renamedHome = dataManager.getHome(p.getName(), homeName);
|
||||||
if (renamedHome.isPublic() && Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
PlayerRenameHomeEvent renameHomeEvent = new PlayerRenameHomeEvent(p, renamedHome, newName);
|
||||||
|
if (renameHomeEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (renamedHome.isPublic()) {
|
||||||
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
dynamicMap.removeDynamicMapMarker(homeName, p.getName());
|
dynamicMap.removeDynamicMapMarker(homeName, p.getName());
|
||||||
}
|
}
|
||||||
dataManager.updateHomeName(p.getName(), homeName, newName);
|
dataManager.updateHomeName(p.getName(), homeName, newName);
|
||||||
|
publicHomeTabCompleter.updatePublicHomeTabCache();
|
||||||
|
} else {
|
||||||
|
dataManager.updateHomeName(p.getName(), homeName, newName);
|
||||||
|
}
|
||||||
renamedHome.setName(newName);
|
renamedHome.setName(newName);
|
||||||
if (renamedHome.isPublic() && Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
if (renamedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
dynamicMap.addDynamicMapMarker(renamedHome);
|
dynamicMap.addDynamicMapMarker(renamedHome);
|
||||||
}
|
}
|
||||||
|
homeTabCompleter.updatePlayerHomeCache(p);
|
||||||
messageManager.sendMessage(p, "edit_home_update_name", homeName, newName);
|
messageManager.sendMessage(p, "edit_home_update_name", homeName, newName);
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> rename <new name>");
|
messageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> rename <new name>");
|
||||||
@@ -111,8 +135,8 @@ public class editHomeCommand implements CommandExecutor {
|
|||||||
case "public":
|
case "public":
|
||||||
Home privateHome = dataManager.getHome(p.getName(), homeName);
|
Home privateHome = dataManager.getHome(p.getName(), homeName);
|
||||||
if (!privateHome.isPublic()) {
|
if (!privateHome.isPublic()) {
|
||||||
if (Main.settings.doEconomy()) {
|
if (HuskHomes.settings.doEconomy()) {
|
||||||
double publicHomeCost = Main.settings.getPublicHomeCost();
|
double publicHomeCost = HuskHomes.settings.getPublicHomeCost();
|
||||||
if (publicHomeCost > 0) {
|
if (publicHomeCost > 0) {
|
||||||
if (!economy.takeMoney(p, publicHomeCost)) {
|
if (!economy.takeMoney(p, publicHomeCost)) {
|
||||||
messageManager.sendMessage(p, "error_insufficient_funds", economy.format(publicHomeCost));
|
messageManager.sendMessage(p, "error_insufficient_funds", economy.format(publicHomeCost));
|
||||||
@@ -125,8 +149,13 @@ public class editHomeCommand implements CommandExecutor {
|
|||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
messageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
||||||
}
|
}
|
||||||
|
PlayerMakeHomePublicEvent makeHomePublicEvent = new PlayerMakeHomePublicEvent(p, privateHome);
|
||||||
|
if (makeHomePublicEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
dataManager.updateHomePrivacy(p.getName(), homeName, true);
|
dataManager.updateHomePrivacy(p.getName(), homeName, true);
|
||||||
if (Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
publicHomeTabCompleter.updatePublicHomeTabCache();
|
||||||
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
dynamicMap.addDynamicMapMarker(privateHome);
|
dynamicMap.addDynamicMapMarker(privateHome);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -136,11 +165,16 @@ public class editHomeCommand implements CommandExecutor {
|
|||||||
case "private":
|
case "private":
|
||||||
Home publicHome = dataManager.getHome(p.getName(), homeName);
|
Home publicHome = dataManager.getHome(p.getName(), homeName);
|
||||||
if (publicHome.isPublic()) {
|
if (publicHome.isPublic()) {
|
||||||
|
PlayerMakeHomePrivateEvent makeHomePrivateEvent = new PlayerMakeHomePrivateEvent(p, publicHome);
|
||||||
|
if (makeHomePrivateEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
dataManager.updateHomePrivacy(p.getName(), homeName, false);
|
dataManager.updateHomePrivacy(p.getName(), homeName, false);
|
||||||
messageManager.sendMessage(p, "edit_home_privacy_private_success", homeName);
|
messageManager.sendMessage(p, "edit_home_privacy_private_success", homeName);
|
||||||
if (Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
dynamicMap.removeDynamicMapMarker(publicHome.getName(), publicHome.getOwnerUsername());
|
dynamicMap.removeDynamicMapMarker(publicHome.getName(), publicHome.getOwnerUsername());
|
||||||
}
|
}
|
||||||
|
publicHomeTabCompleter.updatePublicHomeTabCache();
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(p, "error_edit_home_privacy_already_private", homeName);
|
messageManager.sendMessage(p, "error_edit_home_privacy_already_private", homeName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package me.william278.huskhomes2.Commands;
|
package me.william278.huskhomes2.Commands;
|
||||||
|
|
||||||
import me.william278.huskhomes2.*;
|
import me.william278.huskhomes2.*;
|
||||||
|
import me.william278.huskhomes2.API.PlayerChangeWarpDescriptionEvent;
|
||||||
|
import me.william278.huskhomes2.API.PlayerRelocateWarpEvent;
|
||||||
|
import me.william278.huskhomes2.API.PlayerRenameWarpEvent;
|
||||||
|
import me.william278.huskhomes2.Commands.TabCompleters.warpTabCompleter;
|
||||||
import me.william278.huskhomes2.Integrations.dynamicMap;
|
import me.william278.huskhomes2.Integrations.dynamicMap;
|
||||||
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
import me.william278.huskhomes2.Objects.Warp;
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -22,24 +27,32 @@ public class editWarpCommand implements CommandExecutor {
|
|||||||
switch (args[1]) {
|
switch (args[1]) {
|
||||||
case "location":
|
case "location":
|
||||||
Location newLocation = p.getLocation();
|
Location newLocation = p.getLocation();
|
||||||
|
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
||||||
|
|
||||||
// Remove old marker if on dynmap
|
// Remove old marker if on the Dynmap
|
||||||
Warp locationMovedWarp = dataManager.getWarp(warpName);
|
Warp locationMovedWarp = dataManager.getWarp(warpName);
|
||||||
if (Main.settings.doDynmap() && Main.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
dynamicMap.removeDynamicMapMarker(warpName);
|
dynamicMap.removeDynamicMapMarker(warpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerRelocateWarpEvent relocateHomeEvent = new PlayerRelocateWarpEvent(p, locationMovedWarp, newTeleportLocation);
|
||||||
|
if (relocateHomeEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
dataManager.updateWarpLocation(warpName, p.getLocation());
|
dataManager.updateWarpLocation(warpName, p.getLocation());
|
||||||
messageManager.sendMessage(p, "edit_warp_update_location", warpName);
|
messageManager.sendMessage(p, "edit_warp_update_location", warpName);
|
||||||
|
|
||||||
// Add new updated marker if using dynmap
|
// Add new updated marker if using Dynmap
|
||||||
locationMovedWarp.setLocation(newLocation, Main.settings.getServerID());
|
locationMovedWarp.setLocation(newLocation, HuskHomes.settings.getServerID());
|
||||||
if (Main.settings.doDynmap() && Main.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
dynamicMap.addDynamicMapMarker(locationMovedWarp);
|
dynamicMap.addDynamicMapMarker(locationMovedWarp);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "description":
|
case "description":
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
|
Warp descriptionChangedWarp = dataManager.getWarp(warpName);
|
||||||
|
|
||||||
// Get the new description
|
// Get the new description
|
||||||
StringBuilder newDescription = new StringBuilder();
|
StringBuilder newDescription = new StringBuilder();
|
||||||
for (int i = 2; i < args.length; i++) {
|
for (int i = 2; i < args.length; i++) {
|
||||||
@@ -51,22 +64,26 @@ public class editWarpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
String newDescriptionString = newDescription.toString();
|
String newDescriptionString = newDescription.toString();
|
||||||
|
|
||||||
|
PlayerChangeWarpDescriptionEvent changeWarpDescriptionEvent = new PlayerChangeWarpDescriptionEvent(p, descriptionChangedWarp, newDescriptionString);
|
||||||
|
if (changeWarpDescriptionEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Check the description is valid
|
// Check the description is valid
|
||||||
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
||||||
messageManager.sendMessage(p, "error_edit_warp_invalid_description");
|
messageManager.sendMessage(p, "error_edit_warp_invalid_description");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Main.settings.doDynmap() && Main.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
dynamicMap.removeDynamicMapMarker(warpName);
|
dynamicMap.removeDynamicMapMarker(warpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update description
|
// Update description
|
||||||
dataManager.updateWarpDescription(warpName, newDescriptionString);
|
dataManager.updateWarpDescription(warpName, newDescriptionString);
|
||||||
|
|
||||||
Warp descriptionChangedWarp = dataManager.getWarp(warpName);
|
|
||||||
descriptionChangedWarp.setDescription(newDescriptionString);
|
descriptionChangedWarp.setDescription(newDescriptionString);
|
||||||
if (Main.settings.doDynmap() && Main.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
dynamicMap.addDynamicMapMarker(descriptionChangedWarp);
|
dynamicMap.addDynamicMapMarker(descriptionChangedWarp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,16 +109,21 @@ public class editWarpCommand implements CommandExecutor {
|
|||||||
messageManager.sendMessage(p, "error_set_warp_name_taken");
|
messageManager.sendMessage(p, "error_set_warp_name_taken");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
PlayerRenameWarpEvent renameWarpEvent = new PlayerRenameWarpEvent(p, renamedWarp, newName);
|
||||||
|
if (renameWarpEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (Main.settings.doDynmap() && Main.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
dynamicMap.removeDynamicMapMarker(warpName);
|
dynamicMap.removeDynamicMapMarker(warpName);
|
||||||
}
|
}
|
||||||
dataManager.updateWarpName(warpName, newName);
|
dataManager.updateWarpName(warpName, newName);
|
||||||
|
|
||||||
renamedWarp.setName(newName);
|
renamedWarp.setName(newName);
|
||||||
if (Main.settings.doDynmap() && Main.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
dynamicMap.addDynamicMapMarker(renamedWarp);
|
dynamicMap.addDynamicMapMarker(renamedWarp);
|
||||||
}
|
}
|
||||||
|
warpTabCompleter.updateWarpsTabCache();
|
||||||
messageManager.sendMessage(p, "edit_warp_update_name", warpName, newName);
|
messageManager.sendMessage(p, "edit_warp_update_name", warpName, newName);
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> rename <new warp>");
|
messageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> rename <new warp>");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Commands;
|
package me.william278.huskhomes2.Commands;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.configManager;
|
import me.william278.huskhomes2.configManager;
|
||||||
import me.william278.huskhomes2.messageManager;
|
import me.william278.huskhomes2.messageManager;
|
||||||
import me.william278.huskhomes2.versionChecker;
|
import me.william278.huskhomes2.versionChecker;
|
||||||
@@ -17,7 +17,7 @@ import static net.md_5.bungee.api.chat.ClickEvent.Action.OPEN_URL;
|
|||||||
|
|
||||||
public class huskHomesCommand implements CommandExecutor {
|
public class huskHomesCommand implements CommandExecutor {
|
||||||
|
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
private static void showAboutMenu(CommandSender sender) {
|
private static void showAboutMenu(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + " " + ChatColor.GREEN + "| Version " + plugin.getDescription().getVersion());
|
sender.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + " " + ChatColor.GREEN + "| Version " + plugin.getDescription().getVersion());
|
||||||
@@ -62,7 +62,7 @@ public class huskHomesCommand implements CommandExecutor {
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (p.hasPermission("huskhomes.reload")) {
|
if (p.hasPermission("huskhomes.reload")) {
|
||||||
configManager.loadConfig();
|
configManager.loadConfig();
|
||||||
messageManager.loadMessages(Main.settings.getLanguage());
|
messageManager.loadMessages(HuskHomes.settings.getLanguage());
|
||||||
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | Reloaded config and message files.");
|
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | Reloaded config and message files.");
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(p, "error_no_permission");
|
messageManager.sendMessage(p, "error_no_permission");
|
||||||
@@ -70,7 +70,7 @@ public class huskHomesCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
configManager.loadConfig();
|
configManager.loadConfig();
|
||||||
messageManager.loadMessages(Main.settings.getLanguage());
|
messageManager.loadMessages(HuskHomes.settings.getLanguage());
|
||||||
plugin.getLogger().info("Reloaded config and message files.");
|
plugin.getLogger().info("Reloaded config and message files.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Commands;
|
package me.william278.huskhomes2.Commands;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.messageManager;
|
import me.william278.huskhomes2.messageManager;
|
||||||
import me.william278.huskhomes2.teleportManager;
|
import me.william278.huskhomes2.teleportManager;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -15,7 +15,7 @@ public class rtpCommand implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (Main.settings.doRtpCommand()) {
|
if (HuskHomes.settings.doRtpCommand()) {
|
||||||
if (p.getWorld().getEnvironment() == World.Environment.NORMAL) {
|
if (p.getWorld().getEnvironment() == World.Environment.NORMAL) {
|
||||||
teleportManager.queueRandomTeleport(p);
|
teleportManager.queueRandomTeleport(p);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Commands;
|
package me.william278.huskhomes2.Commands;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.messageManager;
|
import me.william278.huskhomes2.messageManager;
|
||||||
import me.william278.huskhomes2.settingHandler;
|
import me.william278.huskhomes2.settingHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -14,7 +14,7 @@ public class setSpawnCommand implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (Main.settings.doSpawnCommand()) {
|
if (HuskHomes.settings.doSpawnCommand()) {
|
||||||
settingHandler.setSpawnLocation(p.getLocation());
|
settingHandler.setSpawnLocation(p.getLocation());
|
||||||
p.getLocation().getWorld().setSpawnLocation(p.getLocation());
|
p.getLocation().getWorld().setSpawnLocation(p.getLocation());
|
||||||
messageManager.sendMessage(p, "set_spawn_success");
|
messageManager.sendMessage(p, "set_spawn_success");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Commands;
|
package me.william278.huskhomes2.Commands;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.messageManager;
|
import me.william278.huskhomes2.messageManager;
|
||||||
import me.william278.huskhomes2.teleportManager;
|
import me.william278.huskhomes2.teleportManager;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -14,7 +14,7 @@ public class spawnCommand implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (Main.settings.doSpawnCommand()) {
|
if (HuskHomes.settings.doSpawnCommand()) {
|
||||||
if (teleportManager.spawnLocation != null) {
|
if (teleportManager.spawnLocation != null) {
|
||||||
teleportManager.queueTimedTeleport(p, teleportManager.spawnLocation);
|
teleportManager.queueTimedTeleport(p, teleportManager.spawnLocation);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Commands;
|
package me.william278.huskhomes2.Commands;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
import me.william278.huskhomes2.messageManager;
|
import me.william278.huskhomes2.messageManager;
|
||||||
import me.william278.huskhomes2.teleportManager;
|
import me.william278.huskhomes2.teleportManager;
|
||||||
@@ -27,7 +27,7 @@ public class tpCommand implements CommandExecutor {
|
|||||||
double x = Double.parseDouble(args[0]);
|
double x = Double.parseDouble(args[0]);
|
||||||
double y = Double.parseDouble(args[1]);
|
double y = Double.parseDouble(args[1]);
|
||||||
double z = Double.parseDouble(args[2]);
|
double z = Double.parseDouble(args[2]);
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, Main.settings.getServerID());
|
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
||||||
teleportManager.teleportPlayer(p, teleportationPoint);
|
teleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
@@ -43,14 +43,14 @@ public class tpCommand implements CommandExecutor {
|
|||||||
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, Main.settings.getServerID());
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
||||||
teleportManager.teleportPlayer(p, teleportationPoint);
|
teleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case 5:
|
case 5:
|
||||||
if (Main.settings.doBungee()) {
|
if (HuskHomes.settings.doBungee()) {
|
||||||
try {
|
try {
|
||||||
double x = Double.parseDouble(args[0]);
|
double x = Double.parseDouble(args[0]);
|
||||||
double y = Double.parseDouble(args[1]);
|
double y = Double.parseDouble(args[1]);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class warpCommand implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (Main.settings.doWarpCommand()) {
|
if (HuskHomes.settings.doWarpCommand()) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String warpName = args[0];
|
String warpName = args[0];
|
||||||
if (dataManager.warpExists(warpName)) {
|
if (dataManager.warpExists(warpName)) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package me.william278.huskhomes2.Data;
|
|||||||
|
|
||||||
import me.william278.huskhomes2.Data.ErrorLogging.Error;
|
import me.william278.huskhomes2.Data.ErrorLogging.Error;
|
||||||
import me.william278.huskhomes2.Data.ErrorLogging.Errors;
|
import me.william278.huskhomes2.Data.ErrorLogging.Errors;
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.Objects.Home;
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
import me.william278.huskhomes2.Objects.Warp;
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
@@ -10,13 +10,14 @@ import me.william278.huskhomes2.permissionHomeLimits;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public abstract class Database {
|
public abstract class Database {
|
||||||
Main plugin;
|
HuskHomes plugin;
|
||||||
Connection connection;
|
Connection connection;
|
||||||
|
|
||||||
public Database(Main instance) {
|
public Database(HuskHomes instance) {
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ public abstract class Database {
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
connection = getSQLConnection();
|
connection = getSQLConnection();
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + Main.settings.getPlayerDataTable() + ";");
|
PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + ";");
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
close(ps, rs);
|
close(ps, rs);
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ public abstract class Database {
|
|||||||
// Insert a teleportation point, returns generated id
|
// Insert a teleportation point, returns generated id
|
||||||
public Integer addTeleportationPoint(TeleportationPoint point, Connection conn) {
|
public Integer addTeleportationPoint(TeleportationPoint point, Connection conn) {
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = conn.prepareStatement("INSERT INTO " + Main.settings.getLocationsDataTable() + " (world,server,x,y,z,yaw,pitch) VALUES(?,?,?,?,?,?,?);", Statement.RETURN_GENERATED_KEYS);
|
PreparedStatement ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getLocationsDataTable() + " (world,server,x,y,z,yaw,pitch) VALUES(?,?,?,?,?,?,?);", Statement.RETURN_GENERATED_KEYS);
|
||||||
|
|
||||||
ps.setString(1, point.getWorldName());
|
ps.setString(1, point.getWorldName());
|
||||||
ps.setString(2, point.getServer());
|
ps.setString(2, point.getServer());
|
||||||
@@ -70,7 +71,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
Integer locationID = addTeleportationPoint(home, conn);
|
Integer locationID = addTeleportationPoint(home, conn);
|
||||||
|
|
||||||
ps = conn.prepareStatement("INSERT INTO " + Main.settings.getHomesDataTable() + " (player_id,location_id,name,description,public) VALUES(?,?,?,?,?);");
|
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getHomesDataTable() + " (player_id,location_id,name,description,public) VALUES(?,?,?,?,?);");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.setInt(2, locationID);
|
ps.setInt(2, locationID);
|
||||||
ps.setString(3, home.getName());
|
ps.setString(3, home.getName());
|
||||||
@@ -103,7 +104,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(warp, conn);
|
Integer locationID = addTeleportationPoint(warp, conn);
|
||||||
|
|
||||||
// Insert the warp with the location_id of the last inserted teleport point
|
// Insert the warp with the location_id of the last inserted teleport point
|
||||||
ps = conn.prepareStatement("INSERT INTO " + Main.settings.getWarpsDataTable() + " (location_id,name,description) VALUES(?,?,?);");
|
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getWarpsDataTable() + " (location_id,name,description) VALUES(?,?,?);");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setString(2, warp.getName());
|
ps.setString(2, warp.getName());
|
||||||
ps.setString(3, warp.getDescription());
|
ps.setString(3, warp.getDescription());
|
||||||
@@ -131,7 +132,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Delete the warp with the given name
|
// Delete the warp with the given name
|
||||||
ps = conn.prepareStatement("DELETE FROM " + Main.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
ps = conn.prepareStatement("DELETE FROM " + HuskHomes.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
||||||
ps.setString(1, warpName);
|
ps.setString(1, warpName);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
|
|
||||||
@@ -158,7 +159,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Delete the home with the given name and player ID
|
// Delete the home with the given name and player ID
|
||||||
ps = conn.prepareStatement("DELETE FROM " + Main.settings.getHomesDataTable() + " WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("DELETE FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setString(1, homeName);
|
ps.setString(1, homeName);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -185,7 +186,7 @@ public abstract class Database {
|
|||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
ps = conn.prepareStatement("INSERT INTO " + Main.settings.getPlayerDataTable() + " (user_uuid,username,home_slots,rtp_cooldown,is_teleporting) VALUES(?,?,?,?,?);");
|
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getPlayerDataTable() + " (user_uuid,username,home_slots,rtp_cooldown,is_teleporting) VALUES(?,?,?,?,?);");
|
||||||
ps.setString(1, p.getUniqueId().toString());
|
ps.setString(1, p.getUniqueId().toString());
|
||||||
ps.setString(2, p.getName());
|
ps.setString(2, p.getName());
|
||||||
ps.setInt(3, permissionHomeLimits.getFreeHomes(p));
|
ps.setInt(3, permissionHomeLimits.getFreeHomes(p));
|
||||||
@@ -207,13 +208,43 @@ public abstract class Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert a player into the database
|
||||||
|
public void addPlayer(UUID playerUUID, String playerName) {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
|
||||||
|
ps = conn.prepareStatement("INSERT INTO " + HuskHomes.settings.getPlayerDataTable() + " (user_uuid,username,home_slots,rtp_cooldown,is_teleporting) VALUES(?,?,?,?,?);");
|
||||||
|
ps.setString(1, playerUUID.toString());
|
||||||
|
ps.setString(2, playerName);
|
||||||
|
ps.setInt(3, HuskHomes.settings.getFreeHomeSlots());
|
||||||
|
ps.setInt(4, 0);
|
||||||
|
ps.setBoolean(5, false);
|
||||||
|
|
||||||
|
ps.executeUpdate();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (ps != null)
|
||||||
|
ps.close();
|
||||||
|
if (conn != null)
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionClose(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updatePlayerUsername(int playerID, String newName) {
|
public void updatePlayerUsername(int playerID, String newName) {
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getPlayerDataTable() + " SET `username`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `username`=? WHERE `player_id`=?;");
|
||||||
ps.setString(1, newName);
|
ps.setString(1, newName);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -237,7 +268,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getPlayerDataTable() + " SET `is_teleporting`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `is_teleporting`=? WHERE `player_id`=?;");
|
||||||
ps.setBoolean(1, value);
|
ps.setBoolean(1, value);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -261,7 +292,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getPlayerDataTable() + " SET `home_slots`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `home_slots`=? WHERE `player_id`=?;");
|
||||||
ps.setInt(1, newValue);
|
ps.setInt(1, newValue);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -285,7 +316,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getPlayerDataTable() + " SET `rtp_cooldown`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `rtp_cooldown`=? WHERE `player_id`=?;");
|
||||||
ps.setInt(1, newTime);
|
ps.setInt(1, newTime);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -311,7 +342,7 @@ public abstract class Database {
|
|||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
ps = conn.prepareStatement("DELETE FROM " + Main.settings.getLocationsDataTable() + " WHERE `location_id`=?;");
|
ps = conn.prepareStatement("DELETE FROM " + HuskHomes.settings.getLocationsDataTable() + " WHERE `location_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -338,7 +369,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Set the home location ID to the new teleport point for the given home
|
// Set the home location ID to the new teleport point for the given home
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getHomesDataTable() + " SET `public`=? WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getHomesDataTable() + " SET `public`=? WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setBoolean(1, isPublic);
|
ps.setBoolean(1, isPublic);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
@@ -369,7 +400,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(point, conn);
|
Integer locationID = addTeleportationPoint(point, conn);
|
||||||
|
|
||||||
// Set the home location ID to the new teleport point for the given home
|
// Set the home location ID to the new teleport point for the given home
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getHomesDataTable() + " SET `location_id`=? WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getHomesDataTable() + " SET `location_id`=? WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
@@ -400,7 +431,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(point, conn);
|
Integer locationID = addTeleportationPoint(point, conn);
|
||||||
|
|
||||||
// Set the warp location ID to the new teleport point
|
// Set the warp location ID to the new teleport point
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getWarpsDataTable() + " SET `location_id`=? WHERE `name`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getWarpsDataTable() + " SET `location_id`=? WHERE `name`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setString(2, warpName);
|
ps.setString(2, warpName);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -426,7 +457,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Update the home description
|
// Update the home description
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getHomesDataTable() + " SET `description`=? WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getHomesDataTable() + " SET `description`=? WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setString(1, newDescription);
|
ps.setString(1, newDescription);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
@@ -454,7 +485,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Update the warp description
|
// Update the warp description
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getWarpsDataTable() + " SET `description`=? WHERE `name`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getWarpsDataTable() + " SET `description`=? WHERE `name`=?;");
|
||||||
ps.setString(1, newDescription);
|
ps.setString(1, newDescription);
|
||||||
ps.setString(2, warpName);
|
ps.setString(2, warpName);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -481,7 +512,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Update the home name
|
// Update the home name
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getHomesDataTable() + " SET `name`=? WHERE `name`=? AND `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getHomesDataTable() + " SET `name`=? WHERE `name`=? AND `player_id`=?;");
|
||||||
ps.setString(1, newHomeName);
|
ps.setString(1, newHomeName);
|
||||||
ps.setString(2, oldHomeName);
|
ps.setString(2, oldHomeName);
|
||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
@@ -510,7 +541,7 @@ public abstract class Database {
|
|||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
|
|
||||||
// Update the warp name
|
// Update the warp name
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getWarpsDataTable() + " SET `name`=? WHERE `name`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getWarpsDataTable() + " SET `name`=? WHERE `name`=?;");
|
||||||
ps.setString(1, newWarpName);
|
ps.setString(1, newWarpName);
|
||||||
ps.setString(2, oldWarpName);
|
ps.setString(2, oldWarpName);
|
||||||
|
|
||||||
@@ -541,7 +572,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(point, conn);
|
Integer locationID = addTeleportationPoint(point, conn);
|
||||||
|
|
||||||
// Set the destination location with the location_id of the last inserted teleport point
|
// Set the destination location with the location_id of the last inserted teleport point
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getPlayerDataTable() + " SET `last_location_id`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `last_location_id`=? WHERE `player_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -571,7 +602,7 @@ public abstract class Database {
|
|||||||
Integer locationID = addTeleportationPoint(point, conn);
|
Integer locationID = addTeleportationPoint(point, conn);
|
||||||
|
|
||||||
// Set the destination location with the location_id of the last inserted teleport point
|
// Set the destination location with the location_id of the last inserted teleport point
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getPlayerDataTable() + " SET `dest_location_id`=? WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `dest_location_id`=? WHERE `player_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -597,7 +628,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getPlayerDataTable() + " SET `dest_location_id`=NULL WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `dest_location_id`=NULL WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@@ -621,7 +652,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("UPDATE " + Main.settings.getPlayerDataTable() + " SET `last_location_id`=NULL WHERE `player_id`=?;");
|
ps = conn.prepareStatement("UPDATE " + HuskHomes.settings.getPlayerDataTable() + " SET `last_location_id`=NULL WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package me.william278.huskhomes2.Data.ErrorLogging;
|
package me.william278.huskhomes2.Data.ErrorLogging;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Error {
|
public class Error {
|
||||||
|
|
||||||
public static void execute(Main plugin, Exception ex){
|
public static void execute(HuskHomes plugin, Exception ex){
|
||||||
plugin.getLogger().log(Level.SEVERE, "Couldn't execute MySQL statement: ", ex);
|
plugin.getLogger().log(Level.SEVERE, "Couldn't execute MySQL statement: ", ex);
|
||||||
}
|
}
|
||||||
public static void close(Main plugin, Exception ex){
|
public static void close(HuskHomes plugin, Exception ex){
|
||||||
plugin.getLogger().log(Level.SEVERE, "Failed to close MySQL connection: ", ex);
|
plugin.getLogger().log(Level.SEVERE, "Failed to close MySQL connection: ", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package me.william278.huskhomes2.Data;
|
package me.william278.huskhomes2.Data;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.dataManager;
|
import me.william278.huskhomes2.dataManager;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -16,27 +15,27 @@ public class SQL extends Database {
|
|||||||
|
|
||||||
final String SQLiteDatabaseName = "HuskHomesData";
|
final String SQLiteDatabaseName = "HuskHomesData";
|
||||||
|
|
||||||
public SQL(Main instance) {
|
public SQL(HuskHomes instance) {
|
||||||
super(instance);
|
super(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise connection via mySQL
|
// Initialise connection via mySQL
|
||||||
private Connection getMySQLConnection() {
|
private Connection getMySQLConnection() {
|
||||||
String host = Main.settings.getMySQLhost();
|
String host = HuskHomes.settings.getMySQLhost();
|
||||||
int port = Main.settings.getMySQLport();
|
int port = HuskHomes.settings.getMySQLport();
|
||||||
String database = Main.settings.getMySQLdatabase();
|
String database = HuskHomes.settings.getMySQLdatabase();
|
||||||
String username = Main.settings.getMySQLusername();
|
String username = HuskHomes.settings.getMySQLusername();
|
||||||
String password = Main.settings.getMySQLpassword();
|
String password = HuskHomes.settings.getMySQLpassword();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
synchronized (Main.getInstance()) {
|
synchronized (HuskHomes.getInstance()) {
|
||||||
Class.forName("com.mysql.jdbc.Driver");
|
Class.forName("com.mysql.jdbc.Driver");
|
||||||
return DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true&useSSL=false", username, password);
|
return DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true&useSSL=false", username, password);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Main.disablePlugin("[!] Could not connect to the mySQL Database with the credentials provided!\n[!] Check that your host IP address and port are valid and that your username and password are valid and that the user has the correct access permissions on the database.");
|
HuskHomes.disablePlugin("[!] Could not connect to the mySQL Database with the credentials provided!\n[!] Check that your host IP address and port are valid and that your username and password are valid and that the user has the correct access permissions on the database.");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
Main.disablePlugin("[!] A critical exception occurred when attempting to establish a connection to the mySQL database!");
|
HuskHomes.disablePlugin("[!] A critical exception occurred when attempting to establish a connection to the mySQL database!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -48,10 +47,10 @@ public class SQL extends Database {
|
|||||||
if (!dataFolder.exists()) {
|
if (!dataFolder.exists()) {
|
||||||
try {
|
try {
|
||||||
if (!dataFolder.createNewFile()) {
|
if (!dataFolder.createNewFile()) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "File write error: " + SQLiteDatabaseName + ".db");
|
plugin.getLogger().log(Level.SEVERE, "Failed to write new file: " + SQLiteDatabaseName + ".db (file already exists)");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "File write error: " + SQLiteDatabaseName + ".db");
|
plugin.getLogger().log(Level.SEVERE, "An error occurred writing a file: " + SQLiteDatabaseName + ".db (" + e.getCause() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -70,14 +69,14 @@ public class SQL extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Connection getSQLConnection() {
|
public Connection getSQLConnection() {
|
||||||
String dataStorageType = Main.settings.getStorageType().toLowerCase();
|
String dataStorageType = HuskHomes.settings.getStorageType().toLowerCase();
|
||||||
switch (dataStorageType) {
|
switch (dataStorageType) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
return getMySQLConnection();
|
return getMySQLConnection();
|
||||||
case "sqlite":
|
case "sqlite":
|
||||||
return getSQLiteConnection();
|
return getSQLiteConnection();
|
||||||
default:
|
default:
|
||||||
Bukkit.getLogger().warning("An invalid data storage type was specified in config.yml; defaulting to SQLite");
|
plugin.getLogger().log(Level.WARNING, "An invalid data storage type was specified in config.yml; defaulting to SQLite");
|
||||||
return getSQLiteConnection();
|
return getSQLiteConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Events;
|
package me.william278.huskhomes2.Events;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
import me.william278.huskhomes2.dataManager;
|
import me.william278.huskhomes2.dataManager;
|
||||||
import me.william278.huskhomes2.messageManager;
|
import me.william278.huskhomes2.messageManager;
|
||||||
@@ -33,7 +33,7 @@ public class onPlayerDeath implements Listener {
|
|||||||
public void onPlayerDie(PlayerDeathEvent e) {
|
public void onPlayerDie(PlayerDeathEvent e) {
|
||||||
Player p = e.getEntity();
|
Player p = e.getEntity();
|
||||||
if (p.hasPermission("huskhomes.back.death")) {
|
if (p.hasPermission("huskhomes.back.death")) {
|
||||||
dataManager.setPlayerLastPosition(p, new TeleportationPoint(p.getLocation(), Main.settings.getServerID()));
|
dataManager.setPlayerLastPosition(p, new TeleportationPoint(p.getLocation(), HuskHomes.settings.getServerID()));
|
||||||
messageManager.sendMessage(p, "return_by_death");
|
messageManager.sendMessage(p, "return_by_death");
|
||||||
p.spigot().sendMessage(backButton().create());
|
p.spigot().sendMessage(backButton().create());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Events;
|
package me.william278.huskhomes2.Events;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.dataManager;
|
import me.william278.huskhomes2.dataManager;
|
||||||
import me.william278.huskhomes2.teleportManager;
|
import me.william278.huskhomes2.teleportManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -23,7 +23,7 @@ public class onPlayerJoin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If bungee mode, check if the player joined the server from a teleport and act accordingly
|
// If bungee mode, check if the player joined the server from a teleport and act accordingly
|
||||||
if (Main.settings.doBungee()) {
|
if (HuskHomes.settings.doBungee()) {
|
||||||
if (dataManager.getPlayerTeleporting(p)) {
|
if (dataManager.getPlayerTeleporting(p)) {
|
||||||
teleportManager.teleportPlayer(p);
|
teleportManager.teleportPlayer(p);
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-12
@@ -1,6 +1,8 @@
|
|||||||
package me.william278.huskhomes2;
|
package me.william278.huskhomes2;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.API.HuskHomesAPI;
|
||||||
import me.william278.huskhomes2.Commands.*;
|
import me.william278.huskhomes2.Commands.*;
|
||||||
|
import me.william278.huskhomes2.Commands.TabCompleters.*;
|
||||||
import me.william278.huskhomes2.Events.onPlayerDeath;
|
import me.william278.huskhomes2.Events.onPlayerDeath;
|
||||||
import me.william278.huskhomes2.Events.onPlayerJoin;
|
import me.william278.huskhomes2.Events.onPlayerJoin;
|
||||||
import me.william278.huskhomes2.Integrations.dynamicMap;
|
import me.william278.huskhomes2.Integrations.dynamicMap;
|
||||||
@@ -9,17 +11,26 @@ import me.william278.huskhomes2.Objects.Settings;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public final class Main extends JavaPlugin {
|
public final class HuskHomes extends JavaPlugin {
|
||||||
|
|
||||||
private static Main instance;
|
private static HuskHomes instance;
|
||||||
public static Main getInstance() {
|
public static HuskHomes getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
private void setInstance(Main instance) {
|
private void setInstance(HuskHomes instance) {
|
||||||
Main.instance = instance;
|
HuskHomes.instance = instance;
|
||||||
}
|
}
|
||||||
public static Settings settings;
|
public static Settings settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the HuskHomes API
|
||||||
|
* @return an instance of the HuskHomes API
|
||||||
|
* @see HuskHomesAPI
|
||||||
|
*/
|
||||||
|
public HuskHomesAPI getAPI() {
|
||||||
|
return new HuskHomesAPI();
|
||||||
|
}
|
||||||
|
|
||||||
// Disable the plugin for the given reason
|
// Disable the plugin for the given reason
|
||||||
public static void disablePlugin(String reason) {
|
public static void disablePlugin(String reason) {
|
||||||
getInstance().getLogger().severe("Disabling HuskHomes plugin because:\n" + reason);
|
getInstance().getLogger().severe("Disabling HuskHomes plugin because:\n" + reason);
|
||||||
@@ -27,13 +38,30 @@ public final class Main extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialise bungee plugin channels
|
// Initialise bungee plugin channels
|
||||||
private static void setupBungeeChannels(Main plugin) {
|
private static void setupBungeeChannels(HuskHomes plugin) {
|
||||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||||
plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, "BungeeCord", new pluginMessageHandler());
|
plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, "BungeeCord", new pluginMessageHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register tab completers
|
||||||
|
private static void registerTabCompleters(HuskHomes plugin) {
|
||||||
|
plugin.getCommand("home").setTabCompleter(new homeTabCompleter());
|
||||||
|
plugin.getCommand("warp").setTabCompleter(new warpTabCompleter());
|
||||||
|
plugin.getCommand("publichome").setTabCompleter(new publicHomeTabCompleter());
|
||||||
|
plugin.getCommand("tpaccept").setTabCompleter(new emptyTabCompleter());
|
||||||
|
plugin.getCommand("tpdeny").setTabCompleter(new emptyTabCompleter());
|
||||||
|
plugin.getCommand("warplist").setTabCompleter(new emptyTabCompleter());
|
||||||
|
plugin.getCommand("homelist").setTabCompleter(new emptyTabCompleter());
|
||||||
|
plugin.getCommand("rtp").setTabCompleter(new emptyTabCompleter());
|
||||||
|
plugin.getCommand("spawn").setTabCompleter(new emptyTabCompleter());
|
||||||
|
plugin.getCommand("setspawn").setTabCompleter(new emptyTabCompleter());
|
||||||
|
plugin.getCommand("edithome").setTabCompleter(new editHomeTabCompleter());
|
||||||
|
plugin.getCommand("editwarp").setTabCompleter(new editWarpTabCompleter());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Register commands
|
// Register commands
|
||||||
private static void registerCommands(Main plugin) {
|
private static void registerCommands(HuskHomes plugin) {
|
||||||
plugin.getCommand("back").setExecutor(new backCommand());
|
plugin.getCommand("back").setExecutor(new backCommand());
|
||||||
plugin.getCommand("delhome").setExecutor(new delHomeCommand());
|
plugin.getCommand("delhome").setExecutor(new delHomeCommand());
|
||||||
plugin.getCommand("delwarp").setExecutor(new delWarpCommand());
|
plugin.getCommand("delwarp").setExecutor(new delWarpCommand());
|
||||||
@@ -60,7 +88,7 @@ public final class Main extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
private static void registerEvents(Main plugin) {
|
private static void registerEvents(HuskHomes plugin) {
|
||||||
plugin.getServer().getPluginManager().registerEvents(new onPlayerJoin(), plugin);
|
plugin.getServer().getPluginManager().registerEvents(new onPlayerJoin(), plugin);
|
||||||
plugin.getServer().getPluginManager().registerEvents(new onPlayerDeath(), plugin);
|
plugin.getServer().getPluginManager().registerEvents(new onPlayerDeath(), plugin);
|
||||||
}
|
}
|
||||||
@@ -80,7 +108,7 @@ public final class Main extends JavaPlugin {
|
|||||||
configManager.loadConfig();
|
configManager.loadConfig();
|
||||||
|
|
||||||
// Load the messages (in the right language)
|
// Load the messages (in the right language)
|
||||||
messageManager.loadMessages(Main.settings.getLanguage());
|
messageManager.loadMessages(HuskHomes.settings.getLanguage());
|
||||||
|
|
||||||
// Fetch spawn location if set
|
// Fetch spawn location if set
|
||||||
settingHandler.fetchSpawnLocation();
|
settingHandler.fetchSpawnLocation();
|
||||||
@@ -89,17 +117,17 @@ public final class Main extends JavaPlugin {
|
|||||||
dataManager.setupStorage();
|
dataManager.setupStorage();
|
||||||
|
|
||||||
// Setup dynmap if it is enabled
|
// Setup dynmap if it is enabled
|
||||||
if (Main.settings.doDynmap()) {
|
if (HuskHomes.settings.doDynmap()) {
|
||||||
dynamicMap.initializeDynmap();
|
dynamicMap.initializeDynmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup economy if it is enabled
|
// Setup economy if it is enabled
|
||||||
if (Main.settings.doEconomy()) {
|
if (HuskHomes.settings.doEconomy()) {
|
||||||
economy.initializeEconomy();
|
economy.initializeEconomy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return if the plugin is disabled
|
// Return if the plugin is disabled
|
||||||
if (!Main.getInstance().isEnabled()) {
|
if (!HuskHomes.getInstance().isEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Integrations;
|
package me.william278.huskhomes2.Integrations;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.Objects.Home;
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
import me.william278.huskhomes2.Objects.Warp;
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
import me.william278.huskhomes2.dataManager;
|
import me.william278.huskhomes2.dataManager;
|
||||||
@@ -14,7 +14,7 @@ import static org.apache.commons.lang.StringEscapeUtils.escapeHtml;
|
|||||||
public class dynamicMap {
|
public class dynamicMap {
|
||||||
|
|
||||||
private static Plugin dynmap;
|
private static Plugin dynmap;
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
public static void removeDynamicMapMarker(String warpName) {
|
public static void removeDynamicMapMarker(String warpName) {
|
||||||
String markerId = "huskhomes." + warpName;
|
String markerId = "huskhomes." + warpName;
|
||||||
@@ -46,11 +46,11 @@ public class dynamicMap {
|
|||||||
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
||||||
|
|
||||||
MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet("huskhomes.warps");
|
MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet("huskhomes.warps");
|
||||||
Marker m = markerSet.createMarker(markerId, warp.getName(), warp.getWorldName(), warp.getX(), warp.getY(), warp.getZ(), dynmapAPI.getMarkerAPI().getMarkerIcon(Main.settings.getDynmapWarpMarkerIconID()), false);
|
Marker m = markerSet.createMarker(markerId, warp.getName(), warp.getWorldName(), warp.getX(), warp.getY(), warp.getZ(), dynmapAPI.getMarkerAPI().getMarkerIcon(HuskHomes.settings.getDynmapWarpMarkerIconID()), false);
|
||||||
String popupWindow = "<div class=\"infowindow\"><span style=\"font-weight:bold;\">/warp %WARP_NAME%</span><br/><span style=\"font-weight:bold;\">Description: </span>%DESCRIPTION%</div>";
|
String warpPopup = "<div class=\"infowindow\"><span style=\"font-weight:bold;\">/warp %WARP_NAME%</span><br/><span style=\"font-weight:bold;\">Description: </span>%DESCRIPTION%</div>";
|
||||||
popupWindow = popupWindow.replace("%WARP_NAME%", escapeHtml(warp.getName()));
|
warpPopup = warpPopup.replace("%WARP_NAME%", escapeHtml(warp.getName()));
|
||||||
popupWindow = popupWindow.replace("%DESCRIPTION%", escapeHtml(warp.getDescription()));
|
warpPopup = warpPopup.replace("%DESCRIPTION%", escapeHtml(warp.getDescription()));
|
||||||
m.setDescription(popupWindow);
|
m.setDescription(warpPopup);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.getLogger().severe("Error adding warp marker to the Dynamic Map (" + e.getCause() + ")");
|
plugin.getLogger().severe("Error adding warp marker to the Dynamic Map (" + e.getCause() + ")");
|
||||||
plugin.getLogger().warning("This may be because you reloaded the server instead of restarting!");
|
plugin.getLogger().warning("This may be because you reloaded the server instead of restarting!");
|
||||||
@@ -63,12 +63,12 @@ public class dynamicMap {
|
|||||||
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
||||||
|
|
||||||
MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet("huskhomes.public_homes");
|
MarkerSet markerSet = dynmapAPI.getMarkerAPI().getMarkerSet("huskhomes.public_homes");
|
||||||
Marker m = markerSet.createMarker(markerId, home.getName(), home.getWorldName(), home.getX(), home.getY(), home.getZ(), dynmapAPI.getMarkerAPI().getMarkerIcon(Main.settings.getDynmapPublicHomeMarkerIconID()), false);
|
Marker m = markerSet.createMarker(markerId, home.getName(), home.getWorldName(), home.getX(), home.getY(), home.getZ(), dynmapAPI.getMarkerAPI().getMarkerIcon(HuskHomes.settings.getDynmapPublicHomeMarkerIconID()), false);
|
||||||
String popupWindow = "<div class=\"infowindow\"><span style=\"font-weight:bold;\">/phome %HOME_NAME%</span><br/><span style=\"font-weight:bold;\">Owner: </span>%OWNER%<br/><span style=\"font-weight:bold;\">Description: </span>%DESCRIPTION%</div>";
|
String publicHomePopup = "<div class=\"infowindow\"><span style=\"font-weight:bold;\">/phome %HOME_NAME%</span><br/><span style=\"font-weight:bold;\">Owner: </span>%OWNER%<br/><span style=\"font-weight:bold;\">Description: </span>%DESCRIPTION%</div>";
|
||||||
popupWindow = popupWindow.replace("%HOME_NAME%", escapeHtml(home.getName()));
|
publicHomePopup = publicHomePopup.replace("%HOME_NAME%", escapeHtml(home.getName()));
|
||||||
popupWindow = popupWindow.replace("%OWNER%", escapeHtml(home.getOwnerUsername()));
|
publicHomePopup = publicHomePopup.replace("%OWNER%", escapeHtml(home.getOwnerUsername()));
|
||||||
popupWindow = popupWindow.replace("%DESCRIPTION%", escapeHtml(home.getDescription()));
|
publicHomePopup = publicHomePopup.replace("%DESCRIPTION%", escapeHtml(home.getDescription()));
|
||||||
m.setDescription(popupWindow);
|
m.setDescription(publicHomePopup);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.getLogger().severe("Error adding public home marker to the Dynamic Map (" + e.getCause() + ")");
|
plugin.getLogger().severe("Error adding public home marker to the Dynamic Map (" + e.getCause() + ")");
|
||||||
plugin.getLogger().warning("This may be because you reloaded the server instead of restarting!");
|
plugin.getLogger().warning("This may be because you reloaded the server instead of restarting!");
|
||||||
@@ -79,14 +79,14 @@ public class dynamicMap {
|
|||||||
dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
|
dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
|
||||||
|
|
||||||
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
DynmapAPI dynmapAPI = (DynmapAPI) dynmap;
|
||||||
if (Main.settings.showPublicHomesOnDynmap()) {
|
if (HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.public_homes", Main.settings.getDynmapPublicHomeMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.public_homes", HuskHomes.settings.getDynmapPublicHomeMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||||
for (Home home : dataManager.getPublicHomes()) {
|
for (Home home : dataManager.getPublicHomes()) {
|
||||||
addDynamicMapMarker(home);
|
addDynamicMapMarker(home);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Main.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.warps", Main.settings.getDynmapWarpMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
dynmapAPI.getMarkerAPI().createMarkerSet("huskhomes.warps", HuskHomes.settings.getDynmapWarpMarkerSet(), dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||||
for (Warp warp : dataManager.getWarps()) {
|
for (Warp warp : dataManager.getWarps()) {
|
||||||
addDynamicMapMarker(warp);
|
addDynamicMapMarker(warp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package me.william278.huskhomes2.Integrations;
|
package me.william278.huskhomes2.Integrations;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
public class economy {
|
public class economy {
|
||||||
private static Economy economy = null;
|
private static Economy economy = null;
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
public static boolean initializeEconomy() {
|
public static boolean initializeEconomy() {
|
||||||
RegisteredServiceProvider<Economy> economyProvider =
|
RegisteredServiceProvider<Economy> economyProvider =
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package me.william278.huskhomes2.Integrations;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
|
||||||
|
public class vanishChecker {
|
||||||
|
|
||||||
|
public static boolean isVanished(Player player) {
|
||||||
|
if (HuskHomes.settings.isCheckVanishedPlayers()) {
|
||||||
|
for (MetadataValue meta : player.getMetadata("vanished")) {
|
||||||
|
if (meta.asBoolean()) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
package me.william278.huskhomes2.Migrators;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
|
import me.william278.huskhomes2.Objects.Home;
|
||||||
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
|
import me.william278.huskhomes2.Objects.Warp;
|
||||||
|
import me.william278.huskhomes2.dataManager;
|
||||||
|
import me.william278.huskhomes2.settingHandler;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.bukkit.configuration.file.YamlConfiguration.loadConfiguration;
|
||||||
|
|
||||||
|
public class essentialsMigrator {
|
||||||
|
|
||||||
|
// Migrate data from EssentialsX
|
||||||
|
public static void migrate() {
|
||||||
|
String serverID = HuskHomes.settings.getServerID();
|
||||||
|
File essentialsDataFolder = new File(Bukkit.getWorldContainer() + File.separator + "plugins" + File.separator + "Essentials");
|
||||||
|
if (essentialsDataFolder.exists()) {
|
||||||
|
Bukkit.getLogger().info("Essentials plugin data found!");
|
||||||
|
Bukkit.getLogger().info("-- Migration started --");
|
||||||
|
|
||||||
|
// Migrate user data
|
||||||
|
File essentialsPlayerDataFolder = new File(Bukkit.getWorldContainer() + File.separator + "plugins" + File.separator + "Essentials" + File.separator + "userdata");
|
||||||
|
if (essentialsPlayerDataFolder.exists()) {
|
||||||
|
Bukkit.getLogger().info("- Migrating user data and homes -");
|
||||||
|
|
||||||
|
File[] playerFiles = essentialsPlayerDataFolder.listFiles();
|
||||||
|
for (File playerFile : playerFiles) {
|
||||||
|
String uuidS = playerFile.getName().replaceFirst("[.][^.]+$", "");
|
||||||
|
UUID uuid = UUID.fromString(uuidS);
|
||||||
|
FileConfiguration playerFileConfig = loadConfiguration(playerFile);
|
||||||
|
String playerName = playerFileConfig.getString("lastAccountName");
|
||||||
|
Bukkit.getLogger().info("Migrating user data for " + playerName);
|
||||||
|
try {
|
||||||
|
Set<String> essentialsHomes = playerFileConfig.getConfigurationSection("homes").getKeys(false);
|
||||||
|
dataManager.createPlayer(uuid, playerName);
|
||||||
|
for (String home : essentialsHomes) {
|
||||||
|
|
||||||
|
// Get
|
||||||
|
String worldName = playerFileConfig.getString("homes." + home + ".world");
|
||||||
|
double x = playerFileConfig.getDouble("homes." + home + ".x");
|
||||||
|
double y = playerFileConfig.getDouble("homes." + home + ".y");
|
||||||
|
double z = playerFileConfig.getDouble("homes." + home + ".z");
|
||||||
|
float pitch = (float) playerFileConfig.getDouble("homes." + home + ".pitch");
|
||||||
|
float yaw = (float) playerFileConfig.getDouble("homes." + home + ".yaw");
|
||||||
|
|
||||||
|
Home playerHome = new Home(new TeleportationPoint(worldName, x, y, z, yaw, pitch, serverID), playerName, uuidS, home, playerName + "'s home", false);
|
||||||
|
|
||||||
|
Bukkit.getLogger().info("> Migrated home " + home);
|
||||||
|
dataManager.addHome(playerHome, uuid);
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
Bukkit.getLogger().info("No home data found for " + playerName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bukkit.getLogger().info("- All homes migrated! -");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Migrate warps
|
||||||
|
File essentialsWarpsFolder = new File(Bukkit.getWorldContainer() + File.separator + "plugins" + File.separator + "Essentials" + File.separator + "warps");
|
||||||
|
if (essentialsWarpsFolder.exists()) {
|
||||||
|
Bukkit.getLogger().info("- Migrating warps -");
|
||||||
|
|
||||||
|
File[] warpFiles = essentialsWarpsFolder.listFiles();
|
||||||
|
for (File warpFile : warpFiles) {
|
||||||
|
FileConfiguration warpFileConfig = loadConfiguration(warpFile);
|
||||||
|
try {
|
||||||
|
String warpName = warpFileConfig.getString("name");
|
||||||
|
String worldName = warpFileConfig.getString("world");
|
||||||
|
double x = warpFileConfig.getDouble("x");
|
||||||
|
double y = warpFileConfig.getDouble("y");
|
||||||
|
double z = warpFileConfig.getDouble("z");
|
||||||
|
float yaw = (float) warpFileConfig.getDouble("yaw");
|
||||||
|
float pitch = (float) warpFileConfig.getDouble("pitch");
|
||||||
|
|
||||||
|
Warp warp = new Warp(new TeleportationPoint(worldName, x, y, z, yaw, pitch, serverID), warpName, "A publicly accessible warp");
|
||||||
|
dataManager.addWarp(warp);
|
||||||
|
|
||||||
|
Bukkit.getLogger().info("Migrated warp \"" + warpName + "\"");
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
Bukkit.getLogger().warning("Error obtaining a warp's data!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bukkit.getLogger().info("- All warps migrated! -");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Migrate /spawn position
|
||||||
|
File essentialsSpawnData = new File(Bukkit.getWorldContainer() + File.separator + "plugins" + File.separator + "Essentials" + File.separator + "spawn.yml");
|
||||||
|
if (essentialsSpawnData.exists()) {
|
||||||
|
Bukkit.getLogger().info("Migrating /spawn position");
|
||||||
|
|
||||||
|
FileConfiguration spawnConfig = loadConfiguration(essentialsSpawnData);
|
||||||
|
try {
|
||||||
|
String worldName = spawnConfig.getString("spawns.all.world");
|
||||||
|
double x = spawnConfig.getDouble("spawns.all.x");
|
||||||
|
double y = spawnConfig.getDouble("spawns.all.y");
|
||||||
|
double z = spawnConfig.getDouble("spawns.all.z");
|
||||||
|
float yaw = (float) spawnConfig.getDouble("spawns.all.yaw");
|
||||||
|
float pitch = (float) spawnConfig.getDouble("spawns.all.pitch");
|
||||||
|
|
||||||
|
Location spawnLocation = new Location(Bukkit.getWorld(worldName), x, y, z, yaw, pitch);
|
||||||
|
settingHandler.setSpawnLocation(spawnLocation);
|
||||||
|
Bukkit.getLogger().info("/spawn position has been migrated!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Bukkit.getLogger().warning("Error obtaining /spawn position!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getLogger().info("-- Migration completed! --");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Bukkit.getLogger().severe("-- Migration failed! --");
|
||||||
|
Bukkit.getLogger().warning("Could not find Essentials plugin data to migrate!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package me.william278.huskhomes2.Migrators;
|
||||||
|
|
||||||
|
// This class migrates data from HuskHomes 1.5.x to HuskHomes 2.x
|
||||||
|
public class huskHomes1Migrator {
|
||||||
|
|
||||||
|
public static void migrate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,6 +6,10 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object representing a Player's home in-game
|
||||||
|
* @author William
|
||||||
|
*/
|
||||||
public class Home extends TeleportationPoint {
|
public class Home extends TeleportationPoint {
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
@@ -15,6 +19,14 @@ public class Home extends TeleportationPoint {
|
|||||||
UUID ownerUUID;
|
UUID ownerUUID;
|
||||||
String ownerUsername;
|
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) {
|
public Home(Location location, String server, Player homeOwner, String name, boolean isPublic) {
|
||||||
super(location, server);
|
super(location, server);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -24,6 +36,15 @@ public class Home extends TeleportationPoint {
|
|||||||
this.isPublic = isPublic;
|
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) {
|
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);
|
super(teleportationPoint.worldName, teleportationPoint.x, teleportationPoint.y, teleportationPoint.z, teleportationPoint.yaw, teleportationPoint.pitch, teleportationPoint.server);
|
||||||
this.ownerUsername = ownerUsername;
|
this.ownerUsername = ownerUsername;
|
||||||
@@ -33,22 +54,42 @@ public class Home extends TeleportationPoint {
|
|||||||
this.isPublic = isPublic;
|
this.isPublic = isPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the Home is public
|
||||||
|
* @return if the Home is public
|
||||||
|
*/
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
return isPublic;
|
return isPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the privacy of the home
|
||||||
|
* @param isPublic should the home be public?
|
||||||
|
*/
|
||||||
public void setPublic(boolean isPublic) {
|
public void setPublic(boolean isPublic) {
|
||||||
this.isPublic = isPublic;
|
this.isPublic = isPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the UUID of the Home's owner
|
||||||
|
* @return the owner's UUID
|
||||||
|
*/
|
||||||
public UUID getOwnerUUID() {
|
public UUID getOwnerUUID() {
|
||||||
return ownerUUID;
|
return ownerUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the username of the Home's owner
|
||||||
|
* @return the owner's username
|
||||||
|
*/
|
||||||
public String getOwnerUsername() {
|
public String getOwnerUsername() {
|
||||||
return ownerUsername;
|
return ownerUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Player who owns the home
|
||||||
|
* @return the Player owner of the home
|
||||||
|
*/
|
||||||
public Player getOwner() {
|
public Player getOwner() {
|
||||||
Player player = Bukkit.getPlayer(ownerUUID);
|
Player player = Bukkit.getPlayer(ownerUUID);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
@@ -58,23 +99,43 @@ public class Home extends TeleportationPoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOwner(Player p) {
|
/**
|
||||||
this.ownerUUID = p.getUniqueId();
|
* Set the owner of the home
|
||||||
this.ownerUsername = p.getName();
|
* @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() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the description of the home
|
||||||
|
* @return the Home description
|
||||||
|
*/
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the home
|
||||||
|
* @param name the new Home name
|
||||||
|
*/
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the description of the home
|
||||||
|
* @param description the new Home description
|
||||||
|
*/
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.name = description;
|
this.name = description;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Objects;
|
package me.william278.huskhomes2.Objects;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -35,8 +35,8 @@ public class RandomPoint extends TeleportationPoint {
|
|||||||
int negativeX;
|
int negativeX;
|
||||||
int negativeZ;
|
int negativeZ;
|
||||||
|
|
||||||
x = random.nextInt(Main.settings.getRtpRange());
|
x = random.nextInt(HuskHomes.settings.getRtpRange());
|
||||||
z = random.nextInt(Main.settings.getRtpRange());
|
z = random.nextInt(HuskHomes.settings.getRtpRange());
|
||||||
negativeX = random.nextInt(2);
|
negativeX = random.nextInt(2);
|
||||||
negativeZ = random.nextInt(2);
|
negativeZ = random.nextInt(2);
|
||||||
|
|
||||||
@@ -80,8 +80,8 @@ public class RandomPoint extends TeleportationPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RandomPoint(Player player) {
|
public RandomPoint(Player player) {
|
||||||
super(player.getLocation(), Main.settings.getServerID());
|
super(player.getLocation(), HuskHomes.settings.getServerID());
|
||||||
setLocation(getRandomLocation(player.getWorld()), Main.settings.getServerID());
|
setLocation(getRandomLocation(player.getWorld()), HuskHomes.settings.getServerID());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.william278.huskhomes2.Objects;
|
package me.william278.huskhomes2.Objects;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Integrations.economy;
|
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.dataManager;
|
||||||
import me.william278.huskhomes2.messageManager;
|
import me.william278.huskhomes2.messageManager;
|
||||||
import me.william278.huskhomes2.permissionHomeLimits;
|
import me.william278.huskhomes2.permissionHomeLimits;
|
||||||
@@ -31,8 +31,8 @@ public class SetHomeConditions {
|
|||||||
conditionsNotMetReason = "error_set_home_invalid_characters";
|
conditionsNotMetReason = "error_set_home_invalid_characters";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Main.settings.doEconomy()) {
|
if (HuskHomes.settings.doEconomy()) {
|
||||||
double setHomeCost = Main.settings.setHomeCost;
|
double setHomeCost = HuskHomes.settings.setHomeCost;
|
||||||
if (setHomeCost > 0) {
|
if (setHomeCost > 0) {
|
||||||
int currentPlayerHomeSlots = dataManager.getPlayerHomeSlots(player);
|
int currentPlayerHomeSlots = dataManager.getPlayerHomeSlots(player);
|
||||||
if (currentHomeCount > (currentPlayerHomeSlots - 1)) {
|
if (currentHomeCount > (currentPlayerHomeSlots - 1)) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Objects;
|
package me.william278.huskhomes2.Objects;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@@ -45,6 +45,9 @@ public class Settings {
|
|||||||
double publicHomeCost;
|
double publicHomeCost;
|
||||||
double rtpCost;
|
double rtpCost;
|
||||||
|
|
||||||
|
// Vanished player checks
|
||||||
|
boolean checkVanishedPlayers;
|
||||||
|
|
||||||
// Time and maximum home settings
|
// Time and maximum home settings
|
||||||
int maximumHomes;
|
int maximumHomes;
|
||||||
int teleportRequestExpiryTime;
|
int teleportRequestExpiryTime;
|
||||||
@@ -89,7 +92,7 @@ public class Settings {
|
|||||||
this.doDynmap = configFile.getBoolean("dynmap_integration.enabled");
|
this.doDynmap = configFile.getBoolean("dynmap_integration.enabled");
|
||||||
|
|
||||||
if (this.doDynmap) {
|
if (this.doDynmap) {
|
||||||
PluginManager pluginManager = Main.getInstance().getServer().getPluginManager();
|
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
||||||
Plugin dynmap = pluginManager.getPlugin("dynmap");
|
Plugin dynmap = pluginManager.getPlugin("dynmap");
|
||||||
if (dynmap == null) {
|
if (dynmap == null) {
|
||||||
Bukkit.getLogger().warning("Dynmap integration was enabled in config, but the Dynmap plugin could not be found!");
|
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");
|
this.doEconomy = configFile.getBoolean("economy_integration.enabled");
|
||||||
|
|
||||||
if (this.doEconomy) {
|
if (this.doEconomy) {
|
||||||
PluginManager pluginManager = Main.getInstance().getServer().getPluginManager();
|
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
|
||||||
Plugin vault = pluginManager.getPlugin("Vault");
|
Plugin vault = pluginManager.getPlugin("Vault");
|
||||||
if (vault == null) {
|
if (vault == null) {
|
||||||
Bukkit.getLogger().warning("Economy integration was enabled in config, but the Vault plugin could not be found!");
|
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.publicHomeCost = configFile.getDouble("economy_integration.costs.make_home_public");
|
||||||
this.rtpCost = configFile.getDouble("economy_integration.costs.random_teleport");
|
this.rtpCost = configFile.getDouble("economy_integration.costs.random_teleport");
|
||||||
|
|
||||||
|
this.checkVanishedPlayers = configFile.getBoolean("handle_vanished_players");
|
||||||
|
|
||||||
this.doSpawnCommand = configFile.getBoolean("spawn_command.enabled");
|
this.doSpawnCommand = configFile.getBoolean("spawn_command.enabled");
|
||||||
this.doWarpCommand = configFile.getBoolean("enable_warp_command");
|
this.doWarpCommand = configFile.getBoolean("enable_warp_command");
|
||||||
|
|
||||||
@@ -134,7 +139,7 @@ public class Settings {
|
|||||||
this.teleportWarmupTime = configFile.getInt("general.teleport_warmup_time");
|
this.teleportWarmupTime = configFile.getInt("general.teleport_warmup_time");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,6 +188,10 @@ public class Settings {
|
|||||||
return storageType;
|
return storageType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCheckVanishedPlayers() {
|
||||||
|
return checkVanishedPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.william278.huskhomes2.Objects;
|
package me.william278.huskhomes2.Objects;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ public class TeleportRequest {
|
|||||||
this.requestType = requestType.toLowerCase();
|
this.requestType = requestType.toLowerCase();
|
||||||
}
|
}
|
||||||
long currentUnixTime = Instant.now().getEpochSecond();
|
long currentUnixTime = Instant.now().getEpochSecond();
|
||||||
requestExpiryTime = currentUnixTime + Main.settings.getTeleportRequestExpiryTime();
|
requestExpiryTime = currentUnixTime + HuskHomes.settings.getTeleportRequestExpiryTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSenderName() {
|
public String getSenderName() {
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author William
|
||||||
|
* HuskHomes' position representation object; represents an in-game location on a server
|
||||||
|
*/
|
||||||
public class TeleportationPoint {
|
public class TeleportationPoint {
|
||||||
|
|
||||||
String server;
|
String server;
|
||||||
@@ -14,6 +18,11 @@ public class TeleportationPoint {
|
|||||||
float yaw;
|
float yaw;
|
||||||
float pitch;
|
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) {
|
public void setLocation(Location location, String server) {
|
||||||
worldName = location.getWorld().getName();
|
worldName = location.getWorld().getName();
|
||||||
x = location.getX();
|
x = location.getX();
|
||||||
@@ -24,6 +33,11 @@ public class TeleportationPoint {
|
|||||||
this.server = server;
|
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) {
|
public TeleportationPoint(Location location, String server) {
|
||||||
if (location.getWorld() == null) {
|
if (location.getWorld() == null) {
|
||||||
throw new IllegalStateException("The location provided has an invalid world");
|
throw new IllegalStateException("The location provided has an invalid world");
|
||||||
@@ -31,6 +45,16 @@ public class TeleportationPoint {
|
|||||||
setLocation(location, server);
|
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) {
|
public TeleportationPoint(String worldName, double x, double y, double z, float yaw, float pitch, String server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.worldName = worldName;
|
this.worldName = worldName;
|
||||||
@@ -41,14 +65,11 @@ public class TeleportationPoint {
|
|||||||
this.pitch = pitch;
|
this.pitch = pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLocation(Location location, String server) {
|
/**
|
||||||
setLocation(location, 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 String getServer() {
|
*/
|
||||||
return server;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
World world = Bukkit.getWorld(worldName);
|
World world = Bukkit.getWorld(worldName);
|
||||||
if (world != null) {
|
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() {
|
public String getWorldName() {
|
||||||
return worldName;
|
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() {
|
public double getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the y-coordinate of a TeleportationPoint
|
||||||
|
* @return the y-coordinate
|
||||||
|
*/
|
||||||
public double getY() {
|
public double getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the z-coordinate of a TeleportationPoint
|
||||||
|
* @return the z-coordinate
|
||||||
|
*/
|
||||||
public double getZ() {
|
public double getZ() {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the yaw angle of a TeleportationPoint
|
||||||
|
* @return the yaw angle
|
||||||
|
*/
|
||||||
public float getYaw() {
|
public float getYaw() {
|
||||||
return yaw;
|
return yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the pitch angle of a TeleportationPoint
|
||||||
|
* @return the pitch angle
|
||||||
|
*/
|
||||||
public float getPitch() {
|
public float getPitch() {
|
||||||
return pitch;
|
return pitch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package me.william278.huskhomes2.Objects;
|
package me.william278.huskhomes2.Objects;
|
||||||
|
|
||||||
import me.william278.huskhomes2.Main;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.messageManager;
|
import me.william278.huskhomes2.messageManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TimedTeleport {
|
public class TimedTeleport {
|
||||||
@@ -18,7 +17,7 @@ public class TimedTeleport {
|
|||||||
double initialTeleporterHealth;
|
double initialTeleporterHealth;
|
||||||
|
|
||||||
int timeRemaining;
|
int timeRemaining;
|
||||||
final int warmupTime = Main.settings.getTeleportWarmupTime();
|
final int warmupTime = HuskHomes.settings.getTeleportWarmupTime();
|
||||||
|
|
||||||
public TimedTeleport(Player teleporter, TeleportationPoint targetPoint) {
|
public TimedTeleport(Player teleporter, TeleportationPoint targetPoint) {
|
||||||
this.teleporter = teleporter;
|
this.teleporter = teleporter;
|
||||||
|
|||||||
@@ -2,35 +2,67 @@ package me.william278.huskhomes2.Objects;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object representing an in-game warp
|
||||||
|
* @author William
|
||||||
|
*/
|
||||||
public class Warp extends TeleportationPoint {
|
public class Warp extends TeleportationPoint {
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
String description;
|
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) {
|
public Warp(Location location, String server, String name) {
|
||||||
super(location, server);
|
super(location, server);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = "A publicly accessible warp";
|
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) {
|
public Warp(TeleportationPoint teleportationPoint, String name, String description) {
|
||||||
super(teleportationPoint.worldName, teleportationPoint.x, teleportationPoint.y, teleportationPoint.z, teleportationPoint.yaw, teleportationPoint.pitch, teleportationPoint.server);
|
super(teleportationPoint.worldName, teleportationPoint.x, teleportationPoint.y, teleportationPoint.z, teleportationPoint.yaw, teleportationPoint.pitch, teleportationPoint.server);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the description of the Warp
|
||||||
|
* @return the Warp's description
|
||||||
|
*/
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the Warp
|
||||||
|
* @return the Warp's name
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the Warp
|
||||||
|
* @param name the new Warp name
|
||||||
|
*/
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the description of the Warp
|
||||||
|
* @param description the new Warp description
|
||||||
|
*/
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.name = description;
|
this.name = description;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import me.william278.huskhomes2.Objects.Settings;
|
|||||||
|
|
||||||
public class configManager {
|
public class configManager {
|
||||||
|
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
// (Re-)Load the config file
|
// (Re-)Load the config file
|
||||||
public static void loadConfig() {
|
public static void loadConfig() {
|
||||||
@@ -16,6 +16,6 @@ public class configManager {
|
|||||||
"Configuration guide: https://github.com/WiIIiam278/HuskHomes2/wiki \n");
|
"Configuration guide: https://github.com/WiIIiam278/HuskHomes2/wiki \n");
|
||||||
plugin.getConfig().options().copyHeader(true);
|
plugin.getConfig().options().copyHeader(true);
|
||||||
plugin.saveDefaultConfig();
|
plugin.saveDefaultConfig();
|
||||||
Main.settings = new Settings(plugin.getConfig());
|
HuskHomes.settings = new Settings(plugin.getConfig());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,26 +27,26 @@ public class dataManager {
|
|||||||
|
|
||||||
public static String createLocationsTable = "";
|
public static String createLocationsTable = "";
|
||||||
|
|
||||||
public static String createHomesTable = "CREATE TABLE IF NOT EXISTS " + Main.settings.getHomesDataTable() + " (" +
|
public static String createHomesTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getHomesDataTable() + " (" +
|
||||||
"`player_id` integer NOT NULL," +
|
"`player_id` integer NOT NULL," +
|
||||||
"`location_id` integer NOT NULL," +
|
"`location_id` integer NOT NULL," +
|
||||||
"`name` varchar(16) NOT NULL," +
|
"`name` varchar(16) NOT NULL," +
|
||||||
"`description` varchar(255) NOT NULL," +
|
"`description` varchar(255) NOT NULL," +
|
||||||
"`public` boolean NOT NULL," +
|
"`public` boolean NOT NULL," +
|
||||||
"PRIMARY KEY (`player_id`, `name`)," +
|
"PRIMARY KEY (`player_id`, `name`)," +
|
||||||
"FOREIGN KEY (`player_id`) REFERENCES " + Main.settings.getPlayerDataTable() + " (`player_id`) ON DELETE CASCADE ON UPDATE NO ACTION," +
|
"FOREIGN KEY (`player_id`) REFERENCES " + HuskHomes.settings.getPlayerDataTable() + " (`player_id`) ON DELETE CASCADE ON UPDATE NO ACTION," +
|
||||||
"FOREIGN KEY (`location_id`) REFERENCES " + Main.settings.getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
||||||
");";
|
");";
|
||||||
|
|
||||||
public static String createWarpsTable = "CREATE TABLE IF NOT EXISTS " + Main.settings.getWarpsDataTable() + " (" +
|
public static String createWarpsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getWarpsDataTable() + " (" +
|
||||||
"`location_id` integer NOT NULL," +
|
"`location_id` integer NOT NULL," +
|
||||||
"`name` varchar(16) NOT NULL UNIQUE," +
|
"`name` varchar(16) NOT NULL UNIQUE," +
|
||||||
"`description` varchar(255) NOT NULL," +
|
"`description` varchar(255) NOT NULL," +
|
||||||
"PRIMARY KEY (`location_id`)," +
|
"PRIMARY KEY (`location_id`)," +
|
||||||
"FOREIGN KEY (`location_id`) REFERENCES " + Main.settings.getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
||||||
");";
|
");";
|
||||||
|
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
private static Database database;
|
private static Database database;
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ public class dataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeDatabase() {
|
private static void initializeDatabase() {
|
||||||
database = new SQL(Main.getInstance());
|
database = new SQL(HuskHomes.getInstance());
|
||||||
database.load();
|
database.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getPlayerDataTable() + " WHERE `user_uuid`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `user_uuid`=?;");
|
||||||
ps.setString(1, playerUUID.toString());
|
ps.setString(1, playerUUID.toString());
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -103,7 +103,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getPlayerDataTable() + " WHERE `username`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `username`=?;");
|
||||||
ps.setString(1, playerUsername);
|
ps.setString(1, playerUsername);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -138,7 +138,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getPlayerDataTable() + " WHERE `player_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -173,7 +173,7 @@ public class dataManager {
|
|||||||
|
|
||||||
// Return an integer from the player table from a player object
|
// Return an integer from the player table from a player object
|
||||||
public static Integer getPlayerInteger(Player p, String column) {
|
public static Integer getPlayerInteger(Player p, String column) {
|
||||||
return getPlayerInteger(getPlayerId(p.getName()), column);
|
return getPlayerInteger(getPlayerId(p.getUniqueId()), column);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an integer from the player table from a player ID
|
// Return an integer from the player table from a player ID
|
||||||
@@ -184,7 +184,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getPlayerDataTable() + " WHERE `player_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -212,26 +212,16 @@ public class dataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an integer from the player table from a player name
|
|
||||||
public static String getPlayerString(String playerName, String column) {
|
|
||||||
return getPlayerString(getPlayerId(playerName), column);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return an integer from the player table from a player object
|
|
||||||
public static String getPlayerString(Player p, String column) {
|
|
||||||
return getPlayerString(getPlayerId(p.getName()), column);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return an integer from the player table from a player ID
|
// Return an integer from the player table from a player ID
|
||||||
public static Boolean getPlayerTeleporting(Player p) {
|
public static Boolean getPlayerTeleporting(Player p) {
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
Integer playerID = getPlayerId(p.getName());
|
Integer playerID = getPlayerId(p.getUniqueId());
|
||||||
ResultSet rs;
|
ResultSet rs;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getPlayerDataTable() + " WHERE `player_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -308,7 +298,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getHomesDataTable() + " WHERE `player_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `player_id`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -352,7 +342,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getHomesDataTable() + " WHERE `public`;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `public`;");
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
ArrayList<Home> publicHomes = new ArrayList<>();
|
ArrayList<Home> publicHomes = new ArrayList<>();
|
||||||
@@ -392,7 +382,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getWarpsDataTable() + ";");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getWarpsDataTable() + ";");
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
ArrayList<Warp> warps = new ArrayList<>();
|
ArrayList<Warp> warps = new ArrayList<>();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -432,7 +422,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
||||||
ps.setString(1, name);
|
ps.setString(1, name);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -474,7 +464,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
||||||
ps.setInt(1, ownerID);
|
ps.setInt(1, ownerID);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
@@ -507,7 +497,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
||||||
ps.setString(1, warpName);
|
ps.setString(1, warpName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -550,7 +540,7 @@ public class dataManager {
|
|||||||
public static void updateHomeLocation(String ownerName, String homeName, Location newLocation) {
|
public static void updateHomeLocation(String ownerName, String homeName, Location newLocation) {
|
||||||
Integer playerID = getPlayerId(ownerName);
|
Integer playerID = getPlayerId(ownerName);
|
||||||
deleteHomeTeleportLocation(playerID, homeName);
|
deleteHomeTeleportLocation(playerID, homeName);
|
||||||
database.setHomeTeleportPoint(homeName, playerID, new TeleportationPoint(newLocation, Main.settings.getServerID()));
|
database.setHomeTeleportPoint(homeName, playerID, new TeleportationPoint(newLocation, HuskHomes.settings.getServerID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateWarpName(String warpName, String newName) {
|
public static void updateWarpName(String warpName, String newName) {
|
||||||
@@ -563,7 +553,7 @@ public class dataManager {
|
|||||||
|
|
||||||
public static void updateWarpLocation(String warpName, Location newLocation) {
|
public static void updateWarpLocation(String warpName, Location newLocation) {
|
||||||
deleteWarpTeleportLocation(warpName);
|
deleteWarpTeleportLocation(warpName);
|
||||||
database.setWarpTeleportPoint(warpName, new TeleportationPoint(newLocation, Main.settings.getServerID()));
|
database.setWarpTeleportPoint(warpName, new TeleportationPoint(newLocation, HuskHomes.settings.getServerID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a home with a given owner username and home name
|
// Return a home with a given owner username and home name
|
||||||
@@ -575,7 +565,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
@@ -621,7 +611,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getWarpsDataTable() + " WHERE `name`=?;");
|
||||||
ps.setString(1, warpName);
|
ps.setString(1, warpName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -662,7 +652,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getHomesDataTable() + " WHERE `player_id`=? AND `name`=?;");
|
||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.setString(2, homeName);
|
ps.setString(2, homeName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
@@ -695,7 +685,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getPlayerDataTable() + " WHERE `user_uuid`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getPlayerDataTable() + " WHERE `user_uuid`=?;");
|
||||||
ps.setString(1, playerUUID);
|
ps.setString(1, playerUUID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
@@ -726,7 +716,7 @@ public class dataManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
ps = conn.prepareStatement("SELECT * FROM " + Main.settings.getLocationsDataTable() + " WHERE `location_id`=?;");
|
ps = conn.prepareStatement("SELECT * FROM " + HuskHomes.settings.getLocationsDataTable() + " WHERE `location_id`=?;");
|
||||||
ps.setInt(1, locationID);
|
ps.setInt(1, locationID);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
@@ -737,7 +727,7 @@ public class dataManager {
|
|||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().severe("An SQL exception occurred in retrieving a teleportation location.");
|
Bukkit.getLogger().severe("An SQL exception occurred in retrieving a teleportation location.");
|
||||||
Bukkit.getLogger().severe("location ID: " + locationID.toString());
|
Bukkit.getLogger().severe("location ID: " + locationID.toString());
|
||||||
Bukkit.getLogger().severe("SELECT * FROM " + Main.settings.getLocationsDataTable() + " WHERE `location_id`=" + locationID.toString() + ";");
|
Bukkit.getLogger().severe("SELECT * FROM " + HuskHomes.settings.getLocationsDataTable() + " WHERE `location_id`=" + locationID.toString() + ";");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@@ -775,7 +765,7 @@ public class dataManager {
|
|||||||
|
|
||||||
// Update a player's last position location on SQL
|
// Update a player's last position location on SQL
|
||||||
public static void setPlayerLastPosition(Player p, TeleportationPoint point) {
|
public static void setPlayerLastPosition(Player p, TeleportationPoint point) {
|
||||||
Integer playerID = getPlayerId(p.getName());
|
Integer playerID = getPlayerId(p.getUniqueId());
|
||||||
if (playerID != null) {
|
if (playerID != null) {
|
||||||
deletePlayerLastPosition(p);
|
deletePlayerLastPosition(p);
|
||||||
database.setTeleportationLastPosition(playerID, point);
|
database.setTeleportationLastPosition(playerID, point);
|
||||||
@@ -801,7 +791,7 @@ public class dataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setPlayerTeleporting(Player p, boolean value) {
|
public static void setPlayerTeleporting(Player p, boolean value) {
|
||||||
Integer playerID = getPlayerId(p.getName());
|
Integer playerID = getPlayerId(p.getUniqueId());
|
||||||
if (playerID != null) {
|
if (playerID != null) {
|
||||||
database.setPlayerTeleporting(playerID, value);
|
database.setPlayerTeleporting(playerID, value);
|
||||||
} else {
|
} else {
|
||||||
@@ -818,10 +808,10 @@ public class dataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateRtpCooldown(Player p) {
|
public static void updateRtpCooldown(Player p) {
|
||||||
Integer playerID = getPlayerId(p.getName());
|
Integer playerID = getPlayerId(p.getUniqueId());
|
||||||
if (playerID != null) {
|
if (playerID != null) {
|
||||||
long currentTime = Instant.now().getEpochSecond();
|
long currentTime = Instant.now().getEpochSecond();
|
||||||
int newCooldownTime = (int) currentTime + (60 * Main.settings.getRtpCooldown());
|
int newCooldownTime = (int) currentTime + (60 * HuskHomes.settings.getRtpCooldown());
|
||||||
database.setRtpCooldown(playerID, newCooldownTime);
|
database.setRtpCooldown(playerID, newCooldownTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -850,17 +840,20 @@ public class dataManager {
|
|||||||
database.addWarp(warp);
|
database.addWarp(warp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addHome(Home home, Player p) {
|
public static void addHome(Home home, UUID playerUUID) {
|
||||||
Integer playerID = getPlayerId(p.getName());
|
Integer playerID = getPlayerId(playerUUID);
|
||||||
if (playerID != null) {
|
if (playerID != null) {
|
||||||
database.addHome(home, playerID);
|
database.addHome(home, playerID);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().warning("Failed to add a home for " + p.getName());
|
Bukkit.getLogger().warning("Failed to add a home for a player!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void addHome(Home home, Player p) {
|
||||||
|
addHome(home, p.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
public static void deleteHome(String homeName, Player p) {
|
public static void deleteHome(String homeName, Player p) {
|
||||||
Integer playerID = getPlayerId(p.getName());
|
Integer playerID = getPlayerId(p.getUniqueId());
|
||||||
if (playerID != null) {
|
if (playerID != null) {
|
||||||
deleteHomeTeleportLocation(playerID, homeName);
|
deleteHomeTeleportLocation(playerID, homeName);
|
||||||
database.deleteHome(homeName, playerID);
|
database.deleteHome(homeName, playerID);
|
||||||
@@ -875,8 +868,8 @@ public class dataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setupStorage() {
|
public static void setupStorage() {
|
||||||
if (Main.settings.getStorageType().equalsIgnoreCase("mysql")) {
|
if (HuskHomes.settings.getStorageType().equalsIgnoreCase("mysql")) {
|
||||||
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + Main.settings.getPlayerDataTable() + " (" +
|
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getPlayerDataTable() + " (" +
|
||||||
"`player_id` integer AUTO_INCREMENT," +
|
"`player_id` integer AUTO_INCREMENT," +
|
||||||
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
||||||
"`username` varchar(16) NOT NULL," +
|
"`username` varchar(16) NOT NULL," +
|
||||||
@@ -887,10 +880,10 @@ public class dataManager {
|
|||||||
"`last_location_id` integer NULL," +
|
"`last_location_id` integer NULL," +
|
||||||
|
|
||||||
"PRIMARY KEY (`player_id`)," +
|
"PRIMARY KEY (`player_id`)," +
|
||||||
"FOREIGN KEY (`dest_location_id`) REFERENCES " + Main.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
|
"FOREIGN KEY (`dest_location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
|
||||||
"FOREIGN KEY (`last_location_id`) REFERENCES " + Main.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION" +
|
"FOREIGN KEY (`last_location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION" +
|
||||||
");";
|
");";
|
||||||
createLocationsTable = "CREATE TABLE IF NOT EXISTS " + Main.settings.getLocationsDataTable() + " (" +
|
createLocationsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getLocationsDataTable() + " (" +
|
||||||
"`location_id` integer AUTO_INCREMENT," +
|
"`location_id` integer AUTO_INCREMENT," +
|
||||||
"`server` text NOT NULL," +
|
"`server` text NOT NULL," +
|
||||||
"`world` text NOT NULL," +
|
"`world` text NOT NULL," +
|
||||||
@@ -903,7 +896,7 @@ public class dataManager {
|
|||||||
"PRIMARY KEY (`location_id`)" +
|
"PRIMARY KEY (`location_id`)" +
|
||||||
");";
|
");";
|
||||||
} else {
|
} else {
|
||||||
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + Main.settings.getPlayerDataTable() + " (" +
|
createPlayerTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getPlayerDataTable() + " (" +
|
||||||
"`player_id` integer NOT NULL," +
|
"`player_id` integer NOT NULL," +
|
||||||
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
"`user_uuid` char(36) NOT NULL UNIQUE," +
|
||||||
"`username` varchar(16) NOT NULL," +
|
"`username` varchar(16) NOT NULL," +
|
||||||
@@ -913,10 +906,10 @@ public class dataManager {
|
|||||||
"`dest_location_id` integer NULL," +
|
"`dest_location_id` integer NULL," +
|
||||||
"`last_location_id` integer NULL," +
|
"`last_location_id` integer NULL," +
|
||||||
"PRIMARY KEY (`player_id`)," +
|
"PRIMARY KEY (`player_id`)," +
|
||||||
"FOREIGN KEY (`dest_location_id`) REFERENCES " + Main.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
|
"FOREIGN KEY (`dest_location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION," +
|
||||||
"FOREIGN KEY (`last_location_id`) REFERENCES " + Main.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION" +
|
"FOREIGN KEY (`last_location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE SET NULL ON UPDATE NO ACTION" +
|
||||||
");";
|
");";
|
||||||
createLocationsTable = "CREATE TABLE IF NOT EXISTS " + Main.settings.getLocationsDataTable() + " (" +
|
createLocationsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getLocationsDataTable() + " (" +
|
||||||
"`location_id` integer PRIMARY KEY," +
|
"`location_id` integer PRIMARY KEY," +
|
||||||
"`server` text NOT NULL," +
|
"`server` text NOT NULL," +
|
||||||
"`world` text NOT NULL," +
|
"`world` text NOT NULL," +
|
||||||
@@ -934,6 +927,10 @@ public class dataManager {
|
|||||||
database.addPlayer(p);
|
database.addPlayer(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void createPlayer(UUID playerUUID, String playerUsername) {
|
||||||
|
database.addPlayer(playerUUID, playerUsername);
|
||||||
|
}
|
||||||
|
|
||||||
public static void checkPlayerNameChange(Player p) {
|
public static void checkPlayerNameChange(Player p) {
|
||||||
Integer playerID = getPlayerId(p.getUniqueId());
|
Integer playerID = getPlayerId(p.getUniqueId());
|
||||||
if (!getPlayerUsername(playerID).equals(p.getName())) {
|
if (!getPlayerUsername(playerID).equals(p.getName())) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class editingHandler {
|
|||||||
Integer.toString((int) home.getY()),
|
Integer.toString((int) home.getY()),
|
||||||
Integer.toString((int) home.getZ()));
|
Integer.toString((int) home.getZ()));
|
||||||
messageManager.sendMessage(p, "edit_world", home.getWorldName());
|
messageManager.sendMessage(p, "edit_world", home.getWorldName());
|
||||||
if (Main.settings.doBungee()) {
|
if (HuskHomes.settings.doBungee()) {
|
||||||
messageManager.sendMessage(p, "edit_server", home.getServer());
|
messageManager.sendMessage(p, "edit_server", home.getServer());
|
||||||
}
|
}
|
||||||
if (!home.isPublic()) {
|
if (!home.isPublic()) {
|
||||||
@@ -83,7 +83,7 @@ public class editingHandler {
|
|||||||
Integer.toString((int) warp.getY()),
|
Integer.toString((int) warp.getY()),
|
||||||
Integer.toString((int) warp.getZ()));
|
Integer.toString((int) warp.getZ()));
|
||||||
messageManager.sendMessage(p, "edit_world", warp.getWorldName());
|
messageManager.sendMessage(p, "edit_world", warp.getWorldName());
|
||||||
if (Main.settings.doBungee()) {
|
if (HuskHomes.settings.doBungee()) {
|
||||||
messageManager.sendMessage(p, "edit_server", warp.getServer());
|
messageManager.sendMessage(p, "edit_server", warp.getServer());
|
||||||
}
|
}
|
||||||
p.sendMessage("");
|
p.sendMessage("");
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ public class listHandler {
|
|||||||
|
|
||||||
private static void displayPageButtons(Player p, int pageNumber, int homeListSize, int homeUpperBound, String command) {
|
private static void displayPageButtons(Player p, int pageNumber, int homeListSize, int homeUpperBound, String command) {
|
||||||
ComponentBuilder pageButtons = new ComponentBuilder();
|
ComponentBuilder pageButtons = new ComponentBuilder();
|
||||||
TextComponent nextPageButton = pageButton("[Next Page →]", net.md_5.bungee.api.ChatColor.GREEN, command + " " + (pageNumber + 1), "Click to view next 10");
|
TextComponent nextPageButton = pageButton("[Next Page >]", net.md_5.bungee.api.ChatColor.GREEN, command + " " + (pageNumber + 1), "Click to view next 10");
|
||||||
TextComponent previousPageButton = pageButton("[← Last Page]", net.md_5.bungee.api.ChatColor.RED, command + " " + (pageNumber - 1), "Click to view previous 10");
|
TextComponent previousPageButton = pageButton("[< Last Page]", net.md_5.bungee.api.ChatColor.RED, command + " " + (pageNumber - 1), "Click to view previous 10");
|
||||||
TextComponent divider = new TextComponent(" • ");
|
TextComponent divider = new TextComponent(" • ");
|
||||||
divider.setColor(net.md_5.bungee.api.ChatColor.GRAY);
|
divider.setColor(net.md_5.bungee.api.ChatColor.GRAY);
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class messageManager {
|
|||||||
|
|
||||||
private static HashMap<String, String> messages = new HashMap<>();
|
private static HashMap<String, String> messages = new HashMap<>();
|
||||||
|
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
// Delete the file at the pointer specified
|
// Delete the file at the pointer specified
|
||||||
private static void deleteFile(File f) {
|
private static void deleteFile(File f) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
|
|||||||
|
|
||||||
public class permissionHomeLimits {
|
public class permissionHomeLimits {
|
||||||
|
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
// Returns the maximum number of set homes a player can make
|
// Returns the maximum number of set homes a player can make
|
||||||
public static int getSetHomeLimit(Player p) {
|
public static int getSetHomeLimit(Player p) {
|
||||||
@@ -16,11 +16,11 @@ public class permissionHomeLimits {
|
|||||||
try {
|
try {
|
||||||
return Integer.parseInt(permission.split("\\.")[2]);
|
return Integer.parseInt(permission.split("\\.")[2]);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
return Main.settings.getMaximumHomes();
|
return HuskHomes.settings.getMaximumHomes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Main.settings.getMaximumHomes();
|
return HuskHomes.settings.getMaximumHomes();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the number of set homes a player can set for free
|
// Returns the number of set homes a player can set for free
|
||||||
@@ -31,10 +31,10 @@ public class permissionHomeLimits {
|
|||||||
try {
|
try {
|
||||||
return Integer.parseInt(permission.split("\\.")[2]);
|
return Integer.parseInt(permission.split("\\.")[2]);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
return Main.settings.getFreeHomeSlots();
|
return HuskHomes.settings.getFreeHomeSlots();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Main.settings.getFreeHomeSlots();
|
return HuskHomes.settings.getFreeHomeSlots();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package me.william278.huskhomes2;
|
|||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
import me.william278.huskhomes2.Integrations.vanishChecker;
|
||||||
import me.william278.huskhomes2.Objects.TeleportRequest;
|
import me.william278.huskhomes2.Objects.TeleportRequest;
|
||||||
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -13,7 +14,7 @@ import java.io.*;
|
|||||||
|
|
||||||
public class pluginMessageHandler implements PluginMessageListener {
|
public class pluginMessageHandler implements PluginMessageListener {
|
||||||
|
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
// Move a player to a different server in the bungee network
|
// Move a player to a different server in the bungee network
|
||||||
public static void sendPlayer(Player p, String targetServer) {
|
public static void sendPlayer(Player p, String targetServer) {
|
||||||
@@ -101,12 +102,16 @@ public class pluginMessageHandler implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "tpa_request":
|
case "tpa_request":
|
||||||
|
if (!vanishChecker.isVanished(recipient)) {
|
||||||
teleportRequestHandler.teleportRequests.put(recipient, new TeleportRequest(messageData, "tpa"));
|
teleportRequestHandler.teleportRequests.put(recipient, new TeleportRequest(messageData, "tpa"));
|
||||||
messageManager.sendMessage(recipient, "tpa_request_ask", messageData);
|
messageManager.sendMessage(recipient, "tpa_request_ask", messageData);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "tpahere_request":
|
case "tpahere_request":
|
||||||
|
if (!vanishChecker.isVanished(recipient)) {
|
||||||
teleportRequestHandler.teleportRequests.put(recipient, new TeleportRequest(messageData, "tpahere"));
|
teleportRequestHandler.teleportRequests.put(recipient, new TeleportRequest(messageData, "tpahere"));
|
||||||
messageManager.sendMessage(recipient, "tpahere_request_ask", messageData);
|
messageManager.sendMessage(recipient, "tpahere_request_ask", messageData);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "tpa_request_reply":
|
case "tpa_request_reply":
|
||||||
replierName = messageData.split(":")[0];
|
replierName = messageData.split(":")[0];
|
||||||
@@ -136,6 +141,6 @@ public class pluginMessageHandler implements PluginMessageListener {
|
|||||||
// Set the requesters' teleport destination to a teleportation point of the recipient's current location
|
// Set the requesters' teleport destination to a teleportation point of the recipient's current location
|
||||||
public void setTeleportDestination(String requesterName, Player recipient) {
|
public void setTeleportDestination(String requesterName, Player recipient) {
|
||||||
dataManager.setPlayerDestinationLocation(requesterName,
|
dataManager.setPlayerDestinationLocation(requesterName,
|
||||||
new TeleportationPoint(recipient.getLocation(), Main.settings.getServerID()));
|
new TeleportationPoint(recipient.getLocation(), HuskHomes.settings.getServerID()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ import static org.bukkit.Bukkit.getServer;
|
|||||||
|
|
||||||
public class runEverySecond {
|
public class runEverySecond {
|
||||||
|
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
// Cancel expired teleport requests
|
// Cancel expired teleport requests
|
||||||
private static void clearExpiredRequests(HashSet<Player> expiredTeleportRequests) {
|
private static void clearExpiredRequests(HashSet<Player> expiredTeleportRequests) {
|
||||||
@@ -78,8 +78,8 @@ public class runEverySecond {
|
|||||||
teleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPlayerName());
|
teleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPlayerName());
|
||||||
break;
|
break;
|
||||||
case "random":
|
case "random":
|
||||||
if (Main.settings.doEconomy()) {
|
if (HuskHomes.settings.doEconomy()) {
|
||||||
double rtpCost = Main.settings.getRtpCost();
|
double rtpCost = HuskHomes.settings.getRtpCost();
|
||||||
if (rtpCost > 0) {
|
if (rtpCost > 0) {
|
||||||
if (!economy.takeMoney(teleporter, rtpCost)) {
|
if (!economy.takeMoney(teleporter, rtpCost)) {
|
||||||
messageManager.sendMessage(teleporter, "error_insufficient_funds", economy.format(rtpCost));
|
messageManager.sendMessage(teleporter, "error_insufficient_funds", economy.format(rtpCost));
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package me.william278.huskhomes2;
|
package me.william278.huskhomes2;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.API.PlayerDeleteHomeEvent;
|
||||||
|
import me.william278.huskhomes2.API.PlayerDeleteWarpEvent;
|
||||||
|
import me.william278.huskhomes2.API.PlayerSetHomeEvent;
|
||||||
|
import me.william278.huskhomes2.API.PlayerSetWarpEvent;
|
||||||
|
import me.william278.huskhomes2.Commands.TabCompleters.homeTabCompleter;
|
||||||
|
import me.william278.huskhomes2.Commands.TabCompleters.publicHomeTabCompleter;
|
||||||
|
import me.william278.huskhomes2.Commands.TabCompleters.warpTabCompleter;
|
||||||
import me.william278.huskhomes2.Integrations.dynamicMap;
|
import me.william278.huskhomes2.Integrations.dynamicMap;
|
||||||
import me.william278.huskhomes2.Integrations.economy;
|
import me.william278.huskhomes2.Integrations.economy;
|
||||||
import me.william278.huskhomes2.Objects.*;
|
import me.william278.huskhomes2.Objects.*;
|
||||||
@@ -10,25 +17,30 @@ import org.bukkit.entity.Player;
|
|||||||
// This class handles setting homes, warps and the spawn location.
|
// This class handles setting homes, warps and the spawn location.
|
||||||
public class settingHandler {
|
public class settingHandler {
|
||||||
|
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
// Set a home at the specified position
|
// Set a home at the specified position
|
||||||
public static void setHome(Location location, Player player, String name) {
|
public static void setHome(Location location, Player player, String name) {
|
||||||
SetHomeConditions setHomeConditions = new SetHomeConditions(player, name);
|
SetHomeConditions setHomeConditions = new SetHomeConditions(player, name);
|
||||||
if (setHomeConditions.areConditionsMet()) {
|
if (setHomeConditions.areConditionsMet()) {
|
||||||
Home home = new Home(location, Main.settings.getServerID(), player, name, false);
|
Home home = new Home(location, HuskHomes.settings.getServerID(), player, name, false);
|
||||||
|
PlayerSetHomeEvent event = new PlayerSetHomeEvent(player, home);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
dataManager.addHome(home, player);
|
dataManager.addHome(home, player);
|
||||||
messageManager.sendMessage(player, "set_home_success", name);
|
messageManager.sendMessage(player, "set_home_success", name);
|
||||||
if (Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
dynamicMap.addDynamicMapMarker(home);
|
dynamicMap.addDynamicMapMarker(home);
|
||||||
}
|
}
|
||||||
|
homeTabCompleter.updatePlayerHomeCache(player);
|
||||||
} else {
|
} else {
|
||||||
switch (setHomeConditions.getConditionsNotMetReason()) {
|
switch (setHomeConditions.getConditionsNotMetReason()) {
|
||||||
case "error_set_home_maximum_homes":
|
case "error_set_home_maximum_homes":
|
||||||
messageManager.sendMessage(player, "error_set_home_maximum_homes", Integer.toString(Main.settings.getMaximumHomes()));
|
messageManager.sendMessage(player, "error_set_home_maximum_homes", Integer.toString(HuskHomes.settings.getMaximumHomes()));
|
||||||
return;
|
return;
|
||||||
case "error_insufficient_funds":
|
case "error_insufficient_funds":
|
||||||
messageManager.sendMessage(player, "error_insufficient_funds", economy.format(Main.settings.getSetHomeCost()));
|
messageManager.sendMessage(player, "error_insufficient_funds", economy.format(HuskHomes.settings.getSetHomeCost()));
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
messageManager.sendMessage(player, setHomeConditions.getConditionsNotMetReason());
|
messageManager.sendMessage(player, setHomeConditions.getConditionsNotMetReason());
|
||||||
@@ -40,12 +52,17 @@ public class settingHandler {
|
|||||||
public static void setWarp(Location location, Player player, String name) {
|
public static void setWarp(Location location, Player player, String name) {
|
||||||
SetWarpConditions setWarpConditions = new SetWarpConditions(name);
|
SetWarpConditions setWarpConditions = new SetWarpConditions(name);
|
||||||
if (setWarpConditions.areConditionsMet()) {
|
if (setWarpConditions.areConditionsMet()) {
|
||||||
Warp warp = new Warp(location, Main.settings.getServerID(), name);
|
Warp warp = new Warp(location, HuskHomes.settings.getServerID(), name);
|
||||||
|
PlayerSetWarpEvent event = new PlayerSetWarpEvent(player, warp);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
dataManager.addWarp(warp);
|
dataManager.addWarp(warp);
|
||||||
messageManager.sendMessage(player, "set_warp_success", name);
|
messageManager.sendMessage(player, "set_warp_success", name);
|
||||||
if (Main.settings.doDynmap() && Main.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
dynamicMap.addDynamicMapMarker(warp);
|
dynamicMap.addDynamicMapMarker(warp);
|
||||||
}
|
}
|
||||||
|
warpTabCompleter.updateWarpsTabCache();
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(player, setWarpConditions.getConditionsNotMetReason());
|
messageManager.sendMessage(player, setWarpConditions.getConditionsNotMetReason());
|
||||||
}
|
}
|
||||||
@@ -54,13 +71,22 @@ public class settingHandler {
|
|||||||
// Delete a home
|
// Delete a home
|
||||||
public static void deleteHome(Player player, String homeName) {
|
public static void deleteHome(Player player, String homeName) {
|
||||||
if (dataManager.homeExists(player, homeName)) {
|
if (dataManager.homeExists(player, homeName)) {
|
||||||
|
Home home = dataManager.getHome(player.getName(), homeName);
|
||||||
|
if (home.isPublic()) {
|
||||||
// Delete dynmap marker if it exists & if the home is public
|
// Delete dynmap marker if it exists & if the home is public
|
||||||
if (Main.settings.doDynmap() && Main.settings.showPublicHomesOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
if (dataManager.getHome(player.getName(), homeName).isPublic()) {
|
|
||||||
dynamicMap.removeDynamicMapMarker(homeName, player.getName());
|
dynamicMap.removeDynamicMapMarker(homeName, player.getName());
|
||||||
}
|
}
|
||||||
|
PlayerDeleteHomeEvent event = new PlayerDeleteHomeEvent(player, home);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
dataManager.deleteHome(homeName, player);
|
dataManager.deleteHome(homeName, player);
|
||||||
|
publicHomeTabCompleter.updatePublicHomeTabCache();
|
||||||
|
} else {
|
||||||
|
dataManager.deleteHome(homeName, player);
|
||||||
|
}
|
||||||
|
homeTabCompleter.updatePlayerHomeCache(player);
|
||||||
messageManager.sendMessage(player, "home_deleted", homeName);
|
messageManager.sendMessage(player, "home_deleted", homeName);
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(player, "error_home_invalid", homeName);
|
messageManager.sendMessage(player, "error_home_invalid", homeName);
|
||||||
@@ -70,11 +96,17 @@ public class settingHandler {
|
|||||||
// Delete a warp
|
// Delete a warp
|
||||||
public static void deleteWarp(Player player, String warpName) {
|
public static void deleteWarp(Player player, String warpName) {
|
||||||
if (dataManager.warpExists(warpName)) {
|
if (dataManager.warpExists(warpName)) {
|
||||||
|
Warp warp = dataManager.getWarp(warpName);
|
||||||
|
PlayerDeleteWarpEvent event = new PlayerDeleteWarpEvent(player, warp);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
dataManager.deleteWarp(warpName);
|
dataManager.deleteWarp(warpName);
|
||||||
messageManager.sendMessage(player, "warp_deleted");
|
messageManager.sendMessage(player, "warp_deleted");
|
||||||
if (Main.settings.doDynmap() && Main.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
dynamicMap.removeDynamicMapMarker(warpName);
|
dynamicMap.removeDynamicMapMarker(warpName);
|
||||||
}
|
}
|
||||||
|
warpTabCompleter.updateWarpsTabCache();
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(player, "error_warp_invalid");
|
messageManager.sendMessage(player, "error_warp_invalid");
|
||||||
}
|
}
|
||||||
@@ -93,7 +125,7 @@ public class settingHandler {
|
|||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
|
|
||||||
// Update the current spawn location
|
// Update the current spawn location
|
||||||
teleportManager.spawnLocation = new TeleportationPoint(location, Main.settings.getServerID());
|
teleportManager.spawnLocation = new TeleportationPoint(location, HuskHomes.settings.getServerID());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update current spawn location from config
|
// Update current spawn location from config
|
||||||
@@ -103,7 +135,7 @@ public class settingHandler {
|
|||||||
|
|
||||||
// Get spawn location from config
|
// Get spawn location from config
|
||||||
private static TeleportationPoint getSpawnLocation() {
|
private static TeleportationPoint getSpawnLocation() {
|
||||||
String server = Main.settings.getServerID();
|
String server = HuskHomes.settings.getServerID();
|
||||||
try {
|
try {
|
||||||
FileConfiguration config = plugin.getConfig();
|
FileConfiguration config = plugin.getConfig();
|
||||||
String worldName = (config.getString("spawn_command.position.world"));
|
String worldName = (config.getString("spawn_command.position.world"));
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ public class teleportManager {
|
|||||||
public static TeleportationPoint spawnLocation = null;
|
public static TeleportationPoint spawnLocation = null;
|
||||||
|
|
||||||
public static void teleportPlayer(Player player, String targetPlayer) {
|
public static void teleportPlayer(Player player, String targetPlayer) {
|
||||||
dataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), Main.settings.getServerID()));
|
dataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), HuskHomes.settings.getServerID()));
|
||||||
setPlayerDestinationFromTargetPlayer(player, targetPlayer);
|
setPlayerDestinationFromTargetPlayer(player, targetPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void teleportPlayer(Player player, TeleportationPoint point) {
|
public static void teleportPlayer(Player player, TeleportationPoint point) {
|
||||||
dataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), Main.settings.getServerID()));
|
dataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), HuskHomes.settings.getServerID()));
|
||||||
dataManager.setPlayerDestinationLocation(player, point);
|
dataManager.setPlayerDestinationLocation(player, point);
|
||||||
teleportPlayer(player);
|
teleportPlayer(player);
|
||||||
}
|
}
|
||||||
@@ -31,12 +31,12 @@ public class teleportManager {
|
|||||||
TeleportationPoint teleportationPoint = dataManager.getPlayerDestination(p);
|
TeleportationPoint teleportationPoint = dataManager.getPlayerDestination(p);
|
||||||
if (teleportationPoint != null) {
|
if (teleportationPoint != null) {
|
||||||
String server = teleportationPoint.getServer();
|
String server = teleportationPoint.getServer();
|
||||||
if (!Main.settings.doBungee() || server.equals(Main.settings.getServerID())) {
|
if (!HuskHomes.settings.doBungee() || server.equals(HuskHomes.settings.getServerID())) {
|
||||||
p.teleport(teleportationPoint.getLocation());
|
p.teleport(teleportationPoint.getLocation());
|
||||||
messageManager.sendMessage(p, "teleporting_complete");
|
messageManager.sendMessage(p, "teleporting_complete");
|
||||||
dataManager.setPlayerTeleporting(p, false);
|
dataManager.setPlayerTeleporting(p, false);
|
||||||
dataManager.clearPlayerDestination(p.getName());
|
dataManager.clearPlayerDestination(p.getName());
|
||||||
} else if (Main.settings.doBungee()) {
|
} else if (HuskHomes.settings.doBungee()) {
|
||||||
dataManager.setPlayerDestinationLocation(p, teleportationPoint);
|
dataManager.setPlayerDestinationLocation(p, teleportationPoint);
|
||||||
dataManager.setPlayerTeleporting(p, true);
|
dataManager.setPlayerTeleporting(p, true);
|
||||||
pluginMessageHandler.sendPlayer(p, server);
|
pluginMessageHandler.sendPlayer(p, server);
|
||||||
@@ -73,8 +73,8 @@ public class teleportManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Main.settings.doEconomy()) {
|
if (HuskHomes.settings.doEconomy()) {
|
||||||
double rtpCost = Main.settings.getRtpCost();
|
double rtpCost = HuskHomes.settings.getRtpCost();
|
||||||
if (rtpCost > 0) {
|
if (rtpCost > 0) {
|
||||||
if (!economy.hasMoney(player, rtpCost)) {
|
if (!economy.hasMoney(player, rtpCost)) {
|
||||||
messageManager.sendMessage(player, "error_insufficient_funds", economy.format(rtpCost));
|
messageManager.sendMessage(player, "error_insufficient_funds", economy.format(rtpCost));
|
||||||
@@ -83,8 +83,8 @@ public class teleportManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (player.hasPermission("huskhomes.bypass_timer")) {
|
if (player.hasPermission("huskhomes.bypass_timer")) {
|
||||||
if (Main.settings.doEconomy()) {
|
if (HuskHomes.settings.doEconomy()) {
|
||||||
double rtpCost = Main.settings.getRtpCost();
|
double rtpCost = HuskHomes.settings.getRtpCost();
|
||||||
if (rtpCost > 0) {
|
if (rtpCost > 0) {
|
||||||
economy.takeMoney(player, rtpCost);
|
economy.takeMoney(player, rtpCost);
|
||||||
messageManager.sendMessage(player, "rtp_spent_money", economy.format(rtpCost));
|
messageManager.sendMessage(player, "rtp_spent_money", economy.format(rtpCost));
|
||||||
@@ -103,7 +103,7 @@ public class teleportManager {
|
|||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
teleportPlayer(targetPlayer, requester.getName());
|
teleportPlayer(targetPlayer, requester.getName());
|
||||||
} else {
|
} else {
|
||||||
if (Main.settings.doBungee()) {
|
if (HuskHomes.settings.doBungee()) {
|
||||||
teleportHereCrossServer(requester, targetPlayerName);
|
teleportHereCrossServer(requester, targetPlayerName);
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
messageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
||||||
@@ -123,10 +123,10 @@ public class teleportManager {
|
|||||||
Player targetPlayer = Bukkit.getPlayer(targetPlayerName);
|
Player targetPlayer = Bukkit.getPlayer(targetPlayerName);
|
||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
dataManager.setPlayerDestinationLocation(requester,
|
dataManager.setPlayerDestinationLocation(requester,
|
||||||
new TeleportationPoint(targetPlayer.getLocation(), Main.settings.getServerID()));
|
new TeleportationPoint(targetPlayer.getLocation(), HuskHomes.settings.getServerID()));
|
||||||
teleportPlayer(requester);
|
teleportPlayer(requester);
|
||||||
} else {
|
} else {
|
||||||
if (Main.settings.doBungee()) {
|
if (HuskHomes.settings.doBungee()) {
|
||||||
setTeleportationDestinationCrossServer(requester, targetPlayerName);
|
setTeleportationDestinationCrossServer(requester, targetPlayerName);
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
messageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package me.william278.huskhomes2;
|
package me.william278.huskhomes2;
|
||||||
|
|
||||||
|
import me.william278.huskhomes2.Integrations.vanishChecker;
|
||||||
import me.william278.huskhomes2.Objects.TeleportRequest;
|
import me.william278.huskhomes2.Objects.TeleportRequest;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -24,11 +25,15 @@ public class teleportRequestHandler {
|
|||||||
public static void sendTeleportToRequest(Player requester, String targetPlayerName) {
|
public static void sendTeleportToRequest(Player requester, String targetPlayerName) {
|
||||||
Player targetPlayer = Bukkit.getPlayer(targetPlayerName);
|
Player targetPlayer = Bukkit.getPlayer(targetPlayerName);
|
||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
|
if (!vanishChecker.isVanished(targetPlayer)) {
|
||||||
teleportRequests.put(targetPlayer, new TeleportRequest(requester.getName(), "tpa"));
|
teleportRequests.put(targetPlayer, new TeleportRequest(requester.getName(), "tpa"));
|
||||||
messageManager.sendMessage(requester, "tpa_request_sent", targetPlayerName);
|
messageManager.sendMessage(requester, "tpa_request_sent", targetPlayerName);
|
||||||
messageManager.sendMessage(targetPlayer, "tpa_request_ask", requester.getName());
|
messageManager.sendMessage(targetPlayer, "tpa_request_ask", requester.getName());
|
||||||
} else {
|
} else {
|
||||||
if (Main.settings.doBungee()) {
|
messageManager.sendMessage(requester, "error_player_not_found", targetPlayerName);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (HuskHomes.settings.doBungee()) {
|
||||||
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpa");
|
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpa");
|
||||||
messageManager.sendMessage(requester, "tpa_request_sent", targetPlayerName);
|
messageManager.sendMessage(requester, "tpa_request_sent", targetPlayerName);
|
||||||
} else {
|
} else {
|
||||||
@@ -44,7 +49,7 @@ public class teleportRequestHandler {
|
|||||||
messageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName);
|
messageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName);
|
||||||
messageManager.sendMessage(targetPlayer, "tpahere_request_ask", requester.getName());
|
messageManager.sendMessage(targetPlayer, "tpahere_request_ask", requester.getName());
|
||||||
} else {
|
} else {
|
||||||
if (Main.settings.doBungee()) {
|
if (HuskHomes.settings.doBungee()) {
|
||||||
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpahere");
|
sendTeleportRequestCrossServer(requester, targetPlayerName, "tpahere");
|
||||||
messageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName);
|
messageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName);
|
||||||
} else {
|
} else {
|
||||||
@@ -78,7 +83,7 @@ public class teleportRequestHandler {
|
|||||||
messageManager.sendMessage(requester, "tpa_has_declined", p.getName());
|
messageManager.sendMessage(requester, "tpa_has_declined", p.getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Main.settings.doBungee()) {
|
if (HuskHomes.settings.doBungee()) {
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
messageManager.sendMessage(p, "tpa_you_accepted", requesterName);
|
messageManager.sendMessage(p, "tpa_you_accepted", requesterName);
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.net.URLConnection;
|
|||||||
import static net.md_5.bungee.api.chat.ClickEvent.Action.OPEN_URL;
|
import static net.md_5.bungee.api.chat.ClickEvent.Action.OPEN_URL;
|
||||||
|
|
||||||
public class versionChecker {
|
public class versionChecker {
|
||||||
private static final Main plugin = Main.getInstance();
|
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||||
|
|
||||||
public static void adminVersionCheck(Player p) {
|
public static void adminVersionCheck(Player p) {
|
||||||
if (p.hasPermission("huskhomes.version_checker")) {
|
if (p.hasPermission("huskhomes.version_checker")) {
|
||||||
|
|||||||
@@ -50,3 +50,4 @@ economy_integration:
|
|||||||
additional_home_slot: 100
|
additional_home_slot: 100
|
||||||
make_home_public: 50
|
make_home_public: 50
|
||||||
random_teleport: 20
|
random_teleport: 20
|
||||||
|
handle_vanished_players: true
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
name: HuskHomes
|
name: HuskHomes
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
main: me.william278.huskhomes2.Main
|
main: me.william278.huskhomes2.HuskHomes
|
||||||
api-version: 1.16
|
api-version: 1.16
|
||||||
authors: [William278]
|
authors: [William278]
|
||||||
softdepend: [dynmap, Vault]
|
softdepend: [dynmap, Vault]
|
||||||
|
|||||||
Reference in new issue
Block a user