mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-01-31 04:21:40 +01:00
chore: pre-commit changes [skip ci]
This commit is contained in:
parent
dfacc7fbf3
commit
414cda8d25
@ -20,7 +20,8 @@ public class BungeeProxyContainer implements ProxyContainer {
|
||||
String command) {
|
||||
// Should never not be true but just to be safe
|
||||
if (proxyPlayer instanceof BungeeProxyPlayerContainer) {
|
||||
BungeeProxyPlayerContainer playerContainer = (BungeeProxyPlayerContainer) proxyPlayer;
|
||||
BungeeProxyPlayerContainer playerContainer =
|
||||
(BungeeProxyPlayerContainer) proxyPlayer;
|
||||
plugin.getProxy().getPluginManager().dispatchCommand(
|
||||
playerContainer.getPlayer(), command);
|
||||
}
|
||||
@ -31,7 +32,8 @@ public class BungeeProxyContainer implements ProxyContainer {
|
||||
String serverName) {
|
||||
// Should never not be true but just to be safe
|
||||
if (proxyPlayer instanceof BungeeProxyPlayerContainer) {
|
||||
BungeeProxyPlayerContainer playerContainer = (BungeeProxyPlayerContainer) proxyPlayer;
|
||||
BungeeProxyPlayerContainer playerContainer =
|
||||
(BungeeProxyPlayerContainer) proxyPlayer;
|
||||
ServerInfo serverInfo = plugin.getProxy().getServerInfo(serverName);
|
||||
ProxiedPlayer player = playerContainer.getPlayer();
|
||||
if (serverInfo == null) {
|
||||
|
@ -218,7 +218,8 @@ public class AdvancedPortalsCore {
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
for (PlayerContainer playerContainer : this.serverContainer.getPlayers()) {
|
||||
for (PlayerContainer playerContainer :
|
||||
this.serverContainer.getPlayers()) {
|
||||
playerDataRepository.playerLeave(playerContainer);
|
||||
}
|
||||
this.infoLogger.info(Lang.translate("logger.plugindisable"));
|
||||
|
@ -70,13 +70,13 @@ public class CoreListeners {
|
||||
String messageType = buffer.readUTF();
|
||||
|
||||
switch (messageType) {
|
||||
case ProxyMessages.SERVER_DESTI:
|
||||
{
|
||||
ServerDestiPacket serverDestiPacket = ServerDestiPacket.decode(buffer);
|
||||
this.destinationServices.teleportToDestination(serverDestiPacket.getDestination(), player, true);
|
||||
case ProxyMessages.SERVER_DESTI: {
|
||||
ServerDestiPacket serverDestiPacket =
|
||||
ServerDestiPacket.decode(buffer);
|
||||
this.destinationServices.teleportToDestination(
|
||||
serverDestiPacket.getDestination(), player, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@ -88,7 +88,8 @@ public class CoreListeners {
|
||||
* @param toLoc
|
||||
*/
|
||||
public void playerMove(PlayerContainer player, PlayerLocation toLoc) {
|
||||
this.portalServices.checkPortalActivation(player, toLoc, TriggerType.MOVEMENT);
|
||||
this.portalServices.checkPortalActivation(player, toLoc,
|
||||
TriggerType.MOVEMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,7 +133,8 @@ public class CoreListeners {
|
||||
if (itemInHandName.equals("\u00A75Portal Block Placer")) {
|
||||
world.setBlock(blockPos, "NETHER_PORTAL");
|
||||
for (Direction direction : Direction.values()) {
|
||||
BlockLocation checkLoc = new BlockLocation(blockPos, direction);
|
||||
BlockLocation checkLoc =
|
||||
new BlockLocation(blockPos, direction);
|
||||
if (world.getBlock(checkLoc).equals("NETHER_PORTAL")) {
|
||||
world.setBlockAxis(blockPos,
|
||||
world.getBlockAxis(checkLoc));
|
||||
@ -140,12 +142,11 @@ public class CoreListeners {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (itemInHandName.equals("\u00A78End Portal Block Placer")) {
|
||||
} else if (itemInHandName.equals(
|
||||
"\u00A78End Portal Block Placer")) {
|
||||
world.setBlock(blockPos, "END_PORTAL");
|
||||
return true;
|
||||
}
|
||||
else if (itemInHandName.equals("\u00A78Gateway Block Placer")) {
|
||||
} else if (itemInHandName.equals("\u00A78Gateway Block Placer")) {
|
||||
world.setBlock(blockPos, "END_GATEWAY");
|
||||
world.disableBeacon(blockPos);
|
||||
return true;
|
||||
@ -160,27 +161,29 @@ public class CoreListeners {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* If the block is allowed to be interacted with e.g. a lever
|
||||
* @player player causing the event (or null if not a player)
|
||||
* @param blockPos
|
||||
* @return
|
||||
*/
|
||||
public boolean blockInteract(PlayerContainer player, BlockLocation blockPos) {
|
||||
public boolean blockInteract(PlayerContainer player,
|
||||
BlockLocation blockPos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param player
|
||||
* @param blockLoc
|
||||
* @param leftClick true = left click, false = right click
|
||||
* @return if player is allowed to interact with block
|
||||
*/
|
||||
public boolean playerInteractWithBlock(PlayerContainer player,
|
||||
public boolean playerInteractWithBlock(PlayerContainer player,
|
||||
String blockMaterialname,
|
||||
String itemMaterialName, String itemName,
|
||||
String itemMaterialName,
|
||||
String itemName,
|
||||
BlockLocation blockLoc,
|
||||
boolean leftClick) {
|
||||
if (itemName != null && Permissions.CREATE_PORTAL.hasPermission(player)
|
||||
@ -208,20 +211,20 @@ public boolean playerInteractWithBlock(PlayerContainer player,
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void worldChange(PlayerContainer player) {
|
||||
public void worldChange(PlayerContainer player) {
|
||||
this.playerDataServices.setJoinCooldown(player);
|
||||
this.setIfInPortal(player);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean preventEntityCombust(EntityContainer entity) {
|
||||
public boolean preventEntityCombust(EntityContainer entity) {
|
||||
return portalServices.inPortalRegion(entity.getBlockLoc(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean entityPortalEvent(EntityContainer entity) {
|
||||
public boolean entityPortalEvent(EntityContainer entity) {
|
||||
BlockLocation pos = entity.getBlockLoc();
|
||||
if (entity instanceof PlayerContainer ) {
|
||||
if (entity instanceof PlayerContainer) {
|
||||
PlayerContainer player = (PlayerContainer) entity;
|
||||
PlayerData playerData = playerDataServices.getPlayerData(player);
|
||||
if (playerData.getPortalBlockCooldown()) {
|
||||
@ -232,35 +235,38 @@ public boolean entityPortalEvent(EntityContainer entity) {
|
||||
return !(portalServices.inPortalRegion(pos, 1)
|
||||
|| portalServices.inPortalRegion(
|
||||
pos.addY((int) entity.getHeight()), 1));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean playerPortalEvent(PlayerContainer player, PlayerLocation toLoc) {
|
||||
public boolean playerPortalEvent(PlayerContainer player,
|
||||
PlayerLocation toLoc) {
|
||||
PlayerData playerData = playerDataServices.getPlayerData(player);
|
||||
|
||||
if (playerData.getPortalBlockCooldown()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PortalServices.PortalActivationResult portalResult = this.portalServices.checkPortalActivation(
|
||||
player, toLoc, TriggerType.PORTAL);
|
||||
PortalServices.PortalActivationResult portalResult =
|
||||
this.portalServices.checkPortalActivation(player, toLoc,
|
||||
TriggerType.PORTAL);
|
||||
|
||||
if (portalResult != PortalServices.PortalActivationResult.NOT_IN_PORTAL) {
|
||||
if (portalResult
|
||||
!= PortalServices.PortalActivationResult.NOT_IN_PORTAL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extra checks to prevent the player from being teleported by touching a
|
||||
// portal but not having their body fully in the portal
|
||||
// Extra checks to prevent the player from being teleported by touching
|
||||
// a portal but not having their body fully in the portal
|
||||
BlockLocation pos = player.getBlockLoc();
|
||||
|
||||
boolean feetInPortal = portalServices.inPortalRegion(pos, 1);
|
||||
boolean headInPortal =
|
||||
portalServices.inPortalRegion(pos.addY((int) player.getHeight()), 1);
|
||||
boolean headInPortal = portalServices.inPortalRegion(
|
||||
pos.addY((int) player.getHeight()), 1);
|
||||
|
||||
return !(feetInPortal || headInPortal);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean physicsEvent(BlockLocation blockLocation, String string) {
|
||||
public boolean physicsEvent(BlockLocation blockLocation, String string) {
|
||||
return !configRepository.getDisablePhysicsEvents()
|
||||
|| !portalServices.inPortalRegionProtected(blockLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,9 @@ public class CommandWithSubCommands implements CommandTemplate {
|
||||
boolean result =
|
||||
this.subCommandRegistry.registerSubCommand(arg, subCommand)
|
||||
|| hasRegistered;
|
||||
if (subCommand instanceof SubCommand.SubCommandOnInit ) {
|
||||
SubCommand.SubCommandOnInit init = (SubCommand.SubCommandOnInit) subCommand;
|
||||
if (subCommand instanceof SubCommand.SubCommandOnInit) {
|
||||
SubCommand.SubCommandOnInit init =
|
||||
(SubCommand.SubCommandOnInit) subCommand;
|
||||
init.registered();
|
||||
}
|
||||
return result;
|
||||
|
@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.serializeddata.DataTag;
|
||||
import com.sekwah.advancedportals.core.util.TagReader;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -47,14 +46,14 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (tag instanceof Tag.AutoComplete
|
||||
&& startsWith) {
|
||||
if (tag instanceof Tag.AutoComplete && startsWith) {
|
||||
Tag.AutoComplete autoComplete = (Tag.AutoComplete) tag;
|
||||
String argData = split.length == 2 ? split[1] : "";
|
||||
List<String> tagSuggestions = autoComplete.autoComplete(argData);
|
||||
List<String> tagSuggestions =
|
||||
autoComplete.autoComplete(argData);
|
||||
|
||||
if (tagSuggestions != null) {
|
||||
if (tag instanceof Tag.Split ) {
|
||||
if (tag instanceof Tag.Split) {
|
||||
Tag.Split splitTag = (Tag.Split) tag;
|
||||
String multiTagSplit = splitTag.splitString();
|
||||
boolean endsWithSplit =
|
||||
@ -76,8 +75,7 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
|
||||
? argData
|
||||
: argData.substring(
|
||||
0,
|
||||
argData.lastIndexOf(multiTagSplit)
|
||||
+ 1);
|
||||
argData.lastIndexOf(multiTagSplit) + 1);
|
||||
|
||||
tagSuggestions =
|
||||
tagSuggestions
|
||||
@ -129,7 +127,8 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
|
||||
suggestions.add(tag.getName());
|
||||
String[] aliases = tag.getAliases();
|
||||
if (aliases != null) {
|
||||
suggestions.addAll(Arrays.stream(aliases).collect(Collectors.toList()));
|
||||
suggestions.addAll(
|
||||
Arrays.stream(aliases).collect(Collectors.toList()));
|
||||
}
|
||||
});
|
||||
|
||||
@ -145,7 +144,7 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
|
||||
|
||||
for (DataTag dataTag : dataTags) {
|
||||
for (Tag tag : relatedTags) {
|
||||
if (tag instanceof Tag.Split ) {
|
||||
if (tag instanceof Tag.Split) {
|
||||
Tag.Split splitTag = (Tag.Split) tag;
|
||||
String splitString = splitTag.splitString();
|
||||
if (splitString != null) {
|
||||
|
@ -75,7 +75,7 @@ public class Destination implements TagTarget {
|
||||
|
||||
this.destiTags.sort(Comparator.comparingInt(o -> {
|
||||
Tag tag = tagRegistry.getTag(o.NAME);
|
||||
if (tag instanceof Tag.OrderPriority ) {
|
||||
if (tag instanceof Tag.OrderPriority) {
|
||||
Tag.OrderPriority tagPriority = (Tag.OrderPriority) tag;
|
||||
return tagPriority.getPriority().ordinal();
|
||||
} else {
|
||||
|
@ -100,7 +100,8 @@ public class PermissionBuilder {
|
||||
case NOT_OP:
|
||||
return !sender.isOp();
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + permissionDefault);
|
||||
throw new IllegalStateException("Unexpected value: "
|
||||
+ permissionDefault);
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,10 +126,5 @@ public class PermissionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum PermissionDefault {
|
||||
TRUE,
|
||||
FALSE,
|
||||
OP,
|
||||
NOT_OP
|
||||
}
|
||||
public enum PermissionDefault { TRUE, FALSE, OP, NOT_OP }
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class AdvancedPortal implements TagTarget {
|
||||
// sort the tags by priority
|
||||
this.portalTags.sort(Comparator.comparingInt(o -> {
|
||||
Tag tag = tagRegistry.getTag(o.NAME);
|
||||
if (tag instanceof Tag.OrderPriority ) {
|
||||
if (tag instanceof Tag.OrderPriority) {
|
||||
Tag.OrderPriority tagPriority = (Tag.OrderPriority) tag;
|
||||
return tagPriority.getPriority().ordinal();
|
||||
} else {
|
||||
@ -172,8 +172,10 @@ public class AdvancedPortal implements TagTarget {
|
||||
|
||||
if (!preActivated) {
|
||||
if (activationHandler instanceof Tag.DenyBehavior) {
|
||||
Tag.DenyBehavior denyBehaviorHandler = (Tag.DenyBehavior) activationHandler;
|
||||
if (denyBehaviorHandler.getDenyBehavior().equals(Tag.DenyBehavior.Behaviour.SILENT)) {
|
||||
Tag.DenyBehavior denyBehaviorHandler =
|
||||
(Tag.DenyBehavior) activationHandler;
|
||||
if (denyBehaviorHandler.getDenyBehavior().equals(
|
||||
Tag.DenyBehavior.Behaviour.SILENT)) {
|
||||
return ActivationResult.FAILED_DO_NOTHING;
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ public class PortalRepositoryImpl implements IPortalRepository {
|
||||
|
||||
@Override
|
||||
public AdvancedPortal get(String name) {
|
||||
AdvancedPortal portal = dataStorage.loadFile(AdvancedPortal.class,
|
||||
fileLocation + name + ".yaml");
|
||||
AdvancedPortal portal = dataStorage.loadFile(
|
||||
AdvancedPortal.class, fileLocation + name + ".yaml");
|
||||
if (portal != null) {
|
||||
AdvancedPortalsCore.getInstance()
|
||||
.getModule()
|
||||
|
@ -41,7 +41,8 @@ public class DataStorage {
|
||||
ReflectiveRepresenter representer = new ReflectiveRepresenter(options);
|
||||
representer.addClassTag(clazz, Tag.MAP);
|
||||
representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
ReflectiveConstructor constructor = new ReflectiveConstructor(clazz, loaderOptions);
|
||||
ReflectiveConstructor constructor =
|
||||
new ReflectiveConstructor(clazz, loaderOptions);
|
||||
|
||||
AdvancedPortalsCore.getInstance()
|
||||
.getModule()
|
||||
|
@ -72,7 +72,8 @@ public class ReflectiveConstructor<T> extends Constructor {
|
||||
Node node = tuple.getValueNode();
|
||||
|
||||
if (node instanceof ScalarNode) {
|
||||
Object constructedItem = constructFromScalarNode((ScalarNode) node);
|
||||
Object constructedItem =
|
||||
constructFromScalarNode((ScalarNode) node);
|
||||
values.put(key, constructedItem);
|
||||
} else if (node instanceof SequenceNode) {
|
||||
SequenceNode sequenceNode = (SequenceNode) node;
|
||||
@ -131,8 +132,8 @@ public class ReflectiveConstructor<T> extends Constructor {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
infoLogger.warning("Failed to set field " + field.getName()
|
||||
+ " in " + currentClass.getName()
|
||||
+ ": " + e.getMessage());
|
||||
+ " in " + currentClass.getName() + ": "
|
||||
+ e.getMessage());
|
||||
infoLogger.error(e);
|
||||
throw new RuntimeException("Failed to set field "
|
||||
+ field.getName() + " in "
|
||||
|
@ -154,13 +154,15 @@ public class DestinationServices {
|
||||
|
||||
player.teleport(this.destinationRepository.get(name).getLoc());
|
||||
if (doEffect && configRepository.getWarpEffectEnabled()) {
|
||||
WarpEffect.Visual warpEffectVisual = warpEffectRegistry.getVisualEffect(
|
||||
WarpEffect.Visual warpEffectVisual =
|
||||
warpEffectRegistry.getVisualEffect(
|
||||
configRepository.getWarpVisual());
|
||||
if (warpEffectVisual != null) {
|
||||
warpEffectVisual.onWarpVisual(player,
|
||||
WarpEffect.Action.ENTER);
|
||||
}
|
||||
WarpEffect.Sound warpEffectSound = warpEffectRegistry.getSoundEffect(
|
||||
WarpEffect.Sound warpEffectSound =
|
||||
warpEffectRegistry.getSoundEffect(
|
||||
configRepository.getWarpSound());
|
||||
if (warpEffectSound != null) {
|
||||
warpEffectSound.onWarpSound(player,
|
||||
|
@ -27,7 +27,8 @@ public final class PlayerDataServices {
|
||||
|
||||
public PlayerData getPlayerData(PlayerContainer player) {
|
||||
return tempDataMap.computeIfAbsent(player.getUUID(), uuid -> {
|
||||
PlayerData tempData = tempDataRepository.get(player.getUUID().toString());
|
||||
PlayerData tempData =
|
||||
tempDataRepository.get(player.getUUID().toString());
|
||||
|
||||
if (tempData == null) {
|
||||
tempData = new PlayerData();
|
||||
|
@ -131,7 +131,8 @@ public class PortalServices {
|
||||
return PortalActivationResult.PORTAL_ACTIVATED;
|
||||
case FAILED_DO_KNOCKBACK:
|
||||
playerData.setInPortal(portal.getName());
|
||||
double strength = configRepository.getThrowbackStrength();
|
||||
double strength =
|
||||
configRepository.getThrowbackStrength();
|
||||
PlayerUtils.throwPlayerBack(player, strength);
|
||||
return PortalActivationResult.PORTAL_DENIED;
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||
@Override
|
||||
public boolean preActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activeData, String[] argData) {
|
||||
CommandPortalConfig commandPortals = configRepository.getCommandPortals();
|
||||
CommandPortalConfig commandPortals =
|
||||
configRepository.getCommandPortals();
|
||||
|
||||
if (!commandPortals.enabled) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
@ -156,7 +157,9 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||
public boolean created(TagTarget target, PlayerContainer player,
|
||||
String[] argData) {
|
||||
if (argData != null) {
|
||||
com.sekwah.advancedportals.core.serializeddata.config.CommandPortalConfig commandPortals = configRepository.getCommandPortals();
|
||||
com.sekwah.advancedportals.core.serializeddata.config
|
||||
.CommandPortalConfig commandPortals =
|
||||
configRepository.getCommandPortals();
|
||||
if (!commandPortals.enabled) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("tag.command.disabled"));
|
||||
@ -167,37 +170,51 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||
switch (executionCommand) {
|
||||
case '!':
|
||||
if (!commandPortals.op) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
player.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translate("tag.command.op.disabled"));
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.CREATE_COMMAND_OP.hasPermission(player)) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables("tag.command.nopermission", "OP"));
|
||||
if (!Permissions.CREATE_COMMAND_OP.hasPermission(
|
||||
player)) {
|
||||
player.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables(
|
||||
"tag.command.nopermission", "OP"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case '#':
|
||||
if (!commandPortals.console) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("tag.command.console.disabled"));
|
||||
player.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translate(
|
||||
"tag.command.console.disabled"));
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.CREATE_COMMAND_CONSOLE.hasPermission(player)) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables("tag.command.nopermission", "Console"));
|
||||
if (!Permissions.CREATE_COMMAND_CONSOLE.hasPermission(
|
||||
player)) {
|
||||
player.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables(
|
||||
"tag.command.nopermission", "Console"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case '^':
|
||||
if (!commandPortals.permsWildcard) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("tag.command.permswildcard.disabled"));
|
||||
player.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translate(
|
||||
"tag.command.permswildcard.disabled"));
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.CREATE_COMMAND_PERMS.hasPermission(player)) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables("tag.command.nopermission", "*"));
|
||||
if (!Permissions.CREATE_COMMAND_PERMS.hasPermission(
|
||||
player)) {
|
||||
player.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables(
|
||||
"tag.command.nopermission", "*"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -210,14 +227,10 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyed(TagTarget target, PlayerContainer player, String[] argData) {
|
||||
public void destroyed(TagTarget target, PlayerContainer player,
|
||||
String[] argData) {
|
||||
// Needs created but not destroyed
|
||||
}
|
||||
|
||||
public enum CommandLevel{
|
||||
OP,
|
||||
PERMISSION_WILDCARD,
|
||||
CONSOLE,
|
||||
PLAYER
|
||||
}
|
||||
public enum CommandLevel { OP, PERMISSION_WILDCARD, CONSOLE, PLAYER }
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ public class CooldownTag implements Tag.Activation, Tag.Creation {
|
||||
if (activationData.hasActivated()) {
|
||||
if (target instanceof AdvancedPortal) {
|
||||
AdvancedPortal portal = (AdvancedPortal) target;
|
||||
PlayerData playerData = playerDataServices.getPlayerData(player);
|
||||
PlayerData playerData =
|
||||
playerDataServices.getPlayerData(player);
|
||||
try {
|
||||
playerData.setPortalCooldown(
|
||||
portal.getName(), Integer.parseInt(argData[0]) * 1000);
|
||||
|
@ -151,9 +151,11 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
|
||||
}
|
||||
|
||||
if (destination != null) {
|
||||
WarpEffect.Visual warpEffectVisual = warpEffectRegistry.getVisualEffect(
|
||||
WarpEffect.Visual warpEffectVisual =
|
||||
warpEffectRegistry.getVisualEffect(
|
||||
configRepository.getWarpVisual());
|
||||
WarpEffect.Sound warpEffectSound = warpEffectRegistry.getSoundEffect(
|
||||
WarpEffect.Sound warpEffectSound =
|
||||
warpEffectRegistry.getSoundEffect(
|
||||
configRepository.getWarpSound());
|
||||
if (configRepository.getWarpEffectEnabled()) {
|
||||
if (warpEffectVisual != null) {
|
||||
|
@ -11,7 +11,6 @@ import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
import com.sekwah.advancedportals.core.warphandler.TriggerType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -40,7 +40,8 @@ public class TriggerBlockTag
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(String argData) {
|
||||
List<String> triggerBlocks = serverContainer.getCommonTriggerBlocks()
|
||||
List<String> triggerBlocks =
|
||||
serverContainer.getCommonTriggerBlocks()
|
||||
.stream()
|
||||
.filter(block -> block.contains(argData))
|
||||
.collect(Collectors.toList());
|
||||
|
@ -135,7 +135,8 @@ public class Lang {
|
||||
repeatedEquals.append("=");
|
||||
}
|
||||
|
||||
return "\u00A7e" + repeatedEquals.toString() + " " + title + " \u00A7e" + repeatedEquals.toString();
|
||||
return "\u00A7e" + repeatedEquals.toString() + " " + title + " \u00A7e"
|
||||
+ repeatedEquals.toString();
|
||||
}
|
||||
|
||||
private void injectTranslations(String fileName) {
|
||||
|
@ -66,24 +66,34 @@ public class AdvancedPortalsProxyCore {
|
||||
// packets
|
||||
switch (messageType) {
|
||||
case ProxyMessages.PROXY_TRANSFER:
|
||||
ProxyTransferPacket transferPacket = ProxyTransferPacket.decode(buffer);
|
||||
this.logger.info("Transfer request for " + player.getName() + " to " + transferPacket.getServerName());
|
||||
this.proxyContainer.transferPlayer(player, transferPacket.getServerName());
|
||||
ProxyTransferPacket transferPacket =
|
||||
ProxyTransferPacket.decode(buffer);
|
||||
this.logger.info("Transfer request for " + player.getName()
|
||||
+ " to " + transferPacket.getServerName());
|
||||
this.proxyContainer.transferPlayer(
|
||||
player, transferPacket.getServerName());
|
||||
break;
|
||||
case ProxyMessages.PROXY_COMMAND:
|
||||
ProxyCommandPacket commandPacket = ProxyCommandPacket.decode(buffer);
|
||||
this.logger.info("Command request for " + player.getName() + " to run /" + commandPacket.getCommand());
|
||||
this.proxyContainer.invokeCommand(player, commandPacket.getCommand());
|
||||
ProxyCommandPacket commandPacket =
|
||||
ProxyCommandPacket.decode(buffer);
|
||||
this.logger.info("Command request for " + player.getName()
|
||||
+ " to run /" + commandPacket.getCommand());
|
||||
this.proxyContainer.invokeCommand(player,
|
||||
commandPacket.getCommand());
|
||||
break;
|
||||
case ProxyMessages.PROXY_TRANSFER_DESTI:
|
||||
ProxyTransferDestiPacket transferDestiPacket = ProxyTransferDestiPacket.decode(buffer);
|
||||
this.proxyContainer.transferPlayer(player, transferDestiPacket.getServerName());
|
||||
this.playerJoinMap.put(player.getUUID(), new ProxyJoinData(transferDestiPacket.getDestination(), transferDestiPacket.getServerName()));
|
||||
ProxyTransferDestiPacket transferDestiPacket =
|
||||
ProxyTransferDestiPacket.decode(buffer);
|
||||
this.proxyContainer.transferPlayer(
|
||||
player, transferDestiPacket.getServerName());
|
||||
this.playerJoinMap.put(
|
||||
player.getUUID(),
|
||||
new ProxyJoinData(transferDestiPacket.getDestination(),
|
||||
transferDestiPacket.getServerName()));
|
||||
break;
|
||||
default:
|
||||
this.logger.info("Unknown message type: " + messageType);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
String mcVersion = this.getServer().getVersion();
|
||||
Pattern pattern = Pattern.compile("\\(MC: ([\\d.]+)\\)");
|
||||
Matcher matcher = pattern.matcher(mcVersion);
|
||||
SpigotServerContainer serverContainer = new SpigotServerContainer(this.getServer());
|
||||
SpigotServerContainer serverContainer =
|
||||
new SpigotServerContainer(this.getServer());
|
||||
this.portalsCore = new AdvancedPortalsCore(
|
||||
matcher.find() ? matcher.group(1) : "0.0.0", this.getDataFolder(),
|
||||
new SpigotInfoLogger(this), serverContainer);
|
||||
|
@ -2,7 +2,6 @@ package com.sekwah.advancedportals.spigot;
|
||||
|
||||
import com.sekwah.advancedportals.core.permissions.PermissionBuilder;
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PermissionsGeneratorSpigot {
|
||||
|
@ -12,10 +12,9 @@ import com.sekwah.advancedportals.shadowed.inject.Inject;
|
||||
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.spigot.importer.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.spigot.importer.LegacyImporter;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class ImportPortalSubCommand implements SubCommand {
|
||||
@Inject
|
||||
|
@ -11,7 +11,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@ -33,7 +32,9 @@ public class SpigotServerContainer implements ServerContainer {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
private final List<String> fullTriggerBlockList =
|
||||
Arrays.stream(Material.values()).map(Enum::name).collect(Collectors.toList());
|
||||
Arrays.stream(Material.values())
|
||||
.map(Enum::name)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
public SpigotServerContainer(Server server) {
|
||||
this.server = server;
|
||||
|
@ -12,10 +12,8 @@ import com.sekwah.advancedportals.core.serializeddata.config.WarpEffectConfig;
|
||||
import com.sekwah.advancedportals.core.services.DestinationServices;
|
||||
import com.sekwah.advancedportals.core.services.PortalServices;
|
||||
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
@ -44,7 +42,8 @@ public class LegacyImporter {
|
||||
config.getInt(portalName + ".pos2.Z"));
|
||||
List<DataTag> args = new ArrayList<>();
|
||||
args.add(new DataTag("name", portalName));
|
||||
String triggerblock = config.getString(portalName + ".triggerblock");
|
||||
String triggerblock =
|
||||
config.getString(portalName + ".triggerblock");
|
||||
if (triggerblock != null)
|
||||
args.add(new DataTag("triggerblock", triggerblock.split(",")));
|
||||
// It's called bungee as that's the implementation behind it
|
||||
@ -103,7 +102,8 @@ public class LegacyImporter {
|
||||
args.removeIf(dataTag -> dataTag.NAME.equals("delayed"));
|
||||
}
|
||||
|
||||
AdvancedPortal portal = portalServices.createPortal(null, pos1, pos2, args);
|
||||
AdvancedPortal portal =
|
||||
portalServices.createPortal(null, pos1, pos2, args);
|
||||
|
||||
if (portal != null)
|
||||
count++;
|
||||
|
@ -151,13 +151,13 @@ public class ConditionsTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean created(TagTarget target, PlayerContainer player, String[] argData) {
|
||||
public boolean created(TagTarget target, PlayerContainer player,
|
||||
String[] argData) {
|
||||
for (String condition : argData) {
|
||||
if (player instanceof SpigotPlayerContainer) {
|
||||
SpigotPlayerContainer spigotPlayer =
|
||||
(SpigotPlayerContainer) player;
|
||||
if (!checkConditions(condition,
|
||||
spigotPlayer.getPlayer())) {
|
||||
if (!checkConditions(condition, spigotPlayer.getPlayer())) {
|
||||
spigotPlayer.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translate("tag.conditions.invalid"));
|
||||
@ -172,4 +172,4 @@ public class ConditionsTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||
public void destroyed(TagTarget target, PlayerContainer player,
|
||||
String[] argData) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ public class EnderWarpEffect implements WarpEffect.Visual, WarpEffect.Sound {
|
||||
@Override
|
||||
public void onWarpSound(PlayerContainer playerContainer,
|
||||
WarpEffect.Action action) {
|
||||
if (playerContainer
|
||||
instanceof SpigotPlayerContainer) {
|
||||
if (playerContainer instanceof SpigotPlayerContainer) {
|
||||
SpigotPlayerContainer spigotPlayerContainer =
|
||||
(SpigotPlayerContainer) playerContainer;
|
||||
org.bukkit.entity.Player player = spigotPlayerContainer.getPlayer();
|
||||
@ -24,8 +23,7 @@ public class EnderWarpEffect implements WarpEffect.Visual, WarpEffect.Sound {
|
||||
@Override
|
||||
public void onWarpVisual(PlayerContainer playerContainer,
|
||||
WarpEffect.Action action) {
|
||||
if (playerContainer
|
||||
instanceof SpigotPlayerContainer) {
|
||||
if (playerContainer instanceof SpigotPlayerContainer) {
|
||||
SpigotPlayerContainer spigotPlayerContainer =
|
||||
(SpigotPlayerContainer) playerContainer;
|
||||
Player player = spigotPlayerContainer.getPlayer();
|
||||
|
@ -50,9 +50,9 @@ public class AdvancedPortalsVelocityPlugin {
|
||||
@Subscribe
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
if (event.getIdentifier().equals(AP_CHANNEL)) {
|
||||
if (event.getSource()
|
||||
instanceof ServerConnection) {
|
||||
ServerConnection serverConnection = (ServerConnection) event.getSource();
|
||||
if (event.getSource() instanceof ServerConnection) {
|
||||
ServerConnection serverConnection =
|
||||
(ServerConnection) event.getSource();
|
||||
this.proxyCore.incomingMessage(
|
||||
new VelocityProxyPlayerContainer(
|
||||
serverConnection.getPlayer(), AP_CHANNEL),
|
||||
|
@ -15,10 +15,9 @@ public class VelocityProxyContainer implements ProxyContainer {
|
||||
@Override
|
||||
public void invokeCommand(ProxyPlayerContainer proxyPlayer,
|
||||
String command) {
|
||||
if (proxyPlayer
|
||||
instanceof VelocityProxyPlayerContainer) {
|
||||
VelocityProxyPlayerContainer playerContainer
|
||||
= (VelocityProxyPlayerContainer) proxyPlayer;
|
||||
if (proxyPlayer instanceof VelocityProxyPlayerContainer) {
|
||||
VelocityProxyPlayerContainer playerContainer =
|
||||
(VelocityProxyPlayerContainer) proxyPlayer;
|
||||
this.proxy.getCommandManager().executeAsync(
|
||||
playerContainer.getPlayer(), command);
|
||||
}
|
||||
@ -27,14 +26,14 @@ public class VelocityProxyContainer implements ProxyContainer {
|
||||
@Override
|
||||
public void transferPlayer(ProxyPlayerContainer proxyPlayer,
|
||||
String serverName) {
|
||||
if (proxyPlayer
|
||||
instanceof VelocityProxyPlayerContainer) {
|
||||
VelocityProxyPlayerContainer playerContainer
|
||||
= (VelocityProxyPlayerContainer) proxyPlayer;
|
||||
if (proxyPlayer instanceof VelocityProxyPlayerContainer) {
|
||||
VelocityProxyPlayerContainer playerContainer =
|
||||
(VelocityProxyPlayerContainer) proxyPlayer;
|
||||
this.proxy.getServer(serverName);
|
||||
if (this.proxy.getServer(serverName).isPresent()) {
|
||||
playerContainer.getPlayer()
|
||||
.createConnectionRequest(this.proxy.getServer(serverName).get())
|
||||
.createConnectionRequest(
|
||||
this.proxy.getServer(serverName).get())
|
||||
.fireAndForget();
|
||||
} else {
|
||||
playerContainer.getPlayer().sendMessage(
|
||||
|
Loading…
Reference in New Issue
Block a user