mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-02-07 07:52:08 +01:00
fix: check for world existence
This commit is contained in:
parent
004dc754aa
commit
2528ebfe51
@ -3,6 +3,7 @@ package com.sekwah.advancedportals.core.services;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
|
||||
import com.sekwah.advancedportals.core.destination.Destination;
|
||||
import com.sekwah.advancedportals.core.effect.WarpEffect;
|
||||
import com.sekwah.advancedportals.core.registry.TagRegistry;
|
||||
@ -11,6 +12,7 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||
import com.sekwah.advancedportals.core.repository.IDestinationRepository;
|
||||
import com.sekwah.advancedportals.core.serializeddata.DataTag;
|
||||
import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
import java.util.ArrayList;
|
||||
@ -29,6 +31,9 @@ public class DestinationServices {
|
||||
@Inject
|
||||
private ConfigRepository configRepository;
|
||||
|
||||
@Inject
|
||||
InfoLogger infoLogger;
|
||||
|
||||
@Inject
|
||||
TagRegistry tagRegistry;
|
||||
|
||||
@ -137,6 +142,12 @@ public class DestinationServices {
|
||||
public boolean teleportToDestination(String name, PlayerContainer player,
|
||||
boolean doEffect) {
|
||||
if (this.destinationRepository.containsKey(name)) {
|
||||
|
||||
if (player.getServer().getWorld(this.destinationRepository.get(name).getLoc().getWorldName()) == null) {
|
||||
infoLogger.warning(Lang.translate("desti.error.invalidworld"));
|
||||
return false;
|
||||
}
|
||||
|
||||
player.teleport(this.destinationRepository.get(name).getLoc());
|
||||
if (doEffect && configRepository.getWarpEffectEnabled()) {
|
||||
var warpEffectVisual = warpEffectRegistry.getVisualEffect(
|
||||
|
@ -158,6 +158,7 @@ command.error.nametaken= The name &e%1$s &cis already taken.
|
||||
desti.error.save= There was a problem saving the destination.
|
||||
desti.error.noname= You must specify a name. (name:someNameHere)
|
||||
desti.error.notfound= No destination by the name &e%1$s &cwas found.
|
||||
desti.error.invalidworld= Destination world is not valid.
|
||||
|
||||
desti.warpdesti.warp=&aYou have warped to &e%1$s&a.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user