mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-26 05:51:12 +01:00
Remove deprecated getPlayerRef calls
This commit is contained in:
@@ -29,13 +29,17 @@ import at.helpch.placeholderapi.PlaceholderAPI;
|
|||||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import com.hypixel.hytale.component.Ref;
|
||||||
|
import com.hypixel.hytale.component.Store;
|
||||||
import com.hypixel.hytale.server.core.Message;
|
import com.hypixel.hytale.server.core.Message;
|
||||||
import com.hypixel.hytale.server.core.NameMatching;
|
import com.hypixel.hytale.server.core.NameMatching;
|
||||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||||
|
import com.hypixel.hytale.server.core.entity.Entity;
|
||||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||||
import com.hypixel.hytale.server.core.universe.Universe;
|
import com.hypixel.hytale.server.core.universe.Universe;
|
||||||
import com.hypixel.hytale.server.core.universe.world.World;
|
import com.hypixel.hytale.server.core.universe.world.World;
|
||||||
|
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
@@ -108,7 +112,7 @@ public final class CommandParse extends PlaceholderCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
player = ((Player) sender).getPlayerRef();
|
player = getPlayerRef((Player) sender);
|
||||||
} else {
|
} else {
|
||||||
player = (PlayerRef) sender;
|
player = (PlayerRef) sender;
|
||||||
}
|
}
|
||||||
@@ -160,7 +164,7 @@ public final class CommandParse extends PlaceholderCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
playerOne = ((Player) sender).getPlayerRef();
|
playerOne = getPlayerRef((Player) sender);
|
||||||
} else {
|
} else {
|
||||||
playerOne = (PlayerRef) sender;
|
playerOne = (PlayerRef) sender;
|
||||||
}
|
}
|
||||||
@@ -182,7 +186,7 @@ public final class CommandParse extends PlaceholderCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
playerTwo = ((Player) sender).getPlayerRef();
|
playerTwo = getPlayerRef((Player) sender);
|
||||||
} else {
|
} else {
|
||||||
playerTwo = (PlayerRef) sender;
|
playerTwo = (PlayerRef) sender;
|
||||||
}
|
}
|
||||||
@@ -276,4 +280,16 @@ public final class CommandParse extends PlaceholderCommand {
|
|||||||
return Universe.get().getPlayerByUsername(name, NameMatching.EXACT);
|
return Universe.get().getPlayerByUsername(name, NameMatching.EXACT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static PlayerRef getPlayerRef(@NotNull final Player player) {
|
||||||
|
final Ref<EntityStore> ref = player.getReference();
|
||||||
|
|
||||||
|
if (ref == null || !ref.isValid()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Store<EntityStore> store = ref.getStore();
|
||||||
|
return store.getComponent(ref, PlayerRef.getComponentType());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user