Revert "Revert "Report system (version 1)""
This reverts commit d0d2de1e21
.
# Conflicts:
# Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java
This commit is contained in:
parent
b68aea00c6
commit
a663cb3e01
@ -43,6 +43,38 @@ 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)
|
||||
{
|
||||
@ -51,6 +83,14 @@ 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)
|
||||
{
|
||||
@ -59,6 +99,14 @@ 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()
|
||||
{
|
||||
|
@ -0,0 +1,10 @@
|
||||
package mineplex.core.chatsnap;
|
||||
|
||||
/**
|
||||
* Holds all types of messages a player can receive from another player
|
||||
*/
|
||||
public enum MessageType
|
||||
{
|
||||
CHAT,
|
||||
PM
|
||||
}
|
119
Plugins/Mineplex.Core/src/mineplex/core/chatsnap/Snapshot.java
Normal file
119
Plugins/Mineplex.Core/src/mineplex/core/chatsnap/Snapshot.java
Normal file
@ -0,0 +1,119 @@
|
||||
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 +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
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));
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
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));
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -3,10 +3,11 @@ 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
|
||||
public class PrivateMessageEvent extends Event implements Cancellable
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@ -32,11 +33,13 @@ public class PrivateMessageEvent extends Event
|
||||
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 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, showUserReports FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
|
||||
}
|
||||
|
||||
public IncognitoManager getIncognitoManager()
|
||||
|
@ -23,9 +23,10 @@ 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, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
// NOT NULL DEFAULT 0, showUserReports BOOL 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 = ? 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 = ?, showUserReports = ? WHERE uuid=?;";
|
||||
|
||||
public PreferencesRepository(JavaPlugin plugin)
|
||||
{
|
||||
@ -64,8 +65,9 @@ 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(16, entry.getKey());
|
||||
preparedStatement.setString(17, entry.getKey());
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
@ -94,8 +96,9 @@ 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(16, entry.getKey());
|
||||
preparedStatement.setString(17, entry.getKey());
|
||||
preparedStatement.execute();
|
||||
}
|
||||
|
||||
@ -129,6 +132,7 @@ 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,6 +12,7 @@ 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,11 +24,13 @@ 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;
|
||||
|
||||
@ -71,6 +73,15 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
}
|
||||
};
|
||||
|
||||
_toggleUserReports = new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
toggleUserReports(player);
|
||||
}
|
||||
};
|
||||
|
||||
_toggleHubIgnoreVelocity = new IButton()
|
||||
{
|
||||
@Override
|
||||
@ -111,20 +122,22 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
|
||||
if (rank.has(Rank.ADMIN) || rank == Rank.JNR_DEV)
|
||||
{
|
||||
int[] indices = UtilUI.getIndicesFor(4, 0, 2);
|
||||
int[] indices = UtilUI.getIndicesFor(5, 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(3, 0, 2);
|
||||
int[] indices = UtilUI.getIndicesFor(4, 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)
|
||||
{
|
||||
@ -181,6 +194,13 @@ 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;
|
||||
@ -203,6 +223,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
||||
|
||||
public boolean preferencesChanged()
|
||||
{
|
||||
return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled;
|
||||
return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled || _userReportsToggled;
|
||||
}
|
||||
}
|
@ -1,39 +1,97 @@
|
||||
package mineplex.core.report;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
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 String _playerName;
|
||||
public String getPlayerName() { return _playerName; }
|
||||
private UUID _suspect;
|
||||
public UUID getSuspect() { return _suspect; }
|
||||
|
||||
// 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); }
|
||||
// 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); }
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
* @param reportId
|
||||
* @param playerName
|
||||
* @param serverName
|
||||
*/
|
||||
public Report(int reportId, String playerName, String serverName)
|
||||
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)
|
||||
{
|
||||
_reportId = reportId;
|
||||
_playerName = playerName;
|
||||
_suspect = suspect;
|
||||
_serverName = serverName;
|
||||
_reporters = new HashSet<String>();
|
||||
_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;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,77 @@
|
||||
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,21 +1,44 @@
|
||||
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.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
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.util.UtilPlayer;
|
||||
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.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.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
@ -24,134 +47,244 @@ 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 {
|
||||
|
||||
private static ReportManager instance;
|
||||
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;
|
||||
|
||||
// Holds active/open reports in a synchronized database.
|
||||
private DataRepository<Report> reportRepository;
|
||||
|
||||
private DataRepository<ReportProfile> reportProfiles;
|
||||
private DataRepository<Report> _reportRepository;
|
||||
|
||||
// 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;
|
||||
|
||||
/**
|
||||
* Private constructor to prevent non-singleton instances.
|
||||
*/
|
||||
private ReportManager()
|
||||
public ReportManager(JavaPlugin javaPlugin, PreferencesManager preferencesManager, StatsManager statsManager,
|
||||
SnapshotManager snapshotManager, CoreClientManager coreClientManager, String serverName)
|
||||
{
|
||||
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>();
|
||||
_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();
|
||||
|
||||
// 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);
|
||||
ReportNotificationCallback callback = new ReportNotificationCallback(this);
|
||||
ServerCommandManager.getInstance().registerCommandType("ReportNotification", ReportNotification.class, callback);
|
||||
ServerCommandManager.getInstance().registerCommandType("ReportHandlerNotification", ReportHandlerNotification.class, callback);
|
||||
}
|
||||
|
||||
public void closeReport(int reportId, Player reportCloser, String reason,
|
||||
ReportResult result)
|
||||
ReportResult result)
|
||||
{
|
||||
if (isActiveReport(reportId))
|
||||
{
|
||||
Report report = getReport(reportId);
|
||||
reportRepository.removeElement(String.valueOf(reportId)); // Remove report from redis database
|
||||
removeActiveReport(reportId);
|
||||
Report report = getReport(reportId);
|
||||
|
||||
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);
|
||||
if (report != null)
|
||||
{
|
||||
removeReport(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);
|
||||
|
||||
// Update the reputation/profiles of all reporters on this closing report.
|
||||
for (String reporterName : report.getReporters())
|
||||
for (UUID reporterUUID : report.getReporters())
|
||||
{
|
||||
CoreClient reporterAccount = getPlayerAccount(reporterName);
|
||||
ReportProfile reportProfile = getReportProfile(String.valueOf(reporterAccount.getAccountId()));
|
||||
reportProfile.onReportClose(result);
|
||||
reportProfiles.addElement(reportProfile);
|
||||
String reporterName = Bukkit.getOfflinePlayer(reporterUUID).getName();
|
||||
incrementStat(reporterName, result);
|
||||
}
|
||||
|
||||
if (reportCloser != null)
|
||||
{
|
||||
// Notify staff that the report was closed.
|
||||
sendReportNotification(String.format("[Report %d] %s closed this report. (%s).", reportId,
|
||||
reportCloser.getName(), result.toDisplayMessage()));
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handleReport(int reportId, Player reportHandler)
|
||||
{
|
||||
if (reportRepository.elementExists(String.valueOf(reportId)))
|
||||
Report report = getReport(reportId);
|
||||
|
||||
if (report != null)
|
||||
{
|
||||
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));
|
||||
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);
|
||||
|
||||
// TODO: Send display message to handler when they arrive on the server
|
||||
// with info about the case/report.
|
||||
sendStaffNotification(F.main(getReportPrefix(reportId), String.format("%s is handling this report.", handlerName)));
|
||||
Portal.transferPlayer(reportHandler.getName(), report.getServerName());
|
||||
|
||||
int handlerId = getPlayerAccount(reportHandler).getAccountId();
|
||||
reportSqlRepository.logReportHandling(reportId, handlerId); // Log handling into sql database
|
||||
// Show user details of the report every x seconds
|
||||
new ReportHandlerMessageTask(this, report).runTaskTimer(_javaPlugin, 20L * 10, 20L * 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reportPlayer(Player reporter, Player reportedPlayer, String reason)
|
||||
public boolean canReport(Player player)
|
||||
{
|
||||
int reporterId = getPlayerAccount(reporter).getAccountId();
|
||||
ReportProfile reportProfile = getReportProfile(String.valueOf(reporterId));
|
||||
PlayerStats playerStats = _statsManager.Get(player.getName());
|
||||
long abusiveReportsCount = playerStats.getStat(ReportResult.ABUSIVE.getStatName());
|
||||
return abusiveReportsCount < ABUSE_BAN_THRESHOLD;
|
||||
}
|
||||
|
||||
if (reportProfile.canReport())
|
||||
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)
|
||||
{
|
||||
Report report = null;
|
||||
int accountId = _coreClientManager.Get(reporter).getAccountId();
|
||||
_statsManager.incrementStat(accountId, statName, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasActiveReport(reportedPlayer))
|
||||
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)
|
||||
{
|
||||
int reportId = getActiveReport(reportedPlayer.getName());
|
||||
report = getReport(reportId);
|
||||
report.addReporter(reporter.getName());
|
||||
report.addReporter(reporter.getUniqueId(), reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
report = new Report(generateReportId(), reportedPlayer.getUniqueId(), _serverName, category);
|
||||
report.addReporter(reporter.getUniqueId(), reason);
|
||||
_activeReports.put(reportedPlayer.getName().toLowerCase(), report.getReportId());
|
||||
}
|
||||
|
||||
if (report != null)
|
||||
incrementTotalStat(reporter.getName());
|
||||
|
||||
// only start notifying staff when
|
||||
if (report.getReporters().size() >= category.getNotifyThreshold())
|
||||
{
|
||||
// [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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 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())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,66 +292,61 @@ public class ReportManager {
|
||||
{
|
||||
if (hasActiveReport(player))
|
||||
{
|
||||
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()));
|
||||
Report report = getActiveReport(player.getName());
|
||||
sendHandlerNotification(report, F.main(getReportPrefix(report), String.format("%s has left the game.", 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 (Jedis jedis = pool.getResource())
|
||||
try
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
private CoreClient getPlayerAccount(Player player)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
return getPlayerAccount(player.getName());
|
||||
report.updateLastActivity();
|
||||
_reportRepository.addElement(report);
|
||||
}
|
||||
|
||||
private CoreClient getPlayerAccount(String playerName)
|
||||
public void removeReport(int reportId)
|
||||
{
|
||||
return CommandCenter.Instance.GetClientManager().Get(playerName);
|
||||
}
|
||||
|
||||
private int getAccountId(String playerName)
|
||||
{
|
||||
return getPlayerAccount(playerName).getAccountId();
|
||||
_reportRepository.removeElement(String.valueOf(reportId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,45 +355,91 @@ public class ReportManager {
|
||||
*/
|
||||
public boolean hasReportNotifications(Player player)
|
||||
{
|
||||
// If player is not staff, return false.
|
||||
// If player is staff but has report notifications pref disabled, return false;
|
||||
// Else return true.
|
||||
return false;
|
||||
boolean isStaff = CommandCenter.Instance.GetClientManager().Get(player).GetRank().has(Rank.MODERATOR);
|
||||
boolean hasReportNotifications = _preferencesManager.Get(player).ShowUserReports;
|
||||
return isStaff && hasReportNotifications;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a network-wide {@link ReportNotification} to all online staff.
|
||||
*
|
||||
* @param message - the report notification message to send.
|
||||
*/
|
||||
public void sendReportNotification(String message)
|
||||
public void sendStaffNotification(JsonMessage 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 int getActiveReport(String playerName)
|
||||
public Report getActiveReport(String playerName)
|
||||
{
|
||||
if (activeReports.containsKey(playerName.toLowerCase()))
|
||||
Integer reportId = _activeReports.get(playerName.toLowerCase());
|
||||
|
||||
if (reportId != null)
|
||||
{
|
||||
return activeReports.get(playerName.toLowerCase());
|
||||
return getReport(reportId);
|
||||
}
|
||||
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasActiveReport(Player player)
|
||||
{
|
||||
return getActiveReport(player.getName()) != -1;
|
||||
return getActiveReport(player.getName()) != null;
|
||||
}
|
||||
|
||||
public boolean isActiveReport(int reportId)
|
||||
{
|
||||
for (Entry<String, Integer> activeReport : activeReports.entrySet())
|
||||
for (Map.Entry<String, Integer> activeReport : _activeReports.entrySet())
|
||||
{
|
||||
if (activeReport.getValue() == reportId)
|
||||
{
|
||||
@ -278,11 +452,11 @@ public class ReportManager {
|
||||
|
||||
public boolean removeActiveReport(int reportId)
|
||||
{
|
||||
for (Entry<String, Integer> activeReport : activeReports.entrySet())
|
||||
for (Map.Entry<String, Integer> activeReport : _activeReports.entrySet())
|
||||
{
|
||||
if (activeReport.getValue() == reportId)
|
||||
{
|
||||
activeReports.remove(activeReport.getKey());
|
||||
_activeReports.remove(activeReport.getKey());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -290,16 +464,20 @@ public class ReportManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the singleton instance of {@link ReportManager}.
|
||||
*/
|
||||
public static ReportManager getInstance()
|
||||
public Collection<Integer> getActiveReports()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new ReportManager();
|
||||
}
|
||||
return _activeReports.values();
|
||||
}
|
||||
|
||||
return instance;
|
||||
/* STATIC HELPERS */
|
||||
|
||||
public static String getReportPrefix(Report report)
|
||||
{
|
||||
return getReportPrefix(report.getReportId());
|
||||
}
|
||||
|
||||
public static String getReportPrefix(int reportId)
|
||||
{
|
||||
return NAME + " #" + reportId;
|
||||
}
|
||||
}
|
||||
|
@ -4,20 +4,41 @@ 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;
|
||||
|
||||
private static JavaPlugin instance;
|
||||
public static JavaPlugin getPluginInstance() { return instance; }
|
||||
|
||||
public ReportPlugin(JavaPlugin plugin, String serverName)
|
||||
public ReportPlugin(JavaPlugin plugin, ReportManager reportManager)
|
||||
{
|
||||
super("ReportPlugin", plugin);
|
||||
super("Report", plugin);
|
||||
|
||||
instance = 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,6 +47,17 @@ public class ReportPlugin extends MiniPlugin
|
||||
addCommand(new ReportCommand(this));
|
||||
addCommand(new ReportHandleCommand(this));
|
||||
addCommand(new ReportCloseCommand(this));
|
||||
//AddCommand(new ReportDebugCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e)
|
||||
{
|
||||
_reportManager.onPlayerJoin(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e)
|
||||
{
|
||||
_reportManager.onPlayerQuit(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -1,61 +0,0 @@
|
||||
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,36 +2,22 @@ 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
|
||||
{
|
||||
/*
|
||||
* *ReportTicket
|
||||
id, date, accountId reported player, server, accountId of staff who closed, result, reason
|
||||
|
||||
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 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(), ?, ?, ?, ?, ?);";
|
||||
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)
|
||||
public ReportRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
}
|
||||
@ -39,11 +25,7 @@ This will be used to determine if staff are handling
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
/*
|
||||
executeUpdate(CREATE_TICKET_TABLE);
|
||||
executeUpdate(CREATE_HANDLER_TABLE);
|
||||
executeUpdate(CREATE_REPORTERS_TABLE);
|
||||
*/
|
||||
// executeUpdate(CREATE_TICKET_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,22 +34,17 @@ This will be used to determine if staff are handling
|
||||
|
||||
}
|
||||
|
||||
public void logReportHandling(int reportId, int handlerId)
|
||||
public void logReport(final int reportId, final int playerId, final String server, final int closerId, final ReportResult result, final String reason)
|
||||
{
|
||||
executeUpdate(INSERT_HANDLER, new ColumnInt("reportId", reportId), new ColumnInt("handlerId", 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 + ".");
|
||||
}
|
||||
|
||||
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,24 +2,57 @@ package mineplex.core.report;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Contains all possible outcomes for a report.
|
||||
*/
|
||||
public enum ReportResult
|
||||
{
|
||||
UNDETERMINED(ChatColor.WHITE, "Could not determine"),
|
||||
MUTED(ChatColor.YELLOW, "Muted"),
|
||||
BANNED(ChatColor.RED, "Banned"),
|
||||
ABUSE(ChatColor.DARK_RED, "Abuse of report system");
|
||||
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");
|
||||
|
||||
private ChatColor color;
|
||||
private String displayMessage;
|
||||
private final String _statName;
|
||||
private final ChatColor _color;
|
||||
private final String _actionMessage;
|
||||
private final String _resultMessage;
|
||||
private final String[] _lore;
|
||||
|
||||
private ReportResult(ChatColor color, String displayMessage)
|
||||
ReportResult(String statName, ChatColor color, String actionMessage, String resultMessage, String... lore)
|
||||
{
|
||||
this.color = color;
|
||||
this.displayMessage = 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;
|
||||
}
|
||||
|
||||
public String toDisplayMessage()
|
||||
{
|
||||
return color + displayMessage;
|
||||
return _color + _resultMessage;
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,11 @@ 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;
|
||||
|
||||
@ -17,7 +16,7 @@ public class ReportCloseCommand extends CommandBase<ReportPlugin>
|
||||
|
||||
public ReportCloseCommand(ReportPlugin plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "reportclose", "rc");
|
||||
super(plugin, Rank.MODERATOR, "reportclose", "rc");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,7 +32,15 @@ public class ReportCloseCommand extends CommandBase<ReportPlugin>
|
||||
int reportId = Integer.parseInt(args[0]);
|
||||
String reason = F.combine(args, 1, null, false);
|
||||
|
||||
ReportManager.getInstance().closeReport(reportId, player, reason);
|
||||
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."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +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;
|
||||
import mineplex.core.report.ui.ReportCategoryPage;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -23,10 +21,13 @@ public class ReportCommand extends CommandBase<ReportPlugin>
|
||||
@Override
|
||||
public void Execute(final Player player, final String[] args)
|
||||
{
|
||||
if(args == null || args.length < 2)
|
||||
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)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -36,7 +37,14 @@ public class ReportCommand extends CommandBase<ReportPlugin>
|
||||
|
||||
if (reportedPlayer != null)
|
||||
{
|
||||
ReportManager.getInstance().reportPlayer(player, reportedPlayer, reason);
|
||||
if (reportedPlayer == player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "You cannot report yourself."));
|
||||
}
|
||||
else
|
||||
{
|
||||
new ReportCategoryPage(Plugin, player, reportedPlayer, reason).openInventory();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3,10 +3,8 @@ 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;
|
||||
|
||||
@ -17,7 +15,7 @@ public class ReportHandleCommand extends CommandBase<ReportPlugin>
|
||||
|
||||
public ReportHandleCommand(ReportPlugin plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "reporthandle", "rh");
|
||||
super(plugin, Rank.MODERATOR, "reporthandle", "rh");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,13 +24,12 @@ 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]);
|
||||
|
||||
ReportManager.getInstance().handleReport(reportId, player);
|
||||
Plugin.getReportManager().handleReport(reportId, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
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,31 +1,33 @@
|
||||
package mineplex.core.report.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
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
|
||||
{
|
||||
|
||||
// TODO: Encode in JSON-interactive chat message
|
||||
private String notification;
|
||||
private String _notification; // in json format
|
||||
|
||||
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()
|
||||
{
|
||||
// Message all players that can receive report notifications.
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (ReportManager.getInstance().hasReportNotifications(player))
|
||||
{
|
||||
player.sendMessage(notification);
|
||||
}
|
||||
}
|
||||
// Utilitizes a callback functionality to seperate dependencies
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -7,6 +7,9 @@ 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;
|
||||
@ -31,6 +34,8 @@ 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;
|
||||
@ -140,6 +145,10 @@ public class Clans extends JavaPlugin
|
||||
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);
|
||||
|
@ -8,6 +8,9 @@ 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;
|
||||
@ -40,6 +43,8 @@ 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;
|
||||
@ -158,6 +163,9 @@ 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);
|
||||
|
62
Plugins/Mineplex.ReportServer/pom.xml
Normal file
62
Plugins/Mineplex.ReportServer/pom.xml
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
<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>
|
@ -0,0 +1,57 @@
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,142 @@
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
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);
|
||||
}
|
||||
}
|
BIN
Plugins/Mineplex.ReportServer/web/css/Minecraftia.ttf
Normal file
BIN
Plugins/Mineplex.ReportServer/web/css/Minecraftia.ttf
Normal file
Binary file not shown.
6211
Plugins/Mineplex.ReportServer/web/css/bootstrap.css
vendored
Normal file
6211
Plugins/Mineplex.ReportServer/web/css/bootstrap.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
Plugins/Mineplex.ReportServer/web/css/bootstrap.css.map
Normal file
1
Plugins/Mineplex.ReportServer/web/css/bootstrap.css.map
Normal file
File diff suppressed because one or more lines are too long
6
Plugins/Mineplex.ReportServer/web/css/bootstrap.min.css
vendored
Normal file
6
Plugins/Mineplex.ReportServer/web/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
118
Plugins/Mineplex.ReportServer/web/css/tiger.css
Normal file
118
Plugins/Mineplex.ReportServer/web/css/tiger.css
Normal file
@ -0,0 +1,118 @@
|
||||
@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;
|
||||
}
|
BIN
Plugins/Mineplex.ReportServer/web/img/bg.png
Normal file
BIN
Plugins/Mineplex.ReportServer/web/img/bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
Plugins/Mineplex.ReportServer/web/img/bg.psd
Normal file
BIN
Plugins/Mineplex.ReportServer/web/img/bg.psd
Normal file
Binary file not shown.
BIN
Plugins/Mineplex.ReportServer/web/img/logo-full.png
Normal file
BIN
Plugins/Mineplex.ReportServer/web/img/logo-full.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
Plugins/Mineplex.ReportServer/web/img/logo.png
Normal file
BIN
Plugins/Mineplex.ReportServer/web/img/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 227 KiB |
BIN
Plugins/Mineplex.ReportServer/web/img/shaun.gif
Normal file
BIN
Plugins/Mineplex.ReportServer/web/img/shaun.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 971 KiB |
3560
Plugins/Mineplex.ReportServer/web/js/bootstrap.js
vendored
Normal file
3560
Plugins/Mineplex.ReportServer/web/js/bootstrap.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7
Plugins/Mineplex.ReportServer/web/js/bootstrap.min.js
vendored
Normal file
7
Plugins/Mineplex.ReportServer/web/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
10351
Plugins/Mineplex.ReportServer/web/js/jquery.js
vendored
Normal file
10351
Plugins/Mineplex.ReportServer/web/js/jquery.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
12
Plugins/Mineplex.ReportServer/web/js/npm.js
Normal file
12
Plugins/Mineplex.ReportServer/web/js/npm.js
Normal file
@ -0,0 +1,12 @@
|
||||
// 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')
|
211
Plugins/Mineplex.ReportServer/web/js/umd/alert.js
Normal file
211
Plugins/Mineplex.ReportServer/web/js/umd/alert.js
Normal file
@ -0,0 +1,211 @@
|
||||
(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;
|
||||
});
|
187
Plugins/Mineplex.ReportServer/web/js/umd/button.js
Normal file
187
Plugins/Mineplex.ReportServer/web/js/umd/button.js
Normal file
@ -0,0 +1,187 @@
|
||||
(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;
|
||||
});
|
497
Plugins/Mineplex.ReportServer/web/js/umd/carousel.js
Normal file
497
Plugins/Mineplex.ReportServer/web/js/umd/carousel.js
Normal file
@ -0,0 +1,497 @@
|
||||
(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;
|
||||
});
|
383
Plugins/Mineplex.ReportServer/web/js/umd/collapse.js
Normal file
383
Plugins/Mineplex.ReportServer/web/js/umd/collapse.js
Normal file
@ -0,0 +1,383 @@
|
||||
(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;
|
||||
});
|
312
Plugins/Mineplex.ReportServer/web/js/umd/dropdown.js
Normal file
312
Plugins/Mineplex.ReportServer/web/js/umd/dropdown.js
Normal file
@ -0,0 +1,312 @@
|
||||
(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;
|
||||
});
|
555
Plugins/Mineplex.ReportServer/web/js/umd/modal.js
Normal file
555
Plugins/Mineplex.ReportServer/web/js/umd/modal.js
Normal file
@ -0,0 +1,555 @@
|
||||
(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;
|
||||
});
|
220
Plugins/Mineplex.ReportServer/web/js/umd/popover.js
Normal file
220
Plugins/Mineplex.ReportServer/web/js/umd/popover.js
Normal file
@ -0,0 +1,220 @@
|
||||
(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;
|
||||
});
|
339
Plugins/Mineplex.ReportServer/web/js/umd/scrollspy.js
Normal file
339
Plugins/Mineplex.ReportServer/web/js/umd/scrollspy.js
Normal file
@ -0,0 +1,339 @@
|
||||
(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;
|
||||
});
|
282
Plugins/Mineplex.ReportServer/web/js/umd/tab.js
Normal file
282
Plugins/Mineplex.ReportServer/web/js/umd/tab.js
Normal file
@ -0,0 +1,282 @@
|
||||
(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;
|
||||
});
|
638
Plugins/Mineplex.ReportServer/web/js/umd/tooltip.js
Normal file
638
Plugins/Mineplex.ReportServer/web/js/umd/tooltip.js
Normal file
@ -0,0 +1,638 @@
|
||||
(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;
|
||||
});
|
172
Plugins/Mineplex.ReportServer/web/js/umd/util.js
Normal file
172
Plugins/Mineplex.ReportServer/web/js/umd/util.js
Normal file
@ -0,0 +1,172 @@
|
||||
(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;
|
||||
});
|
56
Plugins/Mineplex.ReportServer/web/main.js
Normal file
56
Plugins/Mineplex.ReportServer/web/main.js
Normal file
@ -0,0 +1,56 @@
|
||||
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);
|
||||
}
|
99
Plugins/Mineplex.ReportServer/web/message.php
Normal file
99
Plugins/Mineplex.ReportServer/web/message.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
48
Plugins/Mineplex.ReportServer/web/player.php
Normal file
48
Plugins/Mineplex.ReportServer/web/player.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
128
Plugins/Mineplex.ReportServer/web/reference.html
Normal file
128
Plugins/Mineplex.ReportServer/web/reference.html
Normal file
@ -0,0 +1,128 @@
|
||||
<!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>
|
74
Plugins/Mineplex.ReportServer/web/report.php
Normal file
74
Plugins/Mineplex.ReportServer/web/report.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
62
Plugins/Mineplex.ReportServer/web/snapshot.php
Normal file
62
Plugins/Mineplex.ReportServer/web/snapshot.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
468
Plugins/Mineplex.ReportServer/web/view.php
Normal file
468
Plugins/Mineplex.ReportServer/web/view.php
Normal file
@ -0,0 +1,468 @@
|
||||
<?php
|
||||
|
||||
require_once('snapshot.php');
|
||||
require_once('report.php');
|
||||
require_once('message.php');
|
||||
require_once('player.php');
|
||||
|
||||
const dataDir = 'data/';
|
||||
const collapsedMessageCount = 20;
|
||||
|
||||
// In Java this is "DateTimeFormatter.ISO_LOCAL_DATE_TIME"
|
||||
const jsonDateTimeFormat = 'Y-m-d\TH:i:s';
|
||||
|
||||
/** @var mysqli[] $connections */
|
||||
$connections = array(); // String index = Connection name
|
||||
|
||||
/** PARSE DB CONNECTIONS */
|
||||
|
||||
$dbConfigFile = new SplFileObject('database-config.dat');
|
||||
|
||||
if ($dbConfigFile->isFile())
|
||||
{
|
||||
while (!$dbConfigFile->eof())
|
||||
{
|
||||
$line = trim($dbConfigFile->fgets());
|
||||
|
||||
if ($line) // check not empty line
|
||||
{
|
||||
$parts = explode(' ', $line);
|
||||
$fullUrl = $parts[1];
|
||||
$urlParts = explode('/', $fullUrl);
|
||||
$host = $urlParts[0];
|
||||
$database = $urlParts[1];
|
||||
|
||||
$name = $parts[0];
|
||||
$username = $parts[2];
|
||||
$password = $parts[3];
|
||||
|
||||
$connection = new mysqli($host, $username, $password, $database);
|
||||
|
||||
if ($connection->connect_error) {
|
||||
die("Connection \"$name\" failed: $connection->connect_error");
|
||||
}
|
||||
|
||||
$connections[$name] = $connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
die('database-config.dat does not exist or is not a file.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param String $name
|
||||
* @return mysqli
|
||||
*/
|
||||
function getConnection($name)
|
||||
{
|
||||
global $connections;
|
||||
return $connections[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param String $filename
|
||||
* @return array JSON data array.
|
||||
*/
|
||||
function toDataArray($filename)
|
||||
{
|
||||
return json_decode(file_get_contents($filename), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param String $identifier
|
||||
* @param array $snapshotData Snapshot data array.
|
||||
* @return Snapshot
|
||||
*/
|
||||
function toSnapshot($identifier, $snapshotData)
|
||||
{
|
||||
$timezone = new DateTimeZone($snapshotData["timezone"]);
|
||||
$players = toPlayers($snapshotData['usernames']);
|
||||
$messages = toMessages($players, $snapshotData['snapshots'], $timezone);
|
||||
$generated = parseDateTime($snapshotData["generated"], $timezone);
|
||||
return new Snapshot($identifier, $messages, $players, $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $reportData
|
||||
* @param Player[] $players
|
||||
* @return Report
|
||||
*/
|
||||
function toReport($reportData, $players)
|
||||
{
|
||||
$id = $reportData["id"];
|
||||
$serverName = $reportData["serverName"];
|
||||
$handler = array_key_exists("handler", $reportData) ? getPlayer($players, $reportData["handler"]) : null;
|
||||
$suspect = getPlayer($players, $reportData["suspect"]);
|
||||
$reporters = toReporters($players, $reportData["reporters"]);
|
||||
return new Report($id, $serverName, $handler, $suspect, $reporters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $players
|
||||
* @param array $messagesData Messages data array.
|
||||
* @param DateTimeZone $timezone
|
||||
* @return Message[]
|
||||
*/
|
||||
function toMessages($players, $messagesData, $timezone)
|
||||
{
|
||||
$messages = array();
|
||||
|
||||
for ($i = 0; $i < count($messagesData); $i++)
|
||||
{
|
||||
$messages[$i] = getMessage($players, $messagesData[$i], $timezone);
|
||||
}
|
||||
|
||||
usort($messages, 'compareMessageTimes');
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Message $messageA
|
||||
* @param Message $messageB
|
||||
* @return int
|
||||
*/
|
||||
function compareMessageTimes($messageA, $messageB)
|
||||
{
|
||||
return $messageA->getTimestamp()->getTimestamp() - $messageB->getTimestamp()->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $players
|
||||
* @param array $messageData Message data array.
|
||||
* @param DateTimeZone $timezone
|
||||
* @return Message
|
||||
*/
|
||||
function getMessage($players, $messageData, $timezone)
|
||||
{
|
||||
$sender = getPlayer($players, $messageData['sender']);
|
||||
$recipients = getPlayersFromUUIDs($players, $messageData['recipients']);
|
||||
$dateTime = parseDateTime($messageData['time'], $timezone);
|
||||
$type = Message::getTypeFromString($messageData['type']);
|
||||
$message = $messageData['message'];
|
||||
|
||||
return new Message($sender, $recipients, $dateTime, $type, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $players
|
||||
* @param String[] $uuidArray the UUIDs of the players to fetch
|
||||
* @return Player[]
|
||||
*/
|
||||
function getPlayersFromUUIDs($players, $uuidArray)
|
||||
{
|
||||
$matchedPlayers = array();
|
||||
|
||||
for ($i = 0; $i < count($uuidArray); $i++)
|
||||
{
|
||||
$matchedPlayers[$i] = getPlayer($players, $uuidArray[$i]);
|
||||
}
|
||||
|
||||
return $matchedPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $playersArray
|
||||
* @return Player[]
|
||||
*/
|
||||
function toPlayers($playersArray) // String UUID as Key
|
||||
{
|
||||
$players = array();
|
||||
|
||||
foreach ($playersArray as $uuid => $username)
|
||||
{
|
||||
$connection = getConnection("ACCOUNT");
|
||||
$statement = $connection->prepare("SELECT `rank` FROM `accounts` WHERE `uuid` = ?;");
|
||||
$statement->bind_param('s', $uuid);
|
||||
$statement->execute();
|
||||
$statement->bind_result($rank);
|
||||
$statement->fetch();
|
||||
$statement->close();
|
||||
|
||||
$players[$uuid] = new Player($uuid, $username, $rank);
|
||||
}
|
||||
|
||||
return $players;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $playersArray
|
||||
* @param $reportersArray
|
||||
* @return SplObjectStorage
|
||||
*/
|
||||
function toReporters($playersArray, $reportersArray)
|
||||
{
|
||||
$reporters = new SplObjectStorage();
|
||||
|
||||
foreach ($reportersArray as $reporterUUID => $reason)
|
||||
{
|
||||
$reporters[getPlayer($playersArray, $reporterUUID)] = $reason;
|
||||
}
|
||||
|
||||
return $reporters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $players
|
||||
* @param String $uuid
|
||||
* @return Player
|
||||
*/
|
||||
function getPlayer($players, $uuid)
|
||||
{
|
||||
$player = $players[$uuid];
|
||||
|
||||
if ($player != null)
|
||||
{
|
||||
return $player;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException('Player for UUID not found.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param String $dateTime
|
||||
* @param DateTimeZone $timezone
|
||||
* @return DateTime
|
||||
*/
|
||||
function parseDateTime($dateTime, $timezone)
|
||||
{
|
||||
return DateTime::createFromFormat(jsonDateTimeFormat, $dateTime, $timezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an interval to minutes, days or months, depending on the size.
|
||||
*
|
||||
* @param DateInterval $interval
|
||||
* @return string
|
||||
*/
|
||||
function approximateHumanInterval($interval)
|
||||
{
|
||||
if ($interval->m > 0)
|
||||
{
|
||||
$humanString = $interval->m . ' month' . ($interval->m != 0 ? 's' : '');
|
||||
}
|
||||
else if ($interval->d > 0)
|
||||
{
|
||||
$humanString = $interval->d . ' day' . ($interval->d != 0 ? 's' : '');
|
||||
}
|
||||
else if ($interval->h > 0)
|
||||
{
|
||||
$humanString = $interval->h . ' hour' . ($interval->h != 0 ? 's' : '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$humanString = $interval->i . ' minute' . ($interval->i != 0 ? 's' : '');
|
||||
}
|
||||
|
||||
return $humanString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param String $input
|
||||
* @return String
|
||||
*/
|
||||
function removeBadCharacters($input)
|
||||
{
|
||||
return preg_replace('/[^A-Za-z0-9_\-]/', '_', $input);
|
||||
}
|
||||
|
||||
function getExpandedURL()
|
||||
{
|
||||
$vars = $_GET;
|
||||
$vars['expanded'] = true;
|
||||
return '?' . http_build_query($vars);
|
||||
}
|
||||
|
||||
$validIdentifier = isset($_GET['identifier']);
|
||||
$identifierError = "";
|
||||
|
||||
$identifier = null;
|
||||
$expanded = null;
|
||||
$filePath = null;
|
||||
$snapshot = null;
|
||||
$report = null;
|
||||
|
||||
if ($validIdentifier)
|
||||
{
|
||||
|
||||
$identifier = removeBadCharacters($_GET['identifier']); // prevents escaping
|
||||
$filePath = dataDir . $identifier . '.json';
|
||||
|
||||
if (file_exists($filePath))
|
||||
{
|
||||
$dataArray = toDataArray($filePath);
|
||||
$snapshot = toSnapshot($identifier, $dataArray);
|
||||
$report = toReport($dataArray['report'], $snapshot->getPlayers());
|
||||
$expanded = isset($_GET['expanded']) && $_GET['expanded'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$validIdentifier = false;
|
||||
$identifierError = "Invalid identifier.";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!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>
|
||||
<?php if ($validIdentifier): ?>
|
||||
Report #<?= $report->getId() ?>
|
||||
<?php else: ?>
|
||||
Report System
|
||||
<?php endif; ?>
|
||||
|
||||
· Mineplex
|
||||
</title>
|
||||
</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">
|
||||
<form id="identifier-input" name="identifier-input" action="view.php" method="get">
|
||||
<div class="input-group">
|
||||
<input name="identifier" type="text" class="form-control" placeholder="Enter an identifier provided in-game...">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-secondary" type="submit" form="identifier-input"><i class="fa fa-search"></i> Search</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php if (isset($_GET['identifier']) && !$validIdentifier && !empty($identifierError)): ?>
|
||||
<div id="content" class="center-block" style="text-align: center; background-color: rgba(204, 34, 42, 0.52);">
|
||||
<p class="error-oh-no" style="font-size: 60px;">What did you do?!?!?</p>
|
||||
<img src="img/shaun.gif" />
|
||||
<p class="error-oh-no" style="font-size: 40px;">Error: <?= $identifierError ?></p>
|
||||
<br>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php if (!isset($_GET['identifier'])) exit();
|
||||
|
||||
// INITIALIZE
|
||||
|
||||
// Get messages and the amount that we are going to display
|
||||
$messages = $snapshot->getMessages();
|
||||
$messageCount = count($messages);
|
||||
$displayAmount = $expanded || $messageCount <= collapsedMessageCount ? $messageCount : collapsedMessageCount;
|
||||
|
||||
// Calculate age from timestamp
|
||||
$dateTime = $snapshot->getTimeGenerated();
|
||||
$age = approximateHumanInterval($dateTime->diff(new DateTime('now', $dateTime->getTimezone())));
|
||||
|
||||
// Put all reporter usernames in array for easy access later
|
||||
$reporterUsernames = array();
|
||||
foreach ($report->getReporters() as $reporter)
|
||||
{
|
||||
$reporterUsernames[count($reporterUsernames)] = $reporter->getUsername();
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="content">
|
||||
<div>
|
||||
<hr>
|
||||
<h2 style="font-family: 'Oswald', sans-serif; text-align: center;">
|
||||
Report #<?= $report->getId() ?>
|
||||
</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 ">
|
||||
<?php for ($i = 0; $i < $displayAmount; $i++):
|
||||
$message = $messages[$i];
|
||||
$typeId = $message->getType();
|
||||
$typeDisplayName = Message::$TYPE_DISPLAY_NAMES[$typeId];
|
||||
$isPM = $typeId == Message::TYPE_PM;
|
||||
|
||||
// If this is a PM, then the "-> <recipient>" suffix will be applied.
|
||||
$involved = $message->getSender()->getUsername() . ($isPM ? " -> " . $message->getRecipients()[0]->getUsername() : "");
|
||||
?>
|
||||
|
||||
<span class="label <?= $isPM ? "label-primary chat pm" : "label-info chat" ?>" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><?= $typeDisplayName ?></span>
|
||||
<span class="black"><?= $involved; ?>:</span> <?= $message->getMessage(); ?>
|
||||
|
||||
<?php if ($i < $displayAmount - 1): // Don't break on the last element ?>
|
||||
<br />
|
||||
<?php endif; ?>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!$expanded && $displayAmount < $messageCount): ?>
|
||||
<br />
|
||||
<a href="<?= getExpandedURL() ?>">Show All (<?= $messageCount ?> messages)</a>
|
||||
<?php endif; ?>
|
||||
</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-12">
|
||||
<i class="fa fa-clock-o fa-fw"></i>
|
||||
<span class="label label-pill label-default" title="<?= $dateTime->format('Y/m/d H:i:s T') ?>"><?= $age . ' old' ?></span>
|
||||
<br>
|
||||
|
||||
<i class="fa fa-user-plus fa-fw"></i>
|
||||
<span class="label label-pill label-success">Reported by <?= implode(", ", $reporterUsernames) ?></span>
|
||||
<br>
|
||||
|
||||
<i class="fa fa-user-times fa-fw"></i>
|
||||
<span class="label label-pill label-danger">Suspect is <?= $report->getSuspect()->getUsername() ?></span>
|
||||
<br>
|
||||
|
||||
<i class="fa fa-gavel fa-fw"></i>
|
||||
<span class="label label-pill label-warning">
|
||||
<?php if ($report->getHandler() != null): ?>
|
||||
Staff Member assigned is <?= $report->getHandler()->getUsername() ?>
|
||||
<?php else: ?>
|
||||
No Staff Member assigned
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<h4><i class="fa fa-users"></i> Users</h4>
|
||||
<hr>
|
||||
<?php foreach($snapshot->getPlayers() as $player): ?>
|
||||
<img src="http://cravatar.eu/avatar/<?= $player->getUUID() ?>/55.png" class="pull-left" />
|
||||
<b class="name"><?= $player->getUsername() ?></b> <span class="label label-staff name"><?= $player->getRank() ?></span><br> <!-- TODO different styling for different ranks -->
|
||||
<code style="font-size: 11px;"><?= $player->getUUID() ?></code>
|
||||
<br><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<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>
|
||||
<?php foreach ($connections as $connection) {
|
||||
$connection->close();
|
||||
} ?>
|
@ -75,7 +75,7 @@ public class ServerManager
|
||||
|
||||
public static ConnectionData getConnection(boolean writeable, String name)
|
||||
{
|
||||
return getConfig(DEFAULT_CONFIG).getConnection(writeable, name);
|
||||
return getDefaultConfig().getConnection(writeable, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,6 +87,14 @@ public class ServerManager
|
||||
return getConnection(writeable, "DefaultConnection");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the default {@link RedisConfig} associated with this manager, providing appropriate connections.
|
||||
*/
|
||||
public static RedisConfig getDefaultConfig()
|
||||
{
|
||||
return getConfig(DEFAULT_CONFIG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link RedisConfig} associated with this manager, providing appropriate connections.
|
||||
*/
|
||||
|
@ -9,6 +9,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import mineplex.core.CustomTagFix;
|
||||
import mineplex.core.FoodDupeFix;
|
||||
import mineplex.core.PacketsInteractionFix;
|
||||
import mineplex.core.chatsnap.publishing.SnapshotPublisher;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.chatsnap.SnapshotManager;
|
||||
import mineplex.core.chatsnap.SnapshotPlugin;
|
||||
import mineplex.core.giveaway.GiveawayManager;
|
||||
import mineplex.core.globalpacket.GlobalPacketManager;
|
||||
import net.minecraft.server.v1_8_R3.BiomeBase;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
@ -21,7 +29,6 @@ import mineplex.core.common.util.FileUtil;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
@ -49,6 +56,8 @@ 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.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
@ -61,8 +70,6 @@ import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import nautilus.game.arcade.broadcast.BroadcastManager;
|
||||
import nautilus.game.arcade.game.GameServerConfig;
|
||||
import net.minecraft.server.v1_8_R3.BiomeBase;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
public class Arcade extends JavaPlugin
|
||||
{
|
||||
@ -141,6 +148,10 @@ public class Arcade extends JavaPlugin
|
||||
FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal);
|
||||
Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
|
||||
new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);
|
||||
SnapshotManager snapshotManager = new SnapshotManager(new SnapshotPublisher(this));
|
||||
ReportManager reportManager = new ReportManager(this, preferenceManager, statsManager, snapshotManager, CommandCenter.Instance.GetClientManager(), serverStatusManager.getCurrentServerName());
|
||||
new SnapshotPlugin(this, snapshotManager);
|
||||
new ReportPlugin(this, reportManager);
|
||||
|
||||
BlockRestore blockRestore = new BlockRestore(this);
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
<module>Mineplex.MapParser</module>
|
||||
<module>Mineplex.Minecraft.Game.ClassCombat</module>
|
||||
<module>Mineplex.Minecraft.Game.Core</module>
|
||||
<module>Mineplex.ReportServer</module>
|
||||
<module>Mineplex.ServerData</module>
|
||||
<module>Mineplex.ServerMonitor</module>
|
||||
<module>Mineplex.StaffServer</module>
|
||||
|
Loading…
Reference in New Issue
Block a user