Merge branch 'development'

This commit is contained in:
Brianna 2020-02-01 06:42:07 -05:00
commit d896464217
7 changed files with 93 additions and 44 deletions

View File

@ -1,21 +0,0 @@
stages:
- build
variables:
name: "UltimateModeration"
path: "/builds/$CI_PROJECT_PATH"
version: "1.2.3"
build:
stage: build
image: maven:3.5.3-jdk-8
script:
- find $path/ -type f -name "*.xml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- find $path/ -type f -name "*.yml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- mvn clean package
- find $path/ -depth -path '*original*' -delete
- mv $path/target/*.jar $path/
artifacts:
name: $name-$version
paths:
- "$path/*.jar"

34
pom.xml
View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>UltimateModeration</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>maven-version-number</version>
<version>1.2.4</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>UltimateModeration-${project.version}</finalName>
@ -16,6 +16,28 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.directory}/classes/plugin.yml</file>
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
@ -67,12 +89,18 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.14.4</version>
<version>1.15</version>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>abledskyblock</artifactId>
<version>79.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId>
<version>LATEST</version>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -29,6 +29,7 @@ import com.songoda.ultimatemoderation.tickets.TicketStatus;
import com.songoda.ultimatemoderation.utils.Methods;
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import java.util.List;
import java.util.UUID;
@ -111,18 +112,21 @@ public class UltimateModeration extends SongodaPlugin {
// Register Listeners
guiManager.init();
AbstractGUI.initializeListeners(this);
Bukkit.getPluginManager().registerEvents(new CommandListener(this), this);
Bukkit.getPluginManager().registerEvents(new DeathListener(this), this);
Bukkit.getPluginManager().registerEvents(new MoveListener(this), this);
Bukkit.getPluginManager().registerEvents(new DropListener(this), this);
Bukkit.getPluginManager().registerEvents(new InventoryListener(this), this);
Bukkit.getPluginManager().registerEvents(new ChatListener(this), this);
Bukkit.getPluginManager().registerEvents(new LoginListener(this), this);
Bukkit.getPluginManager().registerEvents(new MobTargetLister(), this);
Bukkit.getPluginManager().registerEvents(new BlockListener(this), this);
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new CommandListener(this), this);
pluginManager.registerEvents(new DeathListener(this), this);
pluginManager.registerEvents(new MoveListener(this), this);
pluginManager.registerEvents(new DropListener(this), this);
pluginManager.registerEvents(new InventoryListener(this), this);
pluginManager.registerEvents(new ChatListener(this), this);
pluginManager.registerEvents(new LoginListener(this), this);
pluginManager.registerEvents(new MobTargetLister(), this);
pluginManager.registerEvents(new BlockListener(this), this);
if (pluginManager.isPluginEnabled("FabledSkyBlock"))
pluginManager.registerEvents(new SkyBlockListener(this), this);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
Bukkit.getPluginManager().registerEvents(new SpyingDismountListener(), this);
pluginManager.registerEvents(new SpyingDismountListener(), this);
// Start tasks
SlowModeTask.startTask(this);

View File

@ -38,6 +38,12 @@ public class ChatListener implements Listener {
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if (!onChat(player, event.getMessage()))
event.setCancelled(true);
}
public static boolean onChat(Player player, String message) {
UltimateModeration instance = UltimateModeration.getInstance();
long slowmode = slowModeOverride == 0 ? Methods.parseTime(Settings.SLOW_MODE.getString()) : slowModeOverride;
@ -46,33 +52,35 @@ public class ChatListener implements Listener {
if (chats.size() != 0) {
Log last = chats.get(chats.size() - 1);
if ((System.currentTimeMillis() - last.sent) < slowmode) {
event.setCancelled(true);
return;
return false;
}
}
}
boolean isCancelled = false;
for (StaffChannel channel : instance.getStaffChatManager().getChats().values()) {
if (!channel.listMembers().contains(player.getUniqueId())) continue;
event.setCancelled(true);
channel.processMessage(event.getMessage(), player);
isCancelled = true;
channel.processMessage(message, player);
}
if (!isChatToggled && !player.hasPermission("um.togglechat.bypass")) {
event.setCancelled(true);
isCancelled = true;
instance.getLocale().getMessage("command.togglechat.muted").sendPrefixedMessage(player);
}
List<AppliedPunishment> appliedPunishments = instance.getPunishmentManager().getPlayer(player).getActivePunishments(PunishmentType.MUTE);
if (!appliedPunishments.isEmpty()) {
appliedPunishments.get(0).sendMessage(player);
event.setCancelled(true);
isCancelled = true;
}
// Log chat.
chatLog.add(new Log(player.getUniqueId(), System.currentTimeMillis(), event.getMessage()));
chatLog.add(new Log(player.getUniqueId(), System.currentTimeMillis(), message));
return !isCancelled;
}
public static void setSlowModeOverride(long slowModeOverride) {
@ -83,7 +91,7 @@ public class ChatListener implements Listener {
return new ArrayList<>(chatLog);
}
public class Log {
public static class Log {
private UUID player;
private long sent;

View File

@ -0,0 +1,30 @@
package com.songoda.ultimatemoderation.listeners;
import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent;
import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import java.util.List;
public class SkyBlockListener implements Listener {
private UltimateModeration instance;
public SkyBlockListener(UltimateModeration ultimateModeration) {
this.instance = ultimateModeration;
}
@EventHandler
public void onIslandChat(PlayerIslandChatEvent event) {
if (!ChatListener.onChat(event.getPlayer(), event.getMessage()))
event.setCancelled(true);
}
}

View File

@ -49,7 +49,7 @@ public abstract class Storage {
new StorageItem("duration", appliedPunishment.getDuration()),
new StorageItem("reason", appliedPunishment.getReason()),
new StorageItem("victim", appliedPunishment.getVictim().toString()),
new StorageItem("punisher", appliedPunishment.getPunisher().toString()),
new StorageItem("punisher", appliedPunishment.getPunisher() == null ? null : appliedPunishment.getPunisher().toString()),
new StorageItem("expiration", appliedPunishment.getExpiration()));
}

View File

@ -4,7 +4,7 @@ main: com.songoda.ultimatemoderation.UltimateModeration
version: maven-version-number
author: Songoda
api-version: 1.13
softdepend: [Vault]
softdepend: [Vault, FabledSkyBlock]
commands:
UltimateModeration:
description: View information on this plugin.