mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 18:14:38 +02:00
Finally fix tests
This commit is contained in:
@@ -432,7 +432,7 @@ public class FakeWorld implements World
|
||||
@Override
|
||||
public UUID getUID()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
return UUID.randomUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.user;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
|
||||
public interface IOfflinePlayer
|
||||
@@ -12,4 +13,6 @@ public interface IOfflinePlayer
|
||||
Location getBedSpawnLocation();
|
||||
|
||||
void setBanned(boolean bln);
|
||||
|
||||
boolean hasPermission(Permission perm);
|
||||
}
|
@@ -24,6 +24,7 @@ import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
|
||||
@@ -34,7 +35,10 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
||||
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
|
||||
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
|
||||
Permissible.class
|
||||
}, excludes = {IOfflinePlayer.class})
|
||||
}, excludes =
|
||||
{
|
||||
IOfflinePlayer.class
|
||||
})
|
||||
protected Player base;
|
||||
protected transient OfflinePlayer offlinePlayer;
|
||||
|
||||
@@ -142,6 +146,19 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission prmsn)
|
||||
{
|
||||
if (isOnlineUser())
|
||||
{
|
||||
return base.hasPermission(prmsn);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile() throws IOException
|
||||
{
|
||||
@@ -405,10 +422,10 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Location getHome(Location loc)
|
||||
{
|
||||
|
||||
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
@@ -419,7 +436,8 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
||||
ArrayList<Location> worldHomes = new ArrayList<Location>();
|
||||
for (com.earth2me.essentials.storage.Location location : getData().getHomes().values())
|
||||
{
|
||||
if (location.getWorldName().equals(loc.getWorld().getName())) {
|
||||
if (location.getWorldName().equals(loc.getWorld().getName()))
|
||||
{
|
||||
try
|
||||
{
|
||||
worldHomes.add(location.getBukkitLocation());
|
||||
@@ -430,10 +448,12 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
||||
}
|
||||
}
|
||||
}
|
||||
if (worldHomes.isEmpty()) {
|
||||
if (worldHomes.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (worldHomes.size() == 1) {
|
||||
if (worldHomes.size() == 1)
|
||||
{
|
||||
return worldHomes.get(0);
|
||||
}
|
||||
double distance = Double.MAX_VALUE;
|
||||
@@ -441,7 +461,8 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
||||
for (Location location : worldHomes)
|
||||
{
|
||||
final double d = loc.distanceSquared(location);
|
||||
if (d < distance) {
|
||||
if (d < distance)
|
||||
{
|
||||
target = location;
|
||||
distance = d;
|
||||
}
|
||||
|
@@ -13,12 +13,17 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.*;
|
||||
import org.bukkit.plugin.messaging.Messenger;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@@ -139,11 +144,200 @@ public class FakeServer implements Server
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
private PluginManager pManager = new PluginManager() {
|
||||
private Set<Permission> permissions = new HashSet<Permission>();
|
||||
|
||||
@Override
|
||||
public void registerInterface(Class<? extends PluginLoader> type) throws IllegalArgumentException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin getPlugin(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin[] getPlugins()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled(Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin[] loadPlugins(File file)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disablePlugins()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPlugins()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEvent(Event event)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvent(Type type, Listener ll, Priority prt, Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvent(Type type, Listener ll, EventExecutor ee, Priority prt, Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvents(Listener ll, Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvent(Class<? extends Event> type, Listener ll, EventPriority ep, EventExecutor ee, Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enablePlugin(Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disablePlugin(Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission getPermission(String string)
|
||||
{
|
||||
for (Permission permission : permissions)
|
||||
{
|
||||
if (permission.getName().equals(string)) {
|
||||
return permission;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(Permission prmsn)
|
||||
{
|
||||
permissions.add(prmsn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(Permission prmsn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permission> getDefaultPermissions(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissionDefaults(Permission prmsn)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeToPermission(String string, Permissible prmsbl)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromPermission(String string, Permissible prmsbl)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permissible> getPermissionSubscriptions(String string)
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeToDefaultPerms(boolean bln, Permissible prmsbl)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromDefaultPerms(boolean bln, Permissible prmsbl)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permissible> getDefaultPermSubscriptions(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permission> getPermissions()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useTimings()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public PluginManager getPluginManager()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
return pManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user