Essentials/Essentials/src/main/java/com/earth2me/essentials/IUser.java

214 lines
5.2 KiB
Java
Raw Normal View History

package com.earth2me.essentials;
Reduce sync loads for teleporting (#3102) This PR reduces the number of sync loads occurring on any teleport caused by essentials. Fixes #2861 Fixes #2287 Fixes #3274 Fixes #3201 Fixes #2120 Before this PR, essentials would get a block multiple times causing sync loads to check if it was safe to teleport to. Now, the target block's chunk if fetched async with PaperLib and passed along to `LocationUtil#isBlockUnsafeForUser` (which internally calls other LocationUtil methods what that chunk object) resulting in the chunk only loading once, off the main thread. The only operations remaining on the main thread is `LocationUtil#getSafeDestination`. This is due to the method's recursion which would be a pain to move async. **However:** since the chunk was already loaded async, `LocationUtil#getSafeDestination` most of the time won't cause sync chunk loads. The only time it would cause sync chunk loads is with an unsafe location near a chunk border. ----------------------------------------- * Reduce sync teleporting loads * Avoid argument re-assigning * Remove async teleports when unnecessary * Make exceptions cleaner * Async all the things Made an async version of every method with fallbacks for deprecated methods. * Remove old now fallback method * Migrate everything to the new async teleport API * Update ITeleport javadocs * Fix invoking via async context * Fix /jail using deprecated method * Fix jail join handler using deprecated method * Rename all teleport classes to indicate async * Remove deprecated methods * Add (and deprecate) old teleport api * Revert TimedTeleport.java * Reduce Diff * Add legacy sendToJail method * Reduce Diff Further * Use getNewExceptionFuture in Commandtpo * Use getNewExceptionFuture everywhere * Fix even more usages * Revert LocationUtil.java * Fix issue causing unsafe locations to not work properly * Add deprecated notice in IUser implementation * Use CompletableFuture#completeExceptionally for exceptions * Use Essentials' logger in EssentialsCommand#showError * Return implementation rather than interface * Avoid possible deadlocks with entity ejections * Nuke some sync loads with homes Took 7 hours and 2 PRs to paper but it's here! * Fix ABI and make the codestyle worse * Make the codestyle worse because muh diff * Further ruin the codestyle * Fix error messages not showing in TimedTeleports * Improve messages around beds for /home * Fix #3274 Allow unsafe locations for different worlds + spectator mode * Fix fly safety operators
2020-06-24 10:52:25 +02:00
import com.earth2me.essentials.api.IAsyncTeleport;
import com.earth2me.essentials.commands.IEssentialsCommand;
import net.ess3.api.ITeleport;
import net.ess3.api.MaxMoneyException;
2020-03-13 03:08:11 +01:00
import net.ess3.api.events.AfkStatusChangeEvent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
2015-04-15 06:06:16 +02:00
import java.math.BigDecimal;
import java.util.Date;
2015-04-15 06:06:16 +02:00
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
2015-04-15 06:06:16 +02:00
2020-10-04 18:03:52 +02:00
/**
* Provides access to the user abstraction and stored data. Maintainers should add methods to <i>this interface</i>.
*
* @deprecated External plugins should use {@link net.ess3.api.IUser} instead of this interface, in case future APIs are added.
*/
@Deprecated
2015-04-15 06:06:16 +02:00
public interface IUser {
boolean isAuthorized(String node);
2015-04-15 06:06:16 +02:00
boolean isAuthorized(IEssentialsCommand cmd);
2015-04-15 06:06:16 +02:00
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
boolean isPermissionSet(String node);
2015-04-15 06:06:16 +02:00
void healCooldown() throws Exception;
2015-04-15 06:06:16 +02:00
void giveMoney(BigDecimal value) throws MaxMoneyException;
2015-04-15 06:06:16 +02:00
void giveMoney(final BigDecimal value, final CommandSource initiator) throws MaxMoneyException;
2015-04-15 06:06:16 +02:00
void payUser(final User reciever, final BigDecimal value) throws Exception;
2015-04-15 06:06:16 +02:00
void takeMoney(BigDecimal value);
2015-04-15 06:06:16 +02:00
void takeMoney(final BigDecimal value, final CommandSource initiator);
2015-04-15 06:06:16 +02:00
boolean canAfford(BigDecimal value);
Boolean canSpawnItem(final Material material);
2015-04-15 06:06:16 +02:00
void setLastLocation();
2015-04-15 06:06:16 +02:00
void setLogoutLocation();
2015-04-15 06:06:16 +02:00
void requestTeleport(final User player, final boolean here);
2013-07-14 13:41:27 +02:00
/**
* Returns whether this user has an outstanding teleport request to deal with.
*
* @return whether there is a teleport request
*/
boolean hasOutstandingTeleportRequest();
Reduce sync loads for teleporting (#3102) This PR reduces the number of sync loads occurring on any teleport caused by essentials. Fixes #2861 Fixes #2287 Fixes #3274 Fixes #3201 Fixes #2120 Before this PR, essentials would get a block multiple times causing sync loads to check if it was safe to teleport to. Now, the target block's chunk if fetched async with PaperLib and passed along to `LocationUtil#isBlockUnsafeForUser` (which internally calls other LocationUtil methods what that chunk object) resulting in the chunk only loading once, off the main thread. The only operations remaining on the main thread is `LocationUtil#getSafeDestination`. This is due to the method's recursion which would be a pain to move async. **However:** since the chunk was already loaded async, `LocationUtil#getSafeDestination` most of the time won't cause sync chunk loads. The only time it would cause sync chunk loads is with an unsafe location near a chunk border. ----------------------------------------- * Reduce sync teleporting loads * Avoid argument re-assigning * Remove async teleports when unnecessary * Make exceptions cleaner * Async all the things Made an async version of every method with fallbacks for deprecated methods. * Remove old now fallback method * Migrate everything to the new async teleport API * Update ITeleport javadocs * Fix invoking via async context * Fix /jail using deprecated method * Fix jail join handler using deprecated method * Rename all teleport classes to indicate async * Remove deprecated methods * Add (and deprecate) old teleport api * Revert TimedTeleport.java * Reduce Diff * Add legacy sendToJail method * Reduce Diff Further * Use getNewExceptionFuture in Commandtpo * Use getNewExceptionFuture everywhere * Fix even more usages * Revert LocationUtil.java * Fix issue causing unsafe locations to not work properly * Add deprecated notice in IUser implementation * Use CompletableFuture#completeExceptionally for exceptions * Use Essentials' logger in EssentialsCommand#showError * Return implementation rather than interface * Avoid possible deadlocks with entity ejections * Nuke some sync loads with homes Took 7 hours and 2 PRs to paper but it's here! * Fix ABI and make the codestyle worse * Make the codestyle worse because muh diff * Further ruin the codestyle * Fix error messages not showing in TimedTeleports * Improve messages around beds for /home * Fix #3274 Allow unsafe locations for different worlds + spectator mode * Fix fly safety operators
2020-06-24 10:52:25 +02:00
/**
* @deprecated This API is not asynchronous. Use {@link com.earth2me.essentials.api.IAsyncTeleport IAsyncTeleport} with {@link IUser#getAsyncTeleport()}
*/
@Deprecated
2015-04-15 06:06:16 +02:00
ITeleport getTeleport();
2013-07-14 13:41:27 +02:00
Reduce sync loads for teleporting (#3102) This PR reduces the number of sync loads occurring on any teleport caused by essentials. Fixes #2861 Fixes #2287 Fixes #3274 Fixes #3201 Fixes #2120 Before this PR, essentials would get a block multiple times causing sync loads to check if it was safe to teleport to. Now, the target block's chunk if fetched async with PaperLib and passed along to `LocationUtil#isBlockUnsafeForUser` (which internally calls other LocationUtil methods what that chunk object) resulting in the chunk only loading once, off the main thread. The only operations remaining on the main thread is `LocationUtil#getSafeDestination`. This is due to the method's recursion which would be a pain to move async. **However:** since the chunk was already loaded async, `LocationUtil#getSafeDestination` most of the time won't cause sync chunk loads. The only time it would cause sync chunk loads is with an unsafe location near a chunk border. ----------------------------------------- * Reduce sync teleporting loads * Avoid argument re-assigning * Remove async teleports when unnecessary * Make exceptions cleaner * Async all the things Made an async version of every method with fallbacks for deprecated methods. * Remove old now fallback method * Migrate everything to the new async teleport API * Update ITeleport javadocs * Fix invoking via async context * Fix /jail using deprecated method * Fix jail join handler using deprecated method * Rename all teleport classes to indicate async * Remove deprecated methods * Add (and deprecate) old teleport api * Revert TimedTeleport.java * Reduce Diff * Add legacy sendToJail method * Reduce Diff Further * Use getNewExceptionFuture in Commandtpo * Use getNewExceptionFuture everywhere * Fix even more usages * Revert LocationUtil.java * Fix issue causing unsafe locations to not work properly * Add deprecated notice in IUser implementation * Use CompletableFuture#completeExceptionally for exceptions * Use Essentials' logger in EssentialsCommand#showError * Return implementation rather than interface * Avoid possible deadlocks with entity ejections * Nuke some sync loads with homes Took 7 hours and 2 PRs to paper but it's here! * Fix ABI and make the codestyle worse * Make the codestyle worse because muh diff * Further ruin the codestyle * Fix error messages not showing in TimedTeleports * Improve messages around beds for /home * Fix #3274 Allow unsafe locations for different worlds + spectator mode * Fix fly safety operators
2020-06-24 10:52:25 +02:00
IAsyncTeleport getAsyncTeleport();
2015-04-15 06:06:16 +02:00
BigDecimal getMoney();
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
void setMoney(final BigDecimal value) throws MaxMoneyException;
2013-07-14 13:41:27 +02:00
2020-03-13 03:08:11 +01:00
void setAfk(final boolean set, final AfkStatusChangeEvent.Cause cause);
2015-04-15 06:06:16 +02:00
/**
* 'Hidden' Represents when a player is hidden from others. This status includes when the player is hidden via other
* supported plugins. Use isVanished() if you want to check if a user is vanished by Essentials.
*
* @return If the user is hidden or not
* @see IUser#isVanished()
2015-04-15 06:06:16 +02:00
*/
boolean isHidden();
2015-04-15 06:06:16 +02:00
void setHidden(boolean vanish);
2015-04-15 06:06:16 +02:00
boolean isGodModeEnabled();
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
String getGroup();
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
boolean inGroup(final String group);
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
boolean canBuild();
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
long getTeleportRequestTime();
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
void enableInvulnerabilityAfterTeleport();
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
void resetInvulnerabilityAfterTeleport();
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
boolean hasInvulnerabilityAfterTeleport();
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
/**
* 'Vanished' Represents when a player is hidden from others by Essentials. This status does NOT include when the
* player is hidden via other plugins. Use isHidden() if you want to check if a user is vanished by any supported
* plugin.
*
* @return If the user is vanished or not
* @see IUser#isHidden()
2015-04-15 06:06:16 +02:00
*/
boolean isVanished();
2015-04-15 06:06:16 +02:00
void setVanished(boolean vanish);
2015-04-15 06:06:16 +02:00
boolean isIgnoreExempt();
2015-06-03 22:11:56 +02:00
void sendMessage(String message);
2015-04-15 06:06:16 +02:00
/*
* UserData
*/
Location getHome(String name) throws Exception;
2015-04-15 06:06:16 +02:00
Location getHome(Location loc) throws Exception;
2015-04-15 06:06:16 +02:00
List<String> getHomes();
2015-04-15 06:06:16 +02:00
void setHome(String name, Location loc);
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
void delHome(String name) throws Exception;
2015-04-15 06:06:16 +02:00
boolean hasHome();
2015-04-15 06:06:16 +02:00
Location getLastLocation();
2015-04-15 06:06:16 +02:00
Location getLogoutLocation();
2015-04-15 06:06:16 +02:00
long getLastTeleportTimestamp();
2013-07-14 13:41:27 +02:00
2015-04-15 06:06:16 +02:00
void setLastTeleportTimestamp(long time);
2015-04-15 06:06:16 +02:00
String getJail();
2015-04-15 06:06:16 +02:00
void setJail(String jail);
2015-04-15 06:06:16 +02:00
List<String> getMails();
2015-04-15 06:06:16 +02:00
void addMail(String mail);
2015-04-15 06:06:16 +02:00
boolean isAfk();
2020-10-03 19:46:05 +02:00
@Deprecated
void setAfk(final boolean set);
2015-07-29 03:45:33 +02:00
boolean isIgnoreMsg();
2020-10-03 19:46:05 +02:00
void setIgnoreMsg(boolean ignoreMsg);
2015-04-15 06:06:16 +02:00
void setConfigProperty(String node, Object object);
2015-04-15 06:06:16 +02:00
Set<String> getConfigKeys();
2015-04-15 06:06:16 +02:00
Map<String, Object> getConfigMap();
2015-04-15 06:06:16 +02:00
Map<String, Object> getConfigMap(String node);
2020-10-03 19:46:05 +02:00
Map<Pattern, Long> getCommandCooldowns();
Date getCommandCooldownExpiry(String label);
2020-10-03 19:46:05 +02:00
void addCommandCooldown(Pattern pattern, Date expiresAt, boolean save);
2020-10-03 19:46:05 +02:00
boolean clearCommandCooldown(Pattern pattern);
2015-04-15 06:06:16 +02:00
/*
* PlayerExtension
*/
Player getBase();
2015-04-15 06:06:16 +02:00
CommandSource getSource();
2015-06-03 22:11:56 +02:00
String getName();
2016-06-18 22:38:20 +02:00
String getDisplayName();
String getAfkMessage();
void setAfkMessage(final String message);
2020-10-03 19:46:05 +02:00
long getAfkSince();
2020-10-03 19:46:05 +02:00
boolean isAcceptingPay();
2020-10-03 19:46:05 +02:00
void setAcceptingPay(boolean acceptingPay);
2020-10-03 19:46:05 +02:00
boolean isPromptingPayConfirm();
2020-10-03 19:46:05 +02:00
void setPromptingPayConfirm(boolean prompt);
2020-10-03 19:46:05 +02:00
boolean isPromptingClearConfirm();
2020-10-03 19:46:05 +02:00
void setPromptingClearConfirm(boolean prompt);
boolean isLastMessageReplyRecipient();
void setLastMessageReplyRecipient(boolean enabled);
Map<User, BigDecimal> getConfirmingPayments();
Block getTargetBlock(int maxDistance);
}