Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/gem-hunters
This commit is contained in:
commit
d0f3aff051
@ -97,10 +97,6 @@ public class UtilShapes
|
|||||||
|
|
||||||
public static BlockFace getFacing(float yaw)
|
public static BlockFace getFacing(float yaw)
|
||||||
{
|
{
|
||||||
while (yaw < 0)
|
|
||||||
{
|
|
||||||
yaw += 360;
|
|
||||||
}
|
|
||||||
return radial[Math.round(yaw / 45f) % 8];
|
return radial[Math.round(yaw / 45f) % 8];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,6 @@
|
|||||||
<artifactId>anticheat</artifactId>
|
<artifactId>anticheat</artifactId>
|
||||||
<version>1.2</version>
|
<version>1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -7,9 +7,6 @@ import mineplex.core.common.util.NautHashMap;
|
|||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
import mineplex.core.lifetimes.Lifetime;
|
|
||||||
import mineplex.core.lifetimes.Lifetimed;
|
|
||||||
import mineplex.core.lifetimes.SimpleLifetime;
|
|
||||||
import mineplex.core.thread.ThreadPool;
|
import mineplex.core.thread.ThreadPool;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@ -29,15 +26,11 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
*
|
*
|
||||||
* This way, we can reflectively create them during {@link #require} when they do not exist, leading to much cleaner code
|
* This way, we can reflectively create them during {@link #require} when they do not exist, leading to much cleaner code
|
||||||
*/
|
*/
|
||||||
public abstract class MiniPlugin implements Listener, Lifetimed
|
public abstract class MiniPlugin implements Listener
|
||||||
{
|
{
|
||||||
// As MiniPlugins can technically be disabled at any time, each
|
|
||||||
// has its own unique Lifetime. If MiniPlugins are declared
|
|
||||||
// to never be able to be disabled, then a "Singleton" Lifetime
|
|
||||||
// could be shared between all of them.
|
|
||||||
private final SimpleLifetime _lifetime = new SimpleLifetime();
|
|
||||||
protected String _moduleName = "Default";
|
protected String _moduleName = "Default";
|
||||||
protected JavaPlugin _plugin;
|
protected JavaPlugin _plugin;
|
||||||
|
protected NautHashMap<String, ICommand> _commands;
|
||||||
|
|
||||||
protected long _initializedTime;
|
protected long _initializedTime;
|
||||||
|
|
||||||
@ -53,7 +46,8 @@ public abstract class MiniPlugin implements Listener, Lifetimed
|
|||||||
|
|
||||||
_initializedTime = System.currentTimeMillis();
|
_initializedTime = System.currentTimeMillis();
|
||||||
|
|
||||||
_lifetime.start();
|
_commands = new NautHashMap<>();
|
||||||
|
|
||||||
onEnable();
|
onEnable();
|
||||||
|
|
||||||
registerEvents(this);
|
registerEvents(this);
|
||||||
@ -177,10 +171,4 @@ public abstract class MiniPlugin implements Listener, Lifetimed
|
|||||||
{
|
{
|
||||||
return Managers.require(clazz);
|
return Managers.require(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Lifetime getLifetime()
|
|
||||||
{
|
|
||||||
return _lifetime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,10 @@ import java.util.List;
|
|||||||
|
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
|
||||||
import mineplex.core.lifetimes.Component;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public interface ICommand extends Component
|
public interface ICommand
|
||||||
{
|
{
|
||||||
void SetCommandCenter(CommandCenter commandCenter);
|
void SetCommandCenter(CommandCenter commandCenter);
|
||||||
void Execute(Player caller, String[] args);
|
void Execute(Player caller, String[] args);
|
||||||
@ -22,16 +21,4 @@ public interface ICommand extends Component
|
|||||||
Rank[] GetSpecificRanks();
|
Rank[] GetSpecificRanks();
|
||||||
|
|
||||||
List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args);
|
List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args);
|
||||||
|
|
||||||
@Override
|
|
||||||
default void activate()
|
|
||||||
{
|
|
||||||
CommandCenter.Instance.addCommand(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void deactivate()
|
|
||||||
{
|
|
||||||
CommandCenter.Instance.removeCommand(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ public enum MineStrikeSkin
|
|||||||
Desert_Eagle_Blaze( "Desert Eagle", "Desert Eagle Blaze", Material.NETHER_STALK, (byte) 0),
|
Desert_Eagle_Blaze( "Desert Eagle", "Desert Eagle Blaze", Material.NETHER_STALK, (byte) 0),
|
||||||
Nova_Koi( "Nova", "Nova Koi", Material.INK_SACK, (byte) 14),
|
Nova_Koi( "Nova", "Nova Koi", Material.INK_SACK, (byte) 14),
|
||||||
XM1014_Tranquility( "XM1014", "XM1014 Tranquility", Material.DIAMOND, (byte) 0),
|
XM1014_Tranquility( "XM1014", "XM1014 Tranquility", Material.DIAMOND, (byte) 0),
|
||||||
PP_Bizon_Streak( "PP-Bizon", "PP-Bizon Streak", Material.INK_SACK, (byte) 4),
|
PP_Bizon_Streak( "PP Bizon", "PP-Bizon Streak", Material.INK_SACK, (byte) 4),
|
||||||
P90_Asiimov( "P90", "P90 Asiimov", Material.INK_SACK, (byte) 0),
|
P90_Asiimov( "P90", "P90 Asiimov", Material.INK_SACK, (byte) 0),
|
||||||
SSG_08_Blood_in_the_Water( "SSG 08", "SSG 08 Blood in the Water", Material.INK_SACK, (byte) 12),
|
SSG_08_Blood_in_the_Water( "SSG 08", "SSG 08 Blood in the Water", Material.INK_SACK, (byte) 12),
|
||||||
AWP_Asiimov( "AWP", "AWP Asiimov", Material.SULPHUR, (byte) 0),
|
AWP_Asiimov( "AWP", "AWP Asiimov", Material.SULPHUR, (byte) 0),
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Component defines behavior that can exist within a Lifetime. Components
|
|
||||||
* should have no impact upon the game while not active.
|
|
||||||
*/
|
|
||||||
public interface Component
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Activates the Component, performing any sort of required initialization.
|
|
||||||
* Components may be activated and deactivated multiple times, however a component
|
|
||||||
* will not be activated more than once without subsequent calls to deactivate.
|
|
||||||
*/
|
|
||||||
void activate();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deactivates the Component, disabling any sort of functionality it provides
|
|
||||||
* and performing clean up. A Component may be subsequently reactivated.
|
|
||||||
*/
|
|
||||||
void deactivate();
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Lifetime represents a duration for which a collection of Components
|
|
||||||
* will be active. While Lifetime does contain a method for registering
|
|
||||||
* instantiated Components, individual Lifetimes may have unique
|
|
||||||
* strategies for creating Components and activating them. Lifetime
|
|
||||||
* doesn't provide any guarantee of Component activation or deactivation
|
|
||||||
* order. Implementations of Lifetime, however, may.
|
|
||||||
* <p />
|
|
||||||
* Lifetime doesn't provide mechanisms for beginning or ending a Lifetime.
|
|
||||||
* This is provided by the various implementations of Lifetime, as it varies
|
|
||||||
* between the implementations and is functionality that most consumers of
|
|
||||||
* Lifetimes will not need.
|
|
||||||
*/
|
|
||||||
public interface Lifetime
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Registers the provided component with this Lifetime. If the Lifetime
|
|
||||||
* is currently active, then the Component will be immediately activated.
|
|
||||||
* @param component the component to register
|
|
||||||
*/
|
|
||||||
void register(Component component);
|
|
||||||
/**
|
|
||||||
* Gets whether the Lifetime is currently active.
|
|
||||||
* @return true if the Lifetime is active
|
|
||||||
*/
|
|
||||||
boolean isActive();
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents an object that is associated with a specific lifetime.
|
|
||||||
* Multiple Lifetimed objects may be associated with the same Lifetime.
|
|
||||||
* As a roughly generalized explanation, any time functionality should
|
|
||||||
* be enabled(whether its a command, listener, etc.) it should be registered
|
|
||||||
* as a Component of a Lifetime. Any object wishing to enable functionality
|
|
||||||
* that is associated with this Lifetimed object should do so with the Lifetime
|
|
||||||
* returned by {@link #getLifetime()}.
|
|
||||||
*/
|
|
||||||
public interface Lifetimed
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Gets the Lifetime associated with this Lifetimed object.
|
|
||||||
* @return non-null Lifetime
|
|
||||||
*/
|
|
||||||
Lifetime getLifetime();
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A convenience class for Components that are a Listener. ListenerComponent
|
|
||||||
* can either be used as a wrapper class for a specific Listener, or can be
|
|
||||||
* extended by another Component to provide event registration.
|
|
||||||
*/
|
|
||||||
public class ListenerComponent implements Component, Listener
|
|
||||||
{
|
|
||||||
private final Listener _listener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a ListenerComponent that registers the provided Listener when
|
|
||||||
* activated and unregisters it when deactivated. The newly created
|
|
||||||
* ListenerComponent will not be registered as a Listener. When a
|
|
||||||
* ListenerComponent is created with this constructor, it is effectively
|
|
||||||
* a wrapper to bind a Listener to a specific lifetime.
|
|
||||||
*
|
|
||||||
* @param listener non-null listener to wrap
|
|
||||||
* @throws IllegalArgumentException if listener is null
|
|
||||||
*/
|
|
||||||
public ListenerComponent(Listener listener) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
Validate.notNull(listener);
|
|
||||||
_listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a ListenerComponent that registers itself when activated and
|
|
||||||
* unregisters itself when deactivated.
|
|
||||||
*/
|
|
||||||
public ListenerComponent()
|
|
||||||
{
|
|
||||||
_listener = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activate()
|
|
||||||
{
|
|
||||||
Bukkit.getPluginManager().registerEvents(_listener, UtilServer.getPlugin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deactivate()
|
|
||||||
{
|
|
||||||
HandlerList.unregisterAll(_listener);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
public interface PhasedComponent<T> extends Component
|
|
||||||
{
|
|
||||||
|
|
||||||
void setPhase(T phase);
|
|
||||||
}
|
|
@ -1,289 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A PhasedLifetime is a lifetime that is composed of several
|
|
||||||
* smaller lifetimes, referred to as phases. This class is provided
|
|
||||||
* in order to support a system in which Components may exist within multiple
|
|
||||||
* Lifetimes. PhasedLifetime is not thread-safe.
|
|
||||||
* <p />
|
|
||||||
* Registering a Component will register it for the entirety of this Lifetime,
|
|
||||||
* unless registered with {@link #register(Component, Iterable)}. Special behavior
|
|
||||||
* is provided for instances of {@link PhasedComponent}. See {@link #register(Component,
|
|
||||||
* Iterable)} for more information. Components registered using {@link
|
|
||||||
* #register(Component)} are registered for the entire duration of the Lifetime.
|
|
||||||
*/
|
|
||||||
public class PhasedLifetime<T> implements Lifetime
|
|
||||||
{
|
|
||||||
private final Map<T, List<RegisteredComponent>> _phases = new HashMap<>();
|
|
||||||
private final List<Component> _global = new ArrayList<>();
|
|
||||||
private boolean _active = false;
|
|
||||||
private T _current;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers the Component for all phases within the provided Iterable,
|
|
||||||
* and creates a Lifetime that is active during all those phases, and
|
|
||||||
* therefore identical to when the provided Component is active. If a change
|
|
||||||
* occurs from a Phase that the Component is active in to another phase that
|
|
||||||
* the component is active in, it will not be disabled. When this
|
|
||||||
* Lifetime ends, all Lifetimes created by this Lifetime also end, as all
|
|
||||||
* phases are considered over.
|
|
||||||
* <p />
|
|
||||||
* If the Component is an instance of PhasedComponent, then any phase change
|
|
||||||
* in which one of the phases is within the provided Iterable of phases will
|
|
||||||
* result in an invocation of {@link PhasedComponent#setPhase(Object)}. This
|
|
||||||
* should not be used as a mechanism to detect when the component is being
|
|
||||||
* disabled, but rather as a means to provide specific behavior when that
|
|
||||||
* phase change occurs. If a phase change drastically changes the behavior
|
|
||||||
* of a Component such that not all functionality is active for some phases
|
|
||||||
* that a Component is registered for, you should consider refactoring that
|
|
||||||
* Component into two separate Components.
|
|
||||||
* <p />
|
|
||||||
* As an example, assume that we have a PhasedLifetime with phases A-F,
|
|
||||||
* and a PhasedComponent is registered for phases A, B, and E. The chain
|
|
||||||
* of events would be as followed(italic indicates an event call to the
|
|
||||||
* PhasedComponent, an activation, or deactivation).
|
|
||||||
* <ul>
|
|
||||||
* <li>Lifetime started with a value of A</li>
|
|
||||||
* <li><i>Component is activated</i></li>
|
|
||||||
* <li><i>setPhase is called with a value of A</i></li>
|
|
||||||
* <li>Phase is set to B</li>
|
|
||||||
* <li><i>setPhase is called with a value of B</i></li>
|
|
||||||
* <li>Phase is set to C</li>
|
|
||||||
* <li><i>setPhase is called with a value of C</i></li>
|
|
||||||
* <li><i>Component is deactivated</i></li>
|
|
||||||
* <li>Phase is set to D</li>
|
|
||||||
* <li>Phase is set to E</li>
|
|
||||||
* <li><i>Component is activated</i></li>
|
|
||||||
* <li><i>setPhase is called with a value of E</i></li>
|
|
||||||
* <li>Phase is set to F</li>
|
|
||||||
* <li><i>setPhase is called with a value of F</i></li>
|
|
||||||
* <li><i>Component is deactivated</i></li>
|
|
||||||
* <li>Lifetime ends</li>
|
|
||||||
* </ul>
|
|
||||||
* <p />
|
|
||||||
* If phases contains no elements, then the Component will not be
|
|
||||||
* registered.
|
|
||||||
* @param component non-null Component being registered
|
|
||||||
* @param phases non-null Iterable of phases to register the Component for
|
|
||||||
* @return a Lifetime corresponding to when the Component is active
|
|
||||||
* @throws IllegalArgumentException if component or phases is null
|
|
||||||
*/
|
|
||||||
public Lifetime register(Component component, Iterable<T> phases) throws IllegalArgumentException {
|
|
||||||
Validate.notNull(component, "Component cannot be null");
|
|
||||||
Validate.notNull(phases, "Phases cannot be null");
|
|
||||||
RegisteredComponent rComponent = new RegisteredComponent(component);
|
|
||||||
for (T phase : phases)
|
|
||||||
{
|
|
||||||
_phases.computeIfAbsent(phase, (p) -> new ArrayList<>()).add(rComponent);
|
|
||||||
if (Objects.equals(phase, _current))
|
|
||||||
{
|
|
||||||
rComponent.start();
|
|
||||||
if (component instanceof PhasedComponent)
|
|
||||||
{
|
|
||||||
((PhasedComponent<T>) component).setPhase(phase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rComponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the Lifetime, activating all components that are active for
|
|
||||||
* the entire lifetime, and then activating all components that are part
|
|
||||||
* of the provided phase.
|
|
||||||
* @param phase non-null phase to start
|
|
||||||
* @throws IllegalArgumentException if phase is null
|
|
||||||
* @throws IllegalStateException if the Lifetime is currently active
|
|
||||||
*/
|
|
||||||
public void start(T phase) throws IllegalArgumentException, IllegalStateException
|
|
||||||
{
|
|
||||||
Validate.notNull(phase, "phase cannot be null");
|
|
||||||
Preconditions.checkState(!_active, "Lifetime already started");
|
|
||||||
_active = true;
|
|
||||||
_global.forEach(PhasedLifetime::active);
|
|
||||||
setPhase(phase);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ends the Lifetime, deactivating all components in the current phase
|
|
||||||
* and then deactivating all components that are active for the entire Lifetime.
|
|
||||||
* A Lifetime may be subsequently reactivated after it has ended.
|
|
||||||
* @throws IllegalStateException if the lifetime isn't active
|
|
||||||
*/
|
|
||||||
public void end() throws IllegalStateException
|
|
||||||
{
|
|
||||||
Preconditions.checkState(_active, "Lifetime not active");
|
|
||||||
List<RegisteredComponent> toDisable = _phases.get(getPhase());
|
|
||||||
if (toDisable != null)
|
|
||||||
{
|
|
||||||
toDisable.forEach(RegisteredComponent::end);
|
|
||||||
}
|
|
||||||
_global.forEach(PhasedLifetime::deactive);
|
|
||||||
_active = false;
|
|
||||||
_current = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the current phase to the provided value, activating components
|
|
||||||
* that are active in the phase and not currently active, and deactiving
|
|
||||||
* components that were previously active and are not registered for the
|
|
||||||
* provided phase.
|
|
||||||
* @param phase non-null
|
|
||||||
* @throws IllegalStateException if the Lifetime isn't active
|
|
||||||
* @throws IllegalArgumentException if the phase equals the current phase
|
|
||||||
* or is null
|
|
||||||
*/
|
|
||||||
public void setPhase(T phase) throws IllegalStateException, IllegalArgumentException
|
|
||||||
{
|
|
||||||
Preconditions.checkState(_active, "Lifetime not active");
|
|
||||||
Validate.isTrue(!Objects.equals(phase, _current), "Can't set the phase to the current phase");
|
|
||||||
Validate.notNull(phase, "the phase cannot be null");
|
|
||||||
T oldPhase = getPhase();
|
|
||||||
_current = phase;
|
|
||||||
List<RegisteredComponent> old = _phases.get(oldPhase);
|
|
||||||
List<RegisteredComponent> nextPhase = _phases.get(phase);
|
|
||||||
|
|
||||||
for (Component c : _global)
|
|
||||||
{
|
|
||||||
if (c instanceof PhasedComponent)
|
|
||||||
{
|
|
||||||
((PhasedComponent<T>) c).setPhase(phase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Disable components that were active in the last phase but not in the next phase.
|
|
||||||
if (old != null)
|
|
||||||
{
|
|
||||||
List<RegisteredComponent> toDisable = new ArrayList<>();
|
|
||||||
toDisable.addAll(old);
|
|
||||||
// Components that are in the next phase shouldn't be disabled.
|
|
||||||
if (nextPhase != null)
|
|
||||||
{
|
|
||||||
toDisable.removeAll(nextPhase);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that all old ones get a setPhase call before disabling them.
|
|
||||||
for (RegisteredComponent r : toDisable)
|
|
||||||
{
|
|
||||||
if (r.getComponent() instanceof PhasedComponent)
|
|
||||||
{
|
|
||||||
((PhasedComponent<T>) r.getComponent()).setPhase(phase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
toDisable.forEach(RegisteredComponent::end);
|
|
||||||
}
|
|
||||||
if (nextPhase != null)
|
|
||||||
{
|
|
||||||
// New but not old
|
|
||||||
List<RegisteredComponent> toActivate = new ArrayList<>();
|
|
||||||
toActivate.addAll(nextPhase);
|
|
||||||
// Ensure that all components from last phase don't end up getting activated again.
|
|
||||||
if (old != null)
|
|
||||||
{
|
|
||||||
toActivate.removeAll(old);
|
|
||||||
}
|
|
||||||
// Start all the new ones
|
|
||||||
toActivate.forEach(RegisteredComponent::start);
|
|
||||||
// Give every remaining component a call to setPhase
|
|
||||||
for (RegisteredComponent r : nextPhase)
|
|
||||||
{
|
|
||||||
if (r.getComponent() instanceof PhasedComponent)
|
|
||||||
{
|
|
||||||
((PhasedComponent<T>) r.getComponent()).setPhase(phase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void active(Component component)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
component.activate();
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
UtilServer.getPlugin().getLogger().severe("Failed to activate component: " + component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static void deactive(Component component)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
component.deactivate();
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
UtilServer.getPlugin().getLogger().severe("Failed to deactivate component: " + component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets the current Phase. If this PhasedLifetime isn't active then
|
|
||||||
* the current phase is null.
|
|
||||||
* @return the current phase, null if not active
|
|
||||||
*/
|
|
||||||
public T getPhase()
|
|
||||||
{
|
|
||||||
return _current;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
* If the Component is an instance of PhasedComponent, it will receive
|
|
||||||
* notifications of phase changes prior to any components registered
|
|
||||||
* with specific phases. Global components will also be deactivated last.
|
|
||||||
* @param component the component to register
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void register(Component component)
|
|
||||||
{
|
|
||||||
_global.add(component);
|
|
||||||
if (this.isActive())
|
|
||||||
{
|
|
||||||
component.activate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isActive()
|
|
||||||
{
|
|
||||||
return _active;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class RegisteredComponent extends SimpleLifetime implements Lifetime {
|
|
||||||
private Component _component;
|
|
||||||
|
|
||||||
public RegisteredComponent(Component component)
|
|
||||||
{
|
|
||||||
this._component = component;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Component getComponent()
|
|
||||||
{
|
|
||||||
return _component;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() throws IllegalStateException
|
|
||||||
{
|
|
||||||
PhasedLifetime.active(_component);
|
|
||||||
super.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void end() throws IllegalStateException
|
|
||||||
{
|
|
||||||
super.end();
|
|
||||||
PhasedLifetime.deactive(_component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Lifetime that is not thread-safe and is essentially a list of Components.
|
|
||||||
* All components are activated in the order that they are registered. All
|
|
||||||
* components are deactivated in the reverse order that they are registered.
|
|
||||||
* Components may not be registered during invocations of start or end. If a
|
|
||||||
* Component throws an exception during activation it will be logged, however the
|
|
||||||
* Component will still only be disabled once all other Components are disabled.
|
|
||||||
*/
|
|
||||||
public class SimpleLifetime implements Lifetime
|
|
||||||
{
|
|
||||||
protected final List<Component> _components = new ArrayList<>();
|
|
||||||
protected boolean _active = false;
|
|
||||||
@Override
|
|
||||||
public void register(Component component)
|
|
||||||
{
|
|
||||||
this._components.add(component);
|
|
||||||
if (this.isActive())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
component.activate();
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
UtilServer.getPlugin().getLogger().severe("Failed to active component: " + component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isActive()
|
|
||||||
{
|
|
||||||
return _active;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the SimpleLifetime, activating all components in the order that
|
|
||||||
* they were registered. A SimpleLifetime may be started multiple times,
|
|
||||||
* so long that every invocation of start after the first is preceded by
|
|
||||||
* an invocation of {@link #end()}. If a Component throws an exception
|
|
||||||
* during activation the exception will be logged, however no specific
|
|
||||||
* error-handling mechanism is provided. The Component will still be
|
|
||||||
* considered active and will be deactivated with all other Components.
|
|
||||||
* @throws IllegalStateException if currently active
|
|
||||||
*/
|
|
||||||
public void start() throws IllegalStateException
|
|
||||||
{
|
|
||||||
Validate.isTrue(!_active);
|
|
||||||
_active = true;
|
|
||||||
for (Component component : _components)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
component.activate();
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
UtilServer.getPlugin().getLogger().severe("Failed to active component: " + component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deactivates all components in the reverse order that they were registered.
|
|
||||||
* Any exception thrown by a Component while being deactivated will be logged,
|
|
||||||
* however no exception handling mechanism is provided.
|
|
||||||
* @throws IllegalStateException if not currently active
|
|
||||||
*/
|
|
||||||
public void end() throws IllegalStateException
|
|
||||||
{
|
|
||||||
Validate.isTrue(_active);
|
|
||||||
_active = false;
|
|
||||||
ListIterator<Component> reverseIterator = _components.listIterator(_components.size());
|
|
||||||
while (reverseIterator.hasPrevious())
|
|
||||||
{
|
|
||||||
Component component = reverseIterator.previous();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
component.deactivate();
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
UtilServer.getPlugin().getLogger().severe("Failed to deactivate component: " + component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -236,10 +236,10 @@ public class RewardManager
|
|||||||
addInventoryReward(Type.VALENTINES_GIFT, getGadget(ItemBow.class), rarity, 300, 0, 1, 5);
|
addInventoryReward(Type.VALENTINES_GIFT, getGadget(ItemBow.class), rarity, 300, 0, 1, 5);
|
||||||
|
|
||||||
// INFUSED CHESTS
|
// INFUSED CHESTS
|
||||||
addInventoryReward(Type.INFUSED_CHESTS, getGadget(ItemCoal.class), rarity, 30, 0, 50, 100);
|
addInventoryReward(Type.INFUSED_GADGETS, getGadget(ItemCoal.class), rarity, 30, 0, 50, 100);
|
||||||
addInventoryReward(Type.INFUSED_CHESTS, getGadget(ItemFreezeCannon.class), rarity, 45, 0, 5, 10);
|
addInventoryReward(Type.INFUSED_GADGETS, getGadget(ItemFreezeCannon.class), rarity, 45, 0, 5, 10);
|
||||||
addInventoryReward(Type.INFUSED_CHESTS, getGadget(ItemPartyPopper.class), rarity, 60, 0, 5, 10);
|
addInventoryReward(Type.INFUSED_GADGETS, getGadget(ItemPartyPopper.class), rarity, 60, 0, 5, 10);
|
||||||
addInventoryReward(Type.INFUSED_CHESTS, getGadget(ItemSnowball.class), rarity, 60, 0, 5, 10);
|
addInventoryReward(Type.INFUSED_GADGETS, getGadget(ItemSnowball.class), rarity, 60, 0, 5, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUncommon()
|
public void addUncommon()
|
||||||
@ -312,10 +312,10 @@ public class RewardManager
|
|||||||
addHat(Type.INFUSED_CHESTS, HatType.PRESENT, rarity, 40, 100);
|
addHat(Type.INFUSED_CHESTS, HatType.PRESENT, rarity, 40, 100);
|
||||||
addHat(Type.INFUSED_CHESTS, HatType.SNOWMAN, rarity, 38, 100);
|
addHat(Type.INFUSED_CHESTS, HatType.SNOWMAN, rarity, 38, 100);
|
||||||
|
|
||||||
addInventoryReward(Type.INFUSED_CHESTS, getGadget(ItemCoal.class), rarity, 33, 0, 65, 200);
|
addInventoryReward(Type.INFUSED_GADGETS, getGadget(ItemCoal.class), rarity, 33, 0, 65, 200);
|
||||||
addInventoryReward(Type.INFUSED_CHESTS, getGadget(ItemFreezeCannon.class), rarity, 45, 0, 25, 40);
|
addInventoryReward(Type.INFUSED_GADGETS, getGadget(ItemFreezeCannon.class), rarity, 45, 0, 25, 40);
|
||||||
addInventoryReward(Type.INFUSED_CHESTS, getGadget(ItemPartyPopper.class), rarity, 60, 0, 25, 40);
|
addInventoryReward(Type.INFUSED_GADGETS, getGadget(ItemPartyPopper.class), rarity, 60, 0, 25, 40);
|
||||||
addInventoryReward(Type.INFUSED_CHESTS, getGadget(ItemSnowball.class), rarity, 60, 0, 25, 40);
|
addInventoryReward(Type.INFUSED_GADGETS, getGadget(ItemSnowball.class), rarity, 60, 0, 25, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRare()
|
public void addRare()
|
||||||
@ -891,12 +891,13 @@ public class RewardManager
|
|||||||
_rewardPools.get(Type.ILLUMINATED).add(reward);
|
_rewardPools.get(Type.ILLUMINATED).add(reward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pool != Type.INFUSED_CHESTS)
|
if (pool != Type.INFUSED_CHESTS && pool != Type.INFUSED_GADGETS)
|
||||||
{
|
{
|
||||||
_rewardPools.get(pool).add(reward);
|
_rewardPools.get(pool).add(reward);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (pool != Type.INFUSED_GADGETS)
|
||||||
_rewardPools.get(Type.ILLUMINATED).add(reward);
|
_rewardPools.get(Type.ILLUMINATED).add(reward);
|
||||||
_rewardPools.get(Type.MYTHICAL).add(reward);
|
_rewardPools.get(Type.MYTHICAL).add(reward);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ public class RewardPool
|
|||||||
HAUNTED(false),
|
HAUNTED(false),
|
||||||
TRICK_OR_TREAT(false),
|
TRICK_OR_TREAT(false),
|
||||||
INFUSED_CHESTS(false),
|
INFUSED_CHESTS(false),
|
||||||
|
INFUSED_GADGETS(true),
|
||||||
MYTHICAL(true),
|
MYTHICAL(true),
|
||||||
THANKFUL(false),
|
THANKFUL(false),
|
||||||
GINGERBREAD(false),
|
GINGERBREAD(false),
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package mineplex.core.shop;
|
package mineplex.core.shop;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.lifetimes.Lifetimed;
|
|
||||||
import mineplex.core.lifetimes.ListenerComponent;
|
|
||||||
import mineplex.core.npc.event.NpcDamageByEntityEvent;
|
import mineplex.core.npc.event.NpcDamageByEntityEvent;
|
||||||
import mineplex.core.npc.event.NpcInteractEntityEvent;
|
import mineplex.core.npc.event.NpcInteractEntityEvent;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory;
|
||||||
@ -18,6 +16,7 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
@ -25,9 +24,8 @@ import org.bukkit.event.inventory.InventoryOpenEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public abstract class ShopBase<PluginType extends Lifetimed> extends ListenerComponent
|
public abstract class ShopBase<PluginType extends MiniPlugin> implements Listener
|
||||||
{
|
{
|
||||||
private NautHashMap<String, Long> _errorThrottling;
|
private NautHashMap<String, Long> _errorThrottling;
|
||||||
private NautHashMap<String, Long> _purchaseBlock;
|
private NautHashMap<String, Long> _purchaseBlock;
|
||||||
@ -51,7 +49,7 @@ public abstract class ShopBase<PluginType extends Lifetimed> extends ListenerCom
|
|||||||
_errorThrottling = new NautHashMap<String, Long>();
|
_errorThrottling = new NautHashMap<String, Long>();
|
||||||
_purchaseBlock = new NautHashMap<String, Long>();
|
_purchaseBlock = new NautHashMap<String, Long>();
|
||||||
|
|
||||||
_plugin.getLifetime().register(this);
|
_plugin.registerEvents(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
@ -149,7 +147,14 @@ public abstract class ShopBase<PluginType extends Lifetimed> extends ListenerCom
|
|||||||
{
|
{
|
||||||
if (_playerPageMap.containsKey(event.getPlayer().getName()) && _playerPageMap.get(event.getPlayer().getName()).getTitle() != null && _playerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle()))
|
if (_playerPageMap.containsKey(event.getPlayer().getName()) && _playerPageMap.get(event.getPlayer().getName()).getTitle() != null && _playerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle()))
|
||||||
{
|
{
|
||||||
removePlayer((Player) event.getPlayer());
|
_playerPageMap.get(event.getPlayer().getName()).playerClosed();
|
||||||
|
_playerPageMap.get(event.getPlayer().getName()).dispose();
|
||||||
|
|
||||||
|
_playerPageMap.remove(event.getPlayer().getName());
|
||||||
|
|
||||||
|
closeShopForPlayer((Player) event.getPlayer());
|
||||||
|
|
||||||
|
_openedShop.remove(event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,39 +166,17 @@ public abstract class ShopBase<PluginType extends Lifetimed> extends ListenerCom
|
|||||||
|
|
||||||
if (_playerPageMap.containsKey(event.getPlayer().getName()) && _playerPageMap.get(event.getPlayer().getName()).getTitle() != null && _playerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle()))
|
if (_playerPageMap.containsKey(event.getPlayer().getName()) && _playerPageMap.get(event.getPlayer().getName()).getTitle() != null && _playerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle()))
|
||||||
{
|
{
|
||||||
removePlayer((Player) event.getPlayer());
|
_playerPageMap.get(event.getPlayer().getName()).playerClosed();
|
||||||
|
_playerPageMap.get(event.getPlayer().getName()).dispose();
|
||||||
|
|
||||||
|
_playerPageMap.remove(event.getPlayer().getName());
|
||||||
|
|
||||||
|
closeShopForPlayer((Player) event.getPlayer());
|
||||||
|
|
||||||
|
_openedShop.remove(event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removePlayer(Player player)
|
|
||||||
{
|
|
||||||
_playerPageMap.get(player.getName()).playerClosed();
|
|
||||||
_playerPageMap.get(player.getName()).dispose();
|
|
||||||
|
|
||||||
_playerPageMap.remove(player.getName());
|
|
||||||
|
|
||||||
closeShopForPlayer(player);
|
|
||||||
|
|
||||||
_openedShop.remove(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deactivate()
|
|
||||||
{
|
|
||||||
super.deactivate();
|
|
||||||
_playerPageMap.entrySet().stream().map(Map.Entry::getKey).map(Bukkit::getPlayer).forEach(p -> {
|
|
||||||
if (_playerPageMap.get(p.getName()).getTitle().equals(p.getOpenInventory().getTitle()))
|
|
||||||
{
|
|
||||||
p.closeInventory();
|
|
||||||
}
|
|
||||||
removePlayer(p);
|
|
||||||
});
|
|
||||||
_playerPageMap.clear();
|
|
||||||
_openedShop.clear();
|
|
||||||
_purchaseBlock.clear();
|
|
||||||
_errorThrottling.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canOpenShop(Player player)
|
protected boolean canOpenShop(Player player)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -208,8 +191,15 @@ public abstract class ShopBase<PluginType extends Lifetimed> extends ListenerCom
|
|||||||
{
|
{
|
||||||
if (_playerPageMap.containsKey(event.getPlayer().getName()))
|
if (_playerPageMap.containsKey(event.getPlayer().getName()))
|
||||||
{
|
{
|
||||||
removePlayer(event.getPlayer());
|
_playerPageMap.get(event.getPlayer().getName()).playerClosed();
|
||||||
|
_playerPageMap.get(event.getPlayer().getName()).dispose();
|
||||||
|
|
||||||
event.getPlayer().closeInventory();
|
event.getPlayer().closeInventory();
|
||||||
|
closeShopForPlayer(event.getPlayer());
|
||||||
|
|
||||||
|
_playerPageMap.remove(event.getPlayer().getName());
|
||||||
|
|
||||||
|
_openedShop.remove(event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
package mineplex.core.shop.page;
|
package mineplex.core.shop.page;
|
||||||
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.common.util.UtilInv;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
|
||||||
import mineplex.core.lifetimes.Lifetimed;
|
|
||||||
import mineplex.core.shop.ShopBase;
|
|
||||||
import mineplex.core.shop.item.IButton;
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom;
|
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom;
|
||||||
@ -20,7 +11,16 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public abstract class ShopPageBase<PluginType extends Lifetimed, ShopType extends ShopBase<PluginType>> extends CraftInventoryCustom implements Listener
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.account.CoreClient;
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.shop.ShopBase;
|
||||||
|
import mineplex.core.shop.item.IButton;
|
||||||
|
|
||||||
|
public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType extends ShopBase<PluginType>> extends CraftInventoryCustom implements Listener
|
||||||
{
|
{
|
||||||
protected PluginType _plugin;
|
protected PluginType _plugin;
|
||||||
protected CoreClientManager _clientManager;
|
protected CoreClientManager _clientManager;
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LoggingComponent implements PhasedComponent {
|
|
||||||
private final List<String> _events;
|
|
||||||
private final String _name;
|
|
||||||
|
|
||||||
public LoggingComponent(List<String> events, String name)
|
|
||||||
{
|
|
||||||
_events = events;
|
|
||||||
this._name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activate()
|
|
||||||
{
|
|
||||||
_events.add(this._name + " activated");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deactivate()
|
|
||||||
{
|
|
||||||
_events.add(this._name + " deactivated");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPhase(Object phase)
|
|
||||||
{
|
|
||||||
_events.add(this._name + " setPhase " + phase);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PhasedLifetimeTest
|
|
||||||
{
|
|
||||||
PhasedLifetime<Phase> _lifetime = new PhasedLifetime<>();
|
|
||||||
List<String> _events = new ArrayList<>();
|
|
||||||
@Test
|
|
||||||
public void testTwoPhaseComponent()
|
|
||||||
{
|
|
||||||
Assert.assertFalse(_lifetime.isActive());
|
|
||||||
_lifetime.register(new LoggingComponent(_events, "component"), Arrays.asList(Phase.A, Phase.B));
|
|
||||||
_lifetime.start(Phase.A);
|
|
||||||
Assert.assertTrue(_lifetime.isActive());
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A"), _events);
|
|
||||||
_lifetime.setPhase(Phase.B);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A", "component setPhase B"), _events);
|
|
||||||
_lifetime.setPhase(Phase.C);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A", "component setPhase B", "component setPhase C", "component deactivated"), _events);
|
|
||||||
_lifetime.end();
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A", "component setPhase B", "component setPhase C", "component deactivated"), _events);
|
|
||||||
Assert.assertFalse(_lifetime.isActive());
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void testGlobalComponent()
|
|
||||||
{
|
|
||||||
_lifetime.register(new LoggingComponent(_events, "component"));
|
|
||||||
_lifetime.start(Phase.A);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A"), _events);
|
|
||||||
_lifetime.setPhase(Phase.B);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A", "component setPhase B"), _events);
|
|
||||||
_lifetime.end();
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A", "component setPhase B", "component deactivated"), _events);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLateRegistration()
|
|
||||||
{
|
|
||||||
_lifetime.start(Phase.A);
|
|
||||||
_lifetime.register(new LoggingComponent(_events, "component"), Arrays.asList(Phase.A, Phase.B));
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A"), _events);
|
|
||||||
_lifetime.setPhase(Phase.B);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A", "component setPhase B"), _events);
|
|
||||||
_lifetime.end();
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase A", "component setPhase B", "component deactivated"), _events);
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void testSinglePhase()
|
|
||||||
{
|
|
||||||
_lifetime.register(new LoggingComponent(_events, "component"), Collections.singletonList(Phase.B));
|
|
||||||
_lifetime.start(Phase.A);
|
|
||||||
Assert.assertEquals(Collections.emptyList(), _events);
|
|
||||||
_lifetime.setPhase(Phase.B);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase B"), _events);
|
|
||||||
_lifetime.setPhase(Phase.C);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase B", "component setPhase C", "component deactivated"), _events);
|
|
||||||
_lifetime.end();
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase B", "component setPhase C", "component deactivated"), _events);
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void testComponentLifetimes()
|
|
||||||
{
|
|
||||||
_lifetime.register(new LoggingComponent(_events, "component"), Collections.singletonList(Phase.B)).register(new LoggingComponent(_events, "child"));
|
|
||||||
_lifetime.start(Phase.A);
|
|
||||||
Assert.assertEquals(Collections.emptyList(), _events);
|
|
||||||
_lifetime.setPhase(Phase.B);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "child activated", "component setPhase B"), _events);
|
|
||||||
_lifetime.setPhase(Phase.C);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "child activated","component setPhase B", "component setPhase C", "child deactivated", "component deactivated"), _events);
|
|
||||||
_lifetime.end();
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "child activated", "component setPhase B", "component setPhase C", "child deactivated", "component deactivated"), _events);
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void testEarlyShutdown()
|
|
||||||
{
|
|
||||||
_lifetime.register(new LoggingComponent(_events, "component"), Arrays.asList(Phase.B, Phase.C));
|
|
||||||
_lifetime.start(Phase.A);
|
|
||||||
Assert.assertEquals(Collections.emptyList(), _events);
|
|
||||||
_lifetime.setPhase(Phase.B);
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase B"), _events);
|
|
||||||
_lifetime.end();
|
|
||||||
Assert.assertEquals(Arrays.asList("component activated", "component setPhase B", "component deactivated"), _events);
|
|
||||||
|
|
||||||
}
|
|
||||||
enum Phase
|
|
||||||
{
|
|
||||||
A,
|
|
||||||
B,
|
|
||||||
C,
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package mineplex.core.lifetimes;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SimpleLifetimeTest
|
|
||||||
{
|
|
||||||
private final SimpleLifetime _lifetime = new SimpleLifetime();
|
|
||||||
private final List<String> _events = new ArrayList<>();
|
|
||||||
@Test
|
|
||||||
public void testAddition()
|
|
||||||
{
|
|
||||||
_lifetime.register(new LoggingComponent(_events,"a"));
|
|
||||||
_lifetime.start();
|
|
||||||
_lifetime.end();
|
|
||||||
Assert.assertEquals(_events, Arrays.asList("a activated", "a deactivated"));
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void testLateAddition()
|
|
||||||
{
|
|
||||||
_lifetime.start();
|
|
||||||
_lifetime.register(new LoggingComponent(_events,"a"));
|
|
||||||
_lifetime.end();
|
|
||||||
Assert.assertEquals(_events, Arrays.asList("a activated", "a deactivated"));
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void testActivationOrder()
|
|
||||||
{
|
|
||||||
_lifetime.register(new LoggingComponent(_events,"a"));
|
|
||||||
_lifetime.register(new LoggingComponent(_events,"b"));
|
|
||||||
_lifetime.start();
|
|
||||||
_lifetime.end();
|
|
||||||
Assert.assertEquals(_events, Arrays.asList("a activated", "b activated", "b deactivated", "a deactivated"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -4,7 +4,6 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -113,7 +112,7 @@ public class Blink extends SkillActive
|
|||||||
//Lock Players
|
//Lock Players
|
||||||
for (Player cur : player.getWorld().getPlayers())
|
for (Player cur : player.getWorld().getPlayers())
|
||||||
{
|
{
|
||||||
if (cur.equals(player) || cur.getGameMode() == GameMode.SPECTATOR)
|
if (cur.equals(player))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (UtilMath.offset(newTarget, cur.getLocation()) > 1)
|
if (UtilMath.offset(newTarget, cur.getLocation()) > 1)
|
||||||
|
@ -4,7 +4,6 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -40,12 +39,12 @@ public class CombatComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddDamage(String source, double dmg, List<DamageChange> mod, Map<String, Object> metadata)
|
public void AddDamage(String source, double dmg, List<DamageChange> mod)
|
||||||
{
|
{
|
||||||
if (source == null)
|
if (source == null)
|
||||||
source = "-";
|
source = "-";
|
||||||
|
|
||||||
GetDamage().addFirst(new CombatDamage(source, dmg, mod, metadata));
|
GetDamage().addFirst(new CombatDamage(source, dmg, mod));
|
||||||
LastDamage = System.currentTimeMillis();
|
LastDamage = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package mineplex.minecraft.game.core.combat;
|
package mineplex.minecraft.game.core.combat;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import mineplex.minecraft.game.core.damage.DamageChange;
|
import mineplex.minecraft.game.core.damage.DamageChange;
|
||||||
|
|
||||||
@ -11,20 +10,14 @@ public class CombatDamage
|
|||||||
private String _name;
|
private String _name;
|
||||||
private double _dmg;
|
private double _dmg;
|
||||||
private long _time;
|
private long _time;
|
||||||
private List<DamageChange> _mod;
|
private List<DamageChange> _mod = new ArrayList<>();
|
||||||
private Map<String, Object> _metadata;
|
|
||||||
|
|
||||||
public CombatDamage(String name, double dmg, List<DamageChange> mod)
|
public CombatDamage(String name, double dmg, List<DamageChange> mod)
|
||||||
{
|
|
||||||
this(name, dmg, mod, new HashMap<>());
|
|
||||||
}
|
|
||||||
public CombatDamage(String name, double dmg, List<DamageChange> mod, Map<String, Object> metadata)
|
|
||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_dmg = dmg;
|
_dmg = dmg;
|
||||||
_time = System.currentTimeMillis();
|
_time = System.currentTimeMillis();
|
||||||
_mod = mod;
|
_mod = mod;
|
||||||
_metadata = metadata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetName()
|
public String GetName()
|
||||||
@ -46,17 +39,4 @@ public class CombatDamage
|
|||||||
{
|
{
|
||||||
return _mod;
|
return _mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves metadata that was associated with this damage via
|
|
||||||
* {@link mineplex.minecraft.game.core.damage.CustomDamageEvent#setMetadata(String, Object)}.
|
|
||||||
* <p/>
|
|
||||||
* There is no standardized metadata that should be expected. Metadata is meant to be used
|
|
||||||
* on a per-minigame basis to store additional information about the damage.
|
|
||||||
* @return a non-null map containing the metadata
|
|
||||||
*/
|
|
||||||
public Map<String, Object> getMetadata()
|
|
||||||
{
|
|
||||||
return _metadata;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package mineplex.minecraft.game.core.combat;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
@ -49,16 +48,11 @@ public class CombatLog
|
|||||||
|
|
||||||
public void Attacked(String damagerName, double damage,
|
public void Attacked(String damagerName, double damage,
|
||||||
LivingEntity damagerEnt, String attackName, List<DamageChange> mod)
|
LivingEntity damagerEnt, String attackName, List<DamageChange> mod)
|
||||||
{
|
|
||||||
this.Attacked(damagerName, damage, damagerEnt, attackName, mod, new HashMap<>());
|
|
||||||
}
|
|
||||||
public void Attacked(String damagerName, double damage,
|
|
||||||
LivingEntity damagerEnt, String attackName, List<DamageChange> mod, Map<String, Object> metadata)
|
|
||||||
{
|
{
|
||||||
// Add Attacked
|
// Add Attacked
|
||||||
CombatComponent comp = GetEnemy(damagerName, damagerEnt);
|
CombatComponent comp = GetEnemy(damagerName, damagerEnt);
|
||||||
|
|
||||||
comp.AddDamage(attackName, damage, mod, metadata);
|
comp.AddDamage(attackName, damage, mod);
|
||||||
|
|
||||||
// Set Last
|
// Set Last
|
||||||
LastDamager = comp;
|
LastDamager = comp;
|
||||||
|
@ -307,10 +307,11 @@ public class CombatManager extends MiniPlugin
|
|||||||
Get((Player)event.GetDamagerEntity(true)).SetLastCombatEngaged(System.currentTimeMillis());
|
Get((Player)event.GetDamagerEntity(true)).SetLastCombatEngaged(System.currentTimeMillis());
|
||||||
Get(event.GetDamageePlayer()).SetLastCombatEngaged(System.currentTimeMillis());
|
Get(event.GetDamageePlayer()).SetLastCombatEngaged(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
Get(event.GetDamageePlayer()).Attacked(
|
Get(event.GetDamageePlayer()).Attacked(
|
||||||
UtilEnt.getName(event.GetDamagerEntity(true)),
|
UtilEnt.getName(event.GetDamagerEntity(true)),
|
||||||
(int) event.GetDamage(), event.GetDamagerEntity(true),
|
(int) event.GetDamage(), event.GetDamagerEntity(true),
|
||||||
reason, event.GetDamageMod(), event.getMetadata());
|
reason, event.GetDamageMod());
|
||||||
}
|
}
|
||||||
// Damager is WORLD
|
// Damager is WORLD
|
||||||
else
|
else
|
||||||
@ -410,7 +411,7 @@ public class CombatManager extends MiniPlugin
|
|||||||
reason = event.GetReason();
|
reason = event.GetReason();
|
||||||
|
|
||||||
Get(event.GetDamageePlayer()).Attacked(source,
|
Get(event.GetDamageePlayer()).Attacked(source,
|
||||||
(int) event.GetDamage(), null, reason, event.GetDamageMod(), event.getMetadata());
|
(int) event.GetDamage(), null, reason, event.GetDamageMod());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,8 +488,8 @@ public class CombatManager extends MiniPlugin
|
|||||||
if (log.GetAssists() > 0)
|
if (log.GetAssists() > 0)
|
||||||
killPlayer += " + " + log.GetAssists();
|
killPlayer += " + " + log.GetAssists();
|
||||||
|
|
||||||
String weapon = (String) log.GetKiller().GetDamage().getFirst().getMetadata().get("customWeapon");
|
String weapon = log.GetKiller().GetLastDamageSource();
|
||||||
weapon = weapon == null ? log.GetKiller().GetLastDamageSource() : weapon;
|
|
||||||
UtilPlayer.message(
|
UtilPlayer.message(
|
||||||
cur,
|
cur,
|
||||||
F.main("Death",
|
F.main("Death",
|
||||||
|
@ -2,9 +2,7 @@ package mineplex.minecraft.game.core.damage;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -31,7 +29,6 @@ public class CustomDamageEvent extends Event implements Cancellable
|
|||||||
|
|
||||||
private HashMap<String, Double> _knockbackMod = new HashMap<String, Double>();
|
private HashMap<String, Double> _knockbackMod = new HashMap<String, Double>();
|
||||||
|
|
||||||
private Map<String, Object> _metadata = new HashMap<>();
|
|
||||||
//Ents
|
//Ents
|
||||||
private LivingEntity _damageeEntity;
|
private LivingEntity _damageeEntity;
|
||||||
private Player _damageePlayer;
|
private Player _damageePlayer;
|
||||||
@ -371,34 +368,6 @@ public class CustomDamageEvent extends Event implements Cancellable
|
|||||||
return IsCancelled();
|
return IsCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Associates the provided metadata key with the provided value.
|
|
||||||
* Metadata can later be retrieved from individual {@link
|
|
||||||
* mineplex.minecraft.game.core.combat.CombatDamage} instances acquired
|
|
||||||
* from the {@link mineplex.minecraft.game.core.combat.CombatLog}.
|
|
||||||
*
|
|
||||||
* @param key non-null key to associate the value with
|
|
||||||
* @param value nullable value
|
|
||||||
* @throws IllegalArgumentException if key is null
|
|
||||||
*/
|
|
||||||
public void setMetadata(String key, Object value)
|
|
||||||
{
|
|
||||||
Validate.notNull(key);
|
|
||||||
_metadata.put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all Metadata associated with this event. There is
|
|
||||||
* no standardized metadata that should be expected.
|
|
||||||
*
|
|
||||||
* @see #setMetadata(String, Object)
|
|
||||||
* @return non-null map of metadata
|
|
||||||
*/
|
|
||||||
public Map<String, Object> getMetadata()
|
|
||||||
{
|
|
||||||
return _metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
/**
|
/**
|
||||||
|
@ -345,7 +345,7 @@ public class DamageManager extends MiniPlugin
|
|||||||
Player damagee = event.GetDamageePlayer();
|
Player damagee = event.GetDamageePlayer();
|
||||||
|
|
||||||
//Not Survival
|
//Not Survival
|
||||||
if (damagee.getGameMode() != GameMode.SURVIVAL && damagee.getGameMode() != GameMode.ADVENTURE)
|
if (damagee.getGameMode() != GameMode.SURVIVAL)
|
||||||
{
|
{
|
||||||
event.SetCancelled("Damagee in Creative");
|
event.SetCancelled("Damagee in Creative");
|
||||||
return;
|
return;
|
||||||
@ -373,7 +373,7 @@ public class DamageManager extends MiniPlugin
|
|||||||
Player damager = event.GetDamagerPlayer(true);
|
Player damager = event.GetDamagerPlayer(true);
|
||||||
|
|
||||||
//Not Survival
|
//Not Survival
|
||||||
if (damager.getGameMode() != GameMode.SURVIVAL && damager.getGameMode() != GameMode.ADVENTURE)
|
if (damager.getGameMode() != GameMode.SURVIVAL)
|
||||||
{
|
{
|
||||||
event.SetCancelled("Damager in Creative");
|
event.SetCancelled("Damager in Creative");
|
||||||
return;
|
return;
|
||||||
|
@ -252,6 +252,7 @@ public class CustomExplosion extends Explosion
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
double d7 = entity.f(this.posX, this.posY, this.posZ) / this._size; // XXX
|
double d7 = entity.f(this.posX, this.posY, this.posZ) / this._size; // XXX
|
||||||
|
|
||||||
if (d7 <= 1.0D)
|
if (d7 <= 1.0D)
|
||||||
{
|
{
|
||||||
double d0 = entity.locX - this.posX;
|
double d0 = entity.locX - this.posX;
|
||||||
|
@ -13,9 +13,6 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.lifetimes.Lifetimed;
|
|
||||||
import mineplex.core.lifetimes.ListenerComponent;
|
|
||||||
import mineplex.core.lifetimes.PhasedLifetime;
|
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -109,8 +106,9 @@ import nautilus.game.arcade.world.WorldData;
|
|||||||
import net.minecraft.server.v1_8_R3.EntityItem;
|
import net.minecraft.server.v1_8_R3.EntityItem;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||||
|
|
||||||
public abstract class Game extends ListenerComponent implements Lifetimed
|
public abstract class Game implements Listener
|
||||||
{
|
{
|
||||||
|
|
||||||
private final static int MAX_TICK_SPEED_MEASUREMENT = 40;
|
private final static int MAX_TICK_SPEED_MEASUREMENT = 40;
|
||||||
|
|
||||||
public long getGameLiveTime()
|
public long getGameLiveTime()
|
||||||
@ -134,7 +132,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
private GameType _gameType;
|
private GameType _gameType;
|
||||||
protected String[] _gameDesc;
|
protected String[] _gameDesc;
|
||||||
|
|
||||||
private PhasedLifetime<GameState> _lifetime = new PhasedLifetime<>();
|
|
||||||
// Map
|
// Map
|
||||||
private HashMap<GameType, ArrayList<String>> _files;
|
private HashMap<GameType, ArrayList<String>> _files;
|
||||||
|
|
||||||
@ -387,7 +384,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
{
|
{
|
||||||
Manager = manager;
|
Manager = manager;
|
||||||
|
|
||||||
_lifetime.register(this);
|
|
||||||
// Player List
|
// Player List
|
||||||
UtilTabTitle.broadcastHeaderAndFooter(C.cGold + C.Bold + gameType.GetName(), "Visit " + C.cGreen + "www.mineplex.com"
|
UtilTabTitle.broadcastHeaderAndFooter(C.cGold + C.Bold + gameType.GetName(), "Visit " + C.cGreen + "www.mineplex.com"
|
||||||
+ ChatColor.RESET + " for News, Forums and Shop");
|
+ ChatColor.RESET + " for News, Forums and Shop");
|
||||||
@ -758,9 +754,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
for (Player player : UtilServer.getPlayers())
|
for (Player player : UtilServer.getPlayers())
|
||||||
player.leaveVehicle();
|
player.leaveVehicle();
|
||||||
|
|
||||||
|
|
||||||
_lifetime.setPhase(state);
|
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
GameStateChangeEvent stateEvent = new GameStateChangeEvent(this, state);
|
GameStateChangeEvent stateEvent = new GameStateChangeEvent(this, state);
|
||||||
UtilServer.getServer().getPluginManager().callEvent(stateEvent);
|
UtilServer.getServer().getPluginManager().callEvent(stateEvent);
|
||||||
@ -2343,11 +2336,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
|
|
||||||
public void disable()
|
public void disable()
|
||||||
{
|
{
|
||||||
cleanupModules();
|
|
||||||
cleanupCommands();
|
|
||||||
Managers.get(AntiHack.class).resetIgnoredChecks();
|
Managers.get(AntiHack.class).resetIgnoredChecks();
|
||||||
getLifetime().end();
|
|
||||||
getStatTrackers().forEach(HandlerList::unregisterAll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -2456,9 +2445,4 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
return clazz.cast(_modules.get(clazz));
|
return clazz.cast(_modules.get(clazz));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PhasedLifetime<GameState> getLifetime()
|
|
||||||
{
|
|
||||||
return _lifetime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package nautilus.game.arcade.game;
|
|
||||||
|
|
||||||
import mineplex.core.lifetimes.Lifetime;
|
|
||||||
import mineplex.core.lifetimes.Lifetimed;
|
|
||||||
import mineplex.core.lifetimes.ListenerComponent;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class GameComponent extends ListenerComponent implements Lifetimed
|
|
||||||
{
|
|
||||||
private final Lifetime _lifetime;
|
|
||||||
|
|
||||||
public GameComponent(Game game, Game.GameState...active)
|
|
||||||
{
|
|
||||||
if (active == null || active.length == 0)
|
|
||||||
{
|
|
||||||
// Active for the entire duration of the game.
|
|
||||||
_lifetime = game.getLifetime();
|
|
||||||
_lifetime.register(this);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
_lifetime = game.getLifetime().register(this, Arrays.asList(active));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Lifetime getLifetime()
|
|
||||||
{
|
|
||||||
return _lifetime;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1115,7 +1115,6 @@ public class Gladiators extends SoloGame
|
|||||||
@Override
|
@Override
|
||||||
public void disable()
|
public void disable()
|
||||||
{
|
{
|
||||||
super.disable();
|
|
||||||
_hotbarEditor.deregisterSelf(); // De-register as listener
|
_hotbarEditor.deregisterSelf(); // De-register as listener
|
||||||
_hotbarEditor.onDisable(); // Fully disable
|
_hotbarEditor.onDisable(); // Fully disable
|
||||||
}
|
}
|
||||||
|
@ -946,7 +946,6 @@ public class GunModule implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
event.SetKnockback(false);
|
event.SetKnockback(false);
|
||||||
event.setMetadata("gunType", "KNIFE");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1058,7 +1057,6 @@ public class GunModule implements Listener
|
|||||||
event.SetIgnoreArmor(true);
|
event.SetIgnoreArmor(true);
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new CustomGunDamageEvent(bullet, event.GetDamageePlayer(), hitArea == 1, event, this));
|
Bukkit.getPluginManager().callEvent(new CustomGunDamageEvent(bullet, event.GetDamageePlayer(), hitArea == 1, event, this));
|
||||||
event.setMetadata("gunType", bullet.Gun.getGunStats().name());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getArrowHitArea(Player damagee, Location origin, Vector trajectory)
|
public int getArrowHitArea(Player damagee, Location origin, Vector trajectory)
|
||||||
|
@ -7,7 +7,6 @@ import java.util.HashSet;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -249,6 +248,7 @@ public class Minestrike extends TeamGame
|
|||||||
GameTeam team = GetTeam(event.getPlayer());
|
GameTeam team = GetTeam(event.getPlayer());
|
||||||
if (team == null)
|
if (team == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
|
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
|
||||||
GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(),
|
GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(),
|
||||||
GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife"));
|
GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife"));
|
||||||
@ -270,7 +270,6 @@ public class Minestrike extends TeamGame
|
|||||||
{
|
{
|
||||||
if (IsAlive(event.getPlayer()))
|
if (IsAlive(event.getPlayer()))
|
||||||
{
|
{
|
||||||
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
|
||||||
//Pistol
|
//Pistol
|
||||||
Gun gun = new Gun(GunStats.GLOCK_18, _gunModule);
|
Gun gun = new Gun(GunStats.GLOCK_18, _gunModule);
|
||||||
_gunModule.registerGun(gun, event.getPlayer());
|
_gunModule.registerGun(gun, event.getPlayer());
|
||||||
@ -291,7 +290,6 @@ public class Minestrike extends TeamGame
|
|||||||
{
|
{
|
||||||
if (IsAlive(event.getPlayer()))
|
if (IsAlive(event.getPlayer()))
|
||||||
{
|
{
|
||||||
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
|
||||||
//Pistol
|
//Pistol
|
||||||
Gun gun = new Gun(GunStats.P2000, _gunModule);
|
Gun gun = new Gun(GunStats.P2000, _gunModule);
|
||||||
_gunModule.registerGun(gun, event.getPlayer());
|
_gunModule.registerGun(gun, event.getPlayer());
|
||||||
@ -403,26 +401,19 @@ public class Minestrike extends TeamGame
|
|||||||
if (GetTeam(killed).equals(GetTeam(killer)))
|
if (GetTeam(killed).equals(GetTeam(killer)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int amount;
|
int amount = 300;
|
||||||
|
|
||||||
String gunType = (String) event.GetLog().GetLastDamager().GetDamage().getFirst().getMetadata().get("gunType");
|
if (event.GetLog().GetLastDamager().GetReason().contains("AWP"))
|
||||||
switch (gunType)
|
|
||||||
{
|
|
||||||
case "AWP":
|
|
||||||
amount = 100;
|
amount = 100;
|
||||||
break;
|
|
||||||
case "PPBIZON":
|
else if (event.GetLog().GetLastDamager().GetReason().contains("PP-Bizon"))
|
||||||
amount = 600;
|
amount = 600;
|
||||||
break;
|
|
||||||
case "NOVA":
|
else if (event.GetLog().GetLastDamager().GetReason().contains("Nova"))
|
||||||
amount = 900;
|
amount = 900;
|
||||||
break;
|
|
||||||
case "KNIFE":
|
else if (event.GetLog().GetLastDamager().GetReason().contains("Knife"))
|
||||||
amount = 1500;
|
amount = 1500;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
amount = 300;
|
|
||||||
}
|
|
||||||
|
|
||||||
_shopManager.addMoney(killer, amount, "kill with " + event.GetLog().GetLastDamager().GetReason());
|
_shopManager.addMoney(killer, amount, "kill with " + event.GetLog().GetLastDamager().GetReason());
|
||||||
|
|
||||||
|
@ -589,10 +589,6 @@ public class Gun extends StrikeItem
|
|||||||
return _gunStats.getGunType();
|
return _gunStats.getGunType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GunStats getGunStats()
|
|
||||||
{
|
|
||||||
return _gunStats;
|
|
||||||
}
|
|
||||||
public String getBaseStatName(boolean withPlayerName)
|
public String getBaseStatName(boolean withPlayerName)
|
||||||
{
|
{
|
||||||
return (withPlayerName ? getOwnerName() + "." : "") + getName() + "." + _activeSkinName;
|
return (withPlayerName ? getOwnerName() + "." : "") + getName() + "." + _activeSkinName;
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package nautilus.game.arcade.game.games.wizards;
|
package nautilus.game.arcade.game.games.wizards;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.lifetimes.Lifetime;
|
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
|
||||||
import nautilus.game.arcade.game.GameComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -21,17 +20,18 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class WizardSpellMenu extends GameComponent
|
public class WizardSpellMenu extends MiniPlugin
|
||||||
{
|
{
|
||||||
private Wizards _wizards;
|
private Wizards _wizards;
|
||||||
private WizardSpellMenuShop _wizardShop;
|
private WizardSpellMenuShop _wizardShop;
|
||||||
private ItemStack _wizardSpells = new ItemBuilder(Material.ENCHANTED_BOOK).setTitle(C.cGold + "Wizard Spells")
|
private ItemStack _wizardSpells = new ItemBuilder(Material.ENCHANTED_BOOK).setTitle(C.cGold + "Wizard Spells")
|
||||||
.addLore(C.cGray + "Right click with this to view the spells").build();
|
.addLore(C.cGray + "Right click with this to view the spells").build();
|
||||||
|
|
||||||
public WizardSpellMenu(Wizards wizards)
|
public WizardSpellMenu(String moduleName, JavaPlugin plugin, Wizards wizards)
|
||||||
{
|
{
|
||||||
super(wizards);
|
super("Wizard Spell Menu", plugin);
|
||||||
_wizardShop = new WizardSpellMenuShop(this, wizards.getArcadeManager().GetClients(), wizards.getArcadeManager()
|
_wizardShop = new WizardSpellMenuShop(this, wizards.getArcadeManager().GetClients(), wizards.getArcadeManager()
|
||||||
.GetDonation(), wizards);
|
.GetDonation(), wizards);
|
||||||
_wizards = wizards;
|
_wizards = wizards;
|
||||||
@ -49,7 +49,7 @@ public class WizardSpellMenu extends GameComponent
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDeath(final PlayerDeathEvent event)
|
public void onDeath(final PlayerDeathEvent event)
|
||||||
{
|
{
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UtilServer.getPlugin(), new Runnable()
|
Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
@ -131,4 +131,5 @@ public class WizardSpellMenu extends GameComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ public class Wizards extends SoloGame
|
|||||||
new KitWitchDoctor(manager)
|
new KitWitchDoctor(manager)
|
||||||
});
|
});
|
||||||
|
|
||||||
_wizard = new WizardSpellMenu(this);
|
_wizard = new WizardSpellMenu("Wizard Spell Menu", getArcadeManager().getPlugin(), this);
|
||||||
|
|
||||||
AnnounceStay = false;
|
AnnounceStay = false;
|
||||||
BlockBreak = true;
|
BlockBreak = true;
|
||||||
@ -357,7 +357,7 @@ public class Wizards extends SoloGame
|
|||||||
{
|
{
|
||||||
percent = 10;
|
percent = 10;
|
||||||
}
|
}
|
||||||
else if (name.contains("GOLD") || name.contains("CHAINMAIL"))
|
else if (name.contains("GOLDEN") || name.contains("CHAINMAIL"))
|
||||||
{
|
{
|
||||||
percent = 15;
|
percent = 15;
|
||||||
}
|
}
|
||||||
@ -1115,16 +1115,8 @@ public class Wizards extends SoloGame
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(InventoryClickEvent event)
|
public void onClick(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
if (event.getClickedInventory() == null)
|
if (event.getClickedInventory() == null || !(event.getClickedInventory().getHolder() instanceof BlockState))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
InventoryHolder holder = event.getClickedInventory().getHolder();
|
|
||||||
// DoubleChests aren't a BlockState as they represent more than one block
|
|
||||||
if (!(holder instanceof BlockState || holder instanceof DoubleChest))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack item = event.getCurrentItem();
|
ItemStack item = event.getCurrentItem();
|
||||||
|
|
||||||
@ -1277,15 +1269,11 @@ public class Wizards extends SoloGame
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDropItem(PlayerDropItemEvent event)
|
public void onDropItem(PlayerDropItemEvent event)
|
||||||
{
|
{
|
||||||
// Check to see if they item they're dropping is from one of the first five slots(wand slots)
|
if (event.getPlayer().getInventory().getHeldItemSlot() < 5)
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
if (event.getPlayer().getInventory().getItem(i) == null)
|
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEndOrPrepare(GameStateChangeEvent event)
|
public void onEndOrPrepare(GameStateChangeEvent event)
|
||||||
|
@ -90,7 +90,7 @@ public class SpellAnvilDrop extends Spell implements SpellClick
|
|||||||
int spellLevel = entity.getMetadata("SpellLevel").get(0).asInt();
|
int spellLevel = entity.getMetadata("SpellLevel").get(0).asInt();
|
||||||
|
|
||||||
CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), Wizards.getArcadeManager()
|
CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), Wizards.getArcadeManager()
|
||||||
.GetExplosion(), entity.getLocation(), 4 + (spellLevel / 2F), "Anvil Drop");
|
.GetExplosion(), entity.getLocation(), 1 + (spellLevel / 2F), "Anvil Drop");
|
||||||
|
|
||||||
explosion.setPlayer((Player) entity.getMetadata("Wizard").get(0).value(), true);
|
explosion.setPlayer((Player) entity.getMetadata("Wizard").get(0).value(), true);
|
||||||
|
|
||||||
@ -98,8 +98,7 @@ public class SpellAnvilDrop extends Spell implements SpellClick
|
|||||||
|
|
||||||
explosion.setDropItems(false);
|
explosion.setDropItems(false);
|
||||||
|
|
||||||
explosion.setBlockExplosionSize(explosion.getSize() -3);
|
explosion.setMaxDamage(6 + (spellLevel * 4));
|
||||||
explosion.setExplosionDamage(3 + (spellLevel * 2));
|
|
||||||
|
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
|
|
||||||
|
@ -32,17 +32,17 @@ public class SpellFireball extends Spell implements SpellClick
|
|||||||
int spellLevel = projectile.getMetadata("SpellLevel").get(0).asInt();
|
int spellLevel = projectile.getMetadata("SpellLevel").get(0).asInt();
|
||||||
|
|
||||||
CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), Wizards.getArcadeManager()
|
CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), Wizards.getArcadeManager()
|
||||||
.GetExplosion(), projectile.getLocation(), (spellLevel * 0.3F) + 4F, "Fireball");
|
.GetExplosion(), projectile.getLocation(), (spellLevel * 0.3F) + 1F, "Fireball");
|
||||||
|
|
||||||
explosion.setPlayer((Player) projectile.getMetadata("FireballSpell").get(0).value(), true);
|
explosion.setPlayer((Player) projectile.getMetadata("FireballSpell").get(0).value(), true);
|
||||||
|
|
||||||
explosion.setFallingBlockExplosion(true);
|
explosion.setFallingBlockExplosion(true);
|
||||||
|
|
||||||
explosion.setBlockExplosionSize(explosion.getSize() - 2);
|
explosion.setBlockExplosionSize(explosion.getSize() + 1);
|
||||||
|
|
||||||
explosion.setDropItems(false);
|
explosion.setDropItems(false);
|
||||||
|
|
||||||
explosion.setExplosionDamage(spellLevel + 6);
|
explosion.setMaxDamage(spellLevel + 6);
|
||||||
|
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
}
|
}
|
||||||
|
@ -278,12 +278,10 @@ public class SpellRumble extends Spell implements SpellClickBlock, SpellClick
|
|||||||
|
|
||||||
if (entity instanceof Player)
|
if (entity instanceof Player)
|
||||||
{
|
{
|
||||||
// Why does Slowing by 2 apply slowness 1? The world may never know.
|
|
||||||
// As such, we subtract one from the spellLevel and ask no more questions
|
|
||||||
Wizards.getArcadeManager()
|
Wizards.getArcadeManager()
|
||||||
.GetCondition()
|
.GetCondition()
|
||||||
.Factory()
|
.Factory()
|
||||||
.Slow("Rumble", (LivingEntity) entity, player, 3, spellLevel-1, false, false,
|
.Slow("Rumble", (LivingEntity) entity, player, 3, spellLevel, false, false,
|
||||||
false, false);
|
false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,6 @@ public class SpellSummonWolves extends Spell implements SpellClick, SpellClickBl
|
|||||||
if (tamer instanceof Player)
|
if (tamer instanceof Player)
|
||||||
{
|
{
|
||||||
event.SetDamager((Player) tamer);
|
event.SetDamager((Player) tamer);
|
||||||
event.setMetadata("customWeapon", "Summon Wolves");
|
|
||||||
event.setKnockbackOrigin(wolf.getLocation());
|
event.setKnockbackOrigin(wolf.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,8 @@ public class GameCreationManager implements Listener
|
|||||||
{
|
{
|
||||||
if (Manager.GetGame().GetState() == GameState.Dead)
|
if (Manager.GetGame().GetState() == GameState.Dead)
|
||||||
{
|
{
|
||||||
Manager.GetGame().disable();
|
HandlerList.unregisterAll(Manager.GetGame());
|
||||||
|
|
||||||
//Schedule Cleanup
|
//Schedule Cleanup
|
||||||
_ended.add(Manager.GetGame());
|
_ended.add(Manager.GetGame());
|
||||||
|
|
||||||
@ -105,6 +106,15 @@ public class GameCreationManager implements Listener
|
|||||||
{
|
{
|
||||||
Game game = gameIterator.next();
|
Game game = gameIterator.next();
|
||||||
|
|
||||||
|
game.cleanupModules();
|
||||||
|
game.cleanupCommands();
|
||||||
|
game.disable();
|
||||||
|
|
||||||
|
HandlerList.unregisterAll(game);
|
||||||
|
|
||||||
|
for (StatTracker tracker : game.getStatTrackers())
|
||||||
|
HandlerList.unregisterAll(tracker);
|
||||||
|
|
||||||
TimingManager.start("GameCreationManager - Attempting Removal - " + game.GetName());
|
TimingManager.start("GameCreationManager - Attempting Removal - " + game.GetName());
|
||||||
|
|
||||||
//Cleaned
|
//Cleaned
|
||||||
@ -114,6 +124,7 @@ public class GameCreationManager implements Listener
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
boolean removedPlayers = false;
|
boolean removedPlayers = false;
|
||||||
if (UtilTime.elapsed(game.GetStateTime(), 20000))
|
if (UtilTime.elapsed(game.GetStateTime(), 20000))
|
||||||
{
|
{
|
||||||
@ -264,7 +275,7 @@ public class GameCreationManager implements Listener
|
|||||||
TimingManager.stop("DisplayNext");
|
TimingManager.stop("DisplayNext");
|
||||||
|
|
||||||
TimingManager.start("registerEvents");
|
TimingManager.start("registerEvents");
|
||||||
Manager.GetGame().getLifetime().start(GameState.Loading);
|
UtilServer.getServer().getPluginManager().registerEvents(Manager.GetGame(), Manager.getPlugin());
|
||||||
TimingManager.stop("registerEvents");
|
TimingManager.stop("registerEvents");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,25 +135,11 @@
|
|||||||
<version>2.8.1</version>
|
<version>2.8.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>4.12</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hamcrest</groupId>
|
|
||||||
<artifactId>hamcrest-library</artifactId>
|
|
||||||
<version>1.3</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.name}</finalName>
|
<finalName>${project.name}</finalName>
|
||||||
<testSourceDirectory>${project.basedir}/test</testSourceDirectory>
|
|
||||||
<sourceDirectory>${project.basedir}/src</sourceDirectory>
|
<sourceDirectory>${project.basedir}/src</sourceDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
Loading…
Reference in New Issue
Block a user