Mixins Reworked
This commit is contained in:
parent
615a212847
commit
5b6b29f6a9
@ -60,6 +60,22 @@ import com.massivecraft.massivecore.engine.EngineMassiveCoreTeleportMixinCause;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreVariable;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreWorldNameSet;
|
||||
import com.massivecraft.massivecore.integration.vault.IntegrationVault;
|
||||
import com.massivecraft.massivecore.mixin.MixinActionbar;
|
||||
import com.massivecraft.massivecore.mixin.MixinActual;
|
||||
import com.massivecraft.massivecore.mixin.MixinCommand;
|
||||
import com.massivecraft.massivecore.mixin.MixinDisplayName;
|
||||
import com.massivecraft.massivecore.mixin.MixinEvent;
|
||||
import com.massivecraft.massivecore.mixin.MixinGamemode;
|
||||
import com.massivecraft.massivecore.mixin.MixinInventory;
|
||||
import com.massivecraft.massivecore.mixin.MixinKick;
|
||||
import com.massivecraft.massivecore.mixin.MixinMessage;
|
||||
import com.massivecraft.massivecore.mixin.MixinModification;
|
||||
import com.massivecraft.massivecore.mixin.MixinPlayed;
|
||||
import com.massivecraft.massivecore.mixin.MixinSenderPs;
|
||||
import com.massivecraft.massivecore.mixin.MixinTeleport;
|
||||
import com.massivecraft.massivecore.mixin.MixinTitle;
|
||||
import com.massivecraft.massivecore.mixin.MixinVisibility;
|
||||
import com.massivecraft.massivecore.mixin.MixinWorld;
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
import com.massivecraft.massivecore.mson.MsonEvent;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
@ -220,7 +236,25 @@ public class MassiveCore extends MassivePlugin
|
||||
CmdMassiveCoreStore.get(),
|
||||
CmdMassiveCoreBuffer.get(),
|
||||
CmdMassiveCoreCmdurl.get(),
|
||||
CmdMassiveCoreClick.get()
|
||||
CmdMassiveCoreClick.get(),
|
||||
|
||||
// Mixin
|
||||
MixinEvent.get(), // NOTE: Should be first
|
||||
MixinActionbar.get(),
|
||||
MixinActual.get(),
|
||||
MixinCommand.get(),
|
||||
MixinDisplayName.get(),
|
||||
MixinGamemode.get(),
|
||||
MixinInventory.get(),
|
||||
MixinKick.get(),
|
||||
MixinMessage.get(),
|
||||
MixinModification.get(),
|
||||
MixinPlayed.get(),
|
||||
MixinSenderPs.get(),
|
||||
MixinTeleport.get(),
|
||||
MixinTitle.get(),
|
||||
MixinVisibility.get(),
|
||||
MixinWorld.get()
|
||||
);
|
||||
|
||||
// Start the examine threads
|
||||
|
@ -1,19 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
|
||||
public interface ActionbarMixin
|
||||
{
|
||||
// Abstract
|
||||
public boolean sendActionbarMessage(Object watcherObject, String message);
|
||||
|
||||
// Parsed
|
||||
public boolean sendActionbarMsg(Object watcherObject, String message);
|
||||
|
||||
// Mson
|
||||
public boolean sendActionbarMson(Object watcherObject, Mson mson);
|
||||
|
||||
// Available
|
||||
public boolean isActionbarAvailable();
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public abstract class ActionbarMixinAbstract implements ActionbarMixin
|
||||
{
|
||||
// Parsed
|
||||
@Override
|
||||
public boolean sendActionbarMsg(Object watcherObject, String message)
|
||||
{
|
||||
return this.sendActionbarMessage(watcherObject, Txt.parse(message));
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave;
|
||||
|
||||
public interface ActualMixin
|
||||
{
|
||||
public boolean isActualJoin(PlayerJoinEvent event);
|
||||
public boolean isActualLeave(EventMassiveCorePlayerLeave event);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public abstract class ActualMixinAbstract implements ActualMixin
|
||||
{
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public interface CommandMixin
|
||||
{
|
||||
public boolean dispatchCommand(Object senderObject, String commandLine);
|
||||
public boolean dispatchCommand(Object presentObject, Object senderObject, String commandLine); // This one is non-abstract
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public abstract class CommandMixinAbstract implements CommandMixin
|
||||
{
|
||||
@Override
|
||||
public boolean dispatchCommand(Object senderObject, String commandLine)
|
||||
{
|
||||
return this.dispatchCommand(senderObject, senderObject, commandLine);
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
|
||||
public interface DisplayNameMixin
|
||||
{
|
||||
public Mson getDisplayNameMson(Object senderObject, Object watcherObject);
|
||||
public String getDisplayName(Object senderObject, Object watcherObject);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
|
||||
public abstract class DisplayNameMixinAbstract implements DisplayNameMixin
|
||||
{
|
||||
public Mson getDisplayNameMson(Object senderObject, Object watcherObject)
|
||||
{
|
||||
String displayName = this.getDisplayName(senderObject, watcherObject);
|
||||
if (displayName == null) return null;
|
||||
return Mson.fromParsedMessage(displayName);
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
public interface GamemodeMixin
|
||||
{
|
||||
public GameMode getGamemode(Object playerObject);
|
||||
public void setGamemode(Object playerObject, GameMode gm);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public abstract class GamemodeMixinAbstract implements GamemodeMixin
|
||||
{
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public interface InventoryMixin
|
||||
{
|
||||
// Create a Player Inventory without a Player
|
||||
public PlayerInventory createPlayerInventory();
|
||||
|
||||
// Create an arbitrary size standard chest-like inventory
|
||||
public Inventory createInventory(InventoryHolder holder, int size, String title);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public abstract class InventoryMixinAbstract implements InventoryMixin
|
||||
{
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public interface KickMixin
|
||||
{
|
||||
public boolean kick(Object senderObject);
|
||||
public boolean kick(Object senderObject, String message);
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public abstract class KickMixinAbstract implements KickMixin
|
||||
{
|
||||
@Override
|
||||
public boolean kick(Object senderObject)
|
||||
{
|
||||
return this.kick(senderObject, null);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.massivecore.predicate.Predicate;
|
||||
|
||||
public interface MessageMixin
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// MSG
|
||||
// -------------------------------------------- //
|
||||
// All implemented in abstract!
|
||||
|
||||
// All
|
||||
public boolean msgAll(String msg);
|
||||
public boolean msgAll(String msg, Object... args);
|
||||
public boolean msgAll(Collection<String> msgs);
|
||||
|
||||
// Predicate
|
||||
public boolean msgPredicate(Predicate<CommandSender> predicate, String msg);
|
||||
public boolean msgPredicate(Predicate<CommandSender> predicate, String msg, Object... args);
|
||||
public boolean msgPredicate(Predicate<CommandSender> predicate, Collection<String> msgs);
|
||||
|
||||
// One
|
||||
public boolean msgOne(Object sendeeObject, String msg);
|
||||
public boolean msgOne(Object sendeeObject, String msg, Object... args);
|
||||
public boolean msgOne(Object sendeeObject, Collection<String> msgs);
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MESSAGE
|
||||
// -------------------------------------------- //
|
||||
|
||||
// All
|
||||
public boolean messageAll(Object message);
|
||||
public boolean messageAll(Object... messages);
|
||||
public boolean messageAll(Collection<?> messages);
|
||||
|
||||
// Predicate
|
||||
public boolean messagePredicate(Predicate<CommandSender> predicate, Object message);
|
||||
public boolean messagePredicate(Predicate<CommandSender> predicate, Object... messages);
|
||||
public boolean messagePredicate(Predicate<CommandSender> predicate, Collection<?> messages);
|
||||
|
||||
// One
|
||||
public boolean messageOne(Object sendeeObject, Object message);
|
||||
public boolean messageOne(Object sendeeObject, Object... messages);
|
||||
public boolean messageOne(Object sendeeObject, Collection<?> messages);
|
||||
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.massivecore.predicate.Predicate;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public abstract class MessageMixinAbstract implements MessageMixin
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// MSG STRING
|
||||
// -------------------------------------------- //
|
||||
// All implemented in abstract!
|
||||
|
||||
// All
|
||||
@Override
|
||||
public boolean msgAll(String msg)
|
||||
{
|
||||
return this.messageAll(Txt.parse(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean msgAll(String msg, Object... args)
|
||||
{
|
||||
return this.messageAll(Txt.parse(msg, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean msgAll(Collection<String> msgs)
|
||||
{
|
||||
return this.messageAll(Txt.parse(msgs));
|
||||
}
|
||||
|
||||
// Predicate
|
||||
@Override
|
||||
public boolean msgPredicate(Predicate<CommandSender> predicate, String msg)
|
||||
{
|
||||
return this.messagePredicate(predicate, Txt.parse(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean msgPredicate(Predicate<CommandSender> predicate, String msg, Object... args)
|
||||
{
|
||||
return this.messagePredicate(predicate, Txt.parse(msg, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean msgPredicate(Predicate<CommandSender> predicate, Collection<String> msgs)
|
||||
{
|
||||
return this.messagePredicate(predicate, Txt.parse(msgs));
|
||||
}
|
||||
|
||||
// One
|
||||
@Override
|
||||
public boolean msgOne(Object sendeeObject, String msg)
|
||||
{
|
||||
return this.messageOne(sendeeObject, Txt.parse(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean msgOne(Object sendeeObject, String msg, Object... args)
|
||||
{
|
||||
return this.messageOne(sendeeObject, Txt.parse(msg, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean msgOne(Object sendeeObject, Collection<String> msgs)
|
||||
{
|
||||
return this.messageOne(sendeeObject, Txt.parse(msgs));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MESSAGE
|
||||
// -------------------------------------------- //
|
||||
|
||||
// All
|
||||
@Override
|
||||
public boolean messageAll(Object message)
|
||||
{
|
||||
return this.messageAll(asCollection(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messageAll(Object... messages)
|
||||
{
|
||||
return this.messageAll(asCollection(messages));
|
||||
}
|
||||
|
||||
// Predicate
|
||||
@Override
|
||||
public boolean messagePredicate(Predicate<CommandSender> predicate, Object message)
|
||||
{
|
||||
return this.messagePredicate(predicate, asCollection(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messagePredicate(Predicate<CommandSender> predicate, Object... messages)
|
||||
{
|
||||
return this.messagePredicate(predicate, asCollection(messages));
|
||||
}
|
||||
|
||||
// One
|
||||
@Override
|
||||
public boolean messageOne(Object sendeeObject, Object message)
|
||||
{
|
||||
return this.messageOne(sendeeObject, asCollection(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean messageOne(Object sendeeObject, Object... messages)
|
||||
{
|
||||
return this.messageOne(sendeeObject, asCollection(messages));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UTIL
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Collection<?> asCollection(Object message)
|
||||
{
|
||||
if (message instanceof Collection) return (Collection<?>) message;
|
||||
if (message instanceof Object[]) return Arrays.asList((Object[]) message);
|
||||
return Collections.singleton(message);
|
||||
}
|
||||
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
import com.massivecraft.massivecore.nms.NmsPacket;
|
||||
import com.massivecraft.massivecore.predicate.Predicate;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
public class MessageMixinDefault extends MessageMixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static MessageMixinDefault i = new MessageMixinDefault();
|
||||
public static MessageMixinDefault get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MESSAGE
|
||||
// -------------------------------------------- //
|
||||
|
||||
// All
|
||||
// NOTE: Targets messageOne
|
||||
@Override
|
||||
public boolean messageAll(Collection<?> messages)
|
||||
{
|
||||
// Check Messages
|
||||
if (messages == null) return false;
|
||||
if (messages.isEmpty()) return false;
|
||||
|
||||
// Here
|
||||
for (CommandSender sender : IdUtil.getLocalSenders())
|
||||
{
|
||||
this.messageOne(sender, messages);
|
||||
}
|
||||
|
||||
// Return
|
||||
return true;
|
||||
}
|
||||
|
||||
// Predicate
|
||||
// NOTE: Targets messageOne
|
||||
@Override
|
||||
public boolean messagePredicate(Predicate<CommandSender> predicate, Collection<?> messages)
|
||||
{
|
||||
// Check Predicate
|
||||
if (predicate == null) return false;
|
||||
|
||||
// Check Messages
|
||||
if (messages == null) return false;
|
||||
if (messages.isEmpty()) return false;
|
||||
|
||||
// Here
|
||||
for (CommandSender sender : IdUtil.getLocalSenders())
|
||||
{
|
||||
if (!predicate.apply(sender)) continue;
|
||||
this.messageOne(sender, messages);
|
||||
}
|
||||
|
||||
// Return
|
||||
return true;
|
||||
}
|
||||
|
||||
// One
|
||||
// NOTE: The core implementation
|
||||
@Override
|
||||
public boolean messageOne(Object sendeeObject, Collection<?> messages)
|
||||
{
|
||||
// Check Sendee
|
||||
CommandSender sendee = IdUtil.getSender(sendeeObject);
|
||||
if (sendee == null) return false;
|
||||
|
||||
// Check Messages
|
||||
if (messages == null) return false;
|
||||
if (messages.isEmpty()) return false;
|
||||
|
||||
// For each Message
|
||||
for (Object message : messages)
|
||||
{
|
||||
if (message instanceof String)
|
||||
{
|
||||
String string = (String)message;
|
||||
sendee.sendMessage(string);
|
||||
}
|
||||
else if (message instanceof Mson)
|
||||
{
|
||||
Mson mson = (Mson)message;
|
||||
if (sendee instanceof Player && NmsPacket.get().isAvailable())
|
||||
{
|
||||
Player player = (Player) sendee;
|
||||
NmsPacket.sendRaw(player, mson.toRaw());
|
||||
}
|
||||
else
|
||||
{
|
||||
sendee.sendMessage(mson.toPlain(true));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String desc = (message == null ? "null" : message.getClass().getSimpleName());
|
||||
throw new IllegalArgumentException(desc + " is neither String nor Mson.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -23,122 +23,58 @@ import com.massivecraft.massivecore.teleport.Destination;
|
||||
|
||||
public class Mixin
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// GET/SET MIXINS
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static WorldMixin worldMixin = WorldMixinDefault.get();
|
||||
public static WorldMixin getWorldMixin() { return worldMixin; }
|
||||
public static void setWorldMixin(WorldMixin val) { worldMixin = val; }
|
||||
|
||||
private static DisplayNameMixin displayNameMixin = DisplayNameMixinDefault.get();
|
||||
public static DisplayNameMixin getDisplayNameMixin() { return displayNameMixin; }
|
||||
public static void setDisplayNameMixin(DisplayNameMixin val) { displayNameMixin = val; }
|
||||
|
||||
private static InventoryMixin inventoryMixin = InventoryMixinDefault.get();
|
||||
public static InventoryMixin getInventoryMixin() { return inventoryMixin; }
|
||||
public static void setInventoryMixin(InventoryMixin val) { inventoryMixin = val; }
|
||||
|
||||
private static SenderPsMixin senderPsMixin = SenderPsMixinDefault.get();
|
||||
public static SenderPsMixin getSenderPsMixin() { return senderPsMixin; }
|
||||
public static void setSenderPsMixin(SenderPsMixin val) { senderPsMixin = val; }
|
||||
|
||||
private static GamemodeMixin gamemodeMixin = GamemodeMixinDefault.get();
|
||||
public static GamemodeMixin getGamemodeMixin() { return gamemodeMixin; }
|
||||
public static void setGamemodeMixin(GamemodeMixin val) { gamemodeMixin = val; }
|
||||
|
||||
private static PlayedMixin playedMixin = PlayedMixinDefault.get();
|
||||
public static PlayedMixin getPlayedMixin() { return playedMixin; }
|
||||
public static void setPlayedMixin(PlayedMixin val) { playedMixin = val; }
|
||||
|
||||
private static VisibilityMixin visibilityMixin = VisibilityMixinDefault.get();
|
||||
public static VisibilityMixin getVisibilityMixin() { return visibilityMixin; }
|
||||
public static void setVisibilityMixin(VisibilityMixin val) { visibilityMixin = val; }
|
||||
|
||||
private static TeleportMixin teleportMixin = TeleportMixinDefault.get();
|
||||
public static TeleportMixin getTeleportMixin() { return teleportMixin; }
|
||||
public static void setTeleportMixin(TeleportMixin val) { teleportMixin = val; }
|
||||
|
||||
private static MessageMixin messageMixin = MessageMixinDefault.get();
|
||||
public static MessageMixin getMessageMixin() { return messageMixin; }
|
||||
public static void setMessageMixin(MessageMixin val) { messageMixin = val; }
|
||||
|
||||
private static ActionbarMixin actionbarMixin = ActionbarMixinDefault.get();
|
||||
public static ActionbarMixin getActionbarMixin() { return actionbarMixin; }
|
||||
public static void setActionbarMixin(ActionbarMixin val) { actionbarMixin = val; }
|
||||
|
||||
private static TitleMixin titleMixin = TitleMixinDefault.get();
|
||||
public static TitleMixin getTitleMixin() { return titleMixin; }
|
||||
public static void setTitleMixin(TitleMixin val) { titleMixin = val; }
|
||||
|
||||
private static KickMixin kickMixin = KickMixinDefault.get();
|
||||
public static KickMixin getKickMixin() { return kickMixin; }
|
||||
public static void setKickMixin(KickMixin val) { kickMixin = val; }
|
||||
|
||||
private static ActualMixin actualMixin = ActualMixinDefault.get();
|
||||
public static ActualMixin getActualMixin() { return actualMixin; }
|
||||
public static void setActualMixin(ActualMixin val) { actualMixin = val; }
|
||||
|
||||
private static CommandMixin commandMixin = CommandMixinDefault.get();
|
||||
public static CommandMixin getCommandMixin() { return commandMixin; }
|
||||
public static void setCommandMixin(CommandMixin val) { commandMixin = val; }
|
||||
|
||||
private static ModificationMixin modificationMixin = ModificationMixinDefault.get();
|
||||
public static ModificationMixin getModificationMixin() { return modificationMixin; }
|
||||
public static void setModificationMixin(ModificationMixin val) { modificationMixin = val; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// STATIC EXPOSE: WORLD
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static boolean canSeeWorld(Permissible permissible, String worldId)
|
||||
{
|
||||
return getWorldMixin().canSeeWorld(permissible, worldId);
|
||||
return MixinWorld.get().canSeeWorld(permissible, worldId);
|
||||
}
|
||||
|
||||
public static List<String> getWorldIds()
|
||||
{
|
||||
return getWorldMixin().getWorldIds();
|
||||
return MixinWorld.get().getWorldIds();
|
||||
}
|
||||
|
||||
public static List<String> getVisibleWorldIds(Permissible permissible)
|
||||
{
|
||||
return getWorldMixin().getVisibleWorldIds(permissible);
|
||||
return MixinWorld.get().getVisibleWorldIds(permissible);
|
||||
}
|
||||
|
||||
public static ChatColor getWorldColor(String worldId)
|
||||
{
|
||||
return getWorldMixin().getWorldColor(worldId);
|
||||
return MixinWorld.get().getWorldColor(worldId);
|
||||
}
|
||||
|
||||
public static List<String> getWorldAliases(String worldId)
|
||||
{
|
||||
return getWorldMixin().getWorldAliases(worldId);
|
||||
return MixinWorld.get().getWorldAliases(worldId);
|
||||
}
|
||||
|
||||
public static String getWorldAliasOrId(String worldId)
|
||||
{
|
||||
return getWorldMixin().getWorldAliasOrId(worldId);
|
||||
return MixinWorld.get().getWorldAliasOrId(worldId);
|
||||
}
|
||||
|
||||
public static String getWorldDisplayName(String worldId)
|
||||
{
|
||||
return getWorldMixin().getWorldDisplayName(worldId);
|
||||
return MixinWorld.get().getWorldDisplayName(worldId);
|
||||
}
|
||||
|
||||
public static PS getWorldSpawnPs(String worldId)
|
||||
{
|
||||
return getWorldMixin().getWorldSpawnPs(worldId);
|
||||
return MixinWorld.get().getWorldSpawnPs(worldId);
|
||||
}
|
||||
|
||||
public static void setWorldSpawnPs(String worldId, PS spawnPs)
|
||||
{
|
||||
getWorldMixin().setWorldSpawnPs(worldId, spawnPs);
|
||||
MixinWorld.get().setWorldSpawnPs(worldId, spawnPs);
|
||||
}
|
||||
|
||||
public static boolean trySetWorldSpawnWp(CommandSender sender, String worldId, PS spawnPs, boolean verbooseChange, boolean verbooseSame)
|
||||
{
|
||||
return getWorldMixin().trySetWorldSpawnWp(sender, worldId, spawnPs, verbooseChange, verbooseSame);
|
||||
return MixinWorld.get().trySetWorldSpawnWp(sender, worldId, spawnPs, verbooseChange, verbooseSame);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -148,17 +84,17 @@ public class Mixin
|
||||
@Deprecated
|
||||
public static String getDisplayName(Object senderObject)
|
||||
{
|
||||
return getDisplayNameMixin().getDisplayName(senderObject, null);
|
||||
return MixinDisplayName.get().getDisplayName(senderObject, null);
|
||||
}
|
||||
|
||||
public static String getDisplayName(Object senderObject, Object watcherObject)
|
||||
{
|
||||
return getDisplayNameMixin().getDisplayName(senderObject, watcherObject);
|
||||
return MixinDisplayName.get().getDisplayName(senderObject, watcherObject);
|
||||
}
|
||||
|
||||
public static Mson getDisplayNameMson(Object senderObject, Object watcherObject)
|
||||
{
|
||||
return getDisplayNameMixin().getDisplayNameMson(senderObject, watcherObject);
|
||||
return MixinDisplayName.get().getDisplayNameMson(senderObject, watcherObject);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -167,12 +103,12 @@ public class Mixin
|
||||
|
||||
public static PlayerInventory createPlayerInventory()
|
||||
{
|
||||
return getInventoryMixin().createPlayerInventory();
|
||||
return MixinInventory.get().createPlayerInventory();
|
||||
}
|
||||
|
||||
public static Inventory createInventory(InventoryHolder holder, int size, String title)
|
||||
{
|
||||
return getInventoryMixin().createInventory(holder, size, title);
|
||||
return MixinInventory.get().createInventory(holder, size, title);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -181,12 +117,12 @@ public class Mixin
|
||||
|
||||
public static PS getSenderPs(Object senderObject)
|
||||
{
|
||||
return getSenderPsMixin().getSenderPs(senderObject);
|
||||
return MixinSenderPs.get().getSenderPs(senderObject);
|
||||
}
|
||||
|
||||
public static void setSenderPs(Object senderObject, PS ps)
|
||||
{
|
||||
getSenderPsMixin().setSenderPs(senderObject, ps);
|
||||
MixinSenderPs.get().setSenderPs(senderObject, ps);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -195,12 +131,12 @@ public class Mixin
|
||||
|
||||
public static GameMode getGamemode(Object playerObject)
|
||||
{
|
||||
return getGamemodeMixin().getGamemode(playerObject);
|
||||
return MixinGamemode.get().getGamemode(playerObject);
|
||||
}
|
||||
|
||||
public static void setGamemode(Object playerObject, GameMode gm)
|
||||
public static void setGamemode(Object playerObject, GameMode gameMode)
|
||||
{
|
||||
getGamemodeMixin().setGamemode(playerObject, gm);
|
||||
MixinGamemode.get().setGamemode(playerObject, gameMode);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -209,27 +145,27 @@ public class Mixin
|
||||
|
||||
public static boolean isOnline(Object senderObject)
|
||||
{
|
||||
return getPlayedMixin().isOnline(senderObject);
|
||||
return MixinPlayed.get().isOnline(senderObject);
|
||||
}
|
||||
public static boolean isOffline(Object senderObject)
|
||||
{
|
||||
return getPlayedMixin().isOffline(senderObject);
|
||||
return MixinPlayed.get().isOffline(senderObject);
|
||||
}
|
||||
public static Long getLastPlayed(Object senderObject)
|
||||
{
|
||||
return getPlayedMixin().getLastPlayed(senderObject);
|
||||
return MixinPlayed.get().getLastPlayed(senderObject);
|
||||
}
|
||||
public static Long getFirstPlayed(Object senderObject)
|
||||
{
|
||||
return getPlayedMixin().getFirstPlayed(senderObject);
|
||||
return MixinPlayed.get().getFirstPlayed(senderObject);
|
||||
}
|
||||
public static boolean hasPlayedBefore(Object senderObject)
|
||||
{
|
||||
return getPlayedMixin().hasPlayedBefore(senderObject);
|
||||
return MixinPlayed.get().hasPlayedBefore(senderObject);
|
||||
}
|
||||
public static String getIp(Object senderObject)
|
||||
{
|
||||
return getPlayedMixin().getIp(senderObject);
|
||||
return MixinPlayed.get().getIp(senderObject);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -238,11 +174,11 @@ public class Mixin
|
||||
|
||||
public static boolean isVisible(Object watcheeObject)
|
||||
{
|
||||
return getVisibilityMixin().isVisible(watcheeObject);
|
||||
return MixinVisibility.get().isVisible(watcheeObject);
|
||||
}
|
||||
public static boolean isVisible(Object watcheeObject, Object watcherObject)
|
||||
{
|
||||
return getVisibilityMixin().isVisible(watcheeObject, watcherObject);
|
||||
return MixinVisibility.get().isVisible(watcheeObject, watcherObject);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -251,20 +187,20 @@ public class Mixin
|
||||
|
||||
public static boolean isCausedByMixin(PlayerTeleportEvent event)
|
||||
{
|
||||
return getTeleportMixin().isCausedByMixin(event);
|
||||
return MixinTeleport.get().isCausedByMixin(event);
|
||||
}
|
||||
|
||||
public static void teleport(Object teleporteeObject, Destination destination) throws TeleporterException
|
||||
{
|
||||
getTeleportMixin().teleport(teleporteeObject, destination);
|
||||
MixinTeleport.get().teleport(teleporteeObject, destination);
|
||||
}
|
||||
public static void teleport(Object teleporteeObject, Destination destination, Permissible delayPermissible) throws TeleporterException
|
||||
{
|
||||
getTeleportMixin().teleport(teleporteeObject, destination, delayPermissible);
|
||||
MixinTeleport.get().teleport(teleporteeObject, destination, delayPermissible);
|
||||
}
|
||||
public static void teleport(Object teleporteeObject, Destination destination, int delaySeconds) throws TeleporterException
|
||||
{
|
||||
getTeleportMixin().teleport(teleporteeObject, destination, delaySeconds);
|
||||
MixinTeleport.get().teleport(teleporteeObject, destination, delaySeconds);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -274,147 +210,140 @@ public class Mixin
|
||||
// MSG: All
|
||||
public static boolean msgAll(String msg)
|
||||
{
|
||||
return getMessageMixin().msgAll(msg);
|
||||
return MixinMessage.get().msgAll(msg);
|
||||
}
|
||||
|
||||
public static boolean msgAll(String msg, Object... args)
|
||||
{
|
||||
return getMessageMixin().msgAll(msg, args);
|
||||
return MixinMessage.get().msgAll(msg, args);
|
||||
}
|
||||
|
||||
public static boolean msgAll(Collection<String> msgs)
|
||||
{
|
||||
return getMessageMixin().msgAll(msgs);
|
||||
return MixinMessage.get().msgAll(msgs);
|
||||
}
|
||||
|
||||
// MSG: Predicate
|
||||
public static boolean msgPredicate(Predicate<CommandSender> predicate, String msg)
|
||||
{
|
||||
return getMessageMixin().msgPredicate(predicate, msg);
|
||||
return MixinMessage.get().msgPredicate(predicate, msg);
|
||||
}
|
||||
|
||||
public static boolean msgPredicate(Predicate<CommandSender> predicate, String msg, Object... args)
|
||||
{
|
||||
return getMessageMixin().msgPredicate(predicate, msg, args);
|
||||
return MixinMessage.get().msgPredicate(predicate, msg, args);
|
||||
}
|
||||
|
||||
public static boolean msgPredicate(Predicate<CommandSender> predicate, Collection<String> msgs)
|
||||
{
|
||||
return getMessageMixin().msgPredicate(predicate, msgs);
|
||||
return MixinMessage.get().msgPredicate(predicate, msgs);
|
||||
}
|
||||
|
||||
// MSG: One
|
||||
public static boolean msgOne(Object sendeeObject, String msg)
|
||||
{
|
||||
return getMessageMixin().msgOne(sendeeObject, msg);
|
||||
return MixinMessage.get().msgOne(sendeeObject, msg);
|
||||
}
|
||||
|
||||
public static boolean msgOne(Object sendeeObject, String msg, Object... args)
|
||||
{
|
||||
return getMessageMixin().msgOne(sendeeObject, msg, args);
|
||||
return MixinMessage.get().msgOne(sendeeObject, msg, args);
|
||||
}
|
||||
|
||||
public static boolean msgOne(Object sendeeObject, Collection<String> msgs)
|
||||
{
|
||||
return getMessageMixin().msgOne(sendeeObject, msgs);
|
||||
return MixinMessage.get().msgOne(sendeeObject, msgs);
|
||||
}
|
||||
|
||||
// MESSAGE: All
|
||||
public static boolean messageAll(Object message)
|
||||
{
|
||||
return getMessageMixin().messageAll(message);
|
||||
return MixinMessage.get().messageAll(message);
|
||||
}
|
||||
|
||||
public static boolean messageAll(Object... messages)
|
||||
{
|
||||
return getMessageMixin().messageAll(messages);
|
||||
return MixinMessage.get().messageAll(messages);
|
||||
}
|
||||
|
||||
public static boolean messageAll(Collection<?> messages)
|
||||
{
|
||||
return getMessageMixin().messageAll(messages);
|
||||
return MixinMessage.get().messageAll(messages);
|
||||
}
|
||||
|
||||
// MESSAGE: Predicate
|
||||
public static boolean messagePredicate(Predicate<CommandSender> predicate, Object message)
|
||||
{
|
||||
return getMessageMixin().messagePredicate(predicate, message);
|
||||
return MixinMessage.get().messagePredicate(predicate, message);
|
||||
}
|
||||
|
||||
public static boolean messagePredicate(Predicate<CommandSender> predicate, Object... messages)
|
||||
{
|
||||
return getMessageMixin().messagePredicate(predicate, messages);
|
||||
return MixinMessage.get().messagePredicate(predicate, messages);
|
||||
}
|
||||
|
||||
public static boolean messagePredicate(Predicate<CommandSender> predicate, Collection<?> messages)
|
||||
{
|
||||
return getMessageMixin().messagePredicate(predicate, messages);
|
||||
return MixinMessage.get().messagePredicate(predicate, messages);
|
||||
}
|
||||
|
||||
// MESSAGE: One
|
||||
public static boolean messageOne(Object sendeeObject, Object message)
|
||||
{
|
||||
return getMessageMixin().messageOne(sendeeObject, message);
|
||||
return MixinMessage.get().messageOne(sendeeObject, message);
|
||||
}
|
||||
|
||||
public static boolean messageOne(Object sendeeObject, Object... messages)
|
||||
{
|
||||
return getMessageMixin().messageOne(sendeeObject, messages);
|
||||
return MixinMessage.get().messageOne(sendeeObject, messages);
|
||||
}
|
||||
|
||||
public static boolean messageOne(Object sendeeObject, Collection<?> messages)
|
||||
{
|
||||
return getMessageMixin().messageOne(sendeeObject, messages);
|
||||
return MixinMessage.get().messageOne(sendeeObject, messages);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// STATIC EXPOSE: ACTIONBAR
|
||||
// -------------------------------------------- //
|
||||
|
||||
// Default
|
||||
public static boolean sendActionbarMessage(Object sendeeObject, String message)
|
||||
{
|
||||
return getActionbarMixin().sendActionbarMessage(sendeeObject, message);
|
||||
return MixinActionbar.get().sendActionbarMessage(sendeeObject, message);
|
||||
}
|
||||
|
||||
// Parsed
|
||||
public static boolean sendActionbarMsg(Object sendeeObject, String message)
|
||||
{
|
||||
return getActionbarMixin().sendActionbarMsg(sendeeObject, message);
|
||||
return MixinActionbar.get().sendActionbarMsg(sendeeObject, message);
|
||||
}
|
||||
|
||||
// Mson
|
||||
public static boolean sendActionbarMson(Object sendeeObject, Mson mson)
|
||||
{
|
||||
return getActionbarMixin().sendActionbarMson(sendeeObject, mson);
|
||||
return MixinActionbar.get().sendActionbarMson(sendeeObject, mson);
|
||||
}
|
||||
|
||||
// Available
|
||||
public static boolean isActionbarAvailable()
|
||||
{
|
||||
return getActionbarMixin().isActionbarAvailable();
|
||||
return MixinActionbar.get().isActionbarAvailable();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// STATIC EXPOSE: TITLE
|
||||
// -------------------------------------------- //
|
||||
|
||||
// Default
|
||||
public static boolean sendTitleMessage(Object watcherObject, int ticksIn, int ticksStay, int ticksOut, String titleMain, String titleSub)
|
||||
{
|
||||
return getTitleMixin().sendTitleMessage(watcherObject, ticksIn, ticksStay, ticksOut, titleMain, titleSub);
|
||||
return MixinTitle.get().sendTitleMessage(watcherObject, ticksIn, ticksStay, ticksOut, titleMain, titleSub);
|
||||
}
|
||||
|
||||
// Parsed
|
||||
public static boolean sendTitleMsg(Object watcherObject, int ticksIn, int ticksStay, int ticksOut, String titleMain, String titleSub)
|
||||
{
|
||||
return getTitleMixin().sendTitleMsg(watcherObject, ticksIn, ticksStay, ticksOut, titleMain, titleSub);
|
||||
return MixinTitle.get().sendTitleMsg(watcherObject, ticksIn, ticksStay, ticksOut, titleMain, titleSub);
|
||||
}
|
||||
|
||||
// Available
|
||||
public static boolean isTitlesAvailable()
|
||||
{
|
||||
return getTitleMixin().isTitlesAvailable();
|
||||
return MixinTitle.get().isTitlesAvailable();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -423,12 +352,12 @@ public class Mixin
|
||||
|
||||
public static boolean kick(Object senderObject)
|
||||
{
|
||||
return getKickMixin().kick(senderObject);
|
||||
return MixinKick.get().kick(senderObject);
|
||||
}
|
||||
|
||||
public static boolean kick(Object senderObject, String message)
|
||||
{
|
||||
return getKickMixin().kick(senderObject, message);
|
||||
return MixinKick.get().kick(senderObject, message);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -437,12 +366,12 @@ public class Mixin
|
||||
|
||||
public static boolean isActualJoin(PlayerJoinEvent event)
|
||||
{
|
||||
return getActualMixin().isActualJoin(event);
|
||||
return MixinActual.get().isActualJoin(event);
|
||||
}
|
||||
|
||||
public static boolean isActualLeave(EventMassiveCorePlayerLeave event)
|
||||
{
|
||||
return getActualMixin().isActualLeave(event);
|
||||
return MixinActual.get().isActualLeave(event);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -451,12 +380,12 @@ public class Mixin
|
||||
|
||||
public static boolean dispatchCommand(Object senderObject, String commandLine)
|
||||
{
|
||||
return getCommandMixin().dispatchCommand(senderObject, commandLine);
|
||||
return MixinCommand.get().dispatchCommand(senderObject, commandLine);
|
||||
}
|
||||
|
||||
public static boolean dispatchCommand(Object presentObject, Object senderObject, String commandLine)
|
||||
{
|
||||
return getCommandMixin().dispatchCommand(presentObject, senderObject, commandLine);
|
||||
return MixinCommand.get().dispatchCommand(presentObject, senderObject, commandLine);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -465,12 +394,12 @@ public class Mixin
|
||||
|
||||
public static void syncModification(Entity<?> entity)
|
||||
{
|
||||
getModificationMixin().syncModification(entity);
|
||||
MixinModification.get().syncModification(entity);
|
||||
}
|
||||
|
||||
public static void syncModification(Coll<?> coll, String id)
|
||||
{
|
||||
getModificationMixin().syncModification(coll, id);
|
||||
MixinModification.get().syncModification(coll, id);
|
||||
}
|
||||
|
||||
}
|
||||
|
39
src/com/massivecraft/massivecore/mixin/MixinAbstract.java
Normal file
39
src/com/massivecraft/massivecore/mixin/MixinAbstract.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.util.ReflectionUtil;
|
||||
|
||||
public class MixinAbstract extends Engine
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// STATIC REFLECTION
|
||||
// -------------------------------------------- //
|
||||
|
||||
private Class<?> clazz = ReflectionUtil.getSuperclassDeclaringField(this.getClass(), true, "d");
|
||||
public MixinAbstract getDefault() { return ReflectionUtil.getField(this.clazz, "d", null); }
|
||||
public MixinAbstract getInstance() { return ReflectionUtil.getField(this.clazz, "i", null); }
|
||||
public void setInstance(MixinAbstract i) { ReflectionUtil.setField(this.clazz, "i", null, i); }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
return this.getInstance() == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
this.setActiveMixin(active);
|
||||
super.setActive(active);
|
||||
}
|
||||
|
||||
public void setActiveMixin(boolean active)
|
||||
{
|
||||
this.setInstance(active ? this : this.getDefault());
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +1,26 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
import com.massivecraft.massivecore.nms.NmsPacket;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class ActionbarMixinDefault extends ActionbarMixinAbstract
|
||||
public class MixinActionbar extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ActionbarMixinDefault i = new ActionbarMixinDefault();
|
||||
public static ActionbarMixinDefault get() { return i; }
|
||||
private static MixinActionbar d = new MixinActionbar();
|
||||
private static MixinActionbar i = d;
|
||||
public static MixinActionbar get() { return i; }
|
||||
public static void set(MixinActionbar i) { MixinActionbar.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean sendActionbarMessage(Object watcherObject, String message)
|
||||
{
|
||||
// Get the player
|
||||
@ -31,7 +32,11 @@ public class ActionbarMixinDefault extends ActionbarMixinAbstract
|
||||
return NmsPacket.sendActionbar(player, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendActionbarMsg(Object watcherObject, String message)
|
||||
{
|
||||
return this.sendActionbarMessage(watcherObject, Txt.parse(message));
|
||||
}
|
||||
|
||||
public boolean sendActionbarMson(Object watcherObject, Mson mson)
|
||||
{
|
||||
// Get the player
|
||||
@ -44,7 +49,6 @@ public class ActionbarMixinDefault extends ActionbarMixinAbstract
|
||||
return NmsPacket.sendActionbar(player, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionbarAvailable()
|
||||
{
|
||||
return NmsPacket.get().isAvailable();
|
@ -4,26 +4,26 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave;
|
||||
|
||||
public class ActualMixinDefault extends ActualMixinAbstract
|
||||
public class MixinActual extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ActualMixinDefault i = new ActualMixinDefault();
|
||||
public static ActualMixinDefault get() { return i; }
|
||||
private static MixinActual d = new MixinActual();
|
||||
private static MixinActual i = d;
|
||||
public static MixinActual get() { return i; }
|
||||
public static void set(MixinActual i) { MixinActual.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean isActualJoin(PlayerJoinEvent event)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActualLeave(EventMassiveCorePlayerLeave event)
|
||||
{
|
||||
return true;
|
@ -2,23 +2,28 @@ package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
public class CommandMixinDefault extends CommandMixinAbstract
|
||||
public class MixinCommand extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static CommandMixinDefault i = new CommandMixinDefault();
|
||||
public static CommandMixinDefault get() { return i; }
|
||||
private static MixinCommand d = new MixinCommand();
|
||||
private static MixinCommand i = d;
|
||||
public static MixinCommand get() { return i; }
|
||||
public static void set(MixinCommand i) { MixinCommand.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean dispatchCommand(Object senderObject, String commandLine)
|
||||
{
|
||||
return this.dispatchCommand(senderObject, senderObject, commandLine);
|
||||
}
|
||||
|
||||
public boolean dispatchCommand(Object presentObject, Object senderObject, String commandLine)
|
||||
{
|
||||
// Additional enforced presence
|
@ -2,25 +2,33 @@ package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
public class DisplayNameMixinDefault extends DisplayNameMixinAbstract
|
||||
public class MixinDisplayName extends MixinAbstract
|
||||
{
|
||||
public final static ChatColor DEFAULT_COLOR = ChatColor.WHITE;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static DisplayNameMixinDefault i = new DisplayNameMixinDefault();
|
||||
public static DisplayNameMixinDefault get() { return i; }
|
||||
private static MixinDisplayName d = new MixinDisplayName();
|
||||
private static MixinDisplayName i = d;
|
||||
public static MixinDisplayName get() { return i; }
|
||||
public static void set(MixinDisplayName i) { MixinDisplayName.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public final static ChatColor DEFAULT_COLOR = ChatColor.WHITE;
|
||||
|
||||
public Mson getDisplayNameMson(Object senderObject, Object watcherObject)
|
||||
{
|
||||
String displayName = this.getDisplayName(senderObject, watcherObject);
|
||||
if (displayName == null) return null;
|
||||
return Mson.fromParsedMessage(displayName);
|
||||
}
|
||||
|
||||
public String getDisplayName(Object senderObject, Object watcherObject)
|
||||
{
|
||||
String senderId = IdUtil.getId(senderObject);
|
44
src/com/massivecraft/massivecore/mixin/MixinEvent.java
Normal file
44
src/com/massivecraft/massivecore/mixin/MixinEvent.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public class MixinEvent extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static MixinEvent d = new MixinEvent();
|
||||
private static MixinEvent i = d;
|
||||
public static MixinEvent get() { return i; }
|
||||
public static void set(MixinEvent i) { MixinEvent.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public <E extends Event & Serializable> void distribute(E event)
|
||||
{
|
||||
this.distribute(event, false);
|
||||
}
|
||||
|
||||
public <E extends Event & Serializable> void distribute(E event, boolean includeSelf)
|
||||
{
|
||||
this.distributeOthers(event);
|
||||
if (includeSelf) this.distributeSelf(event);
|
||||
}
|
||||
|
||||
protected <E extends Event & Serializable> void distributeSelf(E event)
|
||||
{
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
protected <E extends Event & Serializable> void distributeOthers(E event)
|
||||
{
|
||||
// NOTE: This is where the event would be sent to all other servers in the network.
|
||||
}
|
||||
|
||||
}
|
@ -5,20 +5,21 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
public class GamemodeMixinDefault extends GamemodeMixinAbstract
|
||||
public class MixinGamemode extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static GamemodeMixinDefault i = new GamemodeMixinDefault();
|
||||
public static GamemodeMixinDefault get() { return i; }
|
||||
private static MixinGamemode d = new MixinGamemode();
|
||||
private static MixinGamemode i = d;
|
||||
public static MixinGamemode get() { return i; }
|
||||
public static void set(MixinGamemode i) { MixinGamemode.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public GameMode getGamemode(Object playerObject)
|
||||
{
|
||||
Player player = IdUtil.getPlayer(playerObject);
|
||||
@ -27,13 +28,12 @@ public class GamemodeMixinDefault extends GamemodeMixinAbstract
|
||||
return player.getGameMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGamemode(Object playerObject, GameMode gm)
|
||||
public void setGamemode(Object playerObject, GameMode gameMode)
|
||||
{
|
||||
Player player = IdUtil.getPlayer(playerObject);
|
||||
if (player == null) return;
|
||||
|
||||
player.setGameMode(gm);
|
||||
player.setGameMode(gameMode);
|
||||
}
|
||||
|
||||
}
|
@ -7,26 +7,26 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.massivecraft.massivecore.nms.NmsInventory;
|
||||
|
||||
public class InventoryMixinDefault extends InventoryMixinAbstract
|
||||
public class MixinInventory extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static InventoryMixinDefault i = new InventoryMixinDefault();
|
||||
public static InventoryMixinDefault get() { return i; }
|
||||
private static MixinInventory d = new MixinInventory();
|
||||
private static MixinInventory i = d;
|
||||
public static MixinInventory get() { return i; }
|
||||
public static void set(MixinInventory i) { MixinInventory.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public PlayerInventory createPlayerInventory()
|
||||
{
|
||||
return NmsInventory.createPlayerInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory createInventory(InventoryHolder holder, int size, String title)
|
||||
{
|
||||
return Bukkit.createInventory(holder, size, title);
|
@ -4,20 +4,26 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
public class KickMixinDefault extends KickMixinAbstract
|
||||
public class MixinKick extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static KickMixinDefault i = new KickMixinDefault();
|
||||
public static KickMixinDefault get() { return i; }
|
||||
private static MixinKick d = new MixinKick();
|
||||
private static MixinKick i = d;
|
||||
public static MixinKick get() { return i; }
|
||||
public static void set(MixinKick i) { MixinKick.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean kick(Object senderObject)
|
||||
{
|
||||
return this.kick(senderObject, null);
|
||||
}
|
||||
|
||||
public boolean kick(Object senderObject, String message)
|
||||
{
|
||||
Player player = IdUtil.getPlayer(senderObject);
|
213
src/com/massivecraft/massivecore/mixin/MixinMessage.java
Normal file
213
src/com/massivecraft/massivecore/mixin/MixinMessage.java
Normal file
@ -0,0 +1,213 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
import com.massivecraft.massivecore.nms.NmsPacket;
|
||||
import com.massivecraft.massivecore.predicate.Predicate;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class MixinMessage extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static MixinMessage d = new MixinMessage();
|
||||
private static MixinMessage i = d;
|
||||
public static MixinMessage get() { return i; }
|
||||
public static void set(MixinMessage i) { MixinMessage.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MSG > ALL
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean msgAll(String msg)
|
||||
{
|
||||
return this.messageAll(Txt.parse(msg));
|
||||
}
|
||||
|
||||
public boolean msgAll(String msg, Object... args)
|
||||
{
|
||||
return this.messageAll(Txt.parse(msg, args));
|
||||
}
|
||||
|
||||
public boolean msgAll(Collection<String> msgs)
|
||||
{
|
||||
return this.messageAll(Txt.parse(msgs));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MSG > PREDICATE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean msgPredicate(Predicate<CommandSender> predicate, String msg)
|
||||
{
|
||||
return this.messagePredicate(predicate, Txt.parse(msg));
|
||||
}
|
||||
|
||||
public boolean msgPredicate(Predicate<CommandSender> predicate, String msg, Object... args)
|
||||
{
|
||||
return this.messagePredicate(predicate, Txt.parse(msg, args));
|
||||
}
|
||||
|
||||
public boolean msgPredicate(Predicate<CommandSender> predicate, Collection<String> msgs)
|
||||
{
|
||||
return this.messagePredicate(predicate, Txt.parse(msgs));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MSG > ONE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean msgOne(Object sendeeObject, String msg)
|
||||
{
|
||||
return this.messageOne(sendeeObject, Txt.parse(msg));
|
||||
}
|
||||
|
||||
public boolean msgOne(Object sendeeObject, String msg, Object... args)
|
||||
{
|
||||
return this.messageOne(sendeeObject, Txt.parse(msg, args));
|
||||
}
|
||||
|
||||
public boolean msgOne(Object sendeeObject, Collection<String> msgs)
|
||||
{
|
||||
return this.messageOne(sendeeObject, Txt.parse(msgs));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MESSAGE > ALL
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean messageAll(Object message)
|
||||
{
|
||||
return this.messageAll(asCollection(message));
|
||||
}
|
||||
|
||||
public boolean messageAll(Object... messages)
|
||||
{
|
||||
return this.messageAll(asCollection(messages));
|
||||
}
|
||||
|
||||
public boolean messageAll(Collection<?> messages)
|
||||
{
|
||||
// Check Messages
|
||||
if (messages == null) return false;
|
||||
if (messages.isEmpty()) return false;
|
||||
|
||||
// Here
|
||||
for (CommandSender sender : IdUtil.getLocalSenders())
|
||||
{
|
||||
this.messageOne(sender, messages);
|
||||
}
|
||||
|
||||
// Return
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MESSAGE > PREDICATE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean messagePredicate(Predicate<CommandSender> predicate, Object message)
|
||||
{
|
||||
return this.messagePredicate(predicate, asCollection(message));
|
||||
}
|
||||
|
||||
public boolean messagePredicate(Predicate<CommandSender> predicate, Object... messages)
|
||||
{
|
||||
return this.messagePredicate(predicate, asCollection(messages));
|
||||
}
|
||||
|
||||
public boolean messagePredicate(Predicate<CommandSender> predicate, Collection<?> messages)
|
||||
{
|
||||
// Check Predicate
|
||||
if (predicate == null) return false;
|
||||
|
||||
// Check Messages
|
||||
if (messages == null) return false;
|
||||
if (messages.isEmpty()) return false;
|
||||
|
||||
// Here
|
||||
for (CommandSender sender : IdUtil.getLocalSenders())
|
||||
{
|
||||
if ( ! predicate.apply(sender)) continue;
|
||||
this.messageOne(sender, messages);
|
||||
}
|
||||
|
||||
// Return
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MESSAGE > ONE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean messageOne(Object sendeeObject, Object message)
|
||||
{
|
||||
return this.messageOne(sendeeObject, asCollection(message));
|
||||
}
|
||||
|
||||
public boolean messageOne(Object sendeeObject, Object... messages)
|
||||
{
|
||||
return this.messageOne(sendeeObject, asCollection(messages));
|
||||
}
|
||||
|
||||
public boolean messageOne(Object sendeeObject, Collection<?> messages)
|
||||
{
|
||||
// Check Sendee
|
||||
CommandSender sendee = IdUtil.getSender(sendeeObject);
|
||||
if (sendee == null) return false;
|
||||
|
||||
// Check Messages
|
||||
if (messages == null) return false;
|
||||
if (messages.isEmpty()) return false;
|
||||
|
||||
// For each Message
|
||||
for (Object message : messages)
|
||||
{
|
||||
if (message instanceof String)
|
||||
{
|
||||
String string = (String)message;
|
||||
sendee.sendMessage(string);
|
||||
}
|
||||
else if (message instanceof Mson)
|
||||
{
|
||||
Mson mson = (Mson)message;
|
||||
if (sendee instanceof Player && NmsPacket.get().isAvailable())
|
||||
{
|
||||
Player player = (Player) sendee;
|
||||
NmsPacket.sendRaw(player, mson.toRaw());
|
||||
}
|
||||
else
|
||||
{
|
||||
sendee.sendMessage(mson.toPlain(true));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String desc = (message == null ? "null" : message.getClass().getSimpleName());
|
||||
throw new IllegalArgumentException(desc + " is neither String nor Mson.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UTIL
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Collection<?> asCollection(Object message)
|
||||
{
|
||||
if (message instanceof Collection) return (Collection<?>) message;
|
||||
if (message instanceof Object[]) return Arrays.asList((Object[]) message);
|
||||
return Collections.singleton(message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.store.Coll;
|
||||
import com.massivecraft.massivecore.store.Entity;
|
||||
|
||||
public class MixinModification extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static MixinModification d = new MixinModification();
|
||||
private static MixinModification i = d;
|
||||
public static MixinModification get() { return i; }
|
||||
public static void set(MixinModification i) { MixinModification.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void syncModification(Entity<?> entity)
|
||||
{
|
||||
this.syncModification(entity.getColl(), entity.getId());
|
||||
}
|
||||
|
||||
public void syncModification(Coll<?> coll, String id)
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
}
|
@ -9,20 +9,31 @@ import org.bukkit.command.CommandSender;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
|
||||
public class PlayedMixinDefault extends PlayedMixinAbstract
|
||||
public class MixinPlayed extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static PlayedMixinDefault i = new PlayedMixinDefault();
|
||||
public static PlayedMixinDefault get() { return i; }
|
||||
private static MixinPlayed d = new MixinPlayed();
|
||||
private static MixinPlayed i = d;
|
||||
public static MixinPlayed get() { return i; }
|
||||
public static void set(MixinPlayed i) { MixinPlayed.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean isOnline(Object senderObject)
|
||||
{
|
||||
return IdUtil.isOnline(senderObject);
|
||||
}
|
||||
|
||||
public boolean isOffline(Object senderObject)
|
||||
{
|
||||
return ! this.isOnline(senderObject);
|
||||
}
|
||||
|
||||
public Long getFirstPlayed(Object senderObject)
|
||||
{
|
||||
if (MUtil.isNpc(senderObject)) return null;
|
||||
@ -38,7 +49,6 @@ public class PlayedMixinDefault extends PlayedMixinAbstract
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getLastPlayed(Object senderObject)
|
||||
{
|
||||
//if (this.isOnline(senderObject)) return System.currentTimeMillis();
|
||||
@ -58,7 +68,12 @@ public class PlayedMixinDefault extends PlayedMixinAbstract
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlayedBefore(Object senderObject)
|
||||
{
|
||||
Long firstPlayed = this.getFirstPlayed(senderObject);
|
||||
return firstPlayed != null && firstPlayed != 0;
|
||||
}
|
||||
|
||||
public String getIp(Object senderObject)
|
||||
{
|
||||
CommandSender sender = IdUtil.getSender(senderObject);
|
@ -5,20 +5,21 @@ import org.bukkit.entity.Player;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
public class SenderPsMixinDefault extends SenderPsMixinAbstract
|
||||
public class MixinSenderPs extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static SenderPsMixinDefault i = new SenderPsMixinDefault();
|
||||
public static SenderPsMixinDefault get() { return i; }
|
||||
private static MixinSenderPs d = new MixinSenderPs();
|
||||
private static MixinSenderPs i = d;
|
||||
public static MixinSenderPs get() { return i; }
|
||||
public static void set(MixinSenderPs i) { MixinSenderPs.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public PS getSenderPs(Object senderObject)
|
||||
{
|
||||
Player player = IdUtil.getPlayer(senderObject);
|
||||
@ -26,9 +27,9 @@ public class SenderPsMixinDefault extends SenderPsMixinAbstract
|
||||
return PS.valueOf(player.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSenderPs(Object senderObject, PS ps)
|
||||
{
|
||||
// Bukkit does not support setting the physical state for offline players for now.
|
||||
}
|
||||
|
||||
}
|
@ -3,8 +3,11 @@ package com.massivecraft.massivecore.mixin;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.massivecraft.massivecore.MassiveCoreMConf;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreTeleportMixinCause;
|
||||
import com.massivecraft.massivecore.event.EventMassiveCorePlayerPSTeleport;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
@ -13,14 +16,36 @@ import com.massivecraft.massivecore.teleport.ScheduledTeleport;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class TeleportMixinDefault extends TeleportMixinAbstract
|
||||
public class MixinTeleport extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static TeleportMixinDefault i = new TeleportMixinDefault();
|
||||
public static TeleportMixinDefault get() { return i; }
|
||||
private static MixinTeleport d = new MixinTeleport();
|
||||
private static MixinTeleport i = d;
|
||||
public static MixinTeleport get() { return i; }
|
||||
public static void set(MixinTeleport i) { MixinTeleport.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean isCausedByMixin(PlayerTeleportEvent event)
|
||||
{
|
||||
return EngineMassiveCoreTeleportMixinCause.get().isCausedByTeleportMixin(event);
|
||||
}
|
||||
|
||||
public void teleport(Object teleportee, Destination destination) throws TeleporterException
|
||||
{
|
||||
this.teleport(teleportee, destination, 0);
|
||||
}
|
||||
|
||||
public void teleport(Object teleportee, Destination destination, Permissible delayPermissible) throws TeleporterException
|
||||
{
|
||||
int delaySeconds = MassiveCoreMConf.get().getTpdelay(delayPermissible);
|
||||
this.teleport(teleportee, destination, delaySeconds);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CORE LOGIC
|
||||
@ -71,7 +96,6 @@ public class TeleportMixinDefault extends TeleportMixinAbstract
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void teleport(Object teleporteeObject, Destination destination, int delaySeconds) throws TeleporterException
|
||||
{
|
||||
String teleporteeId = IdUtil.getId(teleporteeObject);
|
@ -4,21 +4,23 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.massivecore.nms.NmsPacket;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class TitleMixinDefault extends TitleMixinAbstract
|
||||
public class MixinTitle extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static TitleMixinDefault i = new TitleMixinDefault();
|
||||
public static TitleMixinDefault get() { return i; }
|
||||
private static MixinTitle d = new MixinTitle();
|
||||
private static MixinTitle i = d;
|
||||
public static MixinTitle get() { return i; }
|
||||
public static void set(MixinTitle i) { MixinTitle.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean sendTitleMessage(Object watcherObject, int ticksIn, int ticksStay, int ticksOut, String titleMain, String titleSub)
|
||||
{
|
||||
// Get the player
|
||||
@ -35,7 +37,13 @@ public class TitleMixinDefault extends TitleMixinAbstract
|
||||
return NmsPacket.sendTitle(player, ticksIn, ticksStay, ticksOut, titleMain, titleSub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendTitleMsg(Object watcherObject, int ticksIn, int ticksStay, int ticksOut, String titleMain, String titleSub)
|
||||
{
|
||||
if (titleMain != null) titleMain = Txt.parse(titleMain);
|
||||
if (titleSub != null) titleSub = Txt.parse(titleSub);
|
||||
return this.sendTitleMessage(watcherObject, ticksIn, ticksStay, ticksOut, titleMain, titleSub);
|
||||
}
|
||||
|
||||
public boolean isTitlesAvailable()
|
||||
{
|
||||
return NmsPacket.get().isAvailable();
|
@ -1,24 +1,24 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
|
||||
public class VisibilityMixinDefault extends VisibilityMixinAbstract
|
||||
public class MixinVisibility extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static VisibilityMixinDefault i = new VisibilityMixinDefault();
|
||||
public static VisibilityMixinDefault get() { return i; }
|
||||
private static MixinVisibility d = new MixinVisibility();
|
||||
private static MixinVisibility i = d;
|
||||
public static MixinVisibility get() { return i; }
|
||||
public static void set(MixinVisibility i) { MixinVisibility.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean isVisible(Object watcheeObject)
|
||||
{
|
||||
// The Bukkit API is not about general visibility.
|
||||
@ -40,7 +40,6 @@ public class VisibilityMixinDefault extends VisibilityMixinAbstract
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(Object watcheeObject, Object watcherObject)
|
||||
{
|
||||
Player pwatchee = IdUtil.getPlayer(watcheeObject);
|
@ -14,26 +14,26 @@ import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.ps.PSFormatDesc;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
|
||||
public class WorldMixinDefault extends WorldMixinAbstract
|
||||
public class MixinWorld extends MixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static WorldMixinDefault i = new WorldMixinDefault();
|
||||
public static WorldMixinDefault get() { return i; }
|
||||
private static MixinWorld d = new MixinWorld();
|
||||
private static MixinWorld i = d;
|
||||
public static MixinWorld get() { return i; }
|
||||
public static void set(MixinWorld i) { MixinWorld.i = i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean canSeeWorld(Permissible permissible, String worldId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWorldIds()
|
||||
{
|
||||
// Create
|
||||
@ -49,19 +49,44 @@ public class WorldMixinDefault extends WorldMixinAbstract
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVisibleWorldIds(Permissible permissible)
|
||||
{
|
||||
// Create
|
||||
List<String> ret = new ArrayList<String>();
|
||||
|
||||
// Fill
|
||||
for (String worldId : this.getWorldIds())
|
||||
{
|
||||
if ( ! this.canSeeWorld(permissible, worldId)) continue;
|
||||
ret.add(worldId);
|
||||
}
|
||||
|
||||
// Return
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ChatColor getWorldColor(String worldId)
|
||||
{
|
||||
return ChatColor.WHITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWorldAliases(String worldId)
|
||||
{
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldAliasOrId(String worldId)
|
||||
{
|
||||
List<String> aliases = this.getWorldAliases(worldId);
|
||||
if (aliases.size() > 0) return aliases.get(0);
|
||||
return worldId;
|
||||
}
|
||||
|
||||
public String getWorldDisplayName(String worldId)
|
||||
{
|
||||
return this.getWorldColor(worldId).toString() + this.getWorldAliasOrId(worldId);
|
||||
}
|
||||
|
||||
public PS getWorldSpawnPs(String worldId)
|
||||
{
|
||||
World world = Bukkit.getWorld(worldId);
|
||||
@ -69,7 +94,6 @@ public class WorldMixinDefault extends WorldMixinAbstract
|
||||
return PS.valueOf(world.getSpawnLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorldSpawnPs(String worldId, PS spawnPs)
|
||||
{
|
||||
World world = Bukkit.getWorld(worldId);
|
||||
@ -90,7 +114,6 @@ public class WorldMixinDefault extends WorldMixinAbstract
|
||||
world.setSpawnLocation(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trySetWorldSpawnWp(CommandSender sender, String worldId, PS goal, boolean verbooseChange, boolean verbooseSame)
|
||||
{
|
||||
World world = Bukkit.getWorld(worldId);
|
@ -1,10 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.store.Coll;
|
||||
import com.massivecraft.massivecore.store.Entity;
|
||||
|
||||
public interface ModificationMixin
|
||||
{
|
||||
public void syncModification(Entity<?> entity);
|
||||
public void syncModification(Coll<?> coll, String id);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.store.Entity;
|
||||
|
||||
public abstract class ModificationMixinAbstract implements ModificationMixin
|
||||
{
|
||||
public void syncModification(Entity<?> entity)
|
||||
{
|
||||
this.syncModification(entity.getColl(), entity.getId());
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.store.Coll;
|
||||
|
||||
public class ModificationMixinDefault extends ModificationMixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ModificationMixinDefault i = new ModificationMixinDefault();
|
||||
public static ModificationMixinDefault get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
@Override
|
||||
public void syncModification(Coll<?> coll, String id)
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public interface PlayedMixin
|
||||
{
|
||||
public boolean isOnline(Object senderObject);
|
||||
public boolean isOffline(Object senderObject);
|
||||
public Long getFirstPlayed(Object senderObject);
|
||||
public Long getLastPlayed(Object senderObject);
|
||||
public boolean hasPlayedBefore(Object senderObject);
|
||||
public String getIp(Object senderObject);
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
public abstract class PlayedMixinAbstract implements PlayedMixin
|
||||
{
|
||||
@Override
|
||||
public boolean isOnline(Object senderObject)
|
||||
{
|
||||
return IdUtil.isOnline(senderObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffline(Object senderObject)
|
||||
{
|
||||
return !this.isOnline(senderObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlayedBefore(Object senderObject)
|
||||
{
|
||||
Long firstPlayed = this.getFirstPlayed(senderObject);
|
||||
return firstPlayed != null && firstPlayed != 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
public interface SenderPsMixin
|
||||
{
|
||||
public PS getSenderPs(Object senderObject);
|
||||
public void setSenderPs(Object senderObject, PS ps);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public abstract class SenderPsMixinAbstract implements SenderPsMixin
|
||||
{
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
import com.massivecraft.massivecore.teleport.Destination;
|
||||
|
||||
public interface TeleportMixin
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CHECK
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean isCausedByMixin(PlayerTeleportEvent event);
|
||||
|
||||
// PERMUTATION
|
||||
// # to
|
||||
// PS
|
||||
// CommandSender
|
||||
// SenderEntity
|
||||
// String
|
||||
// PSGetter
|
||||
|
||||
// -------------------------------------------- //
|
||||
// COMMAND SENDER
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void teleport(Object teleporteeObject, Destination destination) throws TeleporterException;
|
||||
public void teleport(Object teleporteeObject, Destination destination, Permissible delayPermissible) throws TeleporterException;
|
||||
public void teleport(Object teleporteeObject, Destination destination, int delaySeconds) throws TeleporterException;
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
import com.massivecraft.massivecore.MassiveCoreMConf;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreTeleportMixinCause;
|
||||
import com.massivecraft.massivecore.teleport.Destination;
|
||||
|
||||
public abstract class TeleportMixinAbstract implements TeleportMixin
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// UTIL
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static int getTpdelay(Permissible delayPermissible)
|
||||
{
|
||||
return MassiveCoreMConf.get().getTpdelay(delayPermissible);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean isCausedByMixin(PlayerTeleportEvent event)
|
||||
{
|
||||
return EngineMassiveCoreTeleportMixinCause.get().isCausedByTeleportMixin(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Object teleportee, Destination destination) throws TeleporterException
|
||||
{
|
||||
this.teleport(teleportee, destination, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Object teleportee, Destination destination, Permissible delayPermissible) throws TeleporterException
|
||||
{
|
||||
this.teleport(teleportee, destination, getTpdelay(delayPermissible));
|
||||
}
|
||||
|
||||
// TO OVERRIDE
|
||||
/*
|
||||
@Override
|
||||
public void teleport(Object teleporteeObject, Destination destination, int delaySeconds) throws TeleporterException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
*/
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public interface TitleMixin
|
||||
{
|
||||
// Abstract
|
||||
public boolean sendTitleMessage(Object watcherObject, int ticksIn, int ticksStay, int ticksOut, String titleMain, String titleSub);
|
||||
|
||||
// Parsed
|
||||
public boolean sendTitleMsg(Object watcherObject, int ticksIn, int ticksStay, int ticksOut, String titleMain, String titleSub);
|
||||
|
||||
// Available
|
||||
public boolean isTitlesAvailable();
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public abstract class TitleMixinAbstract implements TitleMixin
|
||||
{
|
||||
// Parsed
|
||||
@Override
|
||||
public boolean sendTitleMsg(Object watcherObject, int ticksIn, int ticksStay, int ticksOut, String titleMain, String titleSub)
|
||||
{
|
||||
if (titleMain != null) titleMain = Txt.parse(titleMain);
|
||||
if (titleSub != null) titleSub = Txt.parse(titleSub);
|
||||
return this.sendTitleMessage(watcherObject, ticksIn, ticksStay, ticksOut, titleMain, titleSub);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public interface VisibilityMixin
|
||||
{
|
||||
public boolean isVisible(Object watcheeObject);
|
||||
public boolean isVisible(Object watcheeObject, Object watcherObject);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public abstract class VisibilityMixinAbstract implements VisibilityMixin
|
||||
{
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
public interface WorldMixin
|
||||
{
|
||||
public boolean canSeeWorld(Permissible permissible, String worldId);
|
||||
|
||||
public List<String> getWorldIds();
|
||||
|
||||
public List<String> getVisibleWorldIds(Permissible permissible);
|
||||
|
||||
public ChatColor getWorldColor(String worldId);
|
||||
|
||||
public List<String> getWorldAliases(String worldId);
|
||||
|
||||
public String getWorldAliasOrId(String worldId);
|
||||
|
||||
public String getWorldDisplayName(String worldId);
|
||||
|
||||
public PS getWorldSpawnPs(String worldId);
|
||||
|
||||
public void setWorldSpawnPs(String worldId, PS spawnPs);
|
||||
|
||||
public boolean trySetWorldSpawnWp(CommandSender sender, String worldId, PS spawnPs, boolean verbooseChange, boolean verbooseSame);
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
public abstract class WorldMixinAbstract implements WorldMixin
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public List<String> getVisibleWorldIds(Permissible permissible)
|
||||
{
|
||||
// Create
|
||||
List<String> ret = new ArrayList<String>();
|
||||
|
||||
// Fill
|
||||
for (String worldId : this.getWorldIds())
|
||||
{
|
||||
if ( ! this.canSeeWorld(permissible, worldId)) continue;
|
||||
ret.add(worldId);
|
||||
}
|
||||
|
||||
// Return
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldAliasOrId(String worldId)
|
||||
{
|
||||
List<String> aliases = this.getWorldAliases(worldId);
|
||||
if (aliases.size() > 0) return aliases.get(0);
|
||||
return worldId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldDisplayName(String worldId)
|
||||
{
|
||||
return this.getWorldColor(worldId).toString() + this.getWorldAliasOrId(worldId);
|
||||
}
|
||||
|
||||
}
|
@ -264,6 +264,22 @@ public class ReflectionUtil
|
||||
});
|
||||
}
|
||||
|
||||
public static Class<?> getSuperclassDeclaringField(Class<?> clazz, boolean includeSelf, final String fieldName)
|
||||
{
|
||||
return getSuperclassPredicate(clazz, includeSelf, new Predicate<Class<?>>()
|
||||
{
|
||||
@Override
|
||||
public boolean apply(Class<?> clazz)
|
||||
{
|
||||
for (Field field : clazz.getDeclaredFields())
|
||||
{
|
||||
if (field.getName().equals(fieldName)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// AS RUNTIME EXCEPTION
|
||||
// -------------------------------------------- //
|
||||
|
Loading…
Reference in New Issue
Block a user