mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Updated events to choose the best platform for certain tasks.
This commit is contained in:
@ -23,19 +23,23 @@ import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.worldedit.BiomeTypes;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Preference;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.ServerCommandManager;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
class ForgePlatform extends ServerInterface {
|
||||
@ -101,6 +105,33 @@ class ForgePlatform extends ServerInterface {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Player matchPlayer(Player player) {
|
||||
if (player instanceof ForgePlayer) {
|
||||
return player;
|
||||
} else {
|
||||
EntityPlayerMP entity = server.getConfigurationManager().getPlayerForUsername(player.getName());
|
||||
return entity != null ? new ForgePlayer(entity) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public World matchWorld(World world) {
|
||||
if (world instanceof ForgeWorld) {
|
||||
return world;
|
||||
} else {
|
||||
for (WorldServer ws : DimensionManager.getWorlds()) {
|
||||
if (ws.getWorldInfo().getWorldName().equals(world.getName())) {
|
||||
return new ForgeWorld(ws);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandRegistration(List<Command> commands) {
|
||||
if (server == null) return;
|
||||
|
@ -38,7 +38,6 @@ public class ForgePlayer extends LocalPlayer {
|
||||
private EntityPlayerMP player;
|
||||
|
||||
protected ForgePlayer(EntityPlayerMP player) {
|
||||
super((ServerInterface) ForgeWorldEdit.inst.getPlatform());
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class ForgeWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getWorld().provider.getDimensionName();
|
||||
return getWorld().getWorldInfo().getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -459,11 +459,15 @@ public class ForgeWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ((o instanceof ForgeWorld)) {
|
||||
ForgeWorld other = ((ForgeWorld) o);
|
||||
World otherWorld = other.worldRef.get();
|
||||
World thisWorld = other.worldRef.get();
|
||||
return otherWorld != null && thisWorld != null && otherWorld.equals(thisWorld);
|
||||
if (o == null) {
|
||||
return false;
|
||||
} else if ((o instanceof ForgeWorld)) {
|
||||
ForgeWorld other = ((ForgeWorld) o);
|
||||
World otherWorld = other.worldRef.get();
|
||||
World thisWorld = other.worldRef.get();
|
||||
return otherWorld != null && thisWorld != null && otherWorld.equals(thisWorld);
|
||||
} else if (o instanceof com.sk89q.worldedit.world.World) {
|
||||
return ((com.sk89q.worldedit.world.World) o).getName().equals(getName());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user