mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-25 16:09:44 +00:00
Allow for event based test cases.
This commit is contained in:
parent
375caa6f9e
commit
9e20f556e1
2 changed files with 199 additions and 13 deletions
|
@ -49,16 +49,16 @@ public class Commandgod extends EssentialsToggleCommand
|
|||
@Override
|
||||
void togglePlayer(CommandSender sender, User user, Boolean enabled)
|
||||
{
|
||||
if (enabled == null)
|
||||
{
|
||||
enabled = !user.isGodModeEnabled();
|
||||
}
|
||||
|
||||
final User controller = sender instanceof Player ? ess.getUser(sender) : null;
|
||||
final GodStatusChangeEvent godEvent = new GodStatusChangeEvent(controller, user, enabled);
|
||||
ess.getServer().getPluginManager().callEvent(godEvent);
|
||||
if (!godEvent.isCancelled())
|
||||
{
|
||||
if (enabled == null)
|
||||
{
|
||||
enabled = !user.isGodModeEnabled();
|
||||
}
|
||||
|
||||
user.setGodModeEnabled(enabled);
|
||||
|
||||
if (enabled && user.getHealth() != 0)
|
||||
|
|
|
@ -17,16 +17,25 @@ import org.bukkit.command.PluginCommand;
|
|||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.help.HelpMap;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.InvalidPluginException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
import org.bukkit.plugin.UnknownDependencyException;
|
||||
import org.bukkit.plugin.messaging.Messenger;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
@ -129,7 +138,7 @@ public class FakeServer implements Server
|
|||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Player getPlayer(String string)
|
||||
{
|
||||
|
@ -160,7 +169,183 @@ public class FakeServer implements Server
|
|||
@Override
|
||||
public PluginManager getPluginManager()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
return new PluginManager()
|
||||
{
|
||||
@Override
|
||||
public void registerInterface(Class<? extends PluginLoader> loader) throws IllegalArgumentException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin getPlugin(String name)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin[] getPlugins()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled(String name)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled(Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin[] loadPlugins(File directory)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disablePlugins()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPlugins()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEvent(Event event) throws IllegalStateException
|
||||
{
|
||||
Logger.getGlobal().info("Called event " + event.getEventName());
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvents(Listener listener, Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enablePlugin(Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disablePlugin(Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission getPermission(String name)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(Permission perm)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(Permission perm)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(String name)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permission> getDefaultPermissions(boolean op)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissionDefaults(Permission perm)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeToPermission(String permission, Permissible permissible)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromPermission(String permission, Permissible permissible)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permissible> getPermissionSubscriptions(String permission)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeToDefaultPerms(boolean op, Permissible permissible)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromDefaultPerms(boolean op, Permissible permissible)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permissible> getDefaultPermSubscriptions(boolean op)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Permission> getPermissions()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useTimings()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -249,7 +434,7 @@ public class FakeServer implements Server
|
|||
@Override
|
||||
public BukkitTask runTaskAsynchronously(Plugin plugin, Runnable r) throws IllegalArgumentException
|
||||
{
|
||||
r.run();
|
||||
r.run();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -262,7 +447,7 @@ public class FakeServer implements Server
|
|||
@Override
|
||||
public BukkitTask runTaskLaterAsynchronously(Plugin plugin, Runnable r, long l) throws IllegalArgumentException
|
||||
{
|
||||
r.run();
|
||||
r.run();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -638,8 +823,8 @@ public class FakeServer implements Server
|
|||
@Override
|
||||
public ConsoleCommandSender getConsoleSender()
|
||||
{
|
||||
return new ConsoleCommandSender() {
|
||||
|
||||
return new ConsoleCommandSender()
|
||||
{
|
||||
@Override
|
||||
public void sendMessage(String message)
|
||||
{
|
||||
|
@ -649,7 +834,8 @@ public class FakeServer implements Server
|
|||
@Override
|
||||
public void sendMessage(String[] messages)
|
||||
{
|
||||
for (String message : messages) {
|
||||
for (String message : messages)
|
||||
{
|
||||
System.out.println("Console message: " + message);
|
||||
}
|
||||
}
|
||||
|
@ -779,7 +965,7 @@ public class FakeServer implements Server
|
|||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue