3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 16:40:10 +01:00

Give it some protection

Dieser Commit ist enthalten in:
Matsv 2016-07-11 22:06:00 +02:00
Ursprung 693990644f
Commit 873f4dd298

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.api; package us.myles.ViaVersion.api;
import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -12,7 +13,7 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import java.util.UUID; import java.util.UUID;
@Getter @Getter(AccessLevel.PROTECTED)
@RequiredArgsConstructor @RequiredArgsConstructor
public abstract class ViaListener implements Listener { public abstract class ViaListener implements Listener {
private final ViaVersionPlugin plugin; private final ViaVersionPlugin plugin;
@ -25,7 +26,7 @@ public abstract class ViaListener implements Listener {
* @param player Player object * @param player Player object
* @return The UserConnection * @return The UserConnection
*/ */
public UserConnection getUserConnection(@NonNull Player player) { protected UserConnection getUserConnection(@NonNull Player player) {
return getUserConnection(player.getUniqueId()); return getUserConnection(player.getUniqueId());
} }
@ -35,7 +36,7 @@ public abstract class ViaListener implements Listener {
* @param uuid UUID object * @param uuid UUID object
* @return The UserConnection * @return The UserConnection
*/ */
public UserConnection getUserConnection(@NonNull UUID uuid) { protected UserConnection getUserConnection(@NonNull UUID uuid) {
if (!plugin.isPorted(uuid)) return null; if (!plugin.isPorted(uuid)) return null;
return plugin.getConnection(uuid); return plugin.getConnection(uuid);
} }
@ -46,7 +47,7 @@ public abstract class ViaListener implements Listener {
* @param player Player Object * @param player Player Object
* @return True if on pipe * @return True if on pipe
*/ */
public boolean isOnPipe(Player player) { protected boolean isOnPipe(Player player) {
return isOnPipe(player.getUniqueId()); return isOnPipe(player.getUniqueId());
} }
@ -56,7 +57,7 @@ public abstract class ViaListener implements Listener {
* @param uuid UUID Object * @param uuid UUID Object
* @return True if on pipe * @return True if on pipe
*/ */
public boolean isOnPipe(UUID uuid) { protected boolean isOnPipe(UUID uuid) {
UserConnection userConnection = getUserConnection(uuid); UserConnection userConnection = getUserConnection(uuid);
return userConnection != null && return userConnection != null &&
userConnection.get(ProtocolInfo.class).getPipeline().contains(requiredPipeline); userConnection.get(ProtocolInfo.class).getPipeline().contains(requiredPipeline);