Merge branches 'develop' and 'feature/report' of github.com:Mineplex-LLC/Minecraft-PC into feature/report
# Conflicts: # Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java
This commit is contained in:
commit
b68aea00c6
@ -0,0 +1,61 @@
|
||||
package mineplex.core.common.events;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called just before UtilPlayer#message sends out a message to the specified Player.
|
||||
*/
|
||||
public class PlayerMessageEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private String _message;
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public PlayerMessageEvent(Player player, String message)
|
||||
{
|
||||
_player = player;
|
||||
_message = message;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
public String getUnformattedMessage()
|
||||
{
|
||||
return ChatColor.stripColor(_message);
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled)
|
||||
{
|
||||
_cancelled = cancelled;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -43,38 +43,6 @@ public class ChildJsonMessage extends JsonMessage
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage italic()
|
||||
{
|
||||
super.italic();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage underlined()
|
||||
{
|
||||
super.underlined();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage strikethrough()
|
||||
{
|
||||
super.strikethrough();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage obfuscated()
|
||||
{
|
||||
super.obfuscated();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage click(String action, String value)
|
||||
{
|
||||
@ -83,14 +51,6 @@ public class ChildJsonMessage extends JsonMessage
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage click(ClickEvent event, String value)
|
||||
{
|
||||
super.click(event, value);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage hover(String action, String value)
|
||||
{
|
||||
@ -99,14 +59,6 @@ public class ChildJsonMessage extends JsonMessage
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage hover(HoverEvent event, String value)
|
||||
{
|
||||
super.hover(event, value);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ import org.bukkit.util.BlockIterator;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.MinecraftVersion;
|
||||
import mineplex.core.common.events.PlayerMessageEvent;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PlayerConnection;
|
||||
@ -277,6 +278,12 @@ public class UtilPlayer
|
||||
message = UtilWiki.link(message);
|
||||
*/
|
||||
|
||||
PlayerMessageEvent event = UtilServer.CallEvent(new PlayerMessageEvent((Player) client, message));
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
|
||||
((Player) client).sendMessage(message);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,12 @@ public class UtilServer
|
||||
|
||||
public static boolean IsOnline(String name)
|
||||
{
|
||||
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(player -> player.getName().equals(name)));
|
||||
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(name::equals));
|
||||
}
|
||||
|
||||
public static boolean IsOffline(String name)
|
||||
{
|
||||
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(name::equals));
|
||||
}
|
||||
|
||||
public static Player GetPlayer(String name)
|
||||
|
@ -2,10 +2,13 @@ package mineplex.core.common.util;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class UtilStreams
|
||||
{
|
||||
public static boolean IsEmpty(Stream<?> stream)
|
||||
@ -55,4 +58,9 @@ public class UtilStreams
|
||||
return read;
|
||||
}
|
||||
|
||||
public static <T> List<T> ToList(Stream<T> filter)
|
||||
{
|
||||
return Lists.newArrayList((T[]) ToArray(filter));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
package mineplex.core.chatsnap;
|
||||
|
||||
/**
|
||||
* Holds all types of messages a player can receive from another player
|
||||
*/
|
||||
public enum MessageType
|
||||
{
|
||||
CHAT,
|
||||
PM
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
package mineplex.core.chatsnap;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Represents a message sent by a player.
|
||||
*/
|
||||
public class Snapshot implements Comparable<Snapshot>
|
||||
{
|
||||
@SerializedName("type")
|
||||
private MessageType _messageType;
|
||||
|
||||
@SerializedName("sender")
|
||||
private UUID _sender;
|
||||
|
||||
@SerializedName("recipients")
|
||||
private Collection<UUID> _recipients;
|
||||
|
||||
@SerializedName("message")
|
||||
private String _message;
|
||||
|
||||
@SerializedName("time")
|
||||
private LocalDateTime _time;
|
||||
|
||||
public Snapshot(UUID sender, UUID recipient, String message)
|
||||
{
|
||||
this(MessageType.PM, sender, Collections.singletonList(recipient), message, LocalDateTime.now());
|
||||
}
|
||||
|
||||
public Snapshot(UUID sender, Collection<UUID> recipients, String message)
|
||||
{
|
||||
this(MessageType.CHAT, sender, recipients, message, LocalDateTime.now());
|
||||
}
|
||||
|
||||
public Snapshot(MessageType messageType, UUID sender, Collection<UUID> recipients, String message, LocalDateTime time)
|
||||
{
|
||||
_messageType = messageType;
|
||||
_sender = checkNotNull(sender);
|
||||
_recipients = checkNotNull(recipients);
|
||||
_message = checkNotNull(message);
|
||||
_time = checkNotNull(time);
|
||||
|
||||
if (messageType == MessageType.PM && recipients.size() > 1)
|
||||
{
|
||||
throw new IllegalArgumentException("Snapshot type PM may not have more than 1 recipient.");
|
||||
}
|
||||
}
|
||||
|
||||
public MessageType getMessageType()
|
||||
{
|
||||
return _messageType;
|
||||
}
|
||||
|
||||
public UUID getSender()
|
||||
{
|
||||
return _sender;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
public Set<UUID> getRecipients()
|
||||
{
|
||||
return new HashSet<>(_recipients);
|
||||
}
|
||||
|
||||
public LocalDateTime getSentTime()
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Snapshot o)
|
||||
{
|
||||
return getSentTime().compareTo(o.getSentTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Snapshot that = (Snapshot) o;
|
||||
return _time == that._time &&
|
||||
Objects.equals(_sender, that._sender) &&
|
||||
Objects.equals(_recipients, that._recipients) &&
|
||||
Objects.equals(_message, that._message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(_sender, _recipients, _message, _time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Snapshot{" +
|
||||
"sender=" + _sender +
|
||||
", recipients=" + _recipients +
|
||||
", message='" + ChatColor.stripColor(_message) + '\'' +
|
||||
", created=" + _time +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package mineplex.core.chatsnap;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import mineplex.core.chatsnap.publishing.SnapshotPublisher;
|
||||
|
||||
/**
|
||||
* Handles temporary storage of {@link Snapshot} instances.
|
||||
*/
|
||||
public class SnapshotManager
|
||||
{
|
||||
// There aren't any List or Set caching implementations
|
||||
// For an easy work around, we store values as the Key
|
||||
// For the value we just use some dummy object
|
||||
// I went with Boolean as it's the smallest data type
|
||||
private final Cache<Snapshot, Boolean> _snapshots = CacheBuilder.newBuilder()
|
||||
.concurrencyLevel(4)
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
private final SnapshotPublisher _snapshotPublisher;
|
||||
|
||||
public SnapshotManager(SnapshotPublisher snapshotPublisher)
|
||||
{
|
||||
_snapshotPublisher = snapshotPublisher;
|
||||
}
|
||||
|
||||
public SnapshotPublisher getSnapshotPublisher()
|
||||
{
|
||||
return _snapshotPublisher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps a snapshot in memory temporarily (30 minutes) and then discards it.
|
||||
* During this time, other modules (such as the Report module) can access it for their own use.
|
||||
*
|
||||
* @param snapshot the snapshot to temporarily store
|
||||
*/
|
||||
public void cacheSnapshot(Snapshot snapshot)
|
||||
{
|
||||
_snapshots.put(snapshot, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all currently stored snapshots.
|
||||
* The set is in chronological order of the time the message was sent.
|
||||
*
|
||||
* @return a set containing all snapshots
|
||||
*/
|
||||
public Set<Snapshot> getSnapshots()
|
||||
{
|
||||
// The compareTo method in Snapshot will ensure this in chronological order
|
||||
Set<Snapshot> snapshots = new TreeSet<>();
|
||||
snapshots.addAll(_snapshots.asMap().keySet());
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all instances of {@link Snapshot} which involve a particular user.
|
||||
* The user may be the sender or recipient of a message.
|
||||
*
|
||||
* @param search the user to search for snaps involved in
|
||||
* @return the snaps that the user is involved in
|
||||
*/
|
||||
public Set<Snapshot> getSnapshots(UUID search)
|
||||
{
|
||||
return _snapshots.asMap().keySet().stream()
|
||||
.filter(snapshot -> snapshot.getSender().equals(search) || snapshot.getRecipients().contains(search))
|
||||
.collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package mineplex.core.chatsnap;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.chatsnap.commands.ChatCacheCommand;
|
||||
import mineplex.core.message.PrivateMessageEvent;
|
||||
|
||||
/**
|
||||
* Starter class for all snapshot related functions (ie capturing messages, retrieving snapshots).
|
||||
*/
|
||||
public class SnapshotPlugin extends MiniPlugin
|
||||
{
|
||||
private final SnapshotManager _snapshotManager;
|
||||
|
||||
public SnapshotPlugin(JavaPlugin plugin, SnapshotManager snapshotManager)
|
||||
{
|
||||
super("ChatSnap", plugin);
|
||||
_snapshotManager = snapshotManager;
|
||||
}
|
||||
|
||||
public SnapshotManager getSnapshotManager()
|
||||
{
|
||||
return _snapshotManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new ChatCacheCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent e)
|
||||
{
|
||||
_snapshotManager.cacheSnapshot(createSnapshot(e));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPrivateMessage(PrivateMessageEvent e)
|
||||
{
|
||||
_snapshotManager.cacheSnapshot(createSnapshot(e));
|
||||
}
|
||||
|
||||
public Set<UUID> getUUIDSet(Set<Player> playerSet)
|
||||
{
|
||||
return playerSet.stream().map(Player::getUniqueId).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Snapshot createSnapshot(AsyncPlayerChatEvent e)
|
||||
{
|
||||
UUID senderUUID = e.getPlayer().getUniqueId();
|
||||
Set<UUID> uuidSet = getUUIDSet(e.getRecipients());
|
||||
uuidSet.remove(senderUUID);
|
||||
return new Snapshot(senderUUID, uuidSet, e.getMessage());
|
||||
}
|
||||
|
||||
public Snapshot createSnapshot(PrivateMessageEvent e)
|
||||
{
|
||||
Player sender = e.getSender();
|
||||
Player recipient = e.getRecipient();
|
||||
String message = e.getMessage();
|
||||
return new Snapshot(sender.getUniqueId(), recipient.getUniqueId(), message);
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package mineplex.core.chatsnap.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.chatsnap.SnapshotPlugin;
|
||||
import mineplex.core.chatsnap.Snapshot;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
/**
|
||||
* Displays what chat messages we have cached for a player.
|
||||
*/
|
||||
public class ChatCacheCommand extends CommandBase<SnapshotPlugin>
|
||||
{
|
||||
public ChatCacheCommand(SnapshotPlugin plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "chatcache");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), String.format("Invalid arguments, usage: /%s <player>", AliasUsed)));
|
||||
return;
|
||||
}
|
||||
|
||||
final String playerName = args[0];
|
||||
|
||||
// getOfflinePlayer sometimes blocks, see this needs to be async
|
||||
Plugin.getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
|
||||
Set<Snapshot> snaps = Plugin.getSnapshotManager().getSnapshots(offlinePlayer.getUniqueId());
|
||||
|
||||
for (Snapshot snapshot : snaps)
|
||||
{
|
||||
// TODO: show sender name
|
||||
caller.sendMessage(snapshot.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package mineplex.core.chatsnap.publishing;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
/**
|
||||
* Handles serialization of Java 8's {@link LocalDateTime}.
|
||||
*/
|
||||
public class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime>
|
||||
{
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
|
||||
|
||||
private ZoneId _zoneId;
|
||||
|
||||
public LocalDateTimeSerializer(ZoneId zoneId)
|
||||
{
|
||||
_zoneId = zoneId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(LocalDateTime localDateTime, Type type, JsonSerializationContext jsonSerializationContext)
|
||||
{
|
||||
return new JsonPrimitive(localDateTime.atZone(_zoneId).toLocalDateTime().truncatedTo(ChronoUnit.SECONDS).format(FORMATTER));
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package mineplex.core.chatsnap.publishing;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import mineplex.core.report.Report;
|
||||
|
||||
/**
|
||||
* Handles serialization of {@link Report} instances.
|
||||
*/
|
||||
public class ReportSerializer implements JsonSerializer<Report>
|
||||
{
|
||||
@Override
|
||||
public JsonElement serialize(Report report, Type type, JsonSerializationContext jsonSerializationContext)
|
||||
{
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("id", report.getReportId());
|
||||
jsonObject.addProperty("serverName", report.getServerName());
|
||||
|
||||
if (report.getHandler() != null)
|
||||
{
|
||||
jsonObject.addProperty("handler", report.getHandler().toString());
|
||||
}
|
||||
|
||||
jsonObject.addProperty("suspect", report.getSuspect().toString());
|
||||
jsonObject.add("reporters", jsonSerializationContext.serialize(report.getReportReasons()));
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
package mineplex.core.chatsnap.publishing;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import mineplex.core.chatsnap.Snapshot;
|
||||
import mineplex.core.report.Report;
|
||||
import mineplex.serverdata.Utility;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
/**
|
||||
* Class responsible for publishing snapshots on the website via Redis and a separate Report server.
|
||||
*/
|
||||
public class SnapshotPublisher
|
||||
{
|
||||
private static final ZoneId ZONE_ID = ZoneId.of("America/Chicago"); // This means "CST"
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer(ZONE_ID))
|
||||
.registerTypeAdapter(Report.class, new ReportSerializer())
|
||||
.create();
|
||||
|
||||
public static ZoneId getZoneId()
|
||||
{
|
||||
return ZONE_ID;
|
||||
}
|
||||
|
||||
public static Gson getGson()
|
||||
{
|
||||
return GSON;
|
||||
}
|
||||
|
||||
public static String getURL(String token)
|
||||
{
|
||||
return URL_PREFIX + token;
|
||||
}
|
||||
|
||||
private static final String URL_PREFIX = "http://file.mineplex.com/chatsnap/view.php?identifier=";
|
||||
public static final String CHANNEL_DEPLOY = "reportserver:deploy";
|
||||
public static final String CHANNEL_DESTROY = "reportserver:destroy";
|
||||
|
||||
private JavaPlugin _plugin;
|
||||
private JedisPool _jedisPool;
|
||||
|
||||
public SnapshotPublisher(JavaPlugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_jedisPool = Utility.generatePool(ServerManager.getMasterConnection());
|
||||
}
|
||||
|
||||
public void publishChatLog(String token, JsonObject jsonObject)
|
||||
{
|
||||
jsonObject.addProperty("token", token);
|
||||
String json = GSON.toJson(jsonObject);
|
||||
|
||||
// getting a Jedis resource can block, so lets async it
|
||||
Bukkit.getScheduler().runTaskAsynchronously(_plugin, () ->
|
||||
{
|
||||
try (Jedis jedis = _jedisPool.getResource())
|
||||
{
|
||||
jedis.publish(CHANNEL_DEPLOY, json);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void unpublishChatLog(String token)
|
||||
{
|
||||
// getting a Jedis resource can block, so lets async it
|
||||
Bukkit.getScheduler().runTaskAsynchronously(_plugin, () ->
|
||||
{
|
||||
try (Jedis jedis = _jedisPool.getResource())
|
||||
{
|
||||
jedis.publish(CHANNEL_DESTROY, token);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Set<UUID> getUUIDs(Collection<Snapshot> snapshots)
|
||||
{
|
||||
// Being a Set ensures no duplicates
|
||||
Set<UUID> uuids = new HashSet<>();
|
||||
|
||||
for (Snapshot snapshot : snapshots)
|
||||
{
|
||||
uuids.add(snapshot.getSender());
|
||||
uuids.addAll(snapshot.getRecipients().stream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public Map<UUID, String> getUsernameMap(Collection<UUID> collection)
|
||||
{
|
||||
Map<UUID, String> uuidUsernameMap = new HashMap<>();
|
||||
|
||||
for (UUID uuid : collection)
|
||||
{
|
||||
String username = Bukkit.getOfflinePlayer(uuid).getName();
|
||||
uuidUsernameMap.put(uuid, username);
|
||||
}
|
||||
|
||||
return uuidUsernameMap;
|
||||
}
|
||||
}
|
@ -1,18 +1,20 @@
|
||||
package mineplex.core.elo;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class EloManager extends MiniDbClientPlugin<EloClientData>
|
||||
{
|
||||
private EloRepository _repository;
|
||||
@ -139,32 +141,74 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for quickly checking if a player is banned from ranked games
|
||||
* Checks if a player is banned from ranked games async
|
||||
* @param accountId The player's account ID
|
||||
* @param afterCheck Code to be executed with the fetched ban status
|
||||
*/
|
||||
public boolean isRankBanned(int accountId)
|
||||
public void checkRankBannedAsync(int accountId, Callback<Long> afterCheck)
|
||||
{
|
||||
boolean banExpired = System.currentTimeMillis() >= getRankBanExpiry(accountId);
|
||||
getRankBanExpiryAsync(accountId, expiry -> {
|
||||
boolean expired = System.currentTimeMillis() >= expiry;
|
||||
|
||||
if (banExpired)
|
||||
{
|
||||
if (System.currentTimeMillis() >= _repository.getStrikeExpiry(accountId))
|
||||
{
|
||||
_repository.resetStrikes(accountId);
|
||||
}
|
||||
}
|
||||
return !banExpired;
|
||||
if (expired)
|
||||
{
|
||||
_repository.getStrikeExpiry(accountId, strikeExpiration -> {
|
||||
if (System.currentTimeMillis() >= strikeExpiration)
|
||||
{
|
||||
_repository.resetStrikes(accountId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
afterCheck.run(expiry);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for getting a player's remaining ranked game ban duration if applicable
|
||||
* Checks if a player is banned from ranked games (Should not be run on main thread)
|
||||
* @param accountId The player's account ID
|
||||
* @return The ban status of the player
|
||||
*/
|
||||
public boolean checkRankBanned(int accountId)
|
||||
{
|
||||
boolean expired = System.currentTimeMillis() >= getRankBanExpiry(accountId);
|
||||
|
||||
if (expired)
|
||||
{
|
||||
_repository.getStrikeExpiry(accountId, strikeExpiration -> {
|
||||
if (System.currentTimeMillis() >= strikeExpiration)
|
||||
{
|
||||
_repository.resetStrikes(accountId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return !expired;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a player's remaining ranked game ban duration (Should not be run on main thread)
|
||||
* @param accountId The player's account ID
|
||||
* @return The ban expiry of the player (0 if not found)
|
||||
*/
|
||||
public long getRankBanExpiry(int accountId)
|
||||
{
|
||||
return _repository.getBanExpiry(accountId);
|
||||
return _repository.getBanExpiry(accountId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for banning a player from joining ranked games temporarily
|
||||
* Gets a player's remaining ranked game ban duration if applicable async
|
||||
* @param accountId The player's account ID
|
||||
* @param afterFetch Code to be executed with the fetched ban expiration
|
||||
*/
|
||||
public void getRankBanExpiryAsync(int accountId, Callback<Long> afterFetch)
|
||||
{
|
||||
_repository.getBanExpiryAsync(accountId, afterFetch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bans a player from joining ranked games temporarily
|
||||
* @param accountId The player's account ID
|
||||
*/
|
||||
public void banFromRanked(int accountId)
|
||||
{
|
||||
@ -172,7 +216,8 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called when game ends to calculate new Elo and award it
|
||||
* Called when game ends to calculate new Elo and award it
|
||||
* @param gameId The game's ID
|
||||
*/
|
||||
public void endMatch(int gameId)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -47,7 +48,7 @@ public class EloRepository extends MinecraftRepository
|
||||
|
||||
public boolean saveElo(int accountId, int gameType, int oldElo, int elo) throws SQLException
|
||||
{
|
||||
final List<Boolean> ret = Lists.newArrayList();
|
||||
List<Boolean> ret = Lists.newArrayList();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> {
|
||||
boolean updateSucceeded = false;
|
||||
|
||||
@ -65,6 +66,8 @@ public class EloRepository extends MinecraftRepository
|
||||
updateSucceeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
ret.add(updateSucceeded);
|
||||
});
|
||||
|
||||
if (ret.isEmpty())
|
||||
@ -87,98 +90,113 @@ public class EloRepository extends MinecraftRepository
|
||||
return clientData;
|
||||
}
|
||||
|
||||
public long getStrikeExpiry(int accountId)
|
||||
public void getStrikeExpiry(int accountId, Callback<Long> call)
|
||||
{
|
||||
final List<Long> expire = Lists.newArrayList();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeQuery(GRAB_STRIKE_EXPIRY, resultSet -> {
|
||||
boolean called = false;
|
||||
while (resultSet.next())
|
||||
{
|
||||
expire.add(resultSet.getLong(1));
|
||||
called = true;
|
||||
call.run(resultSet.getLong(1));
|
||||
}
|
||||
|
||||
if (!called)
|
||||
{
|
||||
call.run(0L);
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId)));
|
||||
}
|
||||
|
||||
if (expire.isEmpty())
|
||||
{
|
||||
expire.add(System.currentTimeMillis() - 5555);
|
||||
}
|
||||
public void getBanExpiryAsync(int accountId, Callback<Long> call)
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeQuery(GRAB_BAN_EXPIRY, resultSet -> {
|
||||
boolean called = false;
|
||||
while (resultSet.next())
|
||||
{
|
||||
called = true;
|
||||
call.run(resultSet.getLong(1));
|
||||
}
|
||||
|
||||
return expire.get(0);
|
||||
if (!called)
|
||||
{
|
||||
call.run(0L);
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId)));
|
||||
}
|
||||
|
||||
public long getBanExpiry(int accountId)
|
||||
{
|
||||
final List<Long> expire = Lists.newArrayList();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeQuery(GRAB_BAN_EXPIRY, resultSet -> {
|
||||
while (resultSet.next())
|
||||
{
|
||||
expire.add(resultSet.getLong(1));
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId)));
|
||||
List<Long> expiry = new ArrayList<Long>();
|
||||
executeQuery(GRAB_BAN_EXPIRY, resultSet -> {
|
||||
while (resultSet.next())
|
||||
{
|
||||
expiry.add(resultSet.getLong(1));
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId));
|
||||
|
||||
if (expire.isEmpty())
|
||||
{
|
||||
expire.add(System.currentTimeMillis() - 5555);
|
||||
}
|
||||
if (expiry.isEmpty())
|
||||
expiry.add(System.currentTimeMillis() - 5000);
|
||||
|
||||
return expire.get(0);
|
||||
return expiry.get(0);
|
||||
}
|
||||
|
||||
public int getStrikes(int accountId)
|
||||
public void getStrikes(int accountId, Callback<Integer> call)
|
||||
{
|
||||
final List<Integer> strike = Lists.newArrayList();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeQuery(GRAB_STRIKES, resultSet -> {
|
||||
boolean called = false;
|
||||
while (resultSet.next())
|
||||
{
|
||||
strike.add(resultSet.getInt(1));
|
||||
called = true;
|
||||
call.run(resultSet.getInt(1));
|
||||
}
|
||||
|
||||
if (!called)
|
||||
{
|
||||
call.run(0);
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId)));
|
||||
|
||||
if (strike.isEmpty())
|
||||
{
|
||||
strike.add(0);
|
||||
}
|
||||
|
||||
return strike.get(0);
|
||||
}
|
||||
|
||||
public void addRankedBan(int accountId)
|
||||
{
|
||||
int minutes = 1;
|
||||
switch (getStrikes(accountId))
|
||||
{
|
||||
case 0:
|
||||
minutes = 1;
|
||||
break;
|
||||
case 1:
|
||||
minutes = 5;
|
||||
break;
|
||||
case 2:
|
||||
minutes = 10;
|
||||
break;
|
||||
case 3:
|
||||
minutes = 20;
|
||||
break;
|
||||
case 4:
|
||||
minutes = 30;
|
||||
break;
|
||||
case 5:
|
||||
minutes = 60;
|
||||
break;
|
||||
case 6:
|
||||
minutes = 120;
|
||||
break;
|
||||
case 7:
|
||||
minutes = 180;
|
||||
break;
|
||||
case 8:
|
||||
minutes = 240;
|
||||
break;
|
||||
}
|
||||
final long banEnd = System.currentTimeMillis() + UtilTime.convert(minutes, TimeUnit.MINUTES, TimeUnit.MILLISECONDS);
|
||||
final long strikesExpire = System.currentTimeMillis() + UtilTime.convert(1, TimeUnit.DAYS, TimeUnit.MILLISECONDS);
|
||||
final int newStrikes = Math.min(getStrikes(accountId) + 1, 8);
|
||||
getStrikes(accountId, strikes -> {
|
||||
int minutes = 1;
|
||||
switch (strikes)
|
||||
{
|
||||
case 0:
|
||||
minutes = 1;
|
||||
break;
|
||||
case 1:
|
||||
minutes = 5;
|
||||
break;
|
||||
case 2:
|
||||
minutes = 10;
|
||||
break;
|
||||
case 3:
|
||||
minutes = 20;
|
||||
break;
|
||||
case 4:
|
||||
minutes = 30;
|
||||
break;
|
||||
case 5:
|
||||
minutes = 60;
|
||||
break;
|
||||
case 6:
|
||||
minutes = 120;
|
||||
break;
|
||||
case 7:
|
||||
minutes = 180;
|
||||
break;
|
||||
case 8:
|
||||
minutes = 240;
|
||||
break;
|
||||
}
|
||||
long banEnd = System.currentTimeMillis() + UtilTime.convert(minutes, TimeUnit.MINUTES, TimeUnit.MILLISECONDS);
|
||||
long strikesExpire = System.currentTimeMillis() + UtilTime.convert(1, TimeUnit.DAYS, TimeUnit.MILLISECONDS);
|
||||
int newStrikes = Math.min(strikes + 1, 8);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeUpdate(UPDATE_BAN, new ColumnInt("accountId", accountId), new ColumnInt("strikes", newStrikes), new ColumnLong("strikesExpire", strikesExpire), new ColumnLong("banEnd", banEnd)));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> executeUpdate(UPDATE_BAN, new ColumnInt("accountId", accountId), new ColumnInt("strikes", newStrikes), new ColumnLong("strikesExpire", strikesExpire), new ColumnLong("banEnd", banEnd)));
|
||||
});
|
||||
}
|
||||
|
||||
public void resetStrikes(int accountId)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.elo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -10,12 +11,16 @@ import mineplex.core.slack.SlackMessage;
|
||||
import mineplex.core.slack.SlackTeam;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Generates a list of top elos
|
||||
*/
|
||||
public class TopEloCommand extends CommandBase<EloManager>
|
||||
{
|
||||
|
||||
private static final List<String> NAMES = Lists.newArrayList("Relyh", "TadahTech");
|
||||
|
||||
public TopEloCommand(EloManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "gettopelo", "topelo", "getelo");
|
||||
@ -28,7 +33,11 @@ public class TopEloCommand extends CommandBase<EloManager>
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(args.length != 1)
|
||||
if (!NAMES.contains(caller.getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (args.length != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -52,18 +61,18 @@ public class TopEloCommand extends CommandBase<EloManager>
|
||||
caller.sendMessage(C.cWhite + "Top Elo Data");
|
||||
caller.sendMessage(" ");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for(int i = 0; i < data.size(); i++){
|
||||
for (int i = 0; i < data.size(); i++)
|
||||
{
|
||||
StringBuilder messageBuilder = new StringBuilder("#");
|
||||
TopEloData topEloData = data.get(i);
|
||||
builder.append((i + 1)).append(": ").append(topEloData.getName())
|
||||
.append(" ").append(EloDivision.getDivision(topEloData.getElo())).append("").append("\n");
|
||||
messageBuilder.append((i + 1)).append(": ").append(topEloData.getName())
|
||||
.append(" ").append(EloDivision.getDivision(topEloData.getElo())).append("");
|
||||
SlackMessage slackMessage = new SlackMessage(builder.toString());
|
||||
SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#top-elo", slackMessage, false);
|
||||
caller.sendMessage(C.cYellow + messageBuilder.toString());
|
||||
}
|
||||
|
||||
SlackMessage slackMessage = new SlackMessage(builder.toString());
|
||||
SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#top-elo", slackMessage, false);
|
||||
caller.sendMessage(" ");
|
||||
caller.sendMessage(C.cAquaB + C.Strike + "=============================================");
|
||||
});
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
|
||||
public class ItemBuilder
|
||||
{
|
||||
@ -56,6 +57,7 @@ public class ItemBuilder
|
||||
private Material _mat;
|
||||
private String _title = null;
|
||||
private boolean _unbreakable;
|
||||
private boolean _dullEnchantment;
|
||||
private String _playerHeadName = null;
|
||||
private HashSet<ItemFlag> _itemFlags = new HashSet<ItemFlag>();
|
||||
|
||||
@ -268,6 +270,11 @@ public class ItemBuilder
|
||||
|
||||
item.addUnsafeEnchantments(_enchants);
|
||||
|
||||
if (_dullEnchantment)
|
||||
{
|
||||
UtilInv.addDullEnchantment(item);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -413,4 +420,11 @@ public class ItemBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addDullEnchantment(boolean dullEnchantment)
|
||||
{
|
||||
_dullEnchantment = dullEnchantment;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@ -3,11 +3,10 @@ package mineplex.core.message;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PrivateMessageEvent extends Event implements Cancellable
|
||||
public class PrivateMessageEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@ -33,13 +32,11 @@ public class PrivateMessageEvent extends Event implements Cancellable
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel)
|
||||
{
|
||||
_cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
|
@ -142,7 +142,7 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds, showUserReports FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
|
||||
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
|
||||
}
|
||||
|
||||
public IncognitoManager getIncognitoManager()
|
||||
|
@ -23,10 +23,9 @@ public class PreferencesRepository extends MinecraftRepository
|
||||
// privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL
|
||||
// DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL
|
||||
// DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL
|
||||
// NOT NULL DEFAULT 0, showUserReports BOOL NOT NULL DEFAULT 0, PRIMARY
|
||||
// KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
// NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ?, hubMusic = ?, disableAds = ?, showUserReports = ? WHERE uuid=?;";
|
||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ?, hubMusic = ?, disableAds = ? WHERE uuid=?;";
|
||||
|
||||
public PreferencesRepository(JavaPlugin plugin)
|
||||
{
|
||||
@ -65,9 +64,8 @@ public class PreferencesRepository extends MinecraftRepository
|
||||
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
|
||||
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
|
||||
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
|
||||
preparedStatement.setBoolean(16, entry.getValue().ShowUserReports);
|
||||
System.out.println(">> " + entry.getValue().ClanTips);
|
||||
preparedStatement.setString(17, entry.getKey());
|
||||
preparedStatement.setString(16, entry.getKey());
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
@ -96,9 +94,8 @@ public class PreferencesRepository extends MinecraftRepository
|
||||
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
|
||||
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
|
||||
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
|
||||
preparedStatement.setBoolean(16, entry.getValue().ShowUserReports);
|
||||
System.out.println(">> " + entry.getValue().ClanTips);
|
||||
preparedStatement.setString(17, entry.getKey());
|
||||
preparedStatement.setString(16, entry.getKey());
|
||||
preparedStatement.execute();
|
||||
}
|
||||
|
||||
@ -132,7 +129,6 @@ public class PreferencesRepository extends MinecraftRepository
|
||||
preferences.ClanTips = resultSet.getBoolean(13);
|
||||
preferences.HubMusic = resultSet.getBoolean(14);
|
||||
preferences.DisableAds = resultSet.getBoolean(15);
|
||||
preferences.ShowUserReports = resultSet.getBoolean(16);
|
||||
}
|
||||
|
||||
return preferences;
|
||||
|
@ -12,7 +12,6 @@ public class UserPreferences
|
||||
public boolean Invisibility = false;
|
||||
public boolean HubForcefield = false;
|
||||
public boolean ShowMacReports = false;
|
||||
public boolean ShowUserReports = false;
|
||||
public boolean IgnoreVelocity = false;
|
||||
public boolean PendingFriendRequests = true;
|
||||
public boolean friendDisplayInventoryUI = true;
|
||||
|
@ -24,13 +24,11 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
private IButton _toggleHubForcefield;
|
||||
private IButton _toggleHubIgnoreVelocity;
|
||||
private IButton _toggleMacReports;
|
||||
private IButton _toggleUserReports;
|
||||
|
||||
private boolean _hubInvisibilityToggled;
|
||||
private boolean _hubForcefieldToggled;
|
||||
private boolean _hubIgnoreVelocityToggled;
|
||||
private boolean _macReportsToggled;
|
||||
private boolean _userReportsToggled;
|
||||
|
||||
private PreferencesShop _preferencesShop;
|
||||
|
||||
@ -73,15 +71,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
}
|
||||
};
|
||||
|
||||
_toggleUserReports = new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
toggleUserReports(player);
|
||||
}
|
||||
};
|
||||
|
||||
_toggleHubIgnoreVelocity = new IButton()
|
||||
{
|
||||
@Override
|
||||
@ -122,22 +111,20 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
|
||||
if (rank.has(Rank.ADMIN) || rank == Rank.JNR_DEV)
|
||||
{
|
||||
int[] indices = UtilUI.getIndicesFor(5, 0, 2);
|
||||
int[] indices = UtilUI.getIndicesFor(4, 0, 2);
|
||||
|
||||
buildPreference(indices[0], Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
|
||||
buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
|
||||
buildPreference(indices[2], Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||
buildPreference(indices[3], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||
buildPreference(indices[4], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports);
|
||||
}
|
||||
else if (rank.has(Rank.MODERATOR))
|
||||
{
|
||||
int[] indices = UtilUI.getIndicesFor(4, 0, 2);
|
||||
int[] indices = UtilUI.getIndicesFor(3, 0, 2);
|
||||
|
||||
buildPreference(indices[0], Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
|
||||
buildPreference(indices[1], Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||
buildPreference(indices[2], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||
buildPreference(indices[3], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports);
|
||||
}
|
||||
else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH)
|
||||
{
|
||||
@ -194,13 +181,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
buildPage();
|
||||
}
|
||||
|
||||
private void toggleUserReports(org.bukkit.entity.Player player)
|
||||
{
|
||||
getPlugin().Get(player).ShowUserReports = !getPlugin().Get(player).ShowUserReports;
|
||||
_userReportsToggled = !_userReportsToggled;
|
||||
buildPage();
|
||||
}
|
||||
|
||||
private void toggleHubIgnoreVelocity(org.bukkit.entity.Player player)
|
||||
{
|
||||
getPlugin().Get(player).IgnoreVelocity = !getPlugin().Get(player).IgnoreVelocity;
|
||||
@ -223,6 +203,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
|
||||
public boolean preferencesChanged()
|
||||
{
|
||||
return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled || _userReportsToggled;
|
||||
return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled;
|
||||
}
|
||||
}
|
@ -1,97 +1,39 @@
|
||||
package mineplex.core.report;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.serverdata.data.Data;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
/**
|
||||
* Contains data about a report.
|
||||
* Active/open reports have their instances are stored in Redis for cross-server access.
|
||||
*/
|
||||
public class Report implements Data
|
||||
{
|
||||
|
||||
private static final int TIMEOUT_MINS = 15;
|
||||
|
||||
private int _reportId;
|
||||
public int getReportId() { return _reportId; }
|
||||
|
||||
private String _serverName;
|
||||
public String getServerName() { return _serverName; }
|
||||
|
||||
private UUID _suspect;
|
||||
public UUID getSuspect() { return _suspect; }
|
||||
private String _playerName;
|
||||
public String getPlayerName() { return _playerName; }
|
||||
|
||||
// Set of player names and the reason they reported this player
|
||||
private Map<UUID, String> _reportReasons;
|
||||
public Map<UUID, String> getReportReasons() { return _reportReasons; }
|
||||
public Set<UUID> getReporters() { return _reportReasons.keySet(); }
|
||||
public void addReporter(UUID reporter, String reason) { _reportReasons.put(reporter, reason); }
|
||||
// Set of account ids of players who contributed to reporting this player
|
||||
private Set<String> _reporters;
|
||||
public Set<String> getReporters() { return _reporters; }
|
||||
public void addReporter(String reporter) { _reporters.add(reporter); }
|
||||
|
||||
private UUID _handler = null;
|
||||
public void setHandler(UUID handler) { _handler = handler; }
|
||||
public UUID getHandler() { return _handler; }
|
||||
|
||||
private ReportCategory _category;
|
||||
public ReportCategory getCategory() { return _category; }
|
||||
|
||||
private long _lastActivity;
|
||||
public long getLastActivity() { return _lastActivity; }
|
||||
|
||||
private String _token = null;
|
||||
|
||||
public Report(int reportId, UUID suspect, String serverName, ReportCategory category)
|
||||
/**
|
||||
* Class constructor
|
||||
* @param reportId
|
||||
* @param playerName
|
||||
* @param serverName
|
||||
*/
|
||||
public Report(int reportId, String playerName, String serverName)
|
||||
{
|
||||
_reportId = reportId;
|
||||
_suspect = suspect;
|
||||
_playerName = playerName;
|
||||
_serverName = serverName;
|
||||
_reportReasons = new HashMap<>();
|
||||
_category = category;
|
||||
|
||||
updateLastActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a report is still active.
|
||||
* This is determined by checking if the last activity was within the last 15 minutes.
|
||||
*
|
||||
* @return true if active, false if expired
|
||||
*/
|
||||
public boolean isActive()
|
||||
{
|
||||
return _lastActivity + TimeUnit.MINUTES.toMillis(TIMEOUT_MINS) >= System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void updateLastActivity()
|
||||
{
|
||||
_lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean hasToken()
|
||||
{
|
||||
return _token != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a token in the format of reportId-randomCharacters.
|
||||
* Currently this is only used for publishing chat abuse reports.
|
||||
*
|
||||
* @return the full token
|
||||
*/
|
||||
public String getToken()
|
||||
{
|
||||
// since we don't always use this, only generate a token when we need it
|
||||
if (_token == null)
|
||||
{
|
||||
_token = RandomStringUtils.randomAlphabetic(8);
|
||||
}
|
||||
|
||||
return _reportId + "-" + _token;
|
||||
_reporters = new HashSet<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,77 +0,0 @@
|
||||
package mineplex.core.report;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
|
||||
/**
|
||||
* Contains the reasons a player can be reported for.
|
||||
*/
|
||||
public enum ReportCategory
|
||||
{
|
||||
|
||||
// descriptions borrowed from PunishPage
|
||||
HACKING(0, 3, Material.IRON_SWORD, C.cRedB + "Hacking", "X-ray, Forcefield, Speed, Fly etc"),
|
||||
CHAT_ABUSE(1, 1, Material.BOOK_AND_QUILL, C.cDBlueB + "Chat Abuse", "Verbal Abuse, Spam, Harassment, Trolling, etc");
|
||||
|
||||
private int _id;
|
||||
private int _notifyThreshold;
|
||||
private Material _displayMaterial;
|
||||
private String _title;
|
||||
private List<String> _lore;
|
||||
|
||||
ReportCategory(int id, int notifyThreshold, Material displayMaterial, String title, String... lore)
|
||||
{
|
||||
_id = id;
|
||||
_notifyThreshold = notifyThreshold;
|
||||
_displayMaterial = displayMaterial;
|
||||
_title = title;
|
||||
_lore = new ArrayList<>();
|
||||
|
||||
// prefix are lore lines
|
||||
for (String loreLine : lore) {
|
||||
_lore.add(C.cGray + loreLine);
|
||||
}
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getNotifyThreshold()
|
||||
{
|
||||
return _notifyThreshold;
|
||||
}
|
||||
|
||||
public Material getItemMaterial()
|
||||
{
|
||||
return _displayMaterial;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
public List<String> getDescription()
|
||||
{
|
||||
return _lore;
|
||||
}
|
||||
|
||||
public static ReportCategory fromId(int id)
|
||||
{
|
||||
for (ReportCategory category : values())
|
||||
{
|
||||
if (category.getId() == id)
|
||||
{
|
||||
return category;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,44 +1,21 @@
|
||||
package mineplex.core.report;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.chatsnap.Snapshot;
|
||||
import mineplex.core.chatsnap.SnapshotManager;
|
||||
import mineplex.core.chatsnap.publishing.SnapshotPublisher;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.report.command.ReportHandlerNotification;
|
||||
import mineplex.core.report.command.ReportNotificationCallback;
|
||||
import mineplex.core.report.command.ReportNotification;
|
||||
import mineplex.core.report.task.ReportHandlerMessageTask;
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.Utility;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
@ -47,245 +24,134 @@ import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
/**
|
||||
* ReportManager hooks into a synchronized network-wide report system
|
||||
* with methods for updating/fetching/closing reports in real time.
|
||||
* @author Ty
|
||||
*
|
||||
*/
|
||||
public class ReportManager
|
||||
{
|
||||
public class ReportManager {
|
||||
|
||||
private static final String NAME = "Report";
|
||||
|
||||
// statistic constants
|
||||
private static final String STAT_TOTAL_COUNT = "Global.TotalReportsCount";
|
||||
private static final int ABUSE_BAN_THRESHOLD = 1;
|
||||
|
||||
private JavaPlugin _javaPlugin;
|
||||
private PreferencesManager _preferencesManager;
|
||||
private StatsManager _statsManager;
|
||||
private SnapshotManager _snapshotManager;
|
||||
private CoreClientManager _coreClientManager;
|
||||
private String _serverName;
|
||||
private static ReportManager instance;
|
||||
|
||||
// Holds active/open reports in a synchronized database.
|
||||
private DataRepository<Report> _reportRepository;
|
||||
private DataRepository<Report> reportRepository;
|
||||
|
||||
private DataRepository<ReportProfile> reportProfiles;
|
||||
|
||||
// Stores/logs closed tickets, and various reporter/staff actions.
|
||||
private ReportRepository _reportSqlRepository;
|
||||
private ReportRepository reportSqlRepository;
|
||||
|
||||
// A mapping of PlayerName(String) to the ReportId(Integer) for all active reports on this server.
|
||||
private Map<String, Integer> _activeReports;
|
||||
private Map<String, Integer> activeReports;
|
||||
|
||||
public ReportManager(JavaPlugin javaPlugin, PreferencesManager preferencesManager, StatsManager statsManager,
|
||||
SnapshotManager snapshotManager, CoreClientManager coreClientManager, String serverName)
|
||||
/**
|
||||
* Private constructor to prevent non-singleton instances.
|
||||
*/
|
||||
private ReportManager()
|
||||
{
|
||||
_javaPlugin = javaPlugin;
|
||||
_preferencesManager = preferencesManager;
|
||||
_statsManager = statsManager;
|
||||
_snapshotManager = snapshotManager;
|
||||
_coreClientManager = coreClientManager;
|
||||
_serverName = serverName;
|
||||
_reportRepository = new RedisDataRepository<>(Region.ALL, Report.class, "reports");
|
||||
_activeReports = new HashMap<>();
|
||||
_reportSqlRepository = new ReportRepository(javaPlugin);
|
||||
_reportSqlRepository.initialize();
|
||||
this.reportRepository = new RedisDataRepository<Report>(Region.ALL, Report.class, "reports");
|
||||
this.reportProfiles = new RedisDataRepository<ReportProfile>(Region.ALL, ReportProfile.class, "reportprofiles");
|
||||
this.activeReports = new HashMap<String, Integer>();
|
||||
|
||||
ReportNotificationCallback callback = new ReportNotificationCallback(this);
|
||||
ServerCommandManager.getInstance().registerCommandType("ReportNotification", ReportNotification.class, callback);
|
||||
ServerCommandManager.getInstance().registerCommandType("ReportHandlerNotification", ReportHandlerNotification.class, callback);
|
||||
// TODO: Get JavaPlugin instance and locate ConnectionString from config?
|
||||
this.reportSqlRepository = new ReportRepository(ReportPlugin.getPluginInstance(), "CONNECTION STRING HERE");
|
||||
reportSqlRepository.initialize();
|
||||
}
|
||||
|
||||
public void retrieveReportResult(int reportId, Player reportCloser, String reason)
|
||||
{
|
||||
// Prompt the report closer with a menu of options to determine the result
|
||||
// of the report. When confirmation is received, THEN close report.
|
||||
}
|
||||
|
||||
public void closeReport(int reportId, Player reportCloser, String reason)
|
||||
{
|
||||
retrieveReportResult(reportId, reportCloser, reason);
|
||||
}
|
||||
|
||||
public void closeReport(int reportId, Player reportCloser, String reason,
|
||||
ReportResult result)
|
||||
ReportResult result)
|
||||
{
|
||||
Report report = getReport(reportId);
|
||||
|
||||
if (report != null)
|
||||
if (isActiveReport(reportId))
|
||||
{
|
||||
removeReport(reportId);
|
||||
Report report = getReport(reportId);
|
||||
reportRepository.removeElement(String.valueOf(reportId)); // Remove report from redis database
|
||||
removeActiveReport(reportId);
|
||||
|
||||
int closerId = reportCloser != null ? _coreClientManager.Get(reportCloser).getAccountId() : -1;
|
||||
String suspectName = Bukkit.getOfflinePlayer(report.getSuspect()).getName();
|
||||
int playerId = _coreClientManager.Get(suspectName).getAccountId();
|
||||
_reportSqlRepository.logReport(reportId, playerId, _serverName, closerId, result, reason);
|
||||
int closerId = getPlayerAccount(reportCloser).getAccountId();
|
||||
String playerName = getReport(reportId).getPlayerName();
|
||||
int playerId = getPlayerAccount(playerName).getAccountId();
|
||||
String server = null; // TODO: Get current server name
|
||||
reportSqlRepository.logReport(reportId, playerId, server, closerId, result, reason);
|
||||
|
||||
// Update the reputation/profiles of all reporters on this closing report.
|
||||
for (UUID reporterUUID : report.getReporters())
|
||||
for (String reporterName : report.getReporters())
|
||||
{
|
||||
String reporterName = Bukkit.getOfflinePlayer(reporterUUID).getName();
|
||||
incrementStat(reporterName, result);
|
||||
CoreClient reporterAccount = getPlayerAccount(reporterName);
|
||||
ReportProfile reportProfile = getReportProfile(String.valueOf(reporterAccount.getAccountId()));
|
||||
reportProfile.onReportClose(result);
|
||||
reportProfiles.addElement(reportProfile);
|
||||
}
|
||||
|
||||
if (reportCloser != null)
|
||||
{
|
||||
// Notify staff that the report was closed.
|
||||
sendStaffNotification(
|
||||
F.main(getReportPrefix(reportId), String.format("%s closed the report for: %s (%s).",
|
||||
reportCloser.getName(), reason, result.toDisplayMessage() + C.mBody)));
|
||||
|
||||
CommandCenter.Instance.OnPlayerCommandPreprocess(
|
||||
new PlayerCommandPreprocessEvent(reportCloser, "/punish " + suspectName + " " + reason));
|
||||
}
|
||||
|
||||
if (report.getCategory() == ReportCategory.CHAT_ABUSE) // only chat abuse reports have chat logs published
|
||||
{
|
||||
_snapshotManager.getSnapshotPublisher().unpublishChatLog(report.getToken());
|
||||
sendReportNotification(String.format("[Report %d] %s closed this report. (%s).", reportId,
|
||||
reportCloser.getName(), result.toDisplayMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handleReport(int reportId, Player reportHandler)
|
||||
{
|
||||
Report report = getReport(reportId);
|
||||
|
||||
if (report != null)
|
||||
if (reportRepository.elementExists(String.valueOf(reportId)))
|
||||
{
|
||||
if (report.getHandler() != null) {
|
||||
reportHandler.sendMessage(F.main(getReportPrefix(reportId), String.format("%s is already handling this report.", report.getHandler())));
|
||||
} else {
|
||||
String handlerName = reportHandler.getName();
|
||||
report.setHandler(reportHandler.getUniqueId());
|
||||
publishChatSnap(report, false); // so handler is displayed on the web side
|
||||
saveReport(report);
|
||||
Report report = getReport(reportId);
|
||||
Portal.transferPlayer(reportHandler.getName(), report.getServerName());
|
||||
String handlerName = reportHandler.getName();
|
||||
sendReportNotification(String.format("[Report %d] %s is handling this report.", reportId, handlerName));
|
||||
|
||||
sendStaffNotification(F.main(getReportPrefix(reportId), String.format("%s is handling this report.", handlerName)));
|
||||
Portal.transferPlayer(reportHandler.getName(), report.getServerName());
|
||||
// TODO: Send display message to handler when they arrive on the server
|
||||
// with info about the case/report.
|
||||
|
||||
// Show user details of the report every x seconds
|
||||
new ReportHandlerMessageTask(this, report).runTaskTimer(_javaPlugin, 20L * 10, 20L * 10);
|
||||
}
|
||||
int handlerId = getPlayerAccount(reportHandler).getAccountId();
|
||||
reportSqlRepository.logReportHandling(reportId, handlerId); // Log handling into sql database
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canReport(Player player)
|
||||
public void reportPlayer(Player reporter, Player reportedPlayer, String reason)
|
||||
{
|
||||
PlayerStats playerStats = _statsManager.Get(player.getName());
|
||||
long abusiveReportsCount = playerStats.getStat(ReportResult.ABUSIVE.getStatName());
|
||||
return abusiveReportsCount < ABUSE_BAN_THRESHOLD;
|
||||
}
|
||||
int reporterId = getPlayerAccount(reporter).getAccountId();
|
||||
ReportProfile reportProfile = getReportProfile(String.valueOf(reporterId));
|
||||
|
||||
private void incrementTotalStat(String reporter)
|
||||
{
|
||||
int accountId = _coreClientManager.Get(reporter).getAccountId();
|
||||
_statsManager.incrementStat(accountId, STAT_TOTAL_COUNT, 1);
|
||||
}
|
||||
|
||||
private void incrementStat(String reporter, ReportResult reportResult)
|
||||
{
|
||||
String statName = reportResult.getStatName();
|
||||
|
||||
if (statName != null)
|
||||
if (reportProfile.canReport())
|
||||
{
|
||||
int accountId = _coreClientManager.Get(reporter).getAccountId();
|
||||
_statsManager.incrementStat(accountId, statName, 1);
|
||||
}
|
||||
}
|
||||
Report report = null;
|
||||
|
||||
public Report reportPlayer(Player reporter, Player reportedPlayer, ReportCategory category, String reason)
|
||||
{
|
||||
if (canReport(reportedPlayer))
|
||||
{
|
||||
Report report = getActiveReport(reportedPlayer.getName());
|
||||
|
||||
if (report != null && report.getCategory() == category)
|
||||
if (hasActiveReport(reportedPlayer))
|
||||
{
|
||||
report.addReporter(reporter.getUniqueId(), reason);
|
||||
int reportId = getActiveReport(reportedPlayer.getName());
|
||||
report = getReport(reportId);
|
||||
report.addReporter(reporter.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
report = new Report(generateReportId(), reportedPlayer.getUniqueId(), _serverName, category);
|
||||
report.addReporter(reporter.getUniqueId(), reason);
|
||||
_activeReports.put(reportedPlayer.getName().toLowerCase(), report.getReportId());
|
||||
String serverName = null; // TODO: Fetch name of current server
|
||||
int reportId = generateReportId();
|
||||
report = new Report(reportId, reportedPlayer.getName(), serverName);
|
||||
report.addReporter(reporter.getName());
|
||||
activeReports.put(reportedPlayer.getName().toLowerCase(), report.getReportId());
|
||||
reportRepository.addElement(report);
|
||||
}
|
||||
|
||||
incrementTotalStat(reporter.getName());
|
||||
|
||||
// only start notifying staff when
|
||||
if (report.getReporters().size() >= category.getNotifyThreshold())
|
||||
if (report != null)
|
||||
{
|
||||
if (report.getCategory() == ReportCategory.CHAT_ABUSE)
|
||||
{
|
||||
publishChatSnap(report, true);
|
||||
}
|
||||
|
||||
int reportId = report.getReportId();
|
||||
String prefix = getReportPrefix(reportId);
|
||||
String suspectName = Bukkit.getOfflinePlayer(report.getSuspect()).getName();
|
||||
|
||||
// Report #2 > iKeirNez - Flying around in arcade game (Hacking)
|
||||
// Report #2 > Reported by Chiss.
|
||||
// Report #2 > 5 total reporter(s).
|
||||
JsonMessage message = new JsonMessage(F.main(prefix, String.format("%s - %s (%s)",
|
||||
C.cGoldB + suspectName + C.mBody,
|
||||
reason, C.cGoldB + report.getCategory().getTitle() + C.mBody))
|
||||
+ "\n"
|
||||
+ F.main(prefix, String.format("Reported by %s.", reporter.getName()))
|
||||
+ "\n"
|
||||
+ F.main(prefix, String.format("%d total reporter(s).", report.getReporters().size())));
|
||||
|
||||
if (report.getHandler() == null)
|
||||
{
|
||||
// this needs to be 'equals' otherwise we get errors when attempting to send this (due to incomplete JSON)
|
||||
message = message.extra("\n" + F.main(prefix, "Click to handle this ticket."))
|
||||
.click(ClickEvent.RUN_COMMAND, "/reporthandle " + reportId);
|
||||
|
||||
sendStaffNotification(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendHandlerNotification(report, message);
|
||||
}
|
||||
// [Report 42] [MrTwiggy +7] [Cheater102 - 5 - Speed hacking]
|
||||
String message = String.format("[Report %d] [%s %d] [%s - %d - %s]", report.getReportId(),
|
||||
reporter.getName(), reportProfile.getReputation(),
|
||||
reportedPlayer.getName(), report.getReporters().size(), reason);
|
||||
sendReportNotification(message);
|
||||
reportSqlRepository.logReportSending(report.getReportId(), reporterId, reason);
|
||||
}
|
||||
|
||||
// save later so that token is saved (if created)
|
||||
saveReport(report);
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void publishChatSnap(Report report, boolean updateChat)
|
||||
{
|
||||
SnapshotPublisher publisher = _snapshotManager.getSnapshotPublisher();
|
||||
Gson gson = SnapshotPublisher.getGson();
|
||||
Set<UUID> uuids = getUUIDs(report);
|
||||
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("timezone", SnapshotPublisher.getZoneId().getId());
|
||||
jsonObject.add("generated", gson.toJsonTree(LocalDateTime.now()));
|
||||
jsonObject.add("report", gson.toJsonTree(report));
|
||||
|
||||
if (updateChat)
|
||||
{
|
||||
Set<Snapshot> snapshots = _snapshotManager.getSnapshots(report.getSuspect());
|
||||
uuids.addAll(publisher.getUUIDs(snapshots));
|
||||
jsonObject.add("snapshots", gson.toJsonTree(snapshots));
|
||||
}
|
||||
|
||||
Map<UUID, String> usernameMap = publisher.getUsernameMap(uuids);
|
||||
jsonObject.add("usernames", gson.toJsonTree(usernameMap));
|
||||
|
||||
publisher.publishChatLog(report.getToken(), jsonObject);
|
||||
}
|
||||
|
||||
private Set<UUID> getUUIDs(Report report)
|
||||
{
|
||||
Set<UUID> uuids = new HashSet<>(report.getReporters());
|
||||
uuids.add(report.getSuspect());
|
||||
|
||||
if (report.getHandler() != null)
|
||||
{
|
||||
uuids.add(report.getHandler());
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public void onPlayerJoin(Player player)
|
||||
{
|
||||
if (hasActiveReport(player))
|
||||
{
|
||||
Report report = getActiveReport(player.getName());
|
||||
sendHandlerNotification(report, F.main(getReportPrefix(report), String.format("%s has re-joined the game.", player.getName())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,61 +159,66 @@ public class ReportManager
|
||||
{
|
||||
if (hasActiveReport(player))
|
||||
{
|
||||
Report report = getActiveReport(player.getName());
|
||||
sendHandlerNotification(report, F.main(getReportPrefix(report), String.format("%s has left the game.", player.getName())));
|
||||
int reportId = getActiveReport(player.getName());
|
||||
this.closeReport(reportId, null, "Player Quit", ReportResult.UNDETERMINED);
|
||||
// TODO: Handle 'null' report closer in closeReport metohd for NPEs.
|
||||
|
||||
sendReportNotification(String.format("[Report %d] %s has left the game.", reportId, player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public ReportProfile getReportProfile(String playerName)
|
||||
{
|
||||
ReportProfile profile = reportProfiles.getElement(playerName);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
profile = new ReportProfile(playerName, getAccountId(playerName));
|
||||
saveReportProfile(profile);
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
private void saveReportProfile(ReportProfile profile)
|
||||
{
|
||||
reportProfiles.addElement(profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a uniquely generated report id.
|
||||
*/
|
||||
public int generateReportId()
|
||||
{
|
||||
JedisPool pool = Utility.getPool(true);
|
||||
Jedis jedis = pool.getResource();
|
||||
long uniqueReportId = -1;
|
||||
|
||||
try
|
||||
try (Jedis jedis = pool.getResource())
|
||||
{
|
||||
uniqueReportId = jedis.incr("reports.unique-id");
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
pool.returnBrokenResource(jedis);
|
||||
jedis = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (jedis != null)
|
||||
{
|
||||
pool.returnResource(jedis);
|
||||
}
|
||||
}
|
||||
|
||||
return (int) uniqueReportId;
|
||||
}
|
||||
|
||||
public Report getReport(int reportId)
|
||||
{
|
||||
return _reportRepository.getElement(String.valueOf(reportId));
|
||||
return reportRepository.getElement(String.valueOf(reportId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the instance of a report in the repository.
|
||||
* Also updates the last activity field.
|
||||
*
|
||||
* @param report the report to be saved
|
||||
*/
|
||||
public void saveReport(Report report)
|
||||
private CoreClient getPlayerAccount(Player player)
|
||||
{
|
||||
report.updateLastActivity();
|
||||
_reportRepository.addElement(report);
|
||||
return getPlayerAccount(player.getName());
|
||||
}
|
||||
|
||||
public void removeReport(int reportId)
|
||||
private CoreClient getPlayerAccount(String playerName)
|
||||
{
|
||||
_reportRepository.removeElement(String.valueOf(reportId));
|
||||
return CommandCenter.Instance.GetClientManager().Get(playerName);
|
||||
}
|
||||
|
||||
private int getAccountId(String playerName)
|
||||
{
|
||||
return getPlayerAccount(playerName).getAccountId();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -356,91 +227,45 @@ public class ReportManager
|
||||
*/
|
||||
public boolean hasReportNotifications(Player player)
|
||||
{
|
||||
boolean isStaff = CommandCenter.Instance.GetClientManager().Get(player).GetRank().has(Rank.MODERATOR);
|
||||
boolean hasReportNotifications = _preferencesManager.Get(player).ShowUserReports;
|
||||
return isStaff && hasReportNotifications;
|
||||
// If player is not staff, return false.
|
||||
// If player is staff but has report notifications pref disabled, return false;
|
||||
// Else return true.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a network-wide {@link ReportNotification} to all online staff.
|
||||
*
|
||||
* @param message - the report notification message to send.
|
||||
*/
|
||||
public void sendStaffNotification(JsonMessage message)
|
||||
public void sendReportNotification(String message)
|
||||
{
|
||||
ReportNotification reportNotification = new ReportNotification(message);
|
||||
reportNotification.publish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a network-wide {@link ReportNotification} to all online staff.
|
||||
*
|
||||
* @param message - the report notification message to send.
|
||||
*/
|
||||
public void sendStaffNotification(String message)
|
||||
{
|
||||
ReportNotification reportNotification = new ReportNotification(message);
|
||||
reportNotification.publish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send to the handler of a {@link Report}, regardless of whether or not the handler is currently on this server instance.
|
||||
* If there is no handler for a report, it will be sent to all staff instead.
|
||||
*
|
||||
* @param report the report of which a message should be sent ot it's handler
|
||||
* @param jsonMessage the report notification message to send
|
||||
*/
|
||||
public void sendHandlerNotification(Report report, JsonMessage jsonMessage)
|
||||
{
|
||||
if (report.getHandler() != null)
|
||||
{
|
||||
ReportHandlerNotification reportHandlerNotification = new ReportHandlerNotification(report, jsonMessage);
|
||||
reportHandlerNotification.publish();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If there is no report handler, send it to all staff
|
||||
sendStaffNotification(jsonMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send to the handler of a {@link Report}, regardless of whether or not the handler is currently on this server instance.
|
||||
* If there is no handler for a report, it will be sent to all staff instead.
|
||||
*
|
||||
* @param report the report of which a message should be sent ot it's handler
|
||||
* @param message the report notification message to send
|
||||
*/
|
||||
public void sendHandlerNotification(Report report, String message)
|
||||
{
|
||||
sendHandlerNotification(report, new JsonMessage(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playerName - the name of the player whose active report id is being fetched
|
||||
* @return the report id for the active report corresponding with playerName, if one
|
||||
* currently exists, -1 otherwise.
|
||||
*/
|
||||
public Report getActiveReport(String playerName)
|
||||
public int getActiveReport(String playerName)
|
||||
{
|
||||
Integer reportId = _activeReports.get(playerName.toLowerCase());
|
||||
|
||||
if (reportId != null)
|
||||
if (activeReports.containsKey(playerName.toLowerCase()))
|
||||
{
|
||||
return getReport(reportId);
|
||||
return activeReports.get(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean hasActiveReport(Player player)
|
||||
{
|
||||
return getActiveReport(player.getName()) != null;
|
||||
return getActiveReport(player.getName()) != -1;
|
||||
}
|
||||
|
||||
public boolean isActiveReport(int reportId)
|
||||
{
|
||||
for (Map.Entry<String, Integer> activeReport : _activeReports.entrySet())
|
||||
for (Entry<String, Integer> activeReport : activeReports.entrySet())
|
||||
{
|
||||
if (activeReport.getValue() == reportId)
|
||||
{
|
||||
@ -453,11 +278,11 @@ public class ReportManager
|
||||
|
||||
public boolean removeActiveReport(int reportId)
|
||||
{
|
||||
for (Map.Entry<String, Integer> activeReport : _activeReports.entrySet())
|
||||
for (Entry<String, Integer> activeReport : activeReports.entrySet())
|
||||
{
|
||||
if (activeReport.getValue() == reportId)
|
||||
{
|
||||
_activeReports.remove(activeReport.getKey());
|
||||
activeReports.remove(activeReport.getKey());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -465,20 +290,16 @@ public class ReportManager
|
||||
return false;
|
||||
}
|
||||
|
||||
public Collection<Integer> getActiveReports()
|
||||
/**
|
||||
* @return the singleton instance of {@link ReportManager}.
|
||||
*/
|
||||
public static ReportManager getInstance()
|
||||
{
|
||||
return _activeReports.values();
|
||||
}
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new ReportManager();
|
||||
}
|
||||
|
||||
/* STATIC HELPERS */
|
||||
|
||||
public static String getReportPrefix(Report report)
|
||||
{
|
||||
return getReportPrefix(report.getReportId());
|
||||
}
|
||||
|
||||
public static String getReportPrefix(int reportId)
|
||||
{
|
||||
return NAME + " #" + reportId;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
@ -4,41 +4,20 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.report.command.ReportCloseCommand;
|
||||
import mineplex.core.report.command.ReportCommand;
|
||||
import mineplex.core.report.command.ReportHandleCommand;
|
||||
import mineplex.core.report.task.ReportPurgeTask;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Main class for this module, handles initialization and disabling of the module.
|
||||
*/
|
||||
public class ReportPlugin extends MiniPlugin
|
||||
{
|
||||
private final ReportManager _reportManager;
|
||||
private ReportPurgeTask _reportPurgeTask;
|
||||
|
||||
public ReportPlugin(JavaPlugin plugin, ReportManager reportManager)
|
||||
private static JavaPlugin instance;
|
||||
public static JavaPlugin getPluginInstance() { return instance; }
|
||||
|
||||
public ReportPlugin(JavaPlugin plugin, String serverName)
|
||||
{
|
||||
super("Report", plugin);
|
||||
super("ReportPlugin", plugin);
|
||||
|
||||
_reportManager = reportManager;
|
||||
|
||||
// purge old reports every minute
|
||||
_reportPurgeTask = new ReportPurgeTask(_reportManager);
|
||||
_reportPurgeTask.runTaskTimerAsynchronously(getPlugin(), 20L * 10, 20L * 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
_reportPurgeTask.cancel();
|
||||
}
|
||||
|
||||
public ReportManager getReportManager()
|
||||
{
|
||||
return _reportManager;
|
||||
instance = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,17 +26,6 @@ public class ReportPlugin extends MiniPlugin
|
||||
addCommand(new ReportCommand(this));
|
||||
addCommand(new ReportHandleCommand(this));
|
||||
addCommand(new ReportCloseCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e)
|
||||
{
|
||||
_reportManager.onPlayerJoin(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e)
|
||||
{
|
||||
_reportManager.onPlayerQuit(e.getPlayer());
|
||||
//AddCommand(new ReportDebugCommand(this));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
package mineplex.core.report;
|
||||
|
||||
import mineplex.serverdata.data.Data;
|
||||
|
||||
public class ReportProfile implements Data
|
||||
{
|
||||
|
||||
private String _playerName;
|
||||
|
||||
private int _playerId;
|
||||
|
||||
private int _totalReports;
|
||||
|
||||
private int _successfulReports;
|
||||
|
||||
private int _reputation;
|
||||
public int getReputation() { return _reputation; }
|
||||
|
||||
private boolean _banned;
|
||||
|
||||
public ReportProfile(String playerName, int playerId)
|
||||
{
|
||||
_playerName = playerName;
|
||||
_playerId = playerId;
|
||||
_totalReports = 0;
|
||||
_successfulReports = 0;
|
||||
_reputation = 0;
|
||||
_banned = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataId()
|
||||
{
|
||||
return String.valueOf(_playerId);
|
||||
}
|
||||
|
||||
public boolean canReport()
|
||||
{
|
||||
return !_banned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a report made by this player is closed.
|
||||
* @param result - the result of the closed report.
|
||||
*/
|
||||
public void onReportClose(ReportResult result)
|
||||
{
|
||||
_totalReports++;
|
||||
|
||||
if (result == ReportResult.MUTED || result == ReportResult.BANNED)
|
||||
{
|
||||
_successfulReports++;
|
||||
_reputation++;
|
||||
}
|
||||
else if (result == ReportResult.ABUSE)
|
||||
{
|
||||
_reputation = -1;
|
||||
_banned = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,22 +2,36 @@ package mineplex.core.report;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.DatabaseRunnable;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Responsible for all database related operations for this module.
|
||||
*/
|
||||
public class ReportRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_TICKET_TABLE = "CREATE TABLE IF NOT EXISTS reportTickets (reportId INT NOT NULL, eventDate LONG, playerId INT NOT NULL, server VARCHAR(50), closerId INT NOT NULL, result VARCHAR(25), reason VARCHAR(100), PRIMARY KEY (reportId), FOREIGN KEY (playerId) REFERENCES accounts(id), FOREIGN KEY (closerId) REFERENCES accounts(id));";
|
||||
private static String INSERT_TICKET = "INSERT INTO reportTickets (reportId, eventDate, playerId, server, closerId, result, reason) VALUES (?, now(), ?, ?, ?, ?, ?);";
|
||||
/*
|
||||
* *ReportTicket
|
||||
id, date, accountId reported player, server, accountId of staff who closed, result, reason
|
||||
|
||||
public ReportRepository(JavaPlugin plugin)
|
||||
ReportSenders
|
||||
id, date, reportId, accountId of Reporter, Reason for report
|
||||
|
||||
ReportHandlers
|
||||
id, date, reportId, accountId of Staff
|
||||
|
||||
This will be used to determine if staff are handling
|
||||
*/
|
||||
|
||||
private static String CREATE_TICKET_TABLE = "CREATE TABLE IF NOT EXISTS reportTickets (reportId INT NOT NULL, date LONG, eventDate LONG, playerId INT NOT NULL, server VARCHAR(50), closerId INT NOT NULL, result VARCHAR(25), reason VARCHAR(100), PRIMARY KEY (reportId), INDEX playerIdIndex (playerId), INDEX closerIdIndex (closerId));";
|
||||
private static String CREATE_HANDLER_TABLE = "CREATE TABLE IF NOT EXISTS reportHandlers (id INT NOT NULL AUTO_INCREMENT, reportId INT NOT NULL, eventDate LONG, handlerId INT NOT NULL, PRIMARY KEY (id), INDEX handlerIdIndex (handlerId) );";
|
||||
private static String CREATE_REPORTERS_TABLE = "CREATE TABLE IF NOT EXISTS reportSenders (id INT NOT NULL AUTO_INCREMENT, reportId INT NOT NULL, eventDate LONG, reporterId INT NOT NULL, reason VARCHAR(100), PRIMARY KEY (id), INDEX reporterIdIndex (reporterId));";
|
||||
|
||||
private static String INSERT_TICKET = "INSERT INTO reportTickets (reportId, eventDate, playerId, server, closerId, result, reason) VALUES (?, now(), ?, ?, ?, ?, ?);";
|
||||
private static String INSERT_HANDLER = "INSERT INTO reportHandlers (eventDate, reportId, handlerId) VALUES(now(), ?, ?);";
|
||||
private static String INSERT_SENDER = "INSERT INTO reportSenders (eventDate, reportId, reporterId, reason) VALUES(now(), ?, ?, ?);";
|
||||
|
||||
public ReportRepository(JavaPlugin plugin, String connectionString)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
}
|
||||
@ -25,7 +39,11 @@ public class ReportRepository extends MinecraftRepository
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
// executeUpdate(CREATE_TICKET_TABLE);
|
||||
/*
|
||||
executeUpdate(CREATE_TICKET_TABLE);
|
||||
executeUpdate(CREATE_HANDLER_TABLE);
|
||||
executeUpdate(CREATE_REPORTERS_TABLE);
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -34,17 +52,22 @@ public class ReportRepository extends MinecraftRepository
|
||||
|
||||
}
|
||||
|
||||
public void logReport(final int reportId, final int playerId, final String server, final int closerId, final ReportResult result, final String reason)
|
||||
public void logReportHandling(int reportId, int handlerId)
|
||||
{
|
||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
executeUpdate(INSERT_TICKET, new ColumnInt("reportId", reportId), new ColumnInt("playerId", playerId),
|
||||
new ColumnVarChar("server", 50, server), new ColumnInt("closerId", closerId),
|
||||
new ColumnVarChar("result", 25, result.toString()), new ColumnVarChar("reason", 100, reason));
|
||||
}
|
||||
}), "Error logging result for report " + reportId + ".");
|
||||
executeUpdate(INSERT_HANDLER, new ColumnInt("reportId", reportId), new ColumnInt("handlerId", handlerId));
|
||||
}
|
||||
|
||||
public void logReportSending(int reportId, int reporterId, String reason)
|
||||
{
|
||||
executeUpdate(INSERT_SENDER, new ColumnInt("reportId", reportId), new ColumnInt("reporterId", reporterId),
|
||||
new ColumnVarChar("reason", 100, reason));
|
||||
}
|
||||
|
||||
public void logReport(int reportId, int playerId, String server, int closerId, ReportResult result, String reason)
|
||||
{
|
||||
executeUpdate(INSERT_TICKET, new ColumnInt("reportId", reportId), new ColumnInt("playerId", playerId),
|
||||
new ColumnVarChar("server", 50, server), new ColumnInt("closerId", closerId),
|
||||
new ColumnVarChar("result", 25, result.toString()), new ColumnVarChar("reason", 100, reason));
|
||||
}
|
||||
|
||||
}
|
@ -2,57 +2,24 @@ package mineplex.core.report;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Contains all possible outcomes for a report.
|
||||
*/
|
||||
public enum ReportResult
|
||||
{
|
||||
ACCEPTED("Global.AcceptedReportsCount", ChatColor.GREEN, "Accept Report (Punish Player)", "Accepted (Player Received Punishment)"),
|
||||
DENIED("Global.DeniedReportsCount", ChatColor.YELLOW, "Deny Report", "Denied"),
|
||||
ABUSIVE("Global.AbusiveReportsCount", ChatColor.RED, "Mark Abusive Report", "Abusive Report");
|
||||
UNDETERMINED(ChatColor.WHITE, "Could not determine"),
|
||||
MUTED(ChatColor.YELLOW, "Muted"),
|
||||
BANNED(ChatColor.RED, "Banned"),
|
||||
ABUSE(ChatColor.DARK_RED, "Abuse of report system");
|
||||
|
||||
private final String _statName;
|
||||
private final ChatColor _color;
|
||||
private final String _actionMessage;
|
||||
private final String _resultMessage;
|
||||
private final String[] _lore;
|
||||
private ChatColor color;
|
||||
private String displayMessage;
|
||||
|
||||
ReportResult(String statName, ChatColor color, String actionMessage, String resultMessage, String... lore)
|
||||
private ReportResult(ChatColor color, String displayMessage)
|
||||
{
|
||||
_statName = statName;
|
||||
_color = color;
|
||||
_actionMessage = actionMessage;
|
||||
_resultMessage = resultMessage;
|
||||
_lore = lore;
|
||||
}
|
||||
|
||||
public String getStatName()
|
||||
{
|
||||
return _statName;
|
||||
}
|
||||
|
||||
public ChatColor getColor()
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
public String getActionMessage()
|
||||
{
|
||||
return _actionMessage;
|
||||
}
|
||||
|
||||
public String getResultMessage()
|
||||
{
|
||||
return _resultMessage;
|
||||
}
|
||||
|
||||
public String[] getLore()
|
||||
{
|
||||
return _lore;
|
||||
this.color = color;
|
||||
this.displayMessage = displayMessage;
|
||||
}
|
||||
|
||||
public String toDisplayMessage()
|
||||
{
|
||||
return _color + _resultMessage;
|
||||
return color + displayMessage;
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,12 @@ package mineplex.core.report.command;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
import mineplex.core.report.ui.ReportResultPage;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -16,7 +17,7 @@ public class ReportCloseCommand extends CommandBase<ReportPlugin>
|
||||
|
||||
public ReportCloseCommand(ReportPlugin plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "reportclose", "rc");
|
||||
super(plugin, Rank.ADMIN, "reportclose", "rc");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -32,15 +33,7 @@ public class ReportCloseCommand extends CommandBase<ReportPlugin>
|
||||
int reportId = Integer.parseInt(args[0]);
|
||||
String reason = F.combine(args, 1, null, false);
|
||||
|
||||
if (Plugin.getReportManager().isActiveReport(reportId))
|
||||
{
|
||||
ReportResultPage reportResultPage = new ReportResultPage(Plugin, reportId, player, reason);
|
||||
reportResultPage.openInventory(); // report is closed when player selects the result
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "That report either does not exist or has been closed."));
|
||||
}
|
||||
ReportManager.getInstance().closeReport(reportId, player, reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,12 @@ package mineplex.core.report.command;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
import mineplex.core.report.ui.ReportCategoryPage;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -21,13 +23,10 @@ public class ReportCommand extends CommandBase<ReportPlugin>
|
||||
@Override
|
||||
public void Execute(final Player player, final String[] args)
|
||||
{
|
||||
if (!CommandCenter.GetClientManager().hasRank(player, Rank.ULTRA))
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "The report feature is currently in a trial phase for Ultra+ players"));
|
||||
}
|
||||
else if(args == null || args.length < 2)
|
||||
if(args == null || args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -37,14 +36,7 @@ public class ReportCommand extends CommandBase<ReportPlugin>
|
||||
|
||||
if (reportedPlayer != null)
|
||||
{
|
||||
if (reportedPlayer == player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "You cannot report yourself."));
|
||||
}
|
||||
else
|
||||
{
|
||||
new ReportCategoryPage(Plugin, player, reportedPlayer, reason).openInventory();
|
||||
}
|
||||
ReportManager.getInstance().reportPlayer(player, reportedPlayer, reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3,8 +3,10 @@ package mineplex.core.report.command;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
|
||||
@ -15,7 +17,7 @@ public class ReportHandleCommand extends CommandBase<ReportPlugin>
|
||||
|
||||
public ReportHandleCommand(ReportPlugin plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "reporthandle", "rh");
|
||||
super(plugin, Rank.ADMIN, "reporthandle", "rh");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -24,12 +26,13 @@ public class ReportHandleCommand extends CommandBase<ReportPlugin>
|
||||
if(args == null || args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
int reportId = Integer.parseInt(args[0]);
|
||||
|
||||
Plugin.getReportManager().handleReport(reportId, player);
|
||||
ReportManager.getInstance().handleReport(reportId, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
package mineplex.core.report.command;
|
||||
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.report.Report;
|
||||
|
||||
/**
|
||||
* A message regarding a report which is sent only to the player handling the report.
|
||||
*/
|
||||
public class ReportHandlerNotification extends ReportNotification
|
||||
{
|
||||
private int _reportId;
|
||||
private String _server; // the server the incident took place on
|
||||
|
||||
public ReportHandlerNotification(Report report, String notification)
|
||||
{
|
||||
this(report, new JsonMessage(notification));
|
||||
}
|
||||
|
||||
public ReportHandlerNotification(Report report, JsonMessage notification)
|
||||
{
|
||||
super(notification);
|
||||
|
||||
if (report.getHandler() == null)
|
||||
{
|
||||
throw new IllegalStateException("Report has no handler.");
|
||||
}
|
||||
|
||||
_reportId = report.getReportId();
|
||||
_server = report.getServerName();
|
||||
setTargetServers(_server);
|
||||
}
|
||||
|
||||
public int getReportId()
|
||||
{
|
||||
return _reportId;
|
||||
}
|
||||
|
||||
public String getServer()
|
||||
{
|
||||
return _server;
|
||||
}
|
||||
}
|
@ -1,33 +1,31 @@
|
||||
package mineplex.core.report.command;
|
||||
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
/**
|
||||
* A message regarding a report which should be sent to all moderators with report notifications enabled.
|
||||
*/
|
||||
public class ReportNotification extends ServerCommand
|
||||
{
|
||||
private String _notification; // in json format
|
||||
|
||||
// TODO: Encode in JSON-interactive chat message
|
||||
private String notification;
|
||||
|
||||
public ReportNotification(String notification)
|
||||
{
|
||||
this(new JsonMessage(notification));
|
||||
}
|
||||
|
||||
public ReportNotification(JsonMessage notification)
|
||||
{
|
||||
super(); // Send to all servers
|
||||
_notification = notification.toString();
|
||||
}
|
||||
|
||||
public String getNotification()
|
||||
{
|
||||
return _notification;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
// Utilitizes a callback functionality to seperate dependencies
|
||||
// Message all players that can receive report notifications.
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (ReportManager.getInstance().hasReportNotifications(player))
|
||||
{
|
||||
player.sendMessage(notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,70 +0,0 @@
|
||||
package mineplex.core.report.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.report.Report;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
/**
|
||||
* Handles receiving of report notifications.
|
||||
*/
|
||||
public class ReportNotificationCallback implements CommandCallback
|
||||
{
|
||||
private ReportManager _reportManager;
|
||||
|
||||
public ReportNotificationCallback(ReportManager reportManager)
|
||||
{
|
||||
_reportManager = reportManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
{
|
||||
if (command instanceof ReportHandlerNotification)
|
||||
{
|
||||
ReportHandlerNotification reportNotification = (ReportHandlerNotification) command;
|
||||
Report report = _reportManager.getReport(reportNotification.getReportId());
|
||||
|
||||
if (report != null)
|
||||
{
|
||||
UUID handlerUUID = report.getHandler();
|
||||
|
||||
if (handlerUUID != null)
|
||||
{
|
||||
Player handler = Bukkit.getPlayer(handlerUUID);
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
sendRawMessage(handler, reportNotification.getNotification());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command instanceof ReportNotification)
|
||||
{
|
||||
ReportNotification reportNotification = (ReportNotification) command;
|
||||
|
||||
// Message all players that can receive report notifications.
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (_reportManager.hasReportNotifications(player))
|
||||
{
|
||||
sendRawMessage(player, reportNotification.getNotification());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendRawMessage(Player player, String rawMessage)
|
||||
{
|
||||
Server server = UtilServer.getServer();
|
||||
server.dispatchCommand(server.getConsoleSender(), "tellraw " + player.getName() + " " + rawMessage);
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package mineplex.core.report.task;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.chatsnap.publishing.SnapshotPublisher;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.report.Report;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.command.ReportHandlerNotification;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Displays a message containing up-to-date details of a report to it's handler.
|
||||
*/
|
||||
public class ReportHandlerMessageTask extends BukkitRunnable
|
||||
{
|
||||
private static final String DECORATION = C.cAqua + "------------------------------------";
|
||||
|
||||
private ReportManager _reportManager;
|
||||
private Report _report;
|
||||
|
||||
public ReportHandlerMessageTask(ReportManager reportManager, Report report)
|
||||
{
|
||||
_reportManager = reportManager;
|
||||
_report = report;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
int reportId = _report.getReportId();
|
||||
|
||||
if (_reportManager.isActiveReport(reportId))
|
||||
{
|
||||
String suspectName = Bukkit.getOfflinePlayer(_report.getSuspect()).getName();
|
||||
|
||||
JsonMessage jsonMessage = new JsonMessage(DECORATION)
|
||||
.extra("\n")
|
||||
.add(C.cAqua + "Reviewing Ticket " + C.cGold + "#" + reportId)
|
||||
.add("\n\n")
|
||||
.add(C.cPurple + StringUtils.join(getReportReasons(), "\n" + C.cPurple))
|
||||
.add("\n\n")
|
||||
.add(C.cAqua + "Suspect: " + C.cGold + suspectName)
|
||||
.add("\n")
|
||||
.add((_report.hasToken() ? C.cAqua + "Chat Log: " + C.cGold + "Click Here" + "\n" : ""))
|
||||
.click(ClickEvent.OPEN_URL, SnapshotPublisher.getURL(_report.getToken()))
|
||||
.add("\n")
|
||||
.add(C.cAqua + "Type " + C.cGold + "/reportclose " + reportId + " <reason>" + C.cAqua + " to close this report.")
|
||||
.click(ClickEvent.SUGGEST_COMMAND, "/reportclose " + reportId)
|
||||
.add("\n")
|
||||
.add(DECORATION);
|
||||
|
||||
new ReportHandlerNotification(_report, jsonMessage).publish();
|
||||
}
|
||||
else
|
||||
{
|
||||
// report has been closed, so this task should be cancelled
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getReportReasons()
|
||||
{
|
||||
Map<UUID, String> reportReasons = _report.getReportReasons();
|
||||
String[] output = new String[reportReasons.size()];
|
||||
int count = 0;
|
||||
|
||||
for (Map.Entry<UUID, String> entry : reportReasons.entrySet())
|
||||
{
|
||||
String reporterName = Bukkit.getOfflinePlayer(entry.getKey()).getName();
|
||||
// triple backslashes so this translates to valid JSON
|
||||
output[count++] = "\\\"" + entry.getValue() + "\\\" - " + reporterName;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package mineplex.core.report.task;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.report.Report;
|
||||
import mineplex.core.report.ReportManager;
|
||||
|
||||
/**
|
||||
* Checks reports "owned" by this instance for inactivity, purges inactive reports.
|
||||
*/
|
||||
public class ReportPurgeTask extends BukkitRunnable
|
||||
{
|
||||
private ReportManager _reportManager;
|
||||
|
||||
public ReportPurgeTask(ReportManager reportManager)
|
||||
{
|
||||
_reportManager = reportManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (int reportId : new ArrayList<>(_reportManager.getActiveReports())) // create copy as this will be run async
|
||||
{
|
||||
Report report = _reportManager.getReport(reportId);
|
||||
|
||||
if (report != null)
|
||||
{
|
||||
if (checkForPurge(report))
|
||||
{
|
||||
notifyHandler(report);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// report has been leftover for some reason
|
||||
purgeReport(reportId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a report should be purged and carries it out if so.
|
||||
*
|
||||
* @param report the report to check for purging (and act accordingly)
|
||||
* @return true if the report was purged, false otherwise
|
||||
*/
|
||||
public boolean checkForPurge(Report report)
|
||||
{
|
||||
if (!report.isActive())
|
||||
{
|
||||
int reportId = report.getReportId();
|
||||
purgeReport(reportId);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purges a report.
|
||||
*
|
||||
* @param reportId the report id to purge
|
||||
*/
|
||||
public void purgeReport(int reportId)
|
||||
{
|
||||
_reportManager.removeReport(reportId);
|
||||
_reportManager.removeActiveReport(reportId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the handler of a report (if any) that the report was purged.
|
||||
*
|
||||
* @param report the report which was purged
|
||||
*/
|
||||
public void notifyHandler(Report report)
|
||||
{
|
||||
// would result in spam if many reports with no handlers are purged (causing each member of staff to receive a message for every purged report)
|
||||
if (report.getHandler() != null)
|
||||
{
|
||||
_reportManager.sendHandlerNotification(report, ReportManager.getReportPrefix(report) + C.cRed + "Purging report due to inactivity.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package mineplex.core.report.ui;
|
||||
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.gui.SimpleGuiItem;
|
||||
import mineplex.core.report.ReportCategory;
|
||||
|
||||
/**
|
||||
* Represents a clickable button in a {@link ReportCategoryPage} which determines the type of infraction a player has committed.
|
||||
*/
|
||||
public class ReportCategoryButton extends SimpleGuiItem
|
||||
{
|
||||
private ReportCategoryPage _reportCategoryPage;
|
||||
private ReportCategory _category;
|
||||
|
||||
public ReportCategoryButton(ReportCategoryPage reportCategoryPage, ReportCategory category) {
|
||||
super(category.getItemMaterial(), 1, (short) 0);
|
||||
|
||||
ItemMeta itemMeta = getItemMeta();
|
||||
itemMeta.setDisplayName(category.getTitle());
|
||||
itemMeta.setLore(category.getDescription());
|
||||
setItemMeta(itemMeta);
|
||||
|
||||
this._reportCategoryPage = reportCategoryPage;
|
||||
this._category = category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
_reportCategoryPage.addReport(_category);
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package mineplex.core.report.ui;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.report.ReportCategory;
|
||||
import mineplex.core.report.Report;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
|
||||
/**
|
||||
* User interface shown to a player when reporting another player.
|
||||
*/
|
||||
public class ReportCategoryPage extends SimpleGui
|
||||
{
|
||||
private static final Map<Integer, ReportCategory> CATEGORY_SLOTS = Collections.unmodifiableMap(new HashMap<Integer, ReportCategory>()
|
||||
{{
|
||||
int rowStartSlot = 9 * 2; // end of row 2
|
||||
put(rowStartSlot + 3, ReportCategory.HACKING);
|
||||
put(rowStartSlot + 5, ReportCategory.CHAT_ABUSE);
|
||||
}});
|
||||
|
||||
private ReportPlugin _reportPlugin;
|
||||
private Player _reportee;
|
||||
private Player _offender;
|
||||
private String _reason;
|
||||
|
||||
public ReportCategoryPage(ReportPlugin reportPlugin, Player reportee, Player offender, String reason)
|
||||
{
|
||||
super(reportPlugin.getPlugin(), reportee, "Report " + offender.getName(), 9 * 5);
|
||||
|
||||
this._reportPlugin = reportPlugin;
|
||||
this._reportee = reportee;
|
||||
this._offender = offender;
|
||||
this._reason = reason;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
private void buildPage()
|
||||
{
|
||||
for (Map.Entry<Integer, ReportCategory> entry : CATEGORY_SLOTS.entrySet())
|
||||
{
|
||||
ReportCategory category = entry.getValue();
|
||||
setItem(entry.getKey(), new ReportCategoryButton(this, category));
|
||||
}
|
||||
}
|
||||
|
||||
public void addReport(ReportCategory category)
|
||||
{
|
||||
Report report = _reportPlugin.getReportManager().reportPlayer(_reportee, _offender, category, _reason);
|
||||
_reportee.closeInventory();
|
||||
unregisterListener();
|
||||
_reportee.sendMessage(C.cGreen + "Report sent successfully (" + C.cGold + "#" + report.getReportId() + C.cGreen + ").");
|
||||
}
|
||||
|
||||
public void unregisterListener()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package mineplex.core.report.ui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.gui.SimpleGuiItem;
|
||||
import mineplex.core.report.ReportResult;
|
||||
|
||||
/**
|
||||
* Represents a button which can be clicked to determine the result of a report.
|
||||
*/
|
||||
public class ReportResultButton extends SimpleGuiItem
|
||||
{
|
||||
private ReportResultPage _reportResultPage;
|
||||
private ReportResult _result;
|
||||
|
||||
public ReportResultButton(ReportResultPage reportResultPage, ReportResult result, ItemStack displayItem)
|
||||
{
|
||||
super(displayItem);
|
||||
_reportResultPage = reportResultPage;
|
||||
_result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
// replace all occurrences of "%suspect%" in the lore with the actual name
|
||||
ItemMeta itemMeta = getItemMeta();
|
||||
List<String> lore = itemMeta.getLore();
|
||||
|
||||
for (int i = 0; i < lore.size(); i++)
|
||||
{
|
||||
lore.set(i, lore.get(i).replace("%suspect%", _reportResultPage.getPlayer().getName()));
|
||||
}
|
||||
|
||||
itemMeta.setLore(lore);
|
||||
setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
_reportResultPage.setResult(_result);
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package mineplex.core.report.ui;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
import mineplex.core.report.ReportResult;
|
||||
|
||||
/**
|
||||
* User interface shown to a moderator when closing a report to determine the result of the report.
|
||||
*/
|
||||
public class ReportResultPage extends SimpleGui
|
||||
{
|
||||
private static final ItemStack ITEM_ACCEPT = new ItemBuilder(Material.WOOL)
|
||||
.setData(DyeColor.GREEN.getData())
|
||||
.setTitle(C.cGreen + "Accept Report")
|
||||
.addLore("%suspect% is cheating without a doubt.")
|
||||
.build();
|
||||
|
||||
private static final ItemStack ITEM_DENY = new ItemBuilder(Material.WOOL)
|
||||
.setData(DyeColor.YELLOW.getData())
|
||||
.setTitle(C.cYellow + "Deny Report")
|
||||
.addLore("There is not enough evidence against %suspect%.")
|
||||
.build();
|
||||
|
||||
private static final ItemStack ITEM_ABUSE = new ItemBuilder(Material.WOOL)
|
||||
.setData(DyeColor.RED.getData())
|
||||
.setTitle(C.cRed + "Flag Abuse")
|
||||
.addLore("The reporter(s) were abusing the report system.")
|
||||
.build();
|
||||
|
||||
private ReportManager _reportManager;
|
||||
private int _reportId;
|
||||
private Player _reportCloser;
|
||||
private String _reason;
|
||||
|
||||
public ReportResultPage(ReportPlugin reportPlugin, int reportId, Player reportCloser, String reason)
|
||||
{
|
||||
super(reportPlugin.getPlugin(), reportCloser, "Report Result", 9 * 3);
|
||||
_reportManager = reportPlugin.getReportManager();
|
||||
_reportId = reportId;
|
||||
_reportCloser = reportCloser;
|
||||
_reason = reason;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
private void buildPage()
|
||||
{
|
||||
setItem(11, new ReportResultButton(this, ReportResult.ACCEPTED, ITEM_ACCEPT));
|
||||
setItem(13, new ReportResultButton(this, ReportResult.DENIED, ITEM_DENY));
|
||||
setItem(15, new ReportResultButton(this, ReportResult.ABUSIVE, ITEM_ABUSE));
|
||||
}
|
||||
|
||||
public void setResult(ReportResult result)
|
||||
{
|
||||
_reportCloser.closeInventory();
|
||||
unregisterListener();
|
||||
_reportManager.closeReport(_reportId, _reportCloser, _reason, result);
|
||||
}
|
||||
|
||||
public void unregisterListener()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package mineplex.core.sponsorbranding;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* Manager for creating billboards with branding logos
|
||||
*/
|
||||
public class BrandingManager extends MiniPlugin
|
||||
{
|
||||
private ConcurrentHashMap<Integer, BrandingPost> _posts = new ConcurrentHashMap<Integer, BrandingPost>();
|
||||
private ConcurrentHashMap<String, BufferedImage> _imgCache = new ConcurrentHashMap<String, BufferedImage>();
|
||||
|
||||
public BrandingManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Branding Manager", plugin);
|
||||
}
|
||||
|
||||
private BufferedImage getImage(String fileName)
|
||||
{
|
||||
if (_imgCache.containsKey(fileName))
|
||||
{
|
||||
return _imgCache.get(fileName);
|
||||
}
|
||||
|
||||
File folder = new File("../../update");
|
||||
File f = new File(folder, "logos" + File.separatorChar + fileName);
|
||||
BufferedImage image = null;
|
||||
|
||||
if (!f.exists())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
image = ImageIO.read(f);
|
||||
_imgCache.put(fileName, image);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a billboard with a stored logo
|
||||
* @param location The center of the billboard
|
||||
* @param facing The BlockFace the logo will appear on
|
||||
* @param imageFileName The file name of the logo's base image
|
||||
*/
|
||||
public void createPost(Location location, BlockFace facing, String imageFileName)
|
||||
{
|
||||
BufferedImage img = getImage(imageFileName);
|
||||
if (img == null)
|
||||
{
|
||||
System.out.println("ERROR! Invalid image file name!");
|
||||
return;
|
||||
}
|
||||
BrandingPost bp = new BrandingPost(location, facing, img);
|
||||
bp.spawn();
|
||||
_posts.put(_posts.size(), bp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears away all existing billboards
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
for (Integer key : _posts.keySet())
|
||||
{
|
||||
_posts.remove(key).despawn();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,214 @@
|
||||
package mineplex.core.sponsorbranding;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* An instance of a billboard with all its required data
|
||||
*/
|
||||
public class BrandingPost
|
||||
{
|
||||
private Location _center;
|
||||
private BlockFace _facing;
|
||||
private BufferedImage _img;
|
||||
|
||||
private Location[] _corners;
|
||||
private List<ItemFrame> _ents = Lists.newArrayList();
|
||||
|
||||
public BrandingPost(Location center, BlockFace facing, BufferedImage image)
|
||||
{
|
||||
_center = center;
|
||||
_facing = facing;
|
||||
_img = image;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private ItemStack getMapItem(int x, int y, BufferedImage image)
|
||||
{
|
||||
ItemStack item = new ItemStack(Material.MAP);
|
||||
|
||||
MapView map = Bukkit.getServer().createMap(Bukkit.getServer().getWorlds().get(0));
|
||||
for (MapRenderer r : map.getRenderers())
|
||||
{
|
||||
map.removeRenderer(r);
|
||||
}
|
||||
|
||||
map.addRenderer(new LogoMapRenderer(image, x, y));
|
||||
item.setDurability(map.getId());
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a billboard using parameters from instance constructor
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void spawn()
|
||||
{
|
||||
Location corner1 = _center.clone();
|
||||
Location corner2 = _center.clone();
|
||||
Location corner3 = _center.clone();
|
||||
Location corner4 = _center.clone();
|
||||
|
||||
int width = (int) Math.ceil(_img.getWidth() / 128);
|
||||
int height = (int) Math.ceil(_img.getHeight() / 128);
|
||||
|
||||
switch (_facing)
|
||||
{
|
||||
case EAST:
|
||||
corner1.add(0, 1, -2);
|
||||
corner2.add(0, -1, 2);
|
||||
corner3.add(0, 2, -3);
|
||||
corner4.add(0, -2, 3);
|
||||
break;
|
||||
case WEST:
|
||||
corner1.add(0, 1, -2);
|
||||
corner2.add(0, -1, 2);
|
||||
corner3.add(0, 2, -3);
|
||||
corner4.add(0, -2, 3);
|
||||
break;
|
||||
case SOUTH:
|
||||
corner1.add(-2, 1, 0);
|
||||
corner2.add(2, -1, 0);
|
||||
corner3.add(-3, 2, 0);
|
||||
corner4.add(3, -2, 0);
|
||||
break;
|
||||
case NORTH:
|
||||
corner1.add(-2, 1, 0);
|
||||
corner2.add(2, -1, 0);
|
||||
corner3.add(-3, 2, 0);
|
||||
corner4.add(3, -2, 0);
|
||||
break;
|
||||
default:
|
||||
System.out.println("ERROR! Invalid BlockFace given while loading BrandingPost!");
|
||||
return;
|
||||
}
|
||||
|
||||
_corners = new Location[] {corner1, corner2, corner3, corner4};
|
||||
|
||||
for (int x = Math.max(corner1.getBlockX(), corner2.getBlockX()); x >= Math.min(corner1.getBlockX(), corner2.getBlockX()); x--)
|
||||
{
|
||||
for (int y = Math.max(corner1.getBlockY(), corner2.getBlockY()); y >= Math.min(corner1.getBlockY(), corner2.getBlockY()); y--)
|
||||
{
|
||||
for (int z = Math.max(corner1.getBlockZ(), corner2.getBlockZ()); z >= Math.min(corner1.getBlockZ(), corner2.getBlockZ()); z--)
|
||||
{
|
||||
Location set = new Location(_center.getWorld(), x, y, z);
|
||||
set.getBlock().setType(Material.STAINED_CLAY);
|
||||
set.getBlock().setData(DyeColor.LIGHT_BLUE.getWoolData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int xMod = 0;
|
||||
int zMod = 0;
|
||||
|
||||
switch (_facing)
|
||||
{
|
||||
case EAST:
|
||||
zMod = -1;
|
||||
break;
|
||||
case WEST:
|
||||
zMod = 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
xMod = 1;
|
||||
break;
|
||||
case NORTH:
|
||||
xMod = -1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
BufferedImage image = _img;
|
||||
|
||||
if (image == null)
|
||||
{
|
||||
System.out.println("ERROR! Invalid image given while loading BrandingPost!");
|
||||
return;
|
||||
}
|
||||
|
||||
Block base = corner1.getBlock().getRelative(_facing);
|
||||
|
||||
try
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
ItemFrame i = null;
|
||||
Block block = base.getRelative(x * xMod, -y, x * zMod);
|
||||
i = block.getWorld().spawn(block.getLocation(), ItemFrame.class);
|
||||
|
||||
i.setFacingDirection(_facing, false);
|
||||
|
||||
ItemStack item = getMapItem(x, y, _img);
|
||||
i.setItem(item);
|
||||
|
||||
_ents.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("ERROR! ItemFrame space already occupied!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int x = Math.max(corner3.getBlockX(), corner4.getBlockX()); x >= Math.min(corner3.getBlockX(), corner4.getBlockX()); x--)
|
||||
{
|
||||
for (int y = Math.max(corner3.getBlockY(), corner4.getBlockY()); y >= Math.min(corner3.getBlockY(), corner4.getBlockY()); y--)
|
||||
{
|
||||
for (int z = Math.max(corner3.getBlockZ(), corner4.getBlockZ()); z >= Math.min(corner3.getBlockZ(), corner4.getBlockZ()); z--)
|
||||
{
|
||||
Location set = new Location(_center.getWorld(), x, y, z);
|
||||
if (set.getBlock().getType() == Material.STAINED_CLAY)
|
||||
continue;
|
||||
|
||||
set.getBlock().setType(Material.WOOD);
|
||||
set.getBlock().setData((byte)1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears away all blocks and ItemFrames generated by this billboard
|
||||
*/
|
||||
public void despawn()
|
||||
{
|
||||
if (_corners != null)
|
||||
{
|
||||
for (int x = Math.max(_corners[2].getBlockX(), _corners[3].getBlockX()); x >= Math.min(_corners[2].getBlockX(), _corners[3].getBlockX()); x--)
|
||||
{
|
||||
for (int y = Math.max(_corners[2].getBlockY(), _corners[3].getBlockY()); y >= Math.min(_corners[2].getBlockY(), _corners[3].getBlockY()); y--)
|
||||
{
|
||||
for (int z = Math.max(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z >= Math.min(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z--)
|
||||
{
|
||||
Location set = new Location(_center.getWorld(), x, y, z);
|
||||
set.getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ItemFrame it : _ents)
|
||||
{
|
||||
it.setItem(new ItemStack(Material.AIR));
|
||||
it.remove();
|
||||
}
|
||||
_ents.clear();
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package mineplex.core.sponsorbranding;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
/**
|
||||
* Renderer for each map panel of the full billboard logo
|
||||
*/
|
||||
public class LogoMapRenderer extends MapRenderer
|
||||
{
|
||||
private Image _img;
|
||||
private boolean _first = true;
|
||||
|
||||
public LogoMapRenderer(BufferedImage image, int x1, int y1)
|
||||
{
|
||||
recalculateInput(image, x1, y1);
|
||||
}
|
||||
|
||||
private void recalculateInput(BufferedImage input, int x1, int y1)
|
||||
{
|
||||
if (x1 > input.getWidth() || y1 > input.getHeight())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int startX = Math.min(x1 * 128, input.getWidth());
|
||||
startX = Math.max(input.getMinX(), startX);
|
||||
int startY = Math.min(y1 * 128, input.getHeight());
|
||||
startY = Math.max(input.getMinY(), startY);
|
||||
|
||||
_img = input.getSubimage(startX, startY, 128, 128);
|
||||
|
||||
_first = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MapView view, MapCanvas canvas, Player player)
|
||||
{
|
||||
if (_img != null && _first)
|
||||
{
|
||||
canvas.drawImage(0, 0, _img);
|
||||
_first = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,9 +7,6 @@ import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.chatsnap.SnapshotManager;
|
||||
import mineplex.core.chatsnap.SnapshotPlugin;
|
||||
import mineplex.core.chatsnap.publishing.SnapshotPublisher;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.MinecraftVersion;
|
||||
import mineplex.core.common.Pair;
|
||||
@ -34,8 +31,6 @@ import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
import mineplex.core.resourcepack.ResourcePackManager;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.spawn.Spawn;
|
||||
@ -46,6 +41,7 @@ import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
import mineplex.game.clans.shop.building.BuildingShop;
|
||||
import mineplex.game.clans.shop.farming.FarmingShop;
|
||||
@ -117,7 +113,7 @@ public class Clans extends JavaPlugin
|
||||
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
|
||||
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
|
||||
|
||||
// ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
|
||||
ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
|
||||
|
||||
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
||||
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
|
||||
@ -140,20 +136,16 @@ public class Clans extends JavaPlugin
|
||||
ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal);
|
||||
resourcePackManager.setResourcePack(new Pair[]
|
||||
{
|
||||
Pair.create(MinecraftVersion.Version1_8, "http://phinary.ca/ResClans.zip"),
|
||||
Pair.create(MinecraftVersion.Version1_9, "http://phinary.ca/ResClans19.zip")
|
||||
Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResClans.zip"),
|
||||
Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResClans19.zip")
|
||||
}, true);
|
||||
|
||||
SnapshotManager snapshotManager = new SnapshotManager(new SnapshotPublisher(this));
|
||||
new SnapshotPlugin(this, snapshotManager);
|
||||
new ReportPlugin(this, new ReportManager(this, preferenceManager, statsManager, snapshotManager, CommandCenter.Instance.GetClientManager(), serverStatusManager.getCurrentServerName()));
|
||||
|
||||
// Enable custom-gear related managers
|
||||
new CustomTagFix(this, packetHandler);
|
||||
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
|
||||
|
||||
HologramManager hologram = new HologramManager(this, packetHandler);
|
||||
_clansManager = new ClansManager(this, /*clansBans,*/ serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
|
||||
_clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
|
||||
new Recipes(this);
|
||||
new Farming(this);
|
||||
new BuildingShop(_clansManager, _clientManager, _donationManager);
|
||||
|
@ -9,14 +9,11 @@ import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
@ -47,6 +44,7 @@ import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.events.PlayerMessageEvent;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
@ -73,6 +71,7 @@ import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.punish.PunishClient;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
@ -81,6 +80,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.Clans;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.clans.commands.ClanManagementCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||
@ -226,19 +226,19 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator;
|
||||
|
||||
/*private ClansBanManager _clansBans;*/
|
||||
private ClansBanManager _clansBans;
|
||||
|
||||
public ClanTips ClanTips;
|
||||
|
||||
// Spawn area
|
||||
|
||||
public ClansManager(JavaPlugin plugin/*, ClansBanManager clansBans*/, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
|
||||
public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
_instance = this;
|
||||
|
||||
/*_clansBans = clansBans;*/
|
||||
_clansBans = clansBans;
|
||||
_punish = punish;
|
||||
|
||||
_incognitoManager = incognitoManager;
|
||||
@ -355,6 +355,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
loadClan(token);
|
||||
}
|
||||
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");
|
||||
|
||||
|
||||
// new ClaimVisualizer(plugin, this);
|
||||
|
||||
// RedisDataRepository(ConnectionData writeConn, ConnectionData
|
||||
@ -407,7 +410,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
hologram.start();
|
||||
}
|
||||
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");
|
||||
|
||||
_siegeManager = new SiegeManager(this);
|
||||
// _netherManager = new NetherManager(this);
|
||||
@ -603,21 +605,21 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
event.setJoinMessage(null);
|
||||
|
||||
/*if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
{
|
||||
if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
if (_incognitoManager.Get(event.getPlayer()).Status)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*_clansBans.runAfterLoad(event.getPlayer().getName(), () -> {
|
||||
_clansBans.runAfterLoad(event.getPlayer().getName(), () -> {
|
||||
if (_clansBans.Get(event.getPlayer().getName()).isBanned())
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
@ -629,7 +631,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
other.sendMessage(F.sys("Join", event.getPlayer().getName()));
|
||||
}
|
||||
/*});*/
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -642,10 +644,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
if (_clansBans.Get(event.getPlayer().getName()) != null && _clansBans.Get(event.getPlayer().getName()).isBanned())
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
@ -655,7 +657,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
continue;
|
||||
}
|
||||
|
||||
other.sendMessage(F.sys("Quit", event.getPlayer().getName()));
|
||||
other.sendMessage(F.sys("Quit ", event.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,12 +670,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
if (event.getReason().contains("You are banned from Clans"))
|
||||
if (event.getReason().contains("banned from Clans"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -853,7 +855,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
UtilServer.broadcast(String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), _chat.getFilteredMessage(event.getPlayer(), event.getMessage())));
|
||||
for (Player other : event.getRecipients())
|
||||
{
|
||||
if (_tutorial.inTutorial(other))
|
||||
continue;
|
||||
|
||||
UtilPlayer.message(other, String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -901,28 +909,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void handlePlayerChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
// PunishClient punishclient = _punish.GetClient(event.getPlayer().getName());
|
||||
//
|
||||
// if (punishclient != null && punishclient.IsMuted())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (_chat.SilenceCheck(event.getPlayer()))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// MessageData lastMessage = _chat.lastMessage(event.getPlayer());
|
||||
// long chatSlowTime = 1000L * _chat.getChatSlow();
|
||||
// long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
|
||||
// if (timeDiff < chatSlowTime && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER))
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
ClientClan client = Get(event.getPlayer());
|
||||
|
||||
if (client == null)
|
||||
@ -1302,17 +1288,23 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void message(PlayerMessageEvent event)
|
||||
{
|
||||
if(!_tutorial.inTutorial(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getMessage().startsWith(C.cBlue + "Death>"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void handleClansDeath(PlayerDeathEvent event)
|
||||
{
|
||||
event.setDeathMessage(null);
|
||||
|
||||
for(Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if(!_tutorial.inTutorial(player))
|
||||
player.sendMessage(event.getDeathMessage());
|
||||
}
|
||||
|
||||
PlayerClan playerClan;
|
||||
PlayerClan killerClan = null;
|
||||
|
||||
|
@ -6,6 +6,9 @@ import java.util.UUID;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
/**
|
||||
* Stores the information about a ban in Clans.
|
||||
*/
|
||||
public class ClansBan
|
||||
{
|
||||
private int _id;
|
||||
@ -90,4 +93,9 @@ public class ClansBan
|
||||
{
|
||||
return _uuid;
|
||||
}
|
||||
|
||||
public void remove()
|
||||
{
|
||||
_removed = true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
/**
|
||||
* Stores the data provided through the /cban (Clans ban) command for use further in the plugin.
|
||||
*/
|
||||
public class ClansBanCache
|
||||
{
|
||||
private String _victim;
|
||||
private String _reason;
|
||||
|
||||
public ClansBanCache(String victim, String reason)
|
||||
{
|
||||
_victim = victim;
|
||||
_reason = reason;
|
||||
}
|
||||
|
||||
public String getVictim()
|
||||
{
|
||||
return _victim;
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return _reason;
|
||||
}
|
||||
}
|
@ -1,17 +1,22 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
/**
|
||||
* Signifies a player on clans, and a Set of their current clan bans.
|
||||
*/
|
||||
public class ClansBanClient
|
||||
{
|
||||
public String Name;
|
||||
public String UUID;
|
||||
public List<ClansBan> Bans;
|
||||
public Set<ClansBan> Bans;
|
||||
|
||||
public ClansBanClient(String uuid, List<ClansBan> bans)
|
||||
public ClansBanClient(String name, String uuid, Set<ClansBan> bans)
|
||||
{
|
||||
Name = name;
|
||||
UUID = uuid;
|
||||
Bans = bans;
|
||||
}
|
||||
@ -75,7 +80,7 @@ public class ClansBanClient
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ban.getTimeLeft() > longest.getTimeLeft())
|
||||
if (ban.getTimeLeft() > longest.getTimeLeft() || ban.isPermanent())
|
||||
{
|
||||
longest = ban;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -17,16 +16,15 @@ import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.core.common.DefaultHashMap;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilStreams;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
@ -41,7 +39,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
private CoreClientManager _clientManager;
|
||||
private ClansBanRepository _repository;
|
||||
private Map<String, ClansBanClient> _clients;
|
||||
private Map<String, Pair<String, String>> _cache;
|
||||
private Map<String, ClansBanCache> _cache;
|
||||
private DefaultHashMap<String, List<Runnable>> _runAfterLoad;
|
||||
private ClansBanShop _shop;
|
||||
|
||||
@ -55,7 +53,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
|
||||
_clientManager = clientManager;
|
||||
|
||||
_repository = new ClansBanRepository(plugin, this);
|
||||
_repository = new ClansBanRepository(plugin);
|
||||
|
||||
_clients = new HashMap<>();
|
||||
_cache = new HashMap<>();
|
||||
@ -85,29 +83,30 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
}
|
||||
|
||||
player.kickPlayer(reason);
|
||||
|
||||
runSyncLater(() -> {
|
||||
_toKick.remove(name);
|
||||
}, 20l);
|
||||
});
|
||||
}
|
||||
|
||||
if (!event.getType().equals(UpdateType.MIN_01))
|
||||
if (event.getType().equals(UpdateType.MIN_01))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (_lock)
|
||||
{
|
||||
List<String> purge = Lists.newArrayList();
|
||||
|
||||
_clients.keySet().stream().filter(name -> Bukkit.getPlayer(name) == null).forEach(purge::add);
|
||||
|
||||
purge.forEach(this::UnloadClient);
|
||||
synchronized (_lock)
|
||||
{
|
||||
UtilStreams.ToList(_clients.keySet().stream().filter(UtilServer::IsOnline)).forEach(this::UnloadClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ban(ClansBanClient client, String name, String admin, long time, String reason, Callback<ClansBanClient> callback)
|
||||
public void ban(ClansBanClient client, String admin, long time, String reason, Callback<ClansBanClient> callback)
|
||||
{
|
||||
_repository.ban(UUID.fromString(client.UUID), admin, time, reason, time == -1);
|
||||
|
||||
LoadClient(name, callback);
|
||||
runAsync(() -> {
|
||||
_repository.ban(UUID.fromString(client.UUID), admin, time, reason, time == -1, ban -> {
|
||||
client.Bans.add(ban);
|
||||
callback.run(client);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
@ -154,21 +153,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
|
||||
public void UnloadClient(ClansBanClient client)
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
String name = "";
|
||||
|
||||
for (Entry<String, ClansBanClient> entry : _clients.entrySet())
|
||||
{
|
||||
if (entry.getValue().equals(client))
|
||||
{
|
||||
name = entry.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_clients.remove(name);
|
||||
}
|
||||
UnloadClient(client.Name);
|
||||
}
|
||||
|
||||
public void UnloadClient(String name)
|
||||
@ -179,17 +164,24 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadClient(final String name, Callback<ClansBanClient> callback)
|
||||
public void LoadClient(String name, Callback<ClansBanClient> callback)
|
||||
{
|
||||
if (_clients.containsKey(name))
|
||||
{
|
||||
System.out.println("Clans Bans> Soft Warning: Loading client even though client is already loaded.");
|
||||
_clients.remove(name);
|
||||
}
|
||||
|
||||
GetRepository().loadBans(name, client -> {
|
||||
GetRepository().loadClient(name, client -> {
|
||||
synchronized (_lock)
|
||||
{
|
||||
_clients.put(name, client);
|
||||
_clients.put(name.toLowerCase(), client);
|
||||
System.out.println("> CLIENTS: " + _clients);
|
||||
if (callback != null) callback.run(client);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(client);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -207,12 +199,12 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
return _shop;
|
||||
}
|
||||
|
||||
public void cache(Player player, String playerName, String reason)
|
||||
public void cache(Player player, String victim, String reason)
|
||||
{
|
||||
_cache.put(player.getName(), Pair.create(playerName, reason));
|
||||
_cache.put(player.getName(), new ClansBanCache(victim, reason));
|
||||
}
|
||||
|
||||
public Pair<String, String> getCachedData(Player player)
|
||||
public ClansBanCache getCachedData(Player player)
|
||||
{
|
||||
return _cache.get(player.getName());
|
||||
}
|
||||
@ -222,16 +214,17 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
_cache.remove(name);
|
||||
}
|
||||
|
||||
public void unban(ClansBanClient target, ClansBan ban, String name, Callback<ClansBanClient> callback)
|
||||
public void unban(ClansBanClient target, ClansBan ban, Callback<ClansBanClient> callback)
|
||||
{
|
||||
if (!target.UUID.equals(ban.getUUID().toString()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ban.remove();
|
||||
_repository.removeBan(ban);
|
||||
|
||||
LoadClient(name, callback);
|
||||
callback.run(target);
|
||||
}
|
||||
|
||||
public boolean willBeKicked(Player player)
|
||||
@ -239,33 +232,27 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
return _toKick.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void queueToKick(Player target, String reason)
|
||||
{
|
||||
_toKick.put(target.getName(), reason);
|
||||
}
|
||||
|
||||
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
_repository.loadBans(playerName, client -> {
|
||||
LoadClient(playerName, client -> {
|
||||
if (client.isBanned())
|
||||
{
|
||||
String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT);
|
||||
|
||||
if (client.getLongestBan().isPermanent())
|
||||
{
|
||||
time = "Permanent";
|
||||
}
|
||||
|
||||
String reason = C.cRedB + "You are banned from Clans for " + time +
|
||||
"\n" + C.cWhite + client.getLongestBan().getReason();
|
||||
|
||||
_toKick.put(playerName, reason);
|
||||
|
||||
ClansManager.getInstance().runSyncLater(() -> {
|
||||
if (Bukkit.getPlayer(playerName) != null)
|
||||
{
|
||||
Bukkit.getPlayer(playerName).kickPlayer(_toKick.remove(playerName));
|
||||
}
|
||||
else
|
||||
{
|
||||
_runAfterLoad.get(playerName).forEach(Runnable::run);
|
||||
_runAfterLoad.get(playerName).clear();
|
||||
}
|
||||
}, 5L);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
@ -20,65 +19,44 @@ import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class ClansBanRepository extends MinecraftRepository
|
||||
{
|
||||
private ClansBanManager _manager;
|
||||
|
||||
private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);";
|
||||
private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;";
|
||||
private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE uuid = ?;";
|
||||
|
||||
public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager)
|
||||
public ClansBanRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
public void ban(UUID uuid, String admin, long time, String reason, boolean permanent)
|
||||
public void ban(UUID uuid, String admin, long time, String reason, boolean permanent, Callback<ClansBan> callback)
|
||||
{
|
||||
executeInsert(BAN_PLAYER, null,
|
||||
Timestamp banTime = new Timestamp(System.currentTimeMillis());
|
||||
Timestamp unbanTime = new Timestamp(System.currentTimeMillis() + time);
|
||||
|
||||
executeInsert(BAN_PLAYER,
|
||||
generatedKeys -> {
|
||||
if (generatedKeys.next() && callback != null)
|
||||
{
|
||||
callback.run(new ClansBan(generatedKeys.getInt(1), uuid, admin, reason, banTime, unbanTime, permanent, false));
|
||||
}
|
||||
},
|
||||
|
||||
new ColumnVarChar("uuid", 36, uuid.toString()),
|
||||
new ColumnVarChar("admin", 16, admin),
|
||||
new ColumnVarChar("reason", 128, reason),
|
||||
new ColumnTimestamp("banTime", new Timestamp(System.currentTimeMillis())),
|
||||
new ColumnTimestamp("unbanTime", new Timestamp(System.currentTimeMillis() + time)),
|
||||
new ColumnTimestamp("banTime", banTime),
|
||||
new ColumnTimestamp("unbanTime", unbanTime),
|
||||
new ColumnBoolean("permanent", permanent),
|
||||
new ColumnBoolean("removed", false)
|
||||
);
|
||||
}
|
||||
|
||||
public void loadBans(final String name, final Callback<ClansBanClient> callback)
|
||||
public void loadClient(String name, final Callback<ClansBanClient> callback)
|
||||
{
|
||||
loadClientByName(name, client -> {
|
||||
String uuid = UUIDFetcher.getUUIDOf(client.GetPlayerName()).toString();
|
||||
String uuid = UUIDFetcher.getUUIDOf(name).toString();
|
||||
|
||||
executeQuery(GET_ALL_BANS, resultSet -> {
|
||||
final List<ClansBan> list = new ArrayList<ClansBan>();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
int id = resultSet.getInt(1);
|
||||
String ruuid = resultSet.getString(2);
|
||||
String admin = resultSet.getString(3);
|
||||
String reason = resultSet.getString(4);
|
||||
Timestamp banTime = resultSet.getTimestamp(5);
|
||||
Timestamp unbanTime = resultSet.getTimestamp(6);
|
||||
boolean permanent = resultSet.getBoolean(7);
|
||||
boolean removed = resultSet.getBoolean(8);
|
||||
|
||||
list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
|
||||
}
|
||||
|
||||
callback.run(new ClansBanClient(uuid, list));
|
||||
|
||||
}, new ColumnVarChar("uuid", 36, uuid));
|
||||
});
|
||||
}
|
||||
|
||||
public void loadBans(final String name, final String uuid, final ResultSet resultSet, final Callback<ClansBanClient> callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
final List<ClansBan> list = new ArrayList<ClansBan>();
|
||||
executeQuery(GET_ALL_BANS, resultSet -> {
|
||||
final Set<ClansBan> bans = Sets.newConcurrentHashSet();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
@ -91,32 +69,14 @@ public class ClansBanRepository extends MinecraftRepository
|
||||
boolean permanent = resultSet.getBoolean(7);
|
||||
boolean removed = resultSet.getBoolean(8);
|
||||
|
||||
list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
|
||||
|
||||
System.out.println("Got ban for " + name);
|
||||
bans.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
|
||||
}
|
||||
|
||||
callback.run(new ClansBanClient(uuid, list));
|
||||
|
||||
System.out.println("> Successfully handled result");
|
||||
System.out.println(">> FINISH");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadClientByName(String name, Callback<CoreClient> client)
|
||||
{
|
||||
if (_manager.getClientManager().Contains(name))
|
||||
{
|
||||
client.run(_manager.getClientManager().Get(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
_manager.getClientManager().loadClientByName(name, () -> client.run(_manager.getClientManager().Get(name)));
|
||||
}
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(new ClansBanClient(name, uuid, bans));
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 36, uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
|
||||
@ -21,7 +20,7 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
{
|
||||
if (args == null || args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, C.cGold + "/cb <username> <reason> - Displays the \"Clans Punish\" GUI, allowing you to ban the player, and ");
|
||||
UtilPlayer.message(caller, C.cBlue + "/cb <username> <reason>" + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view thier past bans.");
|
||||
}
|
||||
else if (args.length > 1)
|
||||
{
|
||||
@ -36,18 +35,6 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
|
||||
final String finalReason = reason;
|
||||
|
||||
//Match exact online first
|
||||
Player target = UtilPlayer.searchExact(playerName);
|
||||
if (target != null)
|
||||
{
|
||||
Plugin.LoadClient(playerName, client -> {
|
||||
Plugin.cache(caller, playerName, finalReason);
|
||||
Plugin.getShop().attemptShopOpen(caller);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.LoadClient(playerName, client -> {
|
||||
Plugin.cache(caller, playerName, finalReason);
|
||||
Plugin.getShop().attemptShopOpen(caller);
|
||||
@ -55,7 +42,7 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, C.cGold + "/cb <username> <reason> - Displays the \"Clans Punish\" GUI, allowing you to ban the player, and ");
|
||||
UtilPlayer.message(caller, C.cBlue + "/cb <username> <reason>" + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view thier past bans.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,163 +2,144 @@ package mineplex.game.clans.clans.ban.ui;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ban.ClansBan;
|
||||
import mineplex.game.clans.clans.ban.ClansBanClient;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
|
||||
public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
|
||||
{
|
||||
private int _days;
|
||||
private int _hours;
|
||||
private long _time;
|
||||
private boolean _permanent;
|
||||
|
||||
private ClansBanClient _victimClient;
|
||||
|
||||
private String _victim;
|
||||
private String _reason;
|
||||
|
||||
public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final CoreClientManager clientManager, final DonationManager donationManager, final String name, final Player player)
|
||||
{
|
||||
super(banManager, shop, clientManager, donationManager, name, player);
|
||||
|
||||
_victim = getPlugin().getCachedData(player).getVictim();
|
||||
_reason = getPlugin().getCachedData(player).getReason();
|
||||
|
||||
_victimClient = getPlugin().Get(_victim);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
protected void buildPage()
|
||||
{
|
||||
getPlugin().runAsync(() -> {
|
||||
_days = Math.max(0, _days);
|
||||
_hours = Math.max(0, _hours);
|
||||
_time = Math.max(0, _time);
|
||||
|
||||
Pair<String, String> data = getPlugin().getCachedData(getPlayer());
|
||||
getPlugin().LoadClient(data.getLeft(), client -> {
|
||||
int slot = 27;
|
||||
int slot = 27;
|
||||
|
||||
// Middle of first row
|
||||
addButton(4, new ItemBuilder(Material.COAL_BLOCK)
|
||||
.setTitle(C.cDGreenB + data.getLeft())
|
||||
.addLore(" ")
|
||||
.addLore(C.cYellow + data.getRight()).build(), (player, click) -> {});
|
||||
// Middle of first row
|
||||
addButton(4, new ItemBuilder(Material.SKULL_ITEM)
|
||||
.setData((short) 3)
|
||||
.setPlayerHead(_victim)
|
||||
.setTitle(C.cDGreenB + _victim)
|
||||
.addLore(" ")
|
||||
.addLore(C.cYellow + _reason).build(), (player, click) -> {});
|
||||
|
||||
addButton((9 * 1) + 3, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cRed + "-1 Hour").build(),
|
||||
(player, click) -> {
|
||||
_hours--;
|
||||
refresh();
|
||||
});
|
||||
addTimeAdjuster((9 * 1 + 2), -(1000l * 60l * 60l));
|
||||
addTimeAdjuster((9 * 1 + 1), -(1000l * 60l * 60l * 24l));
|
||||
addTimeAdjuster((9 * 1 + 0), -(1000l * 60l * 60l * 24l * 30l));
|
||||
addTimeAdjuster((9 * 1 + 6), (1000l * 60l * 60l));
|
||||
addTimeAdjuster((9 * 1 + 7), (1000l * 60l * 60l * 24l));
|
||||
addTimeAdjuster((9 * 1 + 8), (1000l * 60l * 60l * 24l * 30l));
|
||||
|
||||
addButton((9 * 1) + 2, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cRed + "-1 Day").build(),
|
||||
(player, click) -> {
|
||||
_days--;
|
||||
refresh();
|
||||
});
|
||||
addButton((9 * 1) + 4,
|
||||
new ItemBuilder(Material.RECORD_5)
|
||||
.setTitle(C.cRedB + "Ban Player")
|
||||
.setLore(
|
||||
" ",
|
||||
C.cGray + "Player: " + F.elem(_victim),
|
||||
C.cGray + "Reason: " + F.elem(_reason),
|
||||
C.cGray + "Time: " + F.elem(_permanent ? "Permanent" : UtilTime.MakeStr(_time)),
|
||||
"",
|
||||
C.cRed + C.Italics + "Left-Click to BAN PLAYER",
|
||||
C.cGray + C.Italics + "Right-Click to toggle permanent ban setting"
|
||||
).build(),
|
||||
(player, click) -> {
|
||||
if (click == ClickType.RIGHT)
|
||||
{
|
||||
_permanent = !_permanent;
|
||||
refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
performBan();
|
||||
}
|
||||
});
|
||||
|
||||
addButton((9 * 1) + 1, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cRed + "-30 Days").build(),
|
||||
(player, click) -> {
|
||||
_days -= 30;
|
||||
refresh();
|
||||
});
|
||||
|
||||
|
||||
addButton((9 * 1) + 5, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cGreen + "+1 Hour").build(),
|
||||
(player, click) -> {
|
||||
_hours++;
|
||||
refresh();
|
||||
});
|
||||
|
||||
addButton((9 * 1) + 6, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cGreen + "+1 Day").build(),
|
||||
(player, click) -> {
|
||||
_days++;
|
||||
refresh();
|
||||
});
|
||||
|
||||
addButton((9 * 1) + 7, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cGreen + "+30 Days").build(),
|
||||
(player, click) -> {
|
||||
_days += 30;
|
||||
refresh();
|
||||
});
|
||||
|
||||
// Middle of second row
|
||||
addButton((9 * 1) + 4, new ItemBuilder(Material.WATCH)
|
||||
.setTitle(C.cGold + "Time Options")
|
||||
.addLore(" ")
|
||||
.addLore("Permanent: " + F.elem(_permanent ? "Yes" : "No"))
|
||||
.addLore("Days: " + F.elem(Integer.valueOf(_days)))
|
||||
.addLore("Hours: " + F.elem(Integer.valueOf(_hours)))
|
||||
.addLore(" ")
|
||||
.addLore("Right-Click this button")
|
||||
.addLore("to ban permanently.").build(),
|
||||
(player, click) -> {
|
||||
if (click == ClickType.RIGHT)
|
||||
{
|
||||
_permanent = !_permanent;
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
// Middle of third row
|
||||
addButton((9 * 2) + 4, new ItemBuilder(Material.EMERALD_BLOCK)
|
||||
.setTitle(C.cRedB + "BAN PLAYER")
|
||||
.addLore(" ")
|
||||
.addLore("Player: " + F.elem(data.getLeft()))
|
||||
.addLore("Reason: " + F.elem(data.getRight())).build(),
|
||||
(player, click) -> {
|
||||
getPlugin().runAsync(() -> {
|
||||
double time = _days + ((1.f / 24.f) * _hours);
|
||||
getPlugin().ban(client, data.getLeft(), getPlayer().getName(), _permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), data.getRight(), c -> {
|
||||
UtilPlayer.message(getPlayer(), F.main("Clans", F.elem(data.getLeft()) + " is now banned " + c.getBanTimeFormatted() + "."));
|
||||
|
||||
getPlugin().runSync(() -> {
|
||||
Player target = Bukkit.getPlayer(data.getLeft());
|
||||
|
||||
if (target != null)
|
||||
target.kickPlayer(C.cRedB + "You have been banned from Clans " + c.getBanTimeFormatted() + ".");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
for (ClansBan ban : client.Bans)
|
||||
{
|
||||
ItemStack item =
|
||||
new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK)
|
||||
for (ClansBan ban : _victimClient.Bans)
|
||||
{
|
||||
ItemStack item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK)
|
||||
.setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive")
|
||||
|
||||
.addLore(" ")
|
||||
.addLore("Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime()))
|
||||
.addLore("Admin: " + C.cYellow + ban.getAdmin())
|
||||
.addLore("Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None"))
|
||||
.addLore("Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
||||
.addLore(C.cGray + "Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime()))
|
||||
.addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin())
|
||||
.addLore(C.cGray + "Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None"))
|
||||
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
||||
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
|
||||
.addLore("Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
||||
.addLore(!ban.isActive() ? null : C.cDAqua + "Left-Click to disable ban")
|
||||
.addLore(C.cGray + "Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
||||
.addLore(ban.isActive() ? " " : null)
|
||||
.addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null)
|
||||
.addDullEnchantment(ban.isActive())
|
||||
.build();
|
||||
|
||||
.build();
|
||||
|
||||
if (ban.isActive())
|
||||
UtilInv.addDullEnchantment(item);
|
||||
|
||||
addButton(slot++, item, (player, click) -> {
|
||||
if (ban.isActive())
|
||||
{
|
||||
getPlugin().runAsync(() -> getPlugin().unban(client, ban, data.getLeft(), c -> refresh()));
|
||||
}
|
||||
addButton(slot++, item, (player, click) -> {
|
||||
if (ban.isActive())
|
||||
{
|
||||
getPlugin().runAsync(() -> {
|
||||
getPlugin().unban(_victimClient, ban, client -> {
|
||||
refresh();
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void performBan()
|
||||
{
|
||||
getPlugin().runAsync(() -> {
|
||||
getPlugin().ban(_victimClient, getPlayer().getName(), _permanent ? -1 : _time, _reason, client -> {
|
||||
UtilPlayer.message(getPlayer(), F.main("Clans", F.elem(_victim) + " is now banned " + client.getBanTimeFormatted() + "."));
|
||||
|
||||
Player target = Bukkit.getPlayer(_victim);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
getPlugin().queueToKick(target, C.cRedB + "You have been banned from Clans " + client.getBanTimeFormatted() + ".");
|
||||
}
|
||||
|
||||
refresh();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void addTimeAdjuster(int index, long time)
|
||||
{
|
||||
addButton(index, new ItemBuilder(Material.PAPER).setTitle(C.cRed + (time < 0 ? "-" : "") + UtilTime.MakeStr(Math.abs(time))).build(),
|
||||
(player, click) -> {
|
||||
_time += time;
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -423,8 +423,15 @@ public class ItemMapManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
Byte color = Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), (byte) 0);
|
||||
|
||||
Byte color;
|
||||
try
|
||||
{
|
||||
color = Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), (byte) 0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
color = (byte) 0;
|
||||
}
|
||||
second[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,17 @@ public class ClansRegions extends MiniPlugin
|
||||
{
|
||||
int x = chunkX + xOffset;
|
||||
int z = chunkZ + zOffset;
|
||||
Chunk chunk = location.getWorld().getChunkAt(x, z);
|
||||
Chunk chunk;
|
||||
try
|
||||
{ //Corrupted chunk will hold up whole server
|
||||
chunk = location.getWorld().getChunkAt(x, z);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.out.println("UNABLE TO LOAD CHUNK AT " + x + " , " + z);
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
String chunkStr = UtilWorld.chunkToStr(chunk);
|
||||
|
||||
if (addNegative)
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mineplex.game.clans.clans.siege.weapon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -41,6 +43,7 @@ import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
|
||||
import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
|
||||
import mineplex.game.clans.clans.siege.weapon.util.AccessType;
|
||||
import mineplex.game.clans.clans.siege.weapon.util.WeaponStateInfo;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
|
||||
public class Cannon extends SiegeWeapon
|
||||
{
|
||||
@ -425,32 +428,17 @@ public class Cannon extends SiegeWeapon
|
||||
@EventHandler
|
||||
public void explosionEffects(SiegeWeaponExplodeEvent event)
|
||||
{
|
||||
// for (int i = 0; i < 8; i++)
|
||||
// {
|
||||
// // Explosion particle effects.
|
||||
// Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5);
|
||||
// UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX);
|
||||
// }
|
||||
|
||||
// Block explosion.
|
||||
ArrayList<Block> blocks = new ArrayList<>();
|
||||
int attempts = 0;
|
||||
while (blocks.size() < 10 && (attempts < 30))
|
||||
{
|
||||
Block block = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), (4 * getPowerLevel())).getBlock();
|
||||
|
||||
if (_siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation()) != null && !_siegeManager.getClansManager().getBlacklist().allowed(_siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation()).Owner))
|
||||
List<Block> blocks = Stream.generate(() -> UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 4 * getPowerLevel()).getBlock())
|
||||
.limit(30) // Generate up to 30
|
||||
.distinct() // distinct blocks,
|
||||
.filter(block -> block.getType() != Material.AIR) // filter for non-air
|
||||
.filter(block -> // and blocks whose locations aren't blacklisted,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((block.getType() != Material.AIR) && (!blocks.contains(block)))
|
||||
{
|
||||
blocks.add(block);
|
||||
}
|
||||
|
||||
attempts++;
|
||||
}
|
||||
ClanTerritory claim = _siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation());
|
||||
return claim == null || _siegeManager.getClansManager().getBlacklist().allowed(claim.Owner);
|
||||
})
|
||||
.limit(10) // and take up to 10 of them.
|
||||
.collect(Collectors.toList());
|
||||
|
||||
_clans.getExplosion().BlockExplosion(
|
||||
blocks,
|
||||
@ -459,5 +447,4 @@ public class Cannon extends SiegeWeapon
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -121,6 +121,8 @@ public abstract class SiegeWeapon implements Listener
|
||||
// Customizability
|
||||
private double[] _forcedVelocity;
|
||||
|
||||
private float[] _lockedYaw;
|
||||
|
||||
protected boolean _isRideable;
|
||||
protected boolean _invertRotation;
|
||||
protected AccessRule _mountAccess;
|
||||
@ -299,6 +301,22 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
double yaw = (float) ((float)standYaw + Math.min(dif / _rotSpeed, 4f));
|
||||
|
||||
if (_lockedYaw != null)
|
||||
{
|
||||
float min = _lockedYaw[0];
|
||||
float max = _lockedYaw[1];
|
||||
|
||||
if (yaw < min)
|
||||
{
|
||||
yaw = min;
|
||||
}
|
||||
|
||||
if (yaw > max)
|
||||
{
|
||||
yaw = max;
|
||||
}
|
||||
}
|
||||
|
||||
armorStand.setHeadPose(new EulerAngle(0, Math.toRadians(CustomRotate(_yaw = yaw)), 0));
|
||||
}
|
||||
}
|
||||
@ -313,6 +331,11 @@ public abstract class SiegeWeapon implements Listener
|
||||
_forcedVelocity = new double[] { vertical, horizontal };
|
||||
}
|
||||
|
||||
public void LockYaw(float minYaw, float maxYaw)
|
||||
{
|
||||
_lockedYaw = new float[] { minYaw, maxYaw };
|
||||
}
|
||||
|
||||
private void fire(Player player)
|
||||
{
|
||||
_lastFired = System.currentTimeMillis();
|
||||
@ -458,7 +481,7 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
private void dismount(Player player)
|
||||
{
|
||||
player.teleport(player.getLocation().add(0, 1, 0));
|
||||
_clans.runSync(() -> player.teleport(player.getLocation().add(0, 1, 0)));
|
||||
}
|
||||
|
||||
protected void handleLeftClick(Player player)
|
||||
@ -523,7 +546,12 @@ public abstract class SiegeWeapon implements Listener
|
||||
protected void CustomRightClick(Player player) { return; }
|
||||
protected void CustomCleanup() { return; }
|
||||
protected void CustomUpdateState(String state) { return; }
|
||||
protected double CustomRotate(double yaw) { return yaw; }
|
||||
|
||||
protected double CustomRotate(double yaw)
|
||||
{
|
||||
return yaw;
|
||||
}
|
||||
|
||||
protected boolean CustomDismount(Player player, Entity entity) { return false; }
|
||||
protected boolean CustomMount(Player player) { return false; }
|
||||
|
||||
|
@ -213,16 +213,6 @@ public class Spawn extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ignoreVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
if (_clansManager.getClanUtility().isSafe(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
System.out.println("cancelled");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSkill(SkillTriggerEvent event)
|
||||
{
|
||||
|
@ -62,55 +62,46 @@ public class BlowUpWallGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
|
||||
TutorialRegion region = getObjective().getPlugin().getRegion(shooter);
|
||||
|
||||
if (getObjective().getPlugin().isIn(center, region, ClansMainTutorial.Bounds.ENEMY_ATTACK_AREA))
|
||||
double radius = 5.2;
|
||||
|
||||
HashMap<Block, Double> blockList = new HashMap<Block, Double>();
|
||||
int iR = (int) radius + 1;
|
||||
|
||||
for (int x = -iR; x <= iR; x++)
|
||||
{
|
||||
double radius = 5.2;
|
||||
|
||||
HashMap<Block, Double> blockList = new HashMap<Block, Double>();
|
||||
int iR = (int) radius + 1;
|
||||
|
||||
for (int x = -iR; x <= iR; x++)
|
||||
for (int z = -iR; z <= iR; z++)
|
||||
{
|
||||
for (int z = -iR; z <= iR; z++)
|
||||
for (int y = -iR; y <= iR; y++)
|
||||
{
|
||||
for (int y = -iR; y <= iR; y++)
|
||||
Block curBlock = center.getBlock().getRelative(x, y, z);
|
||||
|
||||
double offset = UtilMath.offset(center, curBlock.getLocation());
|
||||
|
||||
if (offset <= radius)
|
||||
{
|
||||
Block curBlock = center.getBlock().getRelative(x, y, z);
|
||||
|
||||
double offset = UtilMath.offset(center, curBlock.getLocation());
|
||||
|
||||
if (offset <= radius)
|
||||
{
|
||||
blockList.put(curBlock, Double.valueOf(offset));
|
||||
}
|
||||
blockList.put(curBlock, Double.valueOf(offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockList.forEach((block, dist) -> {
|
||||
|
||||
if (block.getType() == Material.SMOOTH_BRICK
|
||||
|| block.getType() == Material.SMOOTH_STAIRS
|
||||
|| block.getType() == Material.IRON_DOOR_BLOCK)
|
||||
|
||||
if (Math.random() < 0.2 + (dist.doubleValue() / 2.55) || dist.doubleValue() < 1.75)
|
||||
{
|
||||
block.setType(Material.AIR, false);
|
||||
|
||||
if (block.getType() != Material.IRON_DOOR_BLOCK && block.getType().name().endsWith("BANNER"))
|
||||
FallingBlocks.Instance.Spawn(block.getLocation(), block.getType(), block.getData(), center);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
finish(shooter);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(shooter, F.main("Clans", "You missed! Try to hit the enemy's front wall, that should make a nice big hole!"));
|
||||
UtilInv.give(shooter, Material.TNT);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
blockList.forEach((block, dist) -> {
|
||||
|
||||
if (block.getType() == Material.SMOOTH_BRICK
|
||||
|| block.getType() == Material.SMOOTH_STAIRS
|
||||
|| block.getType() == Material.IRON_DOOR_BLOCK)
|
||||
|
||||
if (Math.random() < 0.2 + (dist.doubleValue() / 2.55) || dist.doubleValue() < 1.75)
|
||||
{
|
||||
block.setType(Material.AIR, false);
|
||||
|
||||
if (block.getType() != Material.IRON_DOOR_BLOCK && block.getType().name().endsWith("BANNER"))
|
||||
FallingBlocks.Instance.Spawn(block.getLocation(), block.getType(), block.getData(), center);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
finish(shooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,9 +36,11 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
getObjective().getCannons().put(player.getName(), _clansManager.getSiegeManager().spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false));
|
||||
getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.4, 2.45);
|
||||
getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.44, 2.45);
|
||||
getObjective().getCannons().get(player.getName()).setInvincible(true);
|
||||
|
||||
getObjective().getCannons().get(player.getName()).LockYaw(-193, -173);
|
||||
|
||||
TutorialSession session = getObjective().getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getObjective().getPlugin().getPoint(session.getRegion(), ClansMainTutorial.Point.CANNON));
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package mineplex.hub;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.CustomTagFix;
|
||||
import mineplex.core.PacketsInteractionFix;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -12,9 +8,6 @@ import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.chatsnap.SnapshotManager;
|
||||
import mineplex.core.chatsnap.SnapshotPlugin;
|
||||
import mineplex.core.chatsnap.publishing.SnapshotPublisher;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.events.ServerShutdownEvent;
|
||||
import mineplex.core.creature.Creature;
|
||||
@ -47,20 +40,19 @@ import mineplex.core.profileCache.ProfileCacheManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
import mineplex.core.resourcepack.ResourcePackManager;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.sponsorbranding.BrandingManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.titangiveaway.TitanGiveawayManager;
|
||||
import mineplex.core.tournament.TournamentManager;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.core.velocity.VelocityFix;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.hub.modules.BillboardManager;
|
||||
import mineplex.hub.modules.StackerManager;
|
||||
import mineplex.hub.queue.QueueManager;
|
||||
import mineplex.hub.server.ServerManager;
|
||||
@ -75,6 +67,10 @@ import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Hub extends JavaPlugin implements IRelation
|
||||
{
|
||||
private String WEB_CONFIG = "webServer";
|
||||
@ -162,9 +158,6 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
new PacketsInteractionFix(this, packetHandler);
|
||||
new ResourcePackManager(this, portal);
|
||||
new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager);
|
||||
SnapshotManager snapshotManager = new SnapshotManager(new SnapshotPublisher(this));
|
||||
new SnapshotPlugin(this, snapshotManager);
|
||||
new ReportPlugin(this, new ReportManager(this, preferenceManager, statsManager, snapshotManager, CommandCenter.Instance.GetClientManager(), serverStatusManager.getCurrentServerName()));
|
||||
//new Replay(this, packetHandler);
|
||||
|
||||
AprilFoolsManager.Initialize(this, clientManager, disguiseManager);
|
||||
@ -198,6 +191,9 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
||||
BrandingManager brandingManager = new BrandingManager(this);
|
||||
new BillboardManager(this, brandingManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,69 @@
|
||||
package mineplex.hub.modules;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.events.ServerShutdownEvent;
|
||||
import mineplex.core.sponsorbranding.BrandingManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Manager to handle generation and protection of billboards in the hub
|
||||
*/
|
||||
public class BillboardManager extends MiniPlugin
|
||||
{
|
||||
private BrandingManager _branding;
|
||||
|
||||
public BillboardManager(JavaPlugin plugin, BrandingManager branding)
|
||||
{
|
||||
super("Billboard", plugin);
|
||||
_branding = branding;
|
||||
|
||||
generateBoards();
|
||||
}
|
||||
|
||||
private void generateBoards()
|
||||
{
|
||||
_branding.createPost(new Location(Bukkit.getWorld("world"), -2, 77, -33), BlockFace.SOUTH, "logitech.jpg");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopBreaking(HangingBreakEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof ItemFrame)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopBreaking(EntityDamageEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof ItemFrame)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (event.getRightClicked() != null && event.getRightClicked() instanceof ItemFrame)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleShutdown(ServerShutdownEvent event)
|
||||
{
|
||||
_branding.reset();
|
||||
}
|
||||
}
|
@ -411,7 +411,7 @@ public class CombatManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void HandleDeath(PlayerDeathEvent event)
|
||||
{
|
||||
event.setDeathMessage(null);
|
||||
|
@ -1,62 +0,0 @@
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.mineplex</groupId>
|
||||
<artifactId>mineplex-app</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<relativePath>../app.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>ReportServer</name>
|
||||
<artifactId>mineplex-reportserver</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>2.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mineplex</groupId>
|
||||
<artifactId>mineplex-serverdata</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Main-Class>mineplex.reportserver.ReportServer</Main-Class>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,57 +0,0 @@
|
||||
package mineplex.reportserver;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
/**
|
||||
* Class responsible for deleting old files (file age is determined by the "last modified" value).
|
||||
*/
|
||||
public class FilePurger implements Runnable
|
||||
{
|
||||
private static final FileFilter FILE_FILTER = file -> file.isFile() && file.getName().endsWith(".json");
|
||||
|
||||
private final File _dataDir;
|
||||
private final Logger _logger;
|
||||
|
||||
public FilePurger(File dataDir, Logger logger)
|
||||
{
|
||||
_dataDir = dataDir;
|
||||
_logger = logger;
|
||||
|
||||
Validate.notNull(_dataDir, "Data directory cannot be null.");
|
||||
Validate.isTrue(_dataDir.exists() && dataDir.isDirectory(), "Path non-existent or not a directory: %s", _dataDir.getAbsolutePath());
|
||||
Validate.notNull(_logger, "Logger cannot be null.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
int purgeCount = 0;
|
||||
|
||||
for (File file : _dataDir.listFiles(FILE_FILTER))
|
||||
{
|
||||
long lastModified = file.lastModified();
|
||||
long timeSince = System.currentTimeMillis() - lastModified;
|
||||
int days = (int) TimeUnit.MILLISECONDS.toDays(timeSince);
|
||||
|
||||
if (days >= 15) // keep files for 15 days
|
||||
{
|
||||
if (!file.delete())
|
||||
{
|
||||
_logger.warning("Cannot delete file: " + file.getAbsolutePath());
|
||||
}
|
||||
else
|
||||
{
|
||||
purgeCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_logger.info("Purged " + purgeCount + " old chat snapshots.");
|
||||
}
|
||||
}
|
||||
|
@ -1,142 +0,0 @@
|
||||
package mineplex.reportserver;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
|
||||
/**
|
||||
* Listens for commands from Redis (such as "deploy" or "destroy") and executes them.
|
||||
*/
|
||||
public class RedisCommandHandler extends JedisPubSub
|
||||
{
|
||||
private static final Gson _gson = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
|
||||
private static final JsonParser _jsonParser = new JsonParser();
|
||||
|
||||
private final File _directory;
|
||||
private final Logger _logger;
|
||||
|
||||
private final ExecutorService _executorService = Executors.newCachedThreadPool();
|
||||
|
||||
public RedisCommandHandler(File directory, Logger logger)
|
||||
{
|
||||
_directory = directory;
|
||||
_logger = logger;
|
||||
|
||||
Validate.notNull(_directory, "Directory cannot be null.");
|
||||
Validate.isTrue(directory.exists() && directory.isDirectory(), "Path non-existent or not a directory: %s", directory.getPath());
|
||||
Validate.notNull(_logger, "Logger cannot be null.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String channel, String dataString)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (channel.equals(ReportServer.CHANNEL_DEPLOY))
|
||||
{
|
||||
String json = dataString;
|
||||
JsonObject jsonObject = _jsonParser.parse(json).getAsJsonObject();
|
||||
String token = jsonObject.get("token").getAsString();
|
||||
|
||||
File target = new File(_directory, token + ".json");
|
||||
_logger.info("Chat snapshot received [" + token + "], writing to file.");
|
||||
|
||||
if (target.exists() && !jsonObject.has("snapshots"))
|
||||
{
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(target)))
|
||||
{
|
||||
JsonObject originalJsonObject = _jsonParser.parse(bufferedReader).getAsJsonObject();
|
||||
JsonObject usernamesObject = jsonObject.get("usernames").getAsJsonObject();
|
||||
|
||||
// retrieve snapshots from original file and add to jsonObject
|
||||
jsonObject.add("snapshots", originalJsonObject.get("snapshots").getAsJsonArray());
|
||||
|
||||
// add new UUID->Usernames, update existing usernames
|
||||
for (Map.Entry<String, JsonElement> entry : originalJsonObject.get("usernames").getAsJsonObject().entrySet())
|
||||
{
|
||||
usernamesObject.addProperty(entry.getKey(), entry.getValue().getAsJsonPrimitive().getAsString());
|
||||
}
|
||||
|
||||
// re-write json after updating
|
||||
json = _gson.toJson(jsonObject);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.log(Level.SEVERE, "Exception whilst updating an original snapshot.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
writeFile(target, json);
|
||||
}
|
||||
else if (channel.equals(ReportServer.CHANNEL_DESTROY))
|
||||
{
|
||||
// dataString = token
|
||||
File target = new File(_directory, dataString + ".json");
|
||||
_logger.info("Destroy command received [" + dataString + "].");
|
||||
|
||||
if (target.exists() && !target.delete())
|
||||
{
|
||||
_logger.warning("Failed to delete: " + target.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.log(Level.SEVERE, "Error whilst receiving redis message.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFile(File file, String json)
|
||||
{
|
||||
_executorService.submit(() -> Files.write(file.toPath(), Arrays.asList(json.split("\n"))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPMessage(String s, String s1, String s2)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribe(String s, int i)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnsubscribe(String s, int i)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPUnsubscribe(String s, int i)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPSubscribe(String s, int i)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
package mineplex.reportserver;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
/**
|
||||
* Establishes and maintains a connection to Redis.
|
||||
*/
|
||||
public class RedisConnectionHandler implements Runnable
|
||||
{
|
||||
private final String _name;
|
||||
private final JedisPool _jedisPool;
|
||||
private final RedisCommandHandler _handler;
|
||||
private final String[] _channels;
|
||||
private final Logger _logger;
|
||||
|
||||
private long _lastConnectionMillis = -1;
|
||||
private Throwable _lastThrowable = null;
|
||||
|
||||
public RedisConnectionHandler(String name, JedisPool jedisPool, RedisCommandHandler handler, String[] channels, Logger logger)
|
||||
{
|
||||
_name = name;
|
||||
_jedisPool = jedisPool;
|
||||
_handler = handler;
|
||||
_channels = channels;
|
||||
_logger = logger;
|
||||
|
||||
Validate.isTrue(channels.length > 0, "Must provide at least one channel.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
while (!Thread.interrupted())
|
||||
{
|
||||
try
|
||||
{
|
||||
registerChannelHandlers();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// Only log new errors (prevents same error being spammed)
|
||||
if (_lastThrowable == null || !e.getClass().equals(_lastThrowable.getClass()))
|
||||
{
|
||||
if (_lastThrowable == null) // connection just failed
|
||||
{
|
||||
_lastConnectionMillis = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
_logger.log(Level.SEVERE, prefixMessage(
|
||||
"Exception in Redis connection"
|
||||
+ (_lastConnectionMillis != -1 ? " (no connection for " + getLastConnectionDuration() + ")" : "")
|
||||
+ ", attempting to regain connection."
|
||||
), e);
|
||||
|
||||
_lastThrowable = e;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(1000 * 5);
|
||||
}
|
||||
catch (InterruptedException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
_jedisPool.destroy();
|
||||
_logger.warning("Thread interrupted, end of connection.");
|
||||
}
|
||||
|
||||
private void registerChannelHandlers()
|
||||
{
|
||||
try (Jedis jedis = _jedisPool.getResource())
|
||||
{
|
||||
connectionEstablished();
|
||||
jedis.subscribe(_handler, _channels);
|
||||
}
|
||||
}
|
||||
|
||||
private void connectionEstablished()
|
||||
{
|
||||
// subscribe blocks so we need to do all this before
|
||||
_logger.info(
|
||||
_lastThrowable == null
|
||||
? prefixMessage("Connected.")
|
||||
: prefixMessage(String.format("Connected after %s.", getLastConnectionDuration()))
|
||||
);
|
||||
|
||||
_lastThrowable = null;
|
||||
}
|
||||
|
||||
private String prefixMessage(String message)
|
||||
{
|
||||
return String.format("[%s] %s", _name, message);
|
||||
}
|
||||
|
||||
private String getLastConnectionDuration()
|
||||
{
|
||||
return DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - _lastConnectionMillis, true, true);
|
||||
}
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
package mineplex.reportserver;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import mineplex.serverdata.Utility;
|
||||
import mineplex.serverdata.redis.RedisConfig;
|
||||
import mineplex.serverdata.servers.ConnectionData;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
/**
|
||||
* Main class for the Report server, parses command line arguments and initializes the Report server.
|
||||
*/
|
||||
public class ReportServer
|
||||
{
|
||||
public static final String CHANNEL_DEPLOY = "reportserver:deploy";
|
||||
public static final String CHANNEL_DESTROY = "reportserver:destroy";
|
||||
|
||||
private static final String[] CHANNELS = new String[]{CHANNEL_DEPLOY, CHANNEL_DESTROY};
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%6$s%n"); // Nicer log output
|
||||
|
||||
Logger logger = Logger.getLogger("ReportServer");
|
||||
logger.info("Starting report server.");
|
||||
|
||||
Options options = new Options();
|
||||
|
||||
Option dirOption = Option.builder("dataDir")
|
||||
.hasArg()
|
||||
.longOpt("dataDirectory")
|
||||
.desc("Sets the data directory where the JSON files will be stored.")
|
||||
.type(File.class)
|
||||
.build();
|
||||
|
||||
options.addOption(dirOption);
|
||||
|
||||
try
|
||||
{
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine cmd = parser.parse(options, args);
|
||||
File dataDirectory = (File) cmd.getParsedOptionValue(dirOption.getOpt());
|
||||
|
||||
if (dataDirectory == null)
|
||||
{
|
||||
dataDirectory = new File("data");
|
||||
}
|
||||
|
||||
new ReportServer(ServerManager.getDefaultConfig(), dataDirectory, logger);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
logger.log(Level.SEVERE, "Failed to parse arguments.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private final File _dataDirectory;
|
||||
private final Logger _logger;
|
||||
|
||||
private final RedisCommandHandler _handler;
|
||||
private final ScheduledExecutorService _executorService = Executors.newScheduledThreadPool(1);
|
||||
|
||||
public ReportServer(RedisConfig redisConfig, File dataDirectory, Logger logger)
|
||||
{
|
||||
_dataDirectory = dataDirectory;
|
||||
_logger = logger;
|
||||
|
||||
Validate.notNull(_dataDirectory, "Data directory cannot be null.");
|
||||
|
||||
// thrown if path exists but is not a directory
|
||||
Validate.isTrue(!_dataDirectory.exists() || _dataDirectory.isDirectory(), "Not a directory: %s", _dataDirectory.getPath());
|
||||
|
||||
// throws if directory doesn't exist and cannot be created
|
||||
Validate.isTrue(_dataDirectory.exists() || _dataDirectory.mkdir(), "Unable to create directory: " + _dataDirectory.getPath());
|
||||
|
||||
_handler = new RedisCommandHandler(_dataDirectory, _logger);
|
||||
initializeConnectionsConfig(redisConfig);
|
||||
schedulePurgeTask();
|
||||
}
|
||||
|
||||
private void initializeConnectionsConfig(RedisConfig redisConfig)
|
||||
{
|
||||
redisConfig.getConnections(false, null).forEach(this::initializeConnection);
|
||||
}
|
||||
|
||||
private void initializeConnection(ConnectionData connectionData)
|
||||
{
|
||||
JedisPool jedisPool = Utility.generatePool(connectionData);
|
||||
String connectionName = connectionData.getName();
|
||||
Thread thread = new Thread(new RedisConnectionHandler(connectionName, jedisPool, _handler, CHANNELS, _logger), connectionName + " - Redis PubSub Thread");
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private void schedulePurgeTask()
|
||||
{
|
||||
_executorService.scheduleAtFixedRate(new FilePurger(_dataDirectory, _logger), 0, 30, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
Binary file not shown.
6211
Plugins/Mineplex.ReportServer/web/css/bootstrap.css
vendored
6211
Plugins/Mineplex.ReportServer/web/css/bootstrap.css
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,118 +0,0 @@
|
||||
@font-face {
|
||||
font-family: 'Minecraftia';
|
||||
src: url('Minecraftia.ttf');
|
||||
}
|
||||
|
||||
h2,h3,h4,h5,h6 {
|
||||
font-family: 'Oswald', sans-serif;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
|
||||
}
|
||||
|
||||
#header {
|
||||
padding-top: 20px;
|
||||
padding-left: 20%;
|
||||
padding-right: 20%;
|
||||
background-color: #fa8144;
|
||||
height: 175px;
|
||||
text-align: center;
|
||||
font-family: 'Crete Round', serif;
|
||||
background-image: url("../img/bg.png");
|
||||
background-position: -40px -40px;
|
||||
}
|
||||
|
||||
#header h1 {
|
||||
font-size: 55px;
|
||||
text-shadow: 4px 3px 0px rgba(255, 255, 255, 0.55), 9px 8px 0px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
#search {
|
||||
padding: 5px 30%;
|
||||
background-color: rgb(186, 85, 28);
|
||||
}
|
||||
|
||||
#content {
|
||||
padding-top: 10px;
|
||||
padding-left: 20%;
|
||||
padding-right: 20%;
|
||||
min-height: 500px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
border-top: solid 2px rgba(204, 204, 204, 0.64);
|
||||
padding-left: 20%;
|
||||
padding-right: 20%;
|
||||
background-color: rgba(243, 243, 243, 0.64);
|
||||
height: 100px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
#footer img {
|
||||
opacity: 0.35;
|
||||
|
||||
-o-transition:.5s;
|
||||
-ms-transition:.5s;
|
||||
-moz-transition:.5s;
|
||||
-webkit-transition:.5s;
|
||||
/* ...and now for the proper property */
|
||||
transition:.5s;
|
||||
}
|
||||
|
||||
#footer img:hover {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
#footer a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-family: 'Minecraftia';
|
||||
}
|
||||
|
||||
.label-staff {
|
||||
background-color: #FFAA00;
|
||||
}
|
||||
|
||||
.label-ultra {
|
||||
background-color: #55FFFF;
|
||||
}
|
||||
|
||||
#log {
|
||||
font-family: 'Minecraftia';
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.black {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.chat {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.pm {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
#test-bar {
|
||||
align-content: center;
|
||||
padding-top: 20px;
|
||||
background-image: url("../img/bg.png");
|
||||
min-height: 750px;
|
||||
font-family: 'Crete Round', serif;
|
||||
}
|
||||
|
||||
#test-bar h1 {
|
||||
font-size: 48px;
|
||||
text-shadow: 4px 3px 0px rgba(255, 255, 255, 0.55), 9px 8px 0px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.error-oh-no {
|
||||
text-shadow: 4px 3px 0px rgba(255, 255, 255, 0.55), 9px 8px 0px rgba(0,0,0,0.15);
|
||||
color: #d9534f;
|
||||
font-family: Minecraftia;
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
Binary file not shown.
Before Width: | Height: | Size: 227 KiB |
Binary file not shown.
Before Width: | Height: | Size: 971 KiB |
3560
Plugins/Mineplex.ReportServer/web/js/bootstrap.js
vendored
3560
Plugins/Mineplex.ReportServer/web/js/bootstrap.js
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
10351
Plugins/Mineplex.ReportServer/web/js/jquery.js
vendored
10351
Plugins/Mineplex.ReportServer/web/js/jquery.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
||||
// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
|
||||
require('./umd/util.js')
|
||||
require('./umd/alert.js')
|
||||
require('./umd/button.js')
|
||||
require('./umd/carousel.js')
|
||||
require('./umd/collapse.js')
|
||||
require('./umd/dropdown.js')
|
||||
require('./umd/modal.js')
|
||||
require('./umd/scrollspy.js')
|
||||
require('./umd/tab.js')
|
||||
require('./umd/tooltip.js')
|
||||
require('./umd/popover.js')
|
@ -1,211 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module', './util'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module, require('./util'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod, global.Util);
|
||||
global.alert = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module, _util) {
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
var _Util = _interopRequireDefault(_util);
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): alert.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Alert = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'alert';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.alert';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var DATA_API_KEY = '.data-api';
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
var TRANSITION_DURATION = 150;
|
||||
|
||||
var Selector = {
|
||||
DISMISS: '[data-dismiss="alert"]'
|
||||
};
|
||||
|
||||
var Event = {
|
||||
CLOSE: 'close' + EVENT_KEY,
|
||||
CLOSED: 'closed' + EVENT_KEY,
|
||||
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
|
||||
};
|
||||
|
||||
var ClassName = {
|
||||
ALERT: 'alert',
|
||||
FADE: 'fade',
|
||||
IN: 'in'
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Alert = (function () {
|
||||
function Alert(element) {
|
||||
_classCallCheck(this, Alert);
|
||||
|
||||
this._element = element;
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Data Api implementation
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// getters
|
||||
|
||||
_createClass(Alert, [{
|
||||
key: 'close',
|
||||
|
||||
// public
|
||||
|
||||
value: function close(element) {
|
||||
element = element || this._element;
|
||||
|
||||
var rootElement = this._getRootElement(element);
|
||||
var customEvent = this._triggerCloseEvent(rootElement);
|
||||
|
||||
if (customEvent.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._removeElement(rootElement);
|
||||
}
|
||||
}, {
|
||||
key: 'dispose',
|
||||
value: function dispose() {
|
||||
$.removeData(this._element, DATA_KEY);
|
||||
this._element = null;
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
}, {
|
||||
key: '_getRootElement',
|
||||
value: function _getRootElement(element) {
|
||||
var selector = _Util['default'].getSelectorFromElement(element);
|
||||
var parent = false;
|
||||
|
||||
if (selector) {
|
||||
parent = $(selector)[0];
|
||||
}
|
||||
|
||||
if (!parent) {
|
||||
parent = $(element).closest('.' + ClassName.ALERT)[0];
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
}, {
|
||||
key: '_triggerCloseEvent',
|
||||
value: function _triggerCloseEvent(element) {
|
||||
var closeEvent = $.Event(Event.CLOSE);
|
||||
|
||||
$(element).trigger(closeEvent);
|
||||
return closeEvent;
|
||||
}
|
||||
}, {
|
||||
key: '_removeElement',
|
||||
value: function _removeElement(element) {
|
||||
$(element).removeClass(ClassName.IN);
|
||||
|
||||
if (!_Util['default'].supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) {
|
||||
this._destroyElement(element);
|
||||
return;
|
||||
}
|
||||
|
||||
$(element).one(_Util['default'].TRANSITION_END, $.proxy(this._destroyElement, this, element)).emulateTransitionEnd(TRANSITION_DURATION);
|
||||
}
|
||||
}, {
|
||||
key: '_destroyElement',
|
||||
value: function _destroyElement(element) {
|
||||
$(element).detach().trigger(Event.CLOSED).remove();
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var $element = $(this);
|
||||
var data = $element.data(DATA_KEY);
|
||||
|
||||
if (!data) {
|
||||
data = new Alert(this);
|
||||
$element.data(DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (config === 'close') {
|
||||
data[config](this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: '_handleDismiss',
|
||||
value: function _handleDismiss(alertInstance) {
|
||||
return function (event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
alertInstance.close(this);
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Alert;
|
||||
})();
|
||||
|
||||
$(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$.fn[NAME] = Alert._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Alert;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Alert._jQueryInterface;
|
||||
};
|
||||
|
||||
return Alert;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Alert;
|
||||
});
|
@ -1,187 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module);
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod);
|
||||
global.button = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module) {
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): button.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
var Button = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'button';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.button';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var DATA_API_KEY = '.data-api';
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
|
||||
var ClassName = {
|
||||
ACTIVE: 'active',
|
||||
BUTTON: 'btn',
|
||||
FOCUS: 'focus'
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
|
||||
DATA_TOGGLE: '[data-toggle="buttons"]',
|
||||
INPUT: 'input',
|
||||
ACTIVE: '.active',
|
||||
BUTTON: '.btn'
|
||||
};
|
||||
|
||||
var Event = {
|
||||
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY,
|
||||
FOCUS_BLUR_DATA_API: 'focus' + EVENT_KEY + DATA_API_KEY + ' ' + ('blur' + EVENT_KEY + DATA_API_KEY)
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Button = (function () {
|
||||
function Button(element) {
|
||||
_classCallCheck(this, Button);
|
||||
|
||||
this._element = element;
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Data Api implementation
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// getters
|
||||
|
||||
_createClass(Button, [{
|
||||
key: 'toggle',
|
||||
|
||||
// public
|
||||
|
||||
value: function toggle() {
|
||||
var triggerChangeEvent = true;
|
||||
var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0];
|
||||
|
||||
if (rootElement) {
|
||||
var input = $(this._element).find(Selector.INPUT)[0];
|
||||
|
||||
if (input) {
|
||||
if (input.type === 'radio') {
|
||||
if (input.checked && $(this._element).hasClass(ClassName.ACTIVE)) {
|
||||
triggerChangeEvent = false;
|
||||
} else {
|
||||
var activeElement = $(rootElement).find(Selector.ACTIVE)[0];
|
||||
|
||||
if (activeElement) {
|
||||
$(activeElement).removeClass(ClassName.ACTIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (triggerChangeEvent) {
|
||||
input.checked = !$(this._element).hasClass(ClassName.ACTIVE);
|
||||
$(this._element).trigger('change');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE));
|
||||
}
|
||||
|
||||
if (triggerChangeEvent) {
|
||||
$(this._element).toggleClass(ClassName.ACTIVE);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'dispose',
|
||||
value: function dispose() {
|
||||
$.removeData(this._element, DATA_KEY);
|
||||
this._element = null;
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data(DATA_KEY);
|
||||
|
||||
if (!data) {
|
||||
data = new Button(this);
|
||||
$(this).data(DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (config === 'toggle') {
|
||||
data[config]();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Button;
|
||||
})();
|
||||
|
||||
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var button = event.target;
|
||||
|
||||
if (!$(button).hasClass(ClassName.BUTTON)) {
|
||||
button = $(button).closest(Selector.BUTTON);
|
||||
}
|
||||
|
||||
Button._jQueryInterface.call($(button), 'toggle');
|
||||
}).on(Event.FOCUS_BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) {
|
||||
var button = $(event.target).closest(Selector.BUTTON)[0];
|
||||
$(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type));
|
||||
});
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$.fn[NAME] = Button._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Button;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Button._jQueryInterface;
|
||||
};
|
||||
|
||||
return Button;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Button;
|
||||
});
|
@ -1,497 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module', './util'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module, require('./util'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod, global.Util);
|
||||
global.carousel = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module, _util) {
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
var _Util = _interopRequireDefault(_util);
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): carousel.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Carousel = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'carousel';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.carousel';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var DATA_API_KEY = '.data-api';
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
var TRANSITION_DURATION = 600;
|
||||
|
||||
var Default = {
|
||||
interval: 5000,
|
||||
keyboard: true,
|
||||
slide: false,
|
||||
pause: 'hover',
|
||||
wrap: true
|
||||
};
|
||||
|
||||
var DefaultType = {
|
||||
interval: '(number|boolean)',
|
||||
keyboard: 'boolean',
|
||||
slide: '(boolean|string)',
|
||||
pause: '(string|boolean)',
|
||||
wrap: 'boolean'
|
||||
};
|
||||
|
||||
var Direction = {
|
||||
NEXT: 'next',
|
||||
PREVIOUS: 'prev'
|
||||
};
|
||||
|
||||
var Event = {
|
||||
SLIDE: 'slide' + EVENT_KEY,
|
||||
SLID: 'slid' + EVENT_KEY,
|
||||
KEYDOWN: 'keydown' + EVENT_KEY,
|
||||
MOUSEENTER: 'mouseenter' + EVENT_KEY,
|
||||
MOUSELEAVE: 'mouseleave' + EVENT_KEY,
|
||||
LOAD_DATA_API: 'load' + EVENT_KEY + DATA_API_KEY,
|
||||
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
|
||||
};
|
||||
|
||||
var ClassName = {
|
||||
CAROUSEL: 'carousel',
|
||||
ACTIVE: 'active',
|
||||
SLIDE: 'slide',
|
||||
RIGHT: 'right',
|
||||
LEFT: 'left',
|
||||
ITEM: 'carousel-item'
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
ACTIVE: '.active',
|
||||
ACTIVE_ITEM: '.active.carousel-item',
|
||||
ITEM: '.carousel-item',
|
||||
NEXT_PREV: '.next, .prev',
|
||||
INDICATORS: '.carousel-indicators',
|
||||
DATA_SLIDE: '[data-slide], [data-slide-to]',
|
||||
DATA_RIDE: '[data-ride="carousel"]'
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Carousel = (function () {
|
||||
function Carousel(element, config) {
|
||||
_classCallCheck(this, Carousel);
|
||||
|
||||
this._items = null;
|
||||
this._interval = null;
|
||||
this._activeElement = null;
|
||||
|
||||
this._isPaused = false;
|
||||
this._isSliding = false;
|
||||
|
||||
this._config = this._getConfig(config);
|
||||
this._element = $(element)[0];
|
||||
this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0];
|
||||
|
||||
this._addEventListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Data Api implementation
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// getters
|
||||
|
||||
_createClass(Carousel, [{
|
||||
key: 'next',
|
||||
|
||||
// public
|
||||
|
||||
value: function next() {
|
||||
if (!this._isSliding) {
|
||||
this._slide(Direction.NEXT);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'nextWhenVisible',
|
||||
value: function nextWhenVisible() {
|
||||
// Don't call next when the page isn't visible
|
||||
if (!document.hidden) {
|
||||
this.next();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'prev',
|
||||
value: function prev() {
|
||||
if (!this._isSliding) {
|
||||
this._slide(Direction.PREVIOUS);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'pause',
|
||||
value: function pause(event) {
|
||||
if (!event) {
|
||||
this._isPaused = true;
|
||||
}
|
||||
|
||||
if ($(this._element).find(Selector.NEXT_PREV)[0] && _Util['default'].supportsTransitionEnd()) {
|
||||
_Util['default'].triggerTransitionEnd(this._element);
|
||||
this.cycle(true);
|
||||
}
|
||||
|
||||
clearInterval(this._interval);
|
||||
this._interval = null;
|
||||
}
|
||||
}, {
|
||||
key: 'cycle',
|
||||
value: function cycle(event) {
|
||||
if (!event) {
|
||||
this._isPaused = false;
|
||||
}
|
||||
|
||||
if (this._interval) {
|
||||
clearInterval(this._interval);
|
||||
this._interval = null;
|
||||
}
|
||||
|
||||
if (this._config.interval && !this._isPaused) {
|
||||
this._interval = setInterval($.proxy(document.visibilityState ? this.nextWhenVisible : this.next, this), this._config.interval);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'to',
|
||||
value: function to(index) {
|
||||
var _this = this;
|
||||
|
||||
this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
|
||||
|
||||
var activeIndex = this._getItemIndex(this._activeElement);
|
||||
|
||||
if (index > this._items.length - 1 || index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._isSliding) {
|
||||
$(this._element).one(Event.SLID, function () {
|
||||
return _this.to(index);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeIndex === index) {
|
||||
this.pause();
|
||||
this.cycle();
|
||||
return;
|
||||
}
|
||||
|
||||
var direction = index > activeIndex ? Direction.NEXT : Direction.PREVIOUS;
|
||||
|
||||
this._slide(direction, this._items[index]);
|
||||
}
|
||||
}, {
|
||||
key: 'dispose',
|
||||
value: function dispose() {
|
||||
$(this._element).off(EVENT_KEY);
|
||||
$.removeData(this._element, DATA_KEY);
|
||||
|
||||
this._items = null;
|
||||
this._config = null;
|
||||
this._element = null;
|
||||
this._interval = null;
|
||||
this._isPaused = null;
|
||||
this._isSliding = null;
|
||||
this._activeElement = null;
|
||||
this._indicatorsElement = null;
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
}, {
|
||||
key: '_getConfig',
|
||||
value: function _getConfig(config) {
|
||||
config = $.extend({}, Default, config);
|
||||
_Util['default'].typeCheckConfig(NAME, config, DefaultType);
|
||||
return config;
|
||||
}
|
||||
}, {
|
||||
key: '_addEventListeners',
|
||||
value: function _addEventListeners() {
|
||||
if (this._config.keyboard) {
|
||||
$(this._element).on(Event.KEYDOWN, $.proxy(this._keydown, this));
|
||||
}
|
||||
|
||||
if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) {
|
||||
$(this._element).on(Event.MOUSEENTER, $.proxy(this.pause, this)).on(Event.MOUSELEAVE, $.proxy(this.cycle, this));
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_keydown',
|
||||
value: function _keydown(event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (/input|textarea/i.test(event.target.tagName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.which) {
|
||||
case 37:
|
||||
this.prev();break;
|
||||
case 39:
|
||||
this.next();break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_getItemIndex',
|
||||
value: function _getItemIndex(element) {
|
||||
this._items = $.makeArray($(element).parent().find(Selector.ITEM));
|
||||
return this._items.indexOf(element);
|
||||
}
|
||||
}, {
|
||||
key: '_getItemByDirection',
|
||||
value: function _getItemByDirection(direction, activeElement) {
|
||||
var isNextDirection = direction === Direction.NEXT;
|
||||
var isPrevDirection = direction === Direction.PREVIOUS;
|
||||
var activeIndex = this._getItemIndex(activeElement);
|
||||
var lastItemIndex = this._items.length - 1;
|
||||
var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
|
||||
|
||||
if (isGoingToWrap && !this._config.wrap) {
|
||||
return activeElement;
|
||||
}
|
||||
|
||||
var delta = direction === Direction.PREVIOUS ? -1 : 1;
|
||||
var itemIndex = (activeIndex + delta) % this._items.length;
|
||||
|
||||
return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
|
||||
}
|
||||
}, {
|
||||
key: '_triggerSlideEvent',
|
||||
value: function _triggerSlideEvent(relatedTarget, directionalClassname) {
|
||||
var slideEvent = $.Event(Event.SLIDE, {
|
||||
relatedTarget: relatedTarget,
|
||||
direction: directionalClassname
|
||||
});
|
||||
|
||||
$(this._element).trigger(slideEvent);
|
||||
|
||||
return slideEvent;
|
||||
}
|
||||
}, {
|
||||
key: '_setActiveIndicatorElement',
|
||||
value: function _setActiveIndicatorElement(element) {
|
||||
if (this._indicatorsElement) {
|
||||
$(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
|
||||
|
||||
var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
|
||||
|
||||
if (nextIndicator) {
|
||||
$(nextIndicator).addClass(ClassName.ACTIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_slide',
|
||||
value: function _slide(direction, element) {
|
||||
var _this2 = this;
|
||||
|
||||
var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
|
||||
var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
|
||||
|
||||
var isCycling = Boolean(this._interval);
|
||||
|
||||
var directionalClassName = direction === Direction.NEXT ? ClassName.LEFT : ClassName.RIGHT;
|
||||
|
||||
if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
|
||||
this._isSliding = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var slideEvent = this._triggerSlideEvent(nextElement, directionalClassName);
|
||||
if (slideEvent.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeElement || !nextElement) {
|
||||
// some weirdness is happening, so we bail
|
||||
return;
|
||||
}
|
||||
|
||||
this._isSliding = true;
|
||||
|
||||
if (isCycling) {
|
||||
this.pause();
|
||||
}
|
||||
|
||||
this._setActiveIndicatorElement(nextElement);
|
||||
|
||||
var slidEvent = $.Event(Event.SLID, {
|
||||
relatedTarget: nextElement,
|
||||
direction: directionalClassName
|
||||
});
|
||||
|
||||
if (_Util['default'].supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {
|
||||
|
||||
$(nextElement).addClass(direction);
|
||||
|
||||
_Util['default'].reflow(nextElement);
|
||||
|
||||
$(activeElement).addClass(directionalClassName);
|
||||
$(nextElement).addClass(directionalClassName);
|
||||
|
||||
$(activeElement).one(_Util['default'].TRANSITION_END, function () {
|
||||
$(nextElement).removeClass(directionalClassName).removeClass(direction);
|
||||
|
||||
$(nextElement).addClass(ClassName.ACTIVE);
|
||||
|
||||
$(activeElement).removeClass(ClassName.ACTIVE).removeClass(direction).removeClass(directionalClassName);
|
||||
|
||||
_this2._isSliding = false;
|
||||
|
||||
setTimeout(function () {
|
||||
return $(_this2._element).trigger(slidEvent);
|
||||
}, 0);
|
||||
}).emulateTransitionEnd(TRANSITION_DURATION);
|
||||
} else {
|
||||
$(activeElement).removeClass(ClassName.ACTIVE);
|
||||
$(nextElement).addClass(ClassName.ACTIVE);
|
||||
|
||||
this._isSliding = false;
|
||||
$(this._element).trigger(slidEvent);
|
||||
}
|
||||
|
||||
if (isCycling) {
|
||||
this.cycle();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data(DATA_KEY);
|
||||
var _config = $.extend({}, Default, $(this).data());
|
||||
|
||||
if (typeof config === 'object') {
|
||||
$.extend(_config, config);
|
||||
}
|
||||
|
||||
var action = typeof config === 'string' ? config : _config.slide;
|
||||
|
||||
if (!data) {
|
||||
data = new Carousel(this, _config);
|
||||
$(this).data(DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (typeof config === 'number') {
|
||||
data.to(config);
|
||||
} else if (typeof action === 'string') {
|
||||
if (data[action] === undefined) {
|
||||
throw new Error('No method named "' + action + '"');
|
||||
}
|
||||
data[action]();
|
||||
} else if (_config.interval) {
|
||||
data.pause();
|
||||
data.cycle();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: '_dataApiClickHandler',
|
||||
value: function _dataApiClickHandler(event) {
|
||||
var selector = _Util['default'].getSelectorFromElement(this);
|
||||
|
||||
if (!selector) {
|
||||
return;
|
||||
}
|
||||
|
||||
var target = $(selector)[0];
|
||||
|
||||
if (!target || !$(target).hasClass(ClassName.CAROUSEL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var config = $.extend({}, $(target).data(), $(this).data());
|
||||
var slideIndex = this.getAttribute('data-slide-to');
|
||||
|
||||
if (slideIndex) {
|
||||
config.interval = false;
|
||||
}
|
||||
|
||||
Carousel._jQueryInterface.call($(target), config);
|
||||
|
||||
if (slideIndex) {
|
||||
$(target).data(DATA_KEY).to(slideIndex);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}, {
|
||||
key: 'Default',
|
||||
get: function get() {
|
||||
return Default;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Carousel;
|
||||
})();
|
||||
|
||||
$(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler);
|
||||
|
||||
$(window).on(Event.LOAD_DATA_API, function () {
|
||||
$(Selector.DATA_RIDE).each(function () {
|
||||
var $carousel = $(this);
|
||||
Carousel._jQueryInterface.call($carousel, $carousel.data());
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$.fn[NAME] = Carousel._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Carousel;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Carousel._jQueryInterface;
|
||||
};
|
||||
|
||||
return Carousel;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Carousel;
|
||||
});
|
@ -1,383 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module', './util'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module, require('./util'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod, global.Util);
|
||||
global.collapse = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module, _util) {
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
var _Util = _interopRequireDefault(_util);
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): collapse.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Collapse = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'collapse';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.collapse';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var DATA_API_KEY = '.data-api';
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
var TRANSITION_DURATION = 600;
|
||||
|
||||
var Default = {
|
||||
toggle: true,
|
||||
parent: ''
|
||||
};
|
||||
|
||||
var DefaultType = {
|
||||
toggle: 'boolean',
|
||||
parent: 'string'
|
||||
};
|
||||
|
||||
var Event = {
|
||||
SHOW: 'show' + EVENT_KEY,
|
||||
SHOWN: 'shown' + EVENT_KEY,
|
||||
HIDE: 'hide' + EVENT_KEY,
|
||||
HIDDEN: 'hidden' + EVENT_KEY,
|
||||
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
|
||||
};
|
||||
|
||||
var ClassName = {
|
||||
IN: 'in',
|
||||
COLLAPSE: 'collapse',
|
||||
COLLAPSING: 'collapsing',
|
||||
COLLAPSED: 'collapsed'
|
||||
};
|
||||
|
||||
var Dimension = {
|
||||
WIDTH: 'width',
|
||||
HEIGHT: 'height'
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
ACTIVES: '.panel > .in, .panel > .collapsing',
|
||||
DATA_TOGGLE: '[data-toggle="collapse"]'
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Collapse = (function () {
|
||||
function Collapse(element, config) {
|
||||
_classCallCheck(this, Collapse);
|
||||
|
||||
this._isTransitioning = false;
|
||||
this._element = element;
|
||||
this._config = this._getConfig(config);
|
||||
this._triggerArray = $.makeArray($('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]')));
|
||||
|
||||
this._parent = this._config.parent ? this._getParent() : null;
|
||||
|
||||
if (!this._config.parent) {
|
||||
this._addAriaAndCollapsedClass(this._element, this._triggerArray);
|
||||
}
|
||||
|
||||
if (this._config.toggle) {
|
||||
this.toggle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Data Api implementation
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// getters
|
||||
|
||||
_createClass(Collapse, [{
|
||||
key: 'toggle',
|
||||
|
||||
// public
|
||||
|
||||
value: function toggle() {
|
||||
if ($(this._element).hasClass(ClassName.IN)) {
|
||||
this.hide();
|
||||
} else {
|
||||
this.show();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'show',
|
||||
value: function show() {
|
||||
var _this = this;
|
||||
|
||||
if (this._isTransitioning || $(this._element).hasClass(ClassName.IN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var actives = undefined;
|
||||
var activesData = undefined;
|
||||
|
||||
if (this._parent) {
|
||||
actives = $.makeArray($(Selector.ACTIVES));
|
||||
if (!actives.length) {
|
||||
actives = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (actives) {
|
||||
activesData = $(actives).data(DATA_KEY);
|
||||
if (activesData && activesData._isTransitioning) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var startEvent = $.Event(Event.SHOW);
|
||||
$(this._element).trigger(startEvent);
|
||||
if (startEvent.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (actives) {
|
||||
Collapse._jQueryInterface.call($(actives), 'hide');
|
||||
if (!activesData) {
|
||||
$(actives).data(DATA_KEY, null);
|
||||
}
|
||||
}
|
||||
|
||||
var dimension = this._getDimension();
|
||||
|
||||
$(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING);
|
||||
|
||||
this._element.style[dimension] = 0;
|
||||
this._element.setAttribute('aria-expanded', true);
|
||||
|
||||
if (this._triggerArray.length) {
|
||||
$(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true);
|
||||
}
|
||||
|
||||
this.setTransitioning(true);
|
||||
|
||||
var complete = function complete() {
|
||||
$(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.IN);
|
||||
|
||||
_this._element.style[dimension] = '';
|
||||
|
||||
_this.setTransitioning(false);
|
||||
|
||||
$(_this._element).trigger(Event.SHOWN);
|
||||
};
|
||||
|
||||
if (!_Util['default'].supportsTransitionEnd()) {
|
||||
complete();
|
||||
return;
|
||||
}
|
||||
|
||||
var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
|
||||
var scrollSize = 'scroll' + capitalizedDimension;
|
||||
|
||||
$(this._element).one(_Util['default'].TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
|
||||
|
||||
this._element.style[dimension] = this._element[scrollSize] + 'px';
|
||||
}
|
||||
}, {
|
||||
key: 'hide',
|
||||
value: function hide() {
|
||||
var _this2 = this;
|
||||
|
||||
if (this._isTransitioning || !$(this._element).hasClass(ClassName.IN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var startEvent = $.Event(Event.HIDE);
|
||||
$(this._element).trigger(startEvent);
|
||||
if (startEvent.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dimension = this._getDimension();
|
||||
var offsetDimension = dimension === Dimension.WIDTH ? 'offsetWidth' : 'offsetHeight';
|
||||
|
||||
this._element.style[dimension] = this._element[offsetDimension] + 'px';
|
||||
|
||||
_Util['default'].reflow(this._element);
|
||||
|
||||
$(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.IN);
|
||||
|
||||
this._element.setAttribute('aria-expanded', false);
|
||||
|
||||
if (this._triggerArray.length) {
|
||||
$(this._triggerArray).addClass(ClassName.COLLAPSED).attr('aria-expanded', false);
|
||||
}
|
||||
|
||||
this.setTransitioning(true);
|
||||
|
||||
var complete = function complete() {
|
||||
_this2.setTransitioning(false);
|
||||
$(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN);
|
||||
};
|
||||
|
||||
this._element.style[dimension] = 0;
|
||||
|
||||
if (!_Util['default'].supportsTransitionEnd()) {
|
||||
complete();
|
||||
return;
|
||||
}
|
||||
|
||||
$(this._element).one(_Util['default'].TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
|
||||
}
|
||||
}, {
|
||||
key: 'setTransitioning',
|
||||
value: function setTransitioning(isTransitioning) {
|
||||
this._isTransitioning = isTransitioning;
|
||||
}
|
||||
}, {
|
||||
key: 'dispose',
|
||||
value: function dispose() {
|
||||
$.removeData(this._element, DATA_KEY);
|
||||
|
||||
this._config = null;
|
||||
this._parent = null;
|
||||
this._element = null;
|
||||
this._triggerArray = null;
|
||||
this._isTransitioning = null;
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
}, {
|
||||
key: '_getConfig',
|
||||
value: function _getConfig(config) {
|
||||
config = $.extend({}, Default, config);
|
||||
config.toggle = Boolean(config.toggle); // coerce string values
|
||||
_Util['default'].typeCheckConfig(NAME, config, DefaultType);
|
||||
return config;
|
||||
}
|
||||
}, {
|
||||
key: '_getDimension',
|
||||
value: function _getDimension() {
|
||||
var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
|
||||
return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
|
||||
}
|
||||
}, {
|
||||
key: '_getParent',
|
||||
value: function _getParent() {
|
||||
var _this3 = this;
|
||||
|
||||
var parent = $(this._config.parent)[0];
|
||||
var selector = '[data-toggle="collapse"][data-parent="' + this._config.parent + '"]';
|
||||
|
||||
$(parent).find(selector).each(function (i, element) {
|
||||
_this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
|
||||
});
|
||||
|
||||
return parent;
|
||||
}
|
||||
}, {
|
||||
key: '_addAriaAndCollapsedClass',
|
||||
value: function _addAriaAndCollapsedClass(element, triggerArray) {
|
||||
if (element) {
|
||||
var isOpen = $(element).hasClass(ClassName.IN);
|
||||
element.setAttribute('aria-expanded', isOpen);
|
||||
|
||||
if (triggerArray.length) {
|
||||
$(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_getTargetFromElement',
|
||||
value: function _getTargetFromElement(element) {
|
||||
var selector = _Util['default'].getSelectorFromElement(element);
|
||||
return selector ? $(selector)[0] : null;
|
||||
}
|
||||
}, {
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var $this = $(this);
|
||||
var data = $this.data(DATA_KEY);
|
||||
var _config = $.extend({}, Default, $this.data(), typeof config === 'object' && config);
|
||||
|
||||
if (!data && _config.toggle && /show|hide/.test(config)) {
|
||||
_config.toggle = false;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
data = new Collapse(this, _config);
|
||||
$this.data(DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (typeof config === 'string') {
|
||||
if (data[config] === undefined) {
|
||||
throw new Error('No method named "' + config + '"');
|
||||
}
|
||||
data[config]();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}, {
|
||||
key: 'Default',
|
||||
get: function get() {
|
||||
return Default;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Collapse;
|
||||
})();
|
||||
|
||||
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var target = Collapse._getTargetFromElement(this);
|
||||
var data = $(target).data(DATA_KEY);
|
||||
var config = data ? 'toggle' : $(this).data();
|
||||
|
||||
Collapse._jQueryInterface.call($(target), config);
|
||||
});
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$.fn[NAME] = Collapse._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Collapse;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Collapse._jQueryInterface;
|
||||
};
|
||||
|
||||
return Collapse;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Collapse;
|
||||
});
|
@ -1,312 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module', './util'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module, require('./util'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod, global.Util);
|
||||
global.dropdown = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module, _util) {
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
var _Util = _interopRequireDefault(_util);
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): dropdown.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Dropdown = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'dropdown';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.dropdown';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var DATA_API_KEY = '.data-api';
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
|
||||
var Event = {
|
||||
HIDE: 'hide' + EVENT_KEY,
|
||||
HIDDEN: 'hidden' + EVENT_KEY,
|
||||
SHOW: 'show' + EVENT_KEY,
|
||||
SHOWN: 'shown' + EVENT_KEY,
|
||||
CLICK: 'click' + EVENT_KEY,
|
||||
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY,
|
||||
KEYDOWN_DATA_API: 'keydown' + EVENT_KEY + DATA_API_KEY
|
||||
};
|
||||
|
||||
var ClassName = {
|
||||
BACKDROP: 'dropdown-backdrop',
|
||||
DISABLED: 'disabled',
|
||||
OPEN: 'open'
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
BACKDROP: '.dropdown-backdrop',
|
||||
DATA_TOGGLE: '[data-toggle="dropdown"]',
|
||||
FORM_CHILD: '.dropdown form',
|
||||
ROLE_MENU: '[role="menu"]',
|
||||
ROLE_LISTBOX: '[role="listbox"]',
|
||||
NAVBAR_NAV: '.navbar-nav',
|
||||
VISIBLE_ITEMS: '[role="menu"] li:not(.disabled) a, ' + '[role="listbox"] li:not(.disabled) a'
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Dropdown = (function () {
|
||||
function Dropdown(element) {
|
||||
_classCallCheck(this, Dropdown);
|
||||
|
||||
this._element = element;
|
||||
|
||||
this._addEventListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Data Api implementation
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// getters
|
||||
|
||||
_createClass(Dropdown, [{
|
||||
key: 'toggle',
|
||||
|
||||
// public
|
||||
|
||||
value: function toggle() {
|
||||
if (this.disabled || $(this).hasClass(ClassName.DISABLED)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var parent = Dropdown._getParentFromElement(this);
|
||||
var isActive = $(parent).hasClass(ClassName.OPEN);
|
||||
|
||||
Dropdown._clearMenus();
|
||||
|
||||
if (isActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('ontouchstart' in document.documentElement && !$(parent).closest(Selector.NAVBAR_NAV).length) {
|
||||
|
||||
// if mobile we use a backdrop because click events don't delegate
|
||||
var dropdown = document.createElement('div');
|
||||
dropdown.className = ClassName.BACKDROP;
|
||||
$(dropdown).insertBefore(this);
|
||||
$(dropdown).on('click', Dropdown._clearMenus);
|
||||
}
|
||||
|
||||
var relatedTarget = { relatedTarget: this };
|
||||
var showEvent = $.Event(Event.SHOW, relatedTarget);
|
||||
|
||||
$(parent).trigger(showEvent);
|
||||
|
||||
if (showEvent.isDefaultPrevented()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.focus();
|
||||
this.setAttribute('aria-expanded', 'true');
|
||||
|
||||
$(parent).toggleClass(ClassName.OPEN);
|
||||
$(parent).trigger($.Event(Event.SHOWN, relatedTarget));
|
||||
|
||||
return false;
|
||||
}
|
||||
}, {
|
||||
key: 'dispose',
|
||||
value: function dispose() {
|
||||
$.removeData(this._element, DATA_KEY);
|
||||
$(this._element).off(EVENT_KEY);
|
||||
this._element = null;
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
}, {
|
||||
key: '_addEventListeners',
|
||||
value: function _addEventListeners() {
|
||||
$(this._element).on(Event.CLICK, this.toggle);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data(DATA_KEY);
|
||||
|
||||
if (!data) {
|
||||
$(this).data(DATA_KEY, data = new Dropdown(this));
|
||||
}
|
||||
|
||||
if (typeof config === 'string') {
|
||||
if (data[config] === undefined) {
|
||||
throw new Error('No method named "' + config + '"');
|
||||
}
|
||||
data[config].call(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: '_clearMenus',
|
||||
value: function _clearMenus(event) {
|
||||
if (event && event.which === 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
var backdrop = $(Selector.BACKDROP)[0];
|
||||
if (backdrop) {
|
||||
backdrop.parentNode.removeChild(backdrop);
|
||||
}
|
||||
|
||||
var toggles = $.makeArray($(Selector.DATA_TOGGLE));
|
||||
|
||||
for (var i = 0; i < toggles.length; i++) {
|
||||
var _parent = Dropdown._getParentFromElement(toggles[i]);
|
||||
var relatedTarget = { relatedTarget: toggles[i] };
|
||||
|
||||
if (!$(_parent).hasClass(ClassName.OPEN)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event && event.type === 'click' && /input|textarea/i.test(event.target.tagName) && $.contains(_parent, event.target)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var hideEvent = $.Event(Event.HIDE, relatedTarget);
|
||||
$(_parent).trigger(hideEvent);
|
||||
if (hideEvent.isDefaultPrevented()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
toggles[i].setAttribute('aria-expanded', 'false');
|
||||
|
||||
$(_parent).removeClass(ClassName.OPEN).trigger($.Event(Event.HIDDEN, relatedTarget));
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_getParentFromElement',
|
||||
value: function _getParentFromElement(element) {
|
||||
var parent = undefined;
|
||||
var selector = _Util['default'].getSelectorFromElement(element);
|
||||
|
||||
if (selector) {
|
||||
parent = $(selector)[0];
|
||||
}
|
||||
|
||||
return parent || element.parentNode;
|
||||
}
|
||||
}, {
|
||||
key: '_dataApiKeydownHandler',
|
||||
value: function _dataApiKeydownHandler(event) {
|
||||
if (!/(38|40|27|32)/.test(event.which) || /input|textarea/i.test(event.target.tagName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (this.disabled || $(this).hasClass(ClassName.DISABLED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var parent = Dropdown._getParentFromElement(this);
|
||||
var isActive = $(parent).hasClass(ClassName.OPEN);
|
||||
|
||||
if (!isActive && event.which !== 27 || isActive && event.which === 27) {
|
||||
|
||||
if (event.which === 27) {
|
||||
var toggle = $(parent).find(Selector.DATA_TOGGLE)[0];
|
||||
$(toggle).trigger('focus');
|
||||
}
|
||||
|
||||
$(this).trigger('click');
|
||||
return;
|
||||
}
|
||||
|
||||
var items = $.makeArray($(Selector.VISIBLE_ITEMS));
|
||||
|
||||
items = items.filter(function (item) {
|
||||
return item.offsetWidth || item.offsetHeight;
|
||||
});
|
||||
|
||||
if (!items.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var index = items.indexOf(event.target);
|
||||
|
||||
if (event.which === 38 && index > 0) {
|
||||
// up
|
||||
index--;
|
||||
}
|
||||
|
||||
if (event.which === 40 && index < items.length - 1) {
|
||||
// down
|
||||
index++;
|
||||
}
|
||||
|
||||
if (! ~index) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
items[index].focus();
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Dropdown;
|
||||
})();
|
||||
|
||||
$(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.ROLE_MENU, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.ROLE_LISTBOX, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, Dropdown.prototype.toggle).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$.fn[NAME] = Dropdown._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Dropdown;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Dropdown._jQueryInterface;
|
||||
};
|
||||
|
||||
return Dropdown;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Dropdown;
|
||||
});
|
@ -1,555 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module', './util'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module, require('./util'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod, global.Util);
|
||||
global.modal = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module, _util) {
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
var _Util = _interopRequireDefault(_util);
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): modal.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Modal = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'modal';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.modal';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var DATA_API_KEY = '.data-api';
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
var TRANSITION_DURATION = 300;
|
||||
var BACKDROP_TRANSITION_DURATION = 150;
|
||||
|
||||
var Default = {
|
||||
backdrop: true,
|
||||
keyboard: true,
|
||||
focus: true,
|
||||
show: true
|
||||
};
|
||||
|
||||
var DefaultType = {
|
||||
backdrop: '(boolean|string)',
|
||||
keyboard: 'boolean',
|
||||
focus: 'boolean',
|
||||
show: 'boolean'
|
||||
};
|
||||
|
||||
var Event = {
|
||||
HIDE: 'hide' + EVENT_KEY,
|
||||
HIDDEN: 'hidden' + EVENT_KEY,
|
||||
SHOW: 'show' + EVENT_KEY,
|
||||
SHOWN: 'shown' + EVENT_KEY,
|
||||
FOCUSIN: 'focusin' + EVENT_KEY,
|
||||
RESIZE: 'resize' + EVENT_KEY,
|
||||
CLICK_DISMISS: 'click.dismiss' + EVENT_KEY,
|
||||
KEYDOWN_DISMISS: 'keydown.dismiss' + EVENT_KEY,
|
||||
MOUSEUP_DISMISS: 'mouseup.dismiss' + EVENT_KEY,
|
||||
MOUSEDOWN_DISMISS: 'mousedown.dismiss' + EVENT_KEY,
|
||||
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
|
||||
};
|
||||
|
||||
var ClassName = {
|
||||
SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
|
||||
BACKDROP: 'modal-backdrop',
|
||||
OPEN: 'modal-open',
|
||||
FADE: 'fade',
|
||||
IN: 'in'
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
DIALOG: '.modal-dialog',
|
||||
DATA_TOGGLE: '[data-toggle="modal"]',
|
||||
DATA_DISMISS: '[data-dismiss="modal"]',
|
||||
FIXED_CONTENT: '.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed'
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Modal = (function () {
|
||||
function Modal(element, config) {
|
||||
_classCallCheck(this, Modal);
|
||||
|
||||
this._config = this._getConfig(config);
|
||||
this._element = element;
|
||||
this._dialog = $(element).find(Selector.DIALOG)[0];
|
||||
this._backdrop = null;
|
||||
this._isShown = false;
|
||||
this._isBodyOverflowing = false;
|
||||
this._ignoreBackdropClick = false;
|
||||
this._originalBodyPadding = 0;
|
||||
this._scrollbarWidth = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Data Api implementation
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// getters
|
||||
|
||||
_createClass(Modal, [{
|
||||
key: 'toggle',
|
||||
|
||||
// public
|
||||
|
||||
value: function toggle(relatedTarget) {
|
||||
return this._isShown ? this.hide() : this.show(relatedTarget);
|
||||
}
|
||||
}, {
|
||||
key: 'show',
|
||||
value: function show(relatedTarget) {
|
||||
var _this = this;
|
||||
|
||||
var showEvent = $.Event(Event.SHOW, {
|
||||
relatedTarget: relatedTarget
|
||||
});
|
||||
|
||||
$(this._element).trigger(showEvent);
|
||||
|
||||
if (this._isShown || showEvent.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._isShown = true;
|
||||
|
||||
this._checkScrollbar();
|
||||
this._setScrollbar();
|
||||
|
||||
$(document.body).addClass(ClassName.OPEN);
|
||||
|
||||
this._setEscapeEvent();
|
||||
this._setResizeEvent();
|
||||
|
||||
$(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, $.proxy(this.hide, this));
|
||||
|
||||
$(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () {
|
||||
$(_this._element).one(Event.MOUSEUP_DISMISS, function (event) {
|
||||
if ($(event.target).is(_this._element)) {
|
||||
_this._ignoreBackdropClick = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this._showBackdrop($.proxy(this._showElement, this, relatedTarget));
|
||||
}
|
||||
}, {
|
||||
key: 'hide',
|
||||
value: function hide(event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
var hideEvent = $.Event(Event.HIDE);
|
||||
|
||||
$(this._element).trigger(hideEvent);
|
||||
|
||||
if (!this._isShown || hideEvent.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._isShown = false;
|
||||
|
||||
this._setEscapeEvent();
|
||||
this._setResizeEvent();
|
||||
|
||||
$(document).off(Event.FOCUSIN);
|
||||
|
||||
$(this._element).removeClass(ClassName.IN);
|
||||
|
||||
$(this._element).off(Event.CLICK_DISMISS);
|
||||
$(this._dialog).off(Event.MOUSEDOWN_DISMISS);
|
||||
|
||||
if (_Util['default'].supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
|
||||
|
||||
$(this._element).one(_Util['default'].TRANSITION_END, $.proxy(this._hideModal, this)).emulateTransitionEnd(TRANSITION_DURATION);
|
||||
} else {
|
||||
this._hideModal();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'dispose',
|
||||
value: function dispose() {
|
||||
$.removeData(this._element, DATA_KEY);
|
||||
|
||||
$(window).off(EVENT_KEY);
|
||||
$(document).off(EVENT_KEY);
|
||||
$(this._element).off(EVENT_KEY);
|
||||
$(this._backdrop).off(EVENT_KEY);
|
||||
|
||||
this._config = null;
|
||||
this._element = null;
|
||||
this._dialog = null;
|
||||
this._backdrop = null;
|
||||
this._isShown = null;
|
||||
this._isBodyOverflowing = null;
|
||||
this._ignoreBackdropClick = null;
|
||||
this._originalBodyPadding = null;
|
||||
this._scrollbarWidth = null;
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
}, {
|
||||
key: '_getConfig',
|
||||
value: function _getConfig(config) {
|
||||
config = $.extend({}, Default, config);
|
||||
_Util['default'].typeCheckConfig(NAME, config, DefaultType);
|
||||
return config;
|
||||
}
|
||||
}, {
|
||||
key: '_showElement',
|
||||
value: function _showElement(relatedTarget) {
|
||||
var _this2 = this;
|
||||
|
||||
var transition = _Util['default'].supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE);
|
||||
|
||||
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
|
||||
// don't move modals dom position
|
||||
document.body.appendChild(this._element);
|
||||
}
|
||||
|
||||
this._element.style.display = 'block';
|
||||
this._element.scrollTop = 0;
|
||||
|
||||
if (transition) {
|
||||
_Util['default'].reflow(this._element);
|
||||
}
|
||||
|
||||
$(this._element).addClass(ClassName.IN);
|
||||
|
||||
if (this._config.focus) {
|
||||
this._enforceFocus();
|
||||
}
|
||||
|
||||
var shownEvent = $.Event(Event.SHOWN, {
|
||||
relatedTarget: relatedTarget
|
||||
});
|
||||
|
||||
var transitionComplete = function transitionComplete() {
|
||||
if (_this2._config.focus) {
|
||||
_this2._element.focus();
|
||||
}
|
||||
$(_this2._element).trigger(shownEvent);
|
||||
};
|
||||
|
||||
if (transition) {
|
||||
$(this._dialog).one(_Util['default'].TRANSITION_END, transitionComplete).emulateTransitionEnd(TRANSITION_DURATION);
|
||||
} else {
|
||||
transitionComplete();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_enforceFocus',
|
||||
value: function _enforceFocus() {
|
||||
var _this3 = this;
|
||||
|
||||
$(document).off(Event.FOCUSIN) // guard against infinite focus loop
|
||||
.on(Event.FOCUSIN, function (event) {
|
||||
if (_this3._element !== event.target && !$(_this3._element).has(event.target).length) {
|
||||
_this3._element.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: '_setEscapeEvent',
|
||||
value: function _setEscapeEvent() {
|
||||
var _this4 = this;
|
||||
|
||||
if (this._isShown && this._config.keyboard) {
|
||||
$(this._element).on(Event.KEYDOWN_DISMISS, function (event) {
|
||||
if (event.which === 27) {
|
||||
_this4.hide();
|
||||
}
|
||||
});
|
||||
} else if (!this._isShown) {
|
||||
$(this._element).off(Event.KEYDOWN_DISMISS);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_setResizeEvent',
|
||||
value: function _setResizeEvent() {
|
||||
if (this._isShown) {
|
||||
$(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this));
|
||||
} else {
|
||||
$(window).off(Event.RESIZE);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_hideModal',
|
||||
value: function _hideModal() {
|
||||
var _this5 = this;
|
||||
|
||||
this._element.style.display = 'none';
|
||||
this._showBackdrop(function () {
|
||||
$(document.body).removeClass(ClassName.OPEN);
|
||||
_this5._resetAdjustments();
|
||||
_this5._resetScrollbar();
|
||||
$(_this5._element).trigger(Event.HIDDEN);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: '_removeBackdrop',
|
||||
value: function _removeBackdrop() {
|
||||
if (this._backdrop) {
|
||||
$(this._backdrop).remove();
|
||||
this._backdrop = null;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_showBackdrop',
|
||||
value: function _showBackdrop(callback) {
|
||||
var _this6 = this;
|
||||
|
||||
var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '';
|
||||
|
||||
if (this._isShown && this._config.backdrop) {
|
||||
var doAnimate = _Util['default'].supportsTransitionEnd() && animate;
|
||||
|
||||
this._backdrop = document.createElement('div');
|
||||
this._backdrop.className = ClassName.BACKDROP;
|
||||
|
||||
if (animate) {
|
||||
$(this._backdrop).addClass(animate);
|
||||
}
|
||||
|
||||
$(this._backdrop).appendTo(document.body);
|
||||
|
||||
$(this._element).on(Event.CLICK_DISMISS, function (event) {
|
||||
if (_this6._ignoreBackdropClick) {
|
||||
_this6._ignoreBackdropClick = false;
|
||||
return;
|
||||
}
|
||||
if (event.target !== event.currentTarget) {
|
||||
return;
|
||||
}
|
||||
if (_this6._config.backdrop === 'static') {
|
||||
_this6._element.focus();
|
||||
} else {
|
||||
_this6.hide();
|
||||
}
|
||||
});
|
||||
|
||||
if (doAnimate) {
|
||||
_Util['default'].reflow(this._backdrop);
|
||||
}
|
||||
|
||||
$(this._backdrop).addClass(ClassName.IN);
|
||||
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!doAnimate) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$(this._backdrop).one(_Util['default'].TRANSITION_END, callback).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION);
|
||||
} else if (!this._isShown && this._backdrop) {
|
||||
$(this._backdrop).removeClass(ClassName.IN);
|
||||
|
||||
var callbackRemove = function callbackRemove() {
|
||||
_this6._removeBackdrop();
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
if (_Util['default'].supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
|
||||
$(this._backdrop).one(_Util['default'].TRANSITION_END, callbackRemove).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION);
|
||||
} else {
|
||||
callbackRemove();
|
||||
}
|
||||
} else if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// the following methods are used to handle overflowing modals
|
||||
// todo (fat): these should probably be refactored out of modal.js
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
}, {
|
||||
key: '_handleUpdate',
|
||||
value: function _handleUpdate() {
|
||||
this._adjustDialog();
|
||||
}
|
||||
}, {
|
||||
key: '_adjustDialog',
|
||||
value: function _adjustDialog() {
|
||||
var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
|
||||
|
||||
if (!this._isBodyOverflowing && isModalOverflowing) {
|
||||
this._element.style.paddingLeft = this._scrollbarWidth + 'px';
|
||||
}
|
||||
|
||||
if (this._isBodyOverflowing && !isModalOverflowing) {
|
||||
this._element.style.paddingRight = this._scrollbarWidth + 'px~';
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_resetAdjustments',
|
||||
value: function _resetAdjustments() {
|
||||
this._element.style.paddingLeft = '';
|
||||
this._element.style.paddingRight = '';
|
||||
}
|
||||
}, {
|
||||
key: '_checkScrollbar',
|
||||
value: function _checkScrollbar() {
|
||||
var fullWindowWidth = window.innerWidth;
|
||||
if (!fullWindowWidth) {
|
||||
// workaround for missing window.innerWidth in IE8
|
||||
var documentElementRect = document.documentElement.getBoundingClientRect();
|
||||
fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left);
|
||||
}
|
||||
this._isBodyOverflowing = document.body.clientWidth < fullWindowWidth;
|
||||
this._scrollbarWidth = this._getScrollbarWidth();
|
||||
}
|
||||
}, {
|
||||
key: '_setScrollbar',
|
||||
value: function _setScrollbar() {
|
||||
var bodyPadding = parseInt($(Selector.FIXED_CONTENT).css('padding-right') || 0, 10);
|
||||
|
||||
this._originalBodyPadding = document.body.style.paddingRight || '';
|
||||
|
||||
if (this._isBodyOverflowing) {
|
||||
document.body.style.paddingRight = bodyPadding + this._scrollbarWidth + 'px';
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_resetScrollbar',
|
||||
value: function _resetScrollbar() {
|
||||
document.body.style.paddingRight = this._originalBodyPadding;
|
||||
}
|
||||
}, {
|
||||
key: '_getScrollbarWidth',
|
||||
value: function _getScrollbarWidth() {
|
||||
// thx d.walsh
|
||||
var scrollDiv = document.createElement('div');
|
||||
scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
|
||||
document.body.appendChild(scrollDiv);
|
||||
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||
document.body.removeChild(scrollDiv);
|
||||
return scrollbarWidth;
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config, relatedTarget) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data(DATA_KEY);
|
||||
var _config = $.extend({}, Modal.Default, $(this).data(), typeof config === 'object' && config);
|
||||
|
||||
if (!data) {
|
||||
data = new Modal(this, _config);
|
||||
$(this).data(DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (typeof config === 'string') {
|
||||
if (data[config] === undefined) {
|
||||
throw new Error('No method named "' + config + '"');
|
||||
}
|
||||
data[config](relatedTarget);
|
||||
} else if (_config.show) {
|
||||
data.show(relatedTarget);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}, {
|
||||
key: 'Default',
|
||||
get: function get() {
|
||||
return Default;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Modal;
|
||||
})();
|
||||
|
||||
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
|
||||
var _this7 = this;
|
||||
|
||||
var target = undefined;
|
||||
var selector = _Util['default'].getSelectorFromElement(this);
|
||||
|
||||
if (selector) {
|
||||
target = $(selector)[0];
|
||||
}
|
||||
|
||||
var config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data());
|
||||
|
||||
if (this.tagName === 'A') {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
var $target = $(target).one(Event.SHOW, function (showEvent) {
|
||||
if (showEvent.isDefaultPrevented()) {
|
||||
// only register focus restorer if modal will actually get shown
|
||||
return;
|
||||
}
|
||||
|
||||
$target.one(Event.HIDDEN, function () {
|
||||
if ($(_this7).is(':visible')) {
|
||||
_this7.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Modal._jQueryInterface.call($(target), config, this);
|
||||
});
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$.fn[NAME] = Modal._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Modal;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Modal._jQueryInterface;
|
||||
};
|
||||
|
||||
return Modal;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Modal;
|
||||
});
|
@ -1,220 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module', './tooltip'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module, require('./tooltip'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod, global.Tooltip);
|
||||
global.popover = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module, _tooltip) {
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var _Tooltip2 = _interopRequireDefault(_tooltip);
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): popover.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Popover = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'popover';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.popover';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
|
||||
var Default = $.extend({}, _Tooltip2['default'].Default, {
|
||||
placement: 'right',
|
||||
trigger: 'click',
|
||||
content: '',
|
||||
template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-title"></h3>' + '<div class="popover-content"></div></div>'
|
||||
});
|
||||
|
||||
var DefaultType = $.extend({}, _Tooltip2['default'].DefaultType, {
|
||||
content: '(string|element|function)'
|
||||
});
|
||||
|
||||
var ClassName = {
|
||||
FADE: 'fade',
|
||||
IN: 'in'
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
TITLE: '.popover-title',
|
||||
CONTENT: '.popover-content',
|
||||
ARROW: '.popover-arrow'
|
||||
};
|
||||
|
||||
var Event = {
|
||||
HIDE: 'hide' + EVENT_KEY,
|
||||
HIDDEN: 'hidden' + EVENT_KEY,
|
||||
SHOW: 'show' + EVENT_KEY,
|
||||
SHOWN: 'shown' + EVENT_KEY,
|
||||
INSERTED: 'inserted' + EVENT_KEY,
|
||||
CLICK: 'click' + EVENT_KEY,
|
||||
FOCUSIN: 'focusin' + EVENT_KEY,
|
||||
FOCUSOUT: 'focusout' + EVENT_KEY,
|
||||
MOUSEENTER: 'mouseenter' + EVENT_KEY,
|
||||
MOUSELEAVE: 'mouseleave' + EVENT_KEY
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Popover = (function (_Tooltip) {
|
||||
_inherits(Popover, _Tooltip);
|
||||
|
||||
function Popover() {
|
||||
_classCallCheck(this, Popover);
|
||||
|
||||
_get(Object.getPrototypeOf(Popover.prototype), 'constructor', this).apply(this, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
_createClass(Popover, [{
|
||||
key: 'isWithContent',
|
||||
|
||||
// overrides
|
||||
|
||||
value: function isWithContent() {
|
||||
return this.getTitle() || this._getContent();
|
||||
}
|
||||
}, {
|
||||
key: 'getTipElement',
|
||||
value: function getTipElement() {
|
||||
return this.tip = this.tip || $(this.config.template)[0];
|
||||
}
|
||||
}, {
|
||||
key: 'setContent',
|
||||
value: function setContent() {
|
||||
var $tip = $(this.getTipElement());
|
||||
|
||||
// we use append for html objects to maintain js events
|
||||
this.setElementContent($tip.find(Selector.TITLE), this.getTitle());
|
||||
this.setElementContent($tip.find(Selector.CONTENT), this._getContent());
|
||||
|
||||
$tip.removeClass(ClassName.FADE).removeClass(ClassName.IN);
|
||||
|
||||
this.cleanupTether();
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
}, {
|
||||
key: '_getContent',
|
||||
value: function _getContent() {
|
||||
return this.element.getAttribute('data-content') || (typeof this.config.content === 'function' ? this.config.content.call(this.element) : this.config.content);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data(DATA_KEY);
|
||||
var _config = typeof config === 'object' ? config : null;
|
||||
|
||||
if (!data && /destroy|hide/.test(config)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
data = new Popover(this, _config);
|
||||
$(this).data(DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (typeof config === 'string') {
|
||||
if (data[config] === undefined) {
|
||||
throw new Error('No method named "' + config + '"');
|
||||
}
|
||||
data[config]();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
|
||||
// getters
|
||||
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}, {
|
||||
key: 'Default',
|
||||
get: function get() {
|
||||
return Default;
|
||||
}
|
||||
}, {
|
||||
key: 'NAME',
|
||||
get: function get() {
|
||||
return NAME;
|
||||
}
|
||||
}, {
|
||||
key: 'DATA_KEY',
|
||||
get: function get() {
|
||||
return DATA_KEY;
|
||||
}
|
||||
}, {
|
||||
key: 'Event',
|
||||
get: function get() {
|
||||
return Event;
|
||||
}
|
||||
}, {
|
||||
key: 'EVENT_KEY',
|
||||
get: function get() {
|
||||
return EVENT_KEY;
|
||||
}
|
||||
}, {
|
||||
key: 'DefaultType',
|
||||
get: function get() {
|
||||
return DefaultType;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Popover;
|
||||
})(_Tooltip2['default']);
|
||||
|
||||
$.fn[NAME] = Popover._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Popover;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Popover._jQueryInterface;
|
||||
};
|
||||
|
||||
return Popover;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Popover;
|
||||
});
|
@ -1,339 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module', './util'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module, require('./util'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod, global.Util);
|
||||
global.scrollspy = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module, _util) {
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
var _Util = _interopRequireDefault(_util);
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): scrollspy.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var ScrollSpy = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'scrollspy';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.scrollspy';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var DATA_API_KEY = '.data-api';
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
|
||||
var Default = {
|
||||
offset: 10,
|
||||
method: 'auto',
|
||||
target: ''
|
||||
};
|
||||
|
||||
var DefaultType = {
|
||||
offset: 'number',
|
||||
method: 'string',
|
||||
target: '(string|element)'
|
||||
};
|
||||
|
||||
var Event = {
|
||||
ACTIVATE: 'activate' + EVENT_KEY,
|
||||
SCROLL: 'scroll' + EVENT_KEY,
|
||||
LOAD_DATA_API: 'load' + EVENT_KEY + DATA_API_KEY
|
||||
};
|
||||
|
||||
var ClassName = {
|
||||
DROPDOWN_ITEM: 'dropdown-item',
|
||||
DROPDOWN_MENU: 'dropdown-menu',
|
||||
NAV_LINK: 'nav-link',
|
||||
NAV: 'nav',
|
||||
ACTIVE: 'active'
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
DATA_SPY: '[data-spy="scroll"]',
|
||||
ACTIVE: '.active',
|
||||
LIST_ITEM: '.list-item',
|
||||
LI: 'li',
|
||||
LI_DROPDOWN: 'li.dropdown',
|
||||
NAV_LINKS: '.nav-link',
|
||||
DROPDOWN: '.dropdown',
|
||||
DROPDOWN_ITEMS: '.dropdown-item',
|
||||
DROPDOWN_TOGGLE: '.dropdown-toggle'
|
||||
};
|
||||
|
||||
var OffsetMethod = {
|
||||
OFFSET: 'offset',
|
||||
POSITION: 'position'
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var ScrollSpy = (function () {
|
||||
function ScrollSpy(element, config) {
|
||||
_classCallCheck(this, ScrollSpy);
|
||||
|
||||
this._element = element;
|
||||
this._scrollElement = element.tagName === 'BODY' ? window : element;
|
||||
this._config = this._getConfig(config);
|
||||
this._selector = this._config.target + ' ' + Selector.NAV_LINKS + ',' + (this._config.target + ' ' + Selector.DROPDOWN_ITEMS);
|
||||
this._offsets = [];
|
||||
this._targets = [];
|
||||
this._activeTarget = null;
|
||||
this._scrollHeight = 0;
|
||||
|
||||
$(this._scrollElement).on(Event.SCROLL, $.proxy(this._process, this));
|
||||
|
||||
this.refresh();
|
||||
this._process();
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Data Api implementation
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// getters
|
||||
|
||||
_createClass(ScrollSpy, [{
|
||||
key: 'refresh',
|
||||
|
||||
// public
|
||||
|
||||
value: function refresh() {
|
||||
var _this = this;
|
||||
|
||||
var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET;
|
||||
|
||||
var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
|
||||
|
||||
var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
|
||||
|
||||
this._offsets = [];
|
||||
this._targets = [];
|
||||
|
||||
this._scrollHeight = this._getScrollHeight();
|
||||
|
||||
var targets = $.makeArray($(this._selector));
|
||||
|
||||
targets.map(function (element) {
|
||||
var target = undefined;
|
||||
var targetSelector = _Util['default'].getSelectorFromElement(element);
|
||||
|
||||
if (targetSelector) {
|
||||
target = $(targetSelector)[0];
|
||||
}
|
||||
|
||||
if (target && (target.offsetWidth || target.offsetHeight)) {
|
||||
// todo (fat): remove sketch reliance on jQuery position/offset
|
||||
return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
|
||||
}
|
||||
}).filter(function (item) {
|
||||
return item;
|
||||
}).sort(function (a, b) {
|
||||
return a[0] - b[0];
|
||||
}).forEach(function (item) {
|
||||
_this._offsets.push(item[0]);
|
||||
_this._targets.push(item[1]);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'dispose',
|
||||
value: function dispose() {
|
||||
$.removeData(this._element, DATA_KEY);
|
||||
$(this._scrollElement).off(EVENT_KEY);
|
||||
|
||||
this._element = null;
|
||||
this._scrollElement = null;
|
||||
this._config = null;
|
||||
this._selector = null;
|
||||
this._offsets = null;
|
||||
this._targets = null;
|
||||
this._activeTarget = null;
|
||||
this._scrollHeight = null;
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
}, {
|
||||
key: '_getConfig',
|
||||
value: function _getConfig(config) {
|
||||
config = $.extend({}, Default, config);
|
||||
|
||||
if (typeof config.target !== 'string') {
|
||||
var id = $(config.target).attr('id');
|
||||
if (!id) {
|
||||
id = _Util['default'].getUID(NAME);
|
||||
$(config.target).attr('id', id);
|
||||
}
|
||||
config.target = '#' + id;
|
||||
}
|
||||
|
||||
_Util['default'].typeCheckConfig(NAME, config, DefaultType);
|
||||
|
||||
return config;
|
||||
}
|
||||
}, {
|
||||
key: '_getScrollTop',
|
||||
value: function _getScrollTop() {
|
||||
return this._scrollElement === window ? this._scrollElement.scrollY : this._scrollElement.scrollTop;
|
||||
}
|
||||
}, {
|
||||
key: '_getScrollHeight',
|
||||
value: function _getScrollHeight() {
|
||||
return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
||||
}
|
||||
}, {
|
||||
key: '_process',
|
||||
value: function _process() {
|
||||
var scrollTop = this._getScrollTop() + this._config.offset;
|
||||
var scrollHeight = this._getScrollHeight();
|
||||
var maxScroll = this._config.offset + scrollHeight - this._scrollElement.offsetHeight;
|
||||
|
||||
if (this._scrollHeight !== scrollHeight) {
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
if (scrollTop >= maxScroll) {
|
||||
var target = this._targets[this._targets.length - 1];
|
||||
|
||||
if (this._activeTarget !== target) {
|
||||
this._activate(target);
|
||||
}
|
||||
}
|
||||
|
||||
if (this._activeTarget && scrollTop < this._offsets[0]) {
|
||||
this._activeTarget = null;
|
||||
this._clear();
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = this._offsets.length; i--;) {
|
||||
var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (this._offsets[i + 1] === undefined || scrollTop < this._offsets[i + 1]);
|
||||
|
||||
if (isActiveTarget) {
|
||||
this._activate(this._targets[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_activate',
|
||||
value: function _activate(target) {
|
||||
this._activeTarget = target;
|
||||
|
||||
this._clear();
|
||||
|
||||
var queries = this._selector.split(',');
|
||||
queries = queries.map(function (selector) {
|
||||
return selector + '[data-target="' + target + '"],' + (selector + '[href="' + target + '"]');
|
||||
});
|
||||
|
||||
var $link = $(queries.join(','));
|
||||
|
||||
if ($link.hasClass(ClassName.DROPDOWN_ITEM)) {
|
||||
$link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
|
||||
$link.addClass(ClassName.ACTIVE);
|
||||
} else {
|
||||
// todo (fat) this is kinda sus…
|
||||
// recursively add actives to tested nav-links
|
||||
$link.parents(Selector.LI).find(Selector.NAV_LINKS).addClass(ClassName.ACTIVE);
|
||||
}
|
||||
|
||||
$(this._scrollElement).trigger(Event.ACTIVATE, {
|
||||
relatedTarget: target
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: '_clear',
|
||||
value: function _clear() {
|
||||
$(this._selector).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data(DATA_KEY);
|
||||
var _config = typeof config === 'object' && config || null;
|
||||
|
||||
if (!data) {
|
||||
data = new ScrollSpy(this, _config);
|
||||
$(this).data(DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (typeof config === 'string') {
|
||||
if (data[config] === undefined) {
|
||||
throw new Error('No method named "' + config + '"');
|
||||
}
|
||||
data[config]();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}, {
|
||||
key: 'Default',
|
||||
get: function get() {
|
||||
return Default;
|
||||
}
|
||||
}]);
|
||||
|
||||
return ScrollSpy;
|
||||
})();
|
||||
|
||||
$(window).on(Event.LOAD_DATA_API, function () {
|
||||
var scrollSpys = $.makeArray($(Selector.DATA_SPY));
|
||||
|
||||
for (var i = scrollSpys.length; i--;) {
|
||||
var $spy = $(scrollSpys[i]);
|
||||
ScrollSpy._jQueryInterface.call($spy, $spy.data());
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$.fn[NAME] = ScrollSpy._jQueryInterface;
|
||||
$.fn[NAME].Constructor = ScrollSpy;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return ScrollSpy._jQueryInterface;
|
||||
};
|
||||
|
||||
return ScrollSpy;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = ScrollSpy;
|
||||
});
|
@ -1,282 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module', './util'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module, require('./util'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod, global.Util);
|
||||
global.tab = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module, _util) {
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
var _Util = _interopRequireDefault(_util);
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): tab.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Tab = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'tab';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.tab';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var DATA_API_KEY = '.data-api';
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
var TRANSITION_DURATION = 150;
|
||||
|
||||
var Event = {
|
||||
HIDE: 'hide' + EVENT_KEY,
|
||||
HIDDEN: 'hidden' + EVENT_KEY,
|
||||
SHOW: 'show' + EVENT_KEY,
|
||||
SHOWN: 'shown' + EVENT_KEY,
|
||||
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
|
||||
};
|
||||
|
||||
var ClassName = {
|
||||
DROPDOWN_MENU: 'dropdown-menu',
|
||||
ACTIVE: 'active',
|
||||
FADE: 'fade',
|
||||
IN: 'in'
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
A: 'a',
|
||||
LI: 'li',
|
||||
DROPDOWN: '.dropdown',
|
||||
UL: 'ul:not(.dropdown-menu)',
|
||||
FADE_CHILD: '> .nav-item .fade, > .fade',
|
||||
ACTIVE: '.active',
|
||||
ACTIVE_CHILD: '> .nav-item > .active, > .active',
|
||||
DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"]',
|
||||
DROPDOWN_TOGGLE: '.dropdown-toggle',
|
||||
DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Tab = (function () {
|
||||
function Tab(element) {
|
||||
_classCallCheck(this, Tab);
|
||||
|
||||
this._element = element;
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Data Api implementation
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// getters
|
||||
|
||||
_createClass(Tab, [{
|
||||
key: 'show',
|
||||
|
||||
// public
|
||||
|
||||
value: function show() {
|
||||
var _this = this;
|
||||
|
||||
if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var target = undefined;
|
||||
var previous = undefined;
|
||||
var ulElement = $(this._element).closest(Selector.UL)[0];
|
||||
var selector = _Util['default'].getSelectorFromElement(this._element);
|
||||
|
||||
if (ulElement) {
|
||||
previous = $.makeArray($(ulElement).find(Selector.ACTIVE));
|
||||
previous = previous[previous.length - 1];
|
||||
}
|
||||
|
||||
var hideEvent = $.Event(Event.HIDE, {
|
||||
relatedTarget: this._element
|
||||
});
|
||||
|
||||
var showEvent = $.Event(Event.SHOW, {
|
||||
relatedTarget: previous
|
||||
});
|
||||
|
||||
if (previous) {
|
||||
$(previous).trigger(hideEvent);
|
||||
}
|
||||
|
||||
$(this._element).trigger(showEvent);
|
||||
|
||||
if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selector) {
|
||||
target = $(selector)[0];
|
||||
}
|
||||
|
||||
this._activate(this._element, ulElement);
|
||||
|
||||
var complete = function complete() {
|
||||
var hiddenEvent = $.Event(Event.HIDDEN, {
|
||||
relatedTarget: _this._element
|
||||
});
|
||||
|
||||
var shownEvent = $.Event(Event.SHOWN, {
|
||||
relatedTarget: previous
|
||||
});
|
||||
|
||||
$(previous).trigger(hiddenEvent);
|
||||
$(_this._element).trigger(shownEvent);
|
||||
};
|
||||
|
||||
if (target) {
|
||||
this._activate(target, target.parentNode, complete);
|
||||
} else {
|
||||
complete();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'dispose',
|
||||
value: function dispose() {
|
||||
$.removeClass(this._element, DATA_KEY);
|
||||
this._element = null;
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
}, {
|
||||
key: '_activate',
|
||||
value: function _activate(element, container, callback) {
|
||||
var active = $(container).find(Selector.ACTIVE_CHILD)[0];
|
||||
var isTransitioning = callback && _Util['default'].supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE) || Boolean($(container).find(Selector.FADE_CHILD)[0]));
|
||||
|
||||
var complete = $.proxy(this._transitionComplete, this, element, active, isTransitioning, callback);
|
||||
|
||||
if (active && isTransitioning) {
|
||||
$(active).one(_Util['default'].TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
|
||||
} else {
|
||||
complete();
|
||||
}
|
||||
|
||||
if (active) {
|
||||
$(active).removeClass(ClassName.IN);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_transitionComplete',
|
||||
value: function _transitionComplete(element, active, isTransitioning, callback) {
|
||||
if (active) {
|
||||
$(active).removeClass(ClassName.ACTIVE);
|
||||
|
||||
var dropdownChild = $(active).find(Selector.DROPDOWN_ACTIVE_CHILD)[0];
|
||||
|
||||
if (dropdownChild) {
|
||||
$(dropdownChild).removeClass(ClassName.ACTIVE);
|
||||
}
|
||||
|
||||
active.setAttribute('aria-expanded', false);
|
||||
}
|
||||
|
||||
$(element).addClass(ClassName.ACTIVE);
|
||||
element.setAttribute('aria-expanded', true);
|
||||
|
||||
if (isTransitioning) {
|
||||
_Util['default'].reflow(element);
|
||||
$(element).addClass(ClassName.IN);
|
||||
} else {
|
||||
$(element).removeClass(ClassName.FADE);
|
||||
}
|
||||
|
||||
if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) {
|
||||
|
||||
var dropdownElement = $(element).closest(Selector.DROPDOWN)[0];
|
||||
if (dropdownElement) {
|
||||
$(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
|
||||
}
|
||||
|
||||
element.setAttribute('aria-expanded', true);
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var $this = $(this);
|
||||
var data = $this.data(DATA_KEY);
|
||||
|
||||
if (!data) {
|
||||
data = data = new Tab(this);
|
||||
$this.data(DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (typeof config === 'string') {
|
||||
if (data[config] === undefined) {
|
||||
throw new Error('No method named "' + config + '"');
|
||||
}
|
||||
data[config]();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Tab;
|
||||
})();
|
||||
|
||||
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
|
||||
event.preventDefault();
|
||||
Tab._jQueryInterface.call($(this), 'show');
|
||||
});
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$.fn[NAME] = Tab._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Tab;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Tab._jQueryInterface;
|
||||
};
|
||||
|
||||
return Tab;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Tab;
|
||||
});
|
@ -1,638 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module', './util'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module, require('./util'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod, global.Util);
|
||||
global.tooltip = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module, _util) {
|
||||
/* global Tether */
|
||||
|
||||
'use strict';
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||||
|
||||
var _Util = _interopRequireDefault(_util);
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): tooltip.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Tooltip = (function ($) {
|
||||
|
||||
/**
|
||||
* Check for Tether dependency
|
||||
* Tether - http://github.hubspot.com/tether/
|
||||
*/
|
||||
if (window.Tether === undefined) {
|
||||
throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)');
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var NAME = 'tooltip';
|
||||
var VERSION = '4.0.0-alpha';
|
||||
var DATA_KEY = 'bs.tooltip';
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
var TRANSITION_DURATION = 150;
|
||||
var CLASS_PREFIX = 'bs-tether';
|
||||
|
||||
var Default = {
|
||||
animation: true,
|
||||
template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div></div>',
|
||||
trigger: 'hover focus',
|
||||
title: '',
|
||||
delay: 0,
|
||||
html: false,
|
||||
selector: false,
|
||||
placement: 'top',
|
||||
offset: '0 0',
|
||||
constraints: []
|
||||
};
|
||||
|
||||
var DefaultType = {
|
||||
animation: 'boolean',
|
||||
template: 'string',
|
||||
title: '(string|element|function)',
|
||||
trigger: 'string',
|
||||
delay: '(number|object)',
|
||||
html: 'boolean',
|
||||
selector: '(string|boolean)',
|
||||
placement: '(string|function)',
|
||||
offset: 'string',
|
||||
constraints: 'array'
|
||||
};
|
||||
|
||||
var AttachmentMap = {
|
||||
TOP: 'bottom center',
|
||||
RIGHT: 'middle left',
|
||||
BOTTOM: 'top center',
|
||||
LEFT: 'middle right'
|
||||
};
|
||||
|
||||
var HoverState = {
|
||||
IN: 'in',
|
||||
OUT: 'out'
|
||||
};
|
||||
|
||||
var Event = {
|
||||
HIDE: 'hide' + EVENT_KEY,
|
||||
HIDDEN: 'hidden' + EVENT_KEY,
|
||||
SHOW: 'show' + EVENT_KEY,
|
||||
SHOWN: 'shown' + EVENT_KEY,
|
||||
INSERTED: 'inserted' + EVENT_KEY,
|
||||
CLICK: 'click' + EVENT_KEY,
|
||||
FOCUSIN: 'focusin' + EVENT_KEY,
|
||||
FOCUSOUT: 'focusout' + EVENT_KEY,
|
||||
MOUSEENTER: 'mouseenter' + EVENT_KEY,
|
||||
MOUSELEAVE: 'mouseleave' + EVENT_KEY
|
||||
};
|
||||
|
||||
var ClassName = {
|
||||
FADE: 'fade',
|
||||
IN: 'in'
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
TOOLTIP: '.tooltip',
|
||||
TOOLTIP_INNER: '.tooltip-inner'
|
||||
};
|
||||
|
||||
var TetherClass = {
|
||||
element: false,
|
||||
enabled: false
|
||||
};
|
||||
|
||||
var Trigger = {
|
||||
HOVER: 'hover',
|
||||
FOCUS: 'focus',
|
||||
CLICK: 'click',
|
||||
MANUAL: 'manual'
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Tooltip = (function () {
|
||||
function Tooltip(element, config) {
|
||||
_classCallCheck(this, Tooltip);
|
||||
|
||||
// private
|
||||
this._isEnabled = true;
|
||||
this._timeout = 0;
|
||||
this._hoverState = '';
|
||||
this._activeTrigger = {};
|
||||
this._tether = null;
|
||||
|
||||
// protected
|
||||
this.element = element;
|
||||
this.config = this._getConfig(config);
|
||||
this.tip = null;
|
||||
|
||||
this._setListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* jQuery
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// getters
|
||||
|
||||
_createClass(Tooltip, [{
|
||||
key: 'enable',
|
||||
|
||||
// public
|
||||
|
||||
value: function enable() {
|
||||
this._isEnabled = true;
|
||||
}
|
||||
}, {
|
||||
key: 'disable',
|
||||
value: function disable() {
|
||||
this._isEnabled = false;
|
||||
}
|
||||
}, {
|
||||
key: 'toggleEnabled',
|
||||
value: function toggleEnabled() {
|
||||
this._isEnabled = !this._isEnabled;
|
||||
}
|
||||
}, {
|
||||
key: 'toggle',
|
||||
value: function toggle(event) {
|
||||
if (event) {
|
||||
var dataKey = this.constructor.DATA_KEY;
|
||||
var context = $(event.currentTarget).data(dataKey);
|
||||
|
||||
if (!context) {
|
||||
context = new this.constructor(event.currentTarget, this._getDelegateConfig());
|
||||
$(event.currentTarget).data(dataKey, context);
|
||||
}
|
||||
|
||||
context._activeTrigger.click = !context._activeTrigger.click;
|
||||
|
||||
if (context._isWithActiveTrigger()) {
|
||||
context._enter(null, context);
|
||||
} else {
|
||||
context._leave(null, context);
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($(this.getTipElement()).hasClass(ClassName.IN)) {
|
||||
this._leave(null, this);
|
||||
return;
|
||||
}
|
||||
|
||||
this._enter(null, this);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'dispose',
|
||||
value: function dispose() {
|
||||
clearTimeout(this._timeout);
|
||||
|
||||
this.cleanupTether();
|
||||
|
||||
$.removeData(this.element, this.constructor.DATA_KEY);
|
||||
|
||||
$(this.element).off(this.constructor.EVENT_KEY);
|
||||
|
||||
if (this.tip) {
|
||||
$(this.tip).remove();
|
||||
}
|
||||
|
||||
this._isEnabled = null;
|
||||
this._timeout = null;
|
||||
this._hoverState = null;
|
||||
this._activeTrigger = null;
|
||||
this._tether = null;
|
||||
|
||||
this.element = null;
|
||||
this.config = null;
|
||||
this.tip = null;
|
||||
}
|
||||
}, {
|
||||
key: 'show',
|
||||
value: function show() {
|
||||
var _this = this;
|
||||
|
||||
var showEvent = $.Event(this.constructor.Event.SHOW);
|
||||
|
||||
if (this.isWithContent() && this._isEnabled) {
|
||||
$(this.element).trigger(showEvent);
|
||||
|
||||
var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);
|
||||
|
||||
if (showEvent.isDefaultPrevented() || !isInTheDom) {
|
||||
return;
|
||||
}
|
||||
|
||||
var tip = this.getTipElement();
|
||||
var tipId = _Util['default'].getUID(this.constructor.NAME);
|
||||
|
||||
tip.setAttribute('id', tipId);
|
||||
this.element.setAttribute('aria-describedby', tipId);
|
||||
|
||||
this.setContent();
|
||||
|
||||
if (this.config.animation) {
|
||||
$(tip).addClass(ClassName.FADE);
|
||||
}
|
||||
|
||||
var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
|
||||
|
||||
var attachment = this._getAttachment(placement);
|
||||
|
||||
$(tip).data(this.constructor.DATA_KEY, this).appendTo(document.body);
|
||||
|
||||
$(this.element).trigger(this.constructor.Event.INSERTED);
|
||||
|
||||
this._tether = new Tether({
|
||||
attachment: attachment,
|
||||
element: tip,
|
||||
target: this.element,
|
||||
classes: TetherClass,
|
||||
classPrefix: CLASS_PREFIX,
|
||||
offset: this.config.offset,
|
||||
constraints: this.config.constraints,
|
||||
addTargetClasses: false
|
||||
});
|
||||
|
||||
_Util['default'].reflow(tip);
|
||||
this._tether.position();
|
||||
|
||||
$(tip).addClass(ClassName.IN);
|
||||
|
||||
var complete = function complete() {
|
||||
var prevHoverState = _this._hoverState;
|
||||
_this._hoverState = null;
|
||||
|
||||
$(_this.element).trigger(_this.constructor.Event.SHOWN);
|
||||
|
||||
if (prevHoverState === HoverState.OUT) {
|
||||
_this._leave(null, _this);
|
||||
}
|
||||
};
|
||||
|
||||
if (_Util['default'].supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
|
||||
$(this.tip).one(_Util['default'].TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION);
|
||||
return;
|
||||
}
|
||||
|
||||
complete();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'hide',
|
||||
value: function hide(callback) {
|
||||
var _this2 = this;
|
||||
|
||||
var tip = this.getTipElement();
|
||||
var hideEvent = $.Event(this.constructor.Event.HIDE);
|
||||
var complete = function complete() {
|
||||
if (_this2._hoverState !== HoverState.IN && tip.parentNode) {
|
||||
tip.parentNode.removeChild(tip);
|
||||
}
|
||||
|
||||
_this2.element.removeAttribute('aria-describedby');
|
||||
$(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
|
||||
_this2.cleanupTether();
|
||||
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
$(this.element).trigger(hideEvent);
|
||||
|
||||
if (hideEvent.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(tip).removeClass(ClassName.IN);
|
||||
|
||||
if (_Util['default'].supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
|
||||
|
||||
$(tip).one(_Util['default'].TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
|
||||
} else {
|
||||
complete();
|
||||
}
|
||||
|
||||
this._hoverState = '';
|
||||
}
|
||||
|
||||
// protected
|
||||
|
||||
}, {
|
||||
key: 'isWithContent',
|
||||
value: function isWithContent() {
|
||||
return Boolean(this.getTitle());
|
||||
}
|
||||
}, {
|
||||
key: 'getTipElement',
|
||||
value: function getTipElement() {
|
||||
return this.tip = this.tip || $(this.config.template)[0];
|
||||
}
|
||||
}, {
|
||||
key: 'setContent',
|
||||
value: function setContent() {
|
||||
var $tip = $(this.getTipElement());
|
||||
|
||||
this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle());
|
||||
|
||||
$tip.removeClass(ClassName.FADE).removeClass(ClassName.IN);
|
||||
|
||||
this.cleanupTether();
|
||||
}
|
||||
}, {
|
||||
key: 'setElementContent',
|
||||
value: function setElementContent($element, content) {
|
||||
var html = this.config.html;
|
||||
if (typeof content === 'object' && (content.nodeType || content.jquery)) {
|
||||
// content is a DOM node or a jQuery
|
||||
if (html) {
|
||||
if (!$(content).parent().is($element)) {
|
||||
$element.empty().append(content);
|
||||
}
|
||||
} else {
|
||||
$element.text($(content).text());
|
||||
}
|
||||
} else {
|
||||
$element[html ? 'html' : 'text'](content);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'getTitle',
|
||||
value: function getTitle() {
|
||||
var title = this.element.getAttribute('data-original-title');
|
||||
|
||||
if (!title) {
|
||||
title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
}, {
|
||||
key: 'cleanupTether',
|
||||
value: function cleanupTether() {
|
||||
if (this._tether) {
|
||||
this._tether.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
}, {
|
||||
key: '_getAttachment',
|
||||
value: function _getAttachment(placement) {
|
||||
return AttachmentMap[placement.toUpperCase()];
|
||||
}
|
||||
}, {
|
||||
key: '_setListeners',
|
||||
value: function _setListeners() {
|
||||
var _this3 = this;
|
||||
|
||||
var triggers = this.config.trigger.split(' ');
|
||||
|
||||
triggers.forEach(function (trigger) {
|
||||
if (trigger === 'click') {
|
||||
$(_this3.element).on(_this3.constructor.Event.CLICK, _this3.config.selector, $.proxy(_this3.toggle, _this3));
|
||||
} else if (trigger !== Trigger.MANUAL) {
|
||||
var eventIn = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSEENTER : _this3.constructor.Event.FOCUSIN;
|
||||
var eventOut = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSELEAVE : _this3.constructor.Event.FOCUSOUT;
|
||||
|
||||
$(_this3.element).on(eventIn, _this3.config.selector, $.proxy(_this3._enter, _this3)).on(eventOut, _this3.config.selector, $.proxy(_this3._leave, _this3));
|
||||
}
|
||||
});
|
||||
|
||||
if (this.config.selector) {
|
||||
this.config = $.extend({}, this.config, {
|
||||
trigger: 'manual',
|
||||
selector: ''
|
||||
});
|
||||
} else {
|
||||
this._fixTitle();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_fixTitle',
|
||||
value: function _fixTitle() {
|
||||
var titleType = typeof this.element.getAttribute('data-original-title');
|
||||
if (this.element.getAttribute('title') || titleType !== 'string') {
|
||||
this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
|
||||
this.element.setAttribute('title', '');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_enter',
|
||||
value: function _enter(event, context) {
|
||||
var dataKey = this.constructor.DATA_KEY;
|
||||
|
||||
context = context || $(event.currentTarget).data(dataKey);
|
||||
|
||||
if (!context) {
|
||||
context = new this.constructor(event.currentTarget, this._getDelegateConfig());
|
||||
$(event.currentTarget).data(dataKey, context);
|
||||
}
|
||||
|
||||
if (event) {
|
||||
context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
|
||||
}
|
||||
|
||||
if ($(context.getTipElement()).hasClass(ClassName.IN) || context._hoverState === HoverState.IN) {
|
||||
context._hoverState = HoverState.IN;
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(context._timeout);
|
||||
|
||||
context._hoverState = HoverState.IN;
|
||||
|
||||
if (!context.config.delay || !context.config.delay.show) {
|
||||
context.show();
|
||||
return;
|
||||
}
|
||||
|
||||
context._timeout = setTimeout(function () {
|
||||
if (context._hoverState === HoverState.IN) {
|
||||
context.show();
|
||||
}
|
||||
}, context.config.delay.show);
|
||||
}
|
||||
}, {
|
||||
key: '_leave',
|
||||
value: function _leave(event, context) {
|
||||
var dataKey = this.constructor.DATA_KEY;
|
||||
|
||||
context = context || $(event.currentTarget).data(dataKey);
|
||||
|
||||
if (!context) {
|
||||
context = new this.constructor(event.currentTarget, this._getDelegateConfig());
|
||||
$(event.currentTarget).data(dataKey, context);
|
||||
}
|
||||
|
||||
if (event) {
|
||||
context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
|
||||
}
|
||||
|
||||
if (context._isWithActiveTrigger()) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(context._timeout);
|
||||
|
||||
context._hoverState = HoverState.OUT;
|
||||
|
||||
if (!context.config.delay || !context.config.delay.hide) {
|
||||
context.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
context._timeout = setTimeout(function () {
|
||||
if (context._hoverState === HoverState.OUT) {
|
||||
context.hide();
|
||||
}
|
||||
}, context.config.delay.hide);
|
||||
}
|
||||
}, {
|
||||
key: '_isWithActiveTrigger',
|
||||
value: function _isWithActiveTrigger() {
|
||||
for (var trigger in this._activeTrigger) {
|
||||
if (this._activeTrigger[trigger]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}, {
|
||||
key: '_getConfig',
|
||||
value: function _getConfig(config) {
|
||||
config = $.extend({}, this.constructor.Default, $(this.element).data(), config);
|
||||
|
||||
if (config.delay && typeof config.delay === 'number') {
|
||||
config.delay = {
|
||||
show: config.delay,
|
||||
hide: config.delay
|
||||
};
|
||||
}
|
||||
|
||||
_Util['default'].typeCheckConfig(NAME, config, this.constructor.DefaultType);
|
||||
|
||||
return config;
|
||||
}
|
||||
}, {
|
||||
key: '_getDelegateConfig',
|
||||
value: function _getDelegateConfig() {
|
||||
var config = {};
|
||||
|
||||
if (this.config) {
|
||||
for (var key in this.config) {
|
||||
if (this.constructor.Default[key] !== this.config[key]) {
|
||||
config[key] = this.config[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
}], [{
|
||||
key: '_jQueryInterface',
|
||||
value: function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data(DATA_KEY);
|
||||
var _config = typeof config === 'object' ? config : null;
|
||||
|
||||
if (!data && /destroy|hide/.test(config)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
data = new Tooltip(this, _config);
|
||||
$(this).data(DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (typeof config === 'string') {
|
||||
if (data[config] === undefined) {
|
||||
throw new Error('No method named "' + config + '"');
|
||||
}
|
||||
data[config]();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'VERSION',
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}, {
|
||||
key: 'Default',
|
||||
get: function get() {
|
||||
return Default;
|
||||
}
|
||||
}, {
|
||||
key: 'NAME',
|
||||
get: function get() {
|
||||
return NAME;
|
||||
}
|
||||
}, {
|
||||
key: 'DATA_KEY',
|
||||
get: function get() {
|
||||
return DATA_KEY;
|
||||
}
|
||||
}, {
|
||||
key: 'Event',
|
||||
get: function get() {
|
||||
return Event;
|
||||
}
|
||||
}, {
|
||||
key: 'EVENT_KEY',
|
||||
get: function get() {
|
||||
return EVENT_KEY;
|
||||
}
|
||||
}, {
|
||||
key: 'DefaultType',
|
||||
get: function get() {
|
||||
return DefaultType;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Tooltip;
|
||||
})();
|
||||
|
||||
$.fn[NAME] = Tooltip._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Tooltip;
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Tooltip._jQueryInterface;
|
||||
};
|
||||
|
||||
return Tooltip;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Tooltip;
|
||||
});
|
@ -1,172 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports', 'module'], factory);
|
||||
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
||||
factory(exports, module);
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, mod);
|
||||
global.util = mod.exports;
|
||||
}
|
||||
})(this, function (exports, module) {
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.2): util.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var Util = (function ($) {
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Private TransitionEnd Helpers
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var transition = false;
|
||||
|
||||
var TransitionEndEvent = {
|
||||
WebkitTransition: 'webkitTransitionEnd',
|
||||
MozTransition: 'transitionend',
|
||||
OTransition: 'oTransitionEnd otransitionend',
|
||||
transition: 'transitionend'
|
||||
};
|
||||
|
||||
// shoutout AngusCroll (https://goo.gl/pxwQGp)
|
||||
function toType(obj) {
|
||||
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
|
||||
}
|
||||
|
||||
function isElement(obj) {
|
||||
return (obj[0] || obj).nodeType;
|
||||
}
|
||||
|
||||
function getSpecialTransitionEndEvent() {
|
||||
return {
|
||||
bindType: transition.end,
|
||||
delegateType: transition.end,
|
||||
handle: function handle(event) {
|
||||
if ($(event.target).is(this)) {
|
||||
return event.handleObj.handler.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function transitionEndTest() {
|
||||
if (window.QUnit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var el = document.createElement('bootstrap');
|
||||
|
||||
for (var _name in TransitionEndEvent) {
|
||||
if (el.style[_name] !== undefined) {
|
||||
return { end: TransitionEndEvent[_name] };
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function transitionEndEmulator(duration) {
|
||||
var _this = this;
|
||||
|
||||
var called = false;
|
||||
|
||||
$(this).one(Util.TRANSITION_END, function () {
|
||||
called = true;
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
if (!called) {
|
||||
Util.triggerTransitionEnd(_this);
|
||||
}
|
||||
}, duration);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function setTransitionEndSupport() {
|
||||
transition = transitionEndTest();
|
||||
|
||||
$.fn.emulateTransitionEnd = transitionEndEmulator;
|
||||
|
||||
if (Util.supportsTransitionEnd()) {
|
||||
$.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Public Util Api
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var Util = {
|
||||
|
||||
TRANSITION_END: 'bsTransitionEnd',
|
||||
|
||||
getUID: function getUID(prefix) {
|
||||
do {
|
||||
prefix += ~ ~(Math.random() * 1000000); // "~~" acts like a faster Math.floor() here
|
||||
} while (document.getElementById(prefix));
|
||||
return prefix;
|
||||
},
|
||||
|
||||
getSelectorFromElement: function getSelectorFromElement(element) {
|
||||
var selector = element.getAttribute('data-target');
|
||||
|
||||
if (!selector) {
|
||||
selector = element.getAttribute('href') || '';
|
||||
selector = /^#[a-z]/i.test(selector) ? selector : null;
|
||||
}
|
||||
|
||||
return selector;
|
||||
},
|
||||
|
||||
reflow: function reflow(element) {
|
||||
new Function('bs', 'return bs')(element.offsetHeight);
|
||||
},
|
||||
|
||||
triggerTransitionEnd: function triggerTransitionEnd(element) {
|
||||
$(element).trigger(transition.end);
|
||||
},
|
||||
|
||||
supportsTransitionEnd: function supportsTransitionEnd() {
|
||||
return Boolean(transition);
|
||||
},
|
||||
|
||||
typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
|
||||
for (var property in configTypes) {
|
||||
if (configTypes.hasOwnProperty(property)) {
|
||||
var expectedTypes = configTypes[property];
|
||||
var value = config[property];
|
||||
var valueType = undefined;
|
||||
|
||||
if (value && isElement(value)) {
|
||||
valueType = 'element';
|
||||
} else {
|
||||
valueType = toType(value);
|
||||
}
|
||||
|
||||
if (!new RegExp(expectedTypes).test(valueType)) {
|
||||
throw new Error(componentName.toUpperCase() + ': ' + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
setTransitionEndSupport();
|
||||
|
||||
return Util;
|
||||
})(jQuery);
|
||||
|
||||
module.exports = Util;
|
||||
});
|
@ -1,56 +0,0 @@
|
||||
const TAG_UUID = "data-player-uuid";
|
||||
|
||||
var elements = document.querySelectorAll('[' + TAG_UUID + ']'); // NodeList type
|
||||
|
||||
for (var i = 0; i < elements.length; i++)
|
||||
{
|
||||
var element = elements.item(i);
|
||||
|
||||
element.addEventListener("click", (function(element)
|
||||
{
|
||||
return function(e)
|
||||
{
|
||||
var uuid = element.getAttribute("data-player-uuid");
|
||||
copy(uuid);
|
||||
alertElement('<b>Copied UUID to clipboard.</b>', element, 1500);
|
||||
}
|
||||
})(element));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to copy the supplied text into the users clipboard.
|
||||
* If this fails they are presented with a box allowing them to copy and paste the text.
|
||||
* This will only work on a supported browser and if this action is caused by some sort of player input.
|
||||
*
|
||||
* @param text the text to put in the users clipboard
|
||||
*/
|
||||
function copy(text)
|
||||
{
|
||||
var copyElement = document.createElement('input');
|
||||
copyElement.setAttribute('type', 'text');
|
||||
copyElement.setAttribute('value', text);
|
||||
copyElement = document.body.appendChild(copyElement);
|
||||
copyElement.select();
|
||||
|
||||
try
|
||||
{
|
||||
document.execCommand('copy');
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
console.log("document.execCommand('copy'); is not supported by this browser.");
|
||||
prompt('Copy the value below. (CTRL + C, ENTER)', text);
|
||||
}
|
||||
finally
|
||||
{
|
||||
copyElement.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function alertElement(html, element, millis)
|
||||
{
|
||||
var original = element.innerHTML;
|
||||
element.innerHTML = html;
|
||||
setTimeout(function() { element.innerHTML = original; }, millis);
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
<?php class Message
|
||||
{
|
||||
public static $TYPE_DISPLAY_NAMES = array("Chat", "PM");
|
||||
|
||||
const TYPE_CHAT = 0;
|
||||
const TYPE_PM = 1;
|
||||
|
||||
/**
|
||||
* @param $type
|
||||
* @return int
|
||||
*/
|
||||
public static function getTypeFromString($type)
|
||||
{
|
||||
if (strcmp($type, "CHAT") == 0)
|
||||
{
|
||||
return self::TYPE_CHAT;
|
||||
}
|
||||
else if (strcmp($type, "PM") == 0)
|
||||
{
|
||||
return self::TYPE_PM;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/** @var Player */
|
||||
private $sender;
|
||||
|
||||
/** @var Player[] */
|
||||
private $recipients;
|
||||
|
||||
/** @var DateTime */
|
||||
private $timestamp;
|
||||
|
||||
/** @var Int */
|
||||
private $type;
|
||||
|
||||
/** @var String */
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* Message constructor.
|
||||
* @param Player $sender
|
||||
* @param Player[] $recipients
|
||||
* @param DateTime $dateTime
|
||||
* @param Int $type
|
||||
* @param Message
|
||||
*/
|
||||
function Message($sender, $recipients, $dateTime, $type, $message)
|
||||
{
|
||||
$this->sender = $sender;
|
||||
$this->recipients = $recipients;
|
||||
$this->timestamp = $dateTime;
|
||||
$this->type = $type;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getSender()
|
||||
{
|
||||
return $this->sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getRecipients()
|
||||
{
|
||||
return $this->recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getTimestamp()
|
||||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Int
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?php class Player
|
||||
{
|
||||
/** @var String */
|
||||
private $uuid;
|
||||
|
||||
/** @var String */
|
||||
private $username;
|
||||
|
||||
/** @var String */
|
||||
private $rank;
|
||||
|
||||
/**
|
||||
* Player constructor.
|
||||
* @param String $uuid
|
||||
* @param String $username
|
||||
* @param String $rank
|
||||
*/
|
||||
function Player($uuid, $username, $rank)
|
||||
{
|
||||
$this->uuid = $uuid;
|
||||
$this->username = $username;
|
||||
$this->rank = $rank;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getUUID()
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getRank()
|
||||
{
|
||||
return $this->rank;
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="js/jquery.js"></script>
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="css/tiger.css">
|
||||
<link href='https://fonts.googleapis.com/css?family=Crete+Round' rel='stylesheet' type='text/css'>
|
||||
<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
|
||||
<title>Report #1234 · Mineplex</title>
|
||||
|
||||
<script>
|
||||
$("#test").click(function (){
|
||||
alert("test!");
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<div id="header">
|
||||
<img src="img/logo.png" height="70px" width="70px" />
|
||||
<h1>Report System</h1>
|
||||
<!-- <h2><i class="fa fa-camera"></i> Chat Snap</h2> -->
|
||||
</div>
|
||||
<div id="search">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Enter a chat snap report ID...">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-secondary" type="button"><i class="fa fa-search"></i> Search</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div>
|
||||
<hr>
|
||||
<h2 style="font-family: 'Oswald', sans-serif; text-align: center;">
|
||||
Report #1234
|
||||
</h2>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div id="chat" class="col-lg-7">
|
||||
<h4><i class="fa fa-comments"></i> Chat Log</h4>
|
||||
<hr>
|
||||
<div id="log" class="text-muted ">
|
||||
<span class="label label-info chat" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">Chat</span> <span class="black">WilliamTiger:</span> hey
|
||||
<br>
|
||||
<span class="label label-info chat" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">Chat</span> <span class="black">b2_mp:</span> you're a tiger
|
||||
<br>
|
||||
<span class="label label-info chat" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">Chat</span> <span class="black">Mysticate:</span> that's right!!!
|
||||
<br>
|
||||
<span class="label label-info chat" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">Chat</span> <span class="black">WilliamBurns:</span> f*** off not true
|
||||
<br>
|
||||
<span class="label label-info chat" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">Chat</span> <span class="black">Phinary:</span> Please watch your language!
|
||||
<br>
|
||||
<span class="label label-primary chat pm" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">PM</span> <span class="black">jaws12 -> Phinary:</span> somebody report him!
|
||||
<br>
|
||||
<span class="label label-primary chat pm" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">PM</span> <span class="black"> Phinary -> jaws12:</span> Okay I will
|
||||
</div>
|
||||
</div>
|
||||
<div id="users" class="col-lg-5">
|
||||
<h4><i class="fa fa-info-circle"></i> Information</h4>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-lg-1">
|
||||
<i class="fa fa-calendar"></i><br>
|
||||
<i class="fa fa-clock-o"></i><br>
|
||||
<i class="fa fa-user-plus"></i><br>
|
||||
<i class="fa fa-user-times"></i><br>
|
||||
<i class="fa fa-gavel"></i><br>
|
||||
</div>
|
||||
<div class="col-lg-11">
|
||||
<span class="label label-pill label-default">12/8/15</span><br>
|
||||
<span class="label label-pill label-default">4:18 PM</span><br>
|
||||
<span class="label label-pill label-success">Reported by Phinary, jaws12</span><br>
|
||||
<span class="label label-pill label-danger">Suspect is WilliamBurns</span><br>
|
||||
<span class="label label-pill label-warning">Staff Member assigned is Artix</span><br>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<h4><i class="fa fa-users"></i> Users</h4>
|
||||
<hr>
|
||||
<img src="http://cravatar.eu/avatar/WilliamTiger/55.png" class="pull-left" />
|
||||
<b class="name">WilliamTiger</b> <span class="label label-staff name">JR.DEV</span><br>
|
||||
<code style="font-size: 11px;">bfc8dadf-c568-4e31-9776-8e710669b02e</code>
|
||||
<br><br>
|
||||
|
||||
<img src="http://cravatar.eu/avatar/b2_mp/55.png" class="pull-left" />
|
||||
<b class="name">b2_mp</b> <span class="label label-staff name">LEADER</span><br>
|
||||
<code style="font-size: 11px;">efaf9a17-2304-4f42-8433-421523c308dc</code>
|
||||
<br><br>
|
||||
|
||||
<img src="http://cravatar.eu/avatar/jaws12/55.png" class="pull-left" />
|
||||
<b class="name">jaws12</b> <span class="label label-staff name">DEV</span><br>
|
||||
<code style="font-size: 11px;">00c6d020-4346-4f8a-a9b5-67d4bc3251bf</code>
|
||||
<br><br>
|
||||
|
||||
<img src="http://cravatar.eu/avatar/WilliamBurns/55.png" class="pull-left" />
|
||||
<b class="name">WilliamBurns</b> <span class="label label-ultra name">ULTRA</span><br>
|
||||
<code style="font-size: 11px;">f9eedba5-668d-4ee5-9ee8-98edee840608</code>
|
||||
<br><br>
|
||||
|
||||
<img src="http://cravatar.eu/avatar/Phinary/55.png" class="pull-left" />
|
||||
<b class="name">Phinary</b> <span class="label label-staff name">LEADER</span><br>
|
||||
<code style="font-size: 11px;">b33207e2-0dc5-4cbd-b3ee-6c860727f722</code>
|
||||
<br><br>
|
||||
|
||||
<img src="http://cravatar.eu/avatar/Mysticate/55.png" class="pull-left" />
|
||||
<b class="name">Mysticate</b> <span class="label label-staff name">JR.DEV</span><br>
|
||||
<code style="font-size: 11px;">5c359761-d55b-43a4-9b75-2cc64f8d027f</code>
|
||||
<br><br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<a href="http://www.mineplex.com"><img src="img/logo-full.png" width="225px" /></a>
|
||||
<div class="btn-group pull-right indent-link" style="font-family: 'Crete Round', serif; padding-top: 10px;">
|
||||
<a href="http://www.mineplex.com" class="btn btn-link btn-small text-muted">Home</a>
|
||||
<a href="http://www.mineplex.com/shop/" class="btn btn-link btn-small text-muted">Shop</a>
|
||||
<a href="http://www.mineplex.com/forums/" class="btn btn-link btn-small text-muted">Forums</a>
|
||||
<a href="http://www.mineplex.com/supporthub/" class="btn btn-link btn-small text-muted">Support</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,74 +0,0 @@
|
||||
<?php class Report
|
||||
{
|
||||
/** @var Int */
|
||||
private $id;
|
||||
|
||||
/** @var String */
|
||||
private $serverName;
|
||||
|
||||
/** @var Player|Null */
|
||||
private $handler;
|
||||
|
||||
/** @var Player */
|
||||
private $suspect;
|
||||
|
||||
/** @var SplObjectStorage */
|
||||
private $reporters;
|
||||
|
||||
/**
|
||||
* Report constructor.
|
||||
* @param Int $id
|
||||
* @param String $serverName
|
||||
* @param Player|Null $handler
|
||||
* @param Player $suspect
|
||||
* @param SplObjectStorage $reporters
|
||||
*/
|
||||
function Report($id, $serverName, $handler, $suspect, $reporters)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->serverName = $serverName;
|
||||
$this->handler = $handler;
|
||||
$this->suspect = $suspect;
|
||||
$this->reporters = $reporters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getServerName()
|
||||
{
|
||||
return $this->serverName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player|Null
|
||||
*/
|
||||
public function getHandler()
|
||||
{
|
||||
return $this->handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getSuspect()
|
||||
{
|
||||
return $this->suspect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SplObjectStorage
|
||||
*/
|
||||
public function getReporters()
|
||||
{
|
||||
return $this->reporters;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
<?php class Snapshot
|
||||
{
|
||||
|
||||
/** @var String */
|
||||
private $identifier;
|
||||
|
||||
/** @var Message[] */
|
||||
private $messages;
|
||||
|
||||
/** @var Player[] */
|
||||
private $players; // String UUID as Key
|
||||
|
||||
/** @var DateTime */
|
||||
private $generated;
|
||||
|
||||
/**
|
||||
* Snapshot constructor.
|
||||
* @param String $identifier
|
||||
* @param Message[] $messages
|
||||
* @param Player[] $players
|
||||
* @param DateTime $generated
|
||||
*/
|
||||
function Snapshot($identifier, $messages, $players, $generated)
|
||||
{
|
||||
$this->identifier = $identifier;
|
||||
$this->messages = $messages;
|
||||
$this->players = $players;
|
||||
$this->generated = $generated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Message[]
|
||||
*/
|
||||
public function getMessages()
|
||||
{
|
||||
return $this->messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getPlayers()
|
||||
{
|
||||
return $this->players;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getTimeGenerated()
|
||||
{
|
||||
return $this->generated;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user