Merge branch 'development'

This commit is contained in:
Brianna 2020-05-12 17:54:29 -04:00
commit 76a0c296a1
5 changed files with 17 additions and 14 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>UltimateModeration</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1.2.7</version>
<version>1.2.8</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>UltimateModeration-${project.version}</finalName>

View File

@ -184,7 +184,7 @@ public class UltimateModeration extends SongodaPlugin {
if (storage.containsGroup("tickets")) {
for (StorageRow row : storage.getRowsByGroup("tickets")) {
int id = row.get("id").asInt();
int id = Integer.parseInt(row.get("id").asString());
Ticket ticket = new Ticket(
UUID.fromString(row.get("player").asString()),
row.get("subject").asString(),
@ -202,7 +202,7 @@ public class UltimateModeration extends SongodaPlugin {
TicketResponse ticketResponse = new TicketResponse(
UUID.fromString(row.get("author").asString()),
row.get("message").asString(),
row.get("posted").asLong());
Long.parseLong(row.get("posted").asString()));
ticketResponse.setTicketId(id);
ticketManager.getTicket(id).addResponse(ticketResponse);

View File

@ -1,7 +1,6 @@
package com.songoda.ultimatemoderation.commands;
import com.songoda.core.commands.AbstractCommand;
import com.songoda.core.utils.PlayerUtils;
import com.songoda.ultimatemoderation.UltimateModeration;
import com.songoda.ultimatemoderation.punish.Punishment;
import com.songoda.ultimatemoderation.punish.PunishmentType;
@ -11,6 +10,7 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.omg.CORBA.TypeCodePackage.BadKind;
import java.util.ArrayList;
import java.util.Arrays;
@ -55,11 +55,6 @@ public class CommandBan extends AbstractCommand {
return ReturnType.FAILURE;
}
if (sender instanceof Player && VaultPermissions.hasPermission(Bukkit.getWorlds().get(0).getName(), player, "um.ban.exempt")) {
instance.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
if (instance.getPunishmentManager().getPlayer(player).getActivePunishments()
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
instance.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender);
@ -71,8 +66,16 @@ public class CommandBan extends AbstractCommand {
return ReturnType.FAILURE;
}
new Punishment(PunishmentType.BAN, duration == 0 ? -1 : duration, reason.equals("") ? null : reason)
.execute(sender, player);
long durationFinal = duration;
Bukkit.getScheduler().runTaskAsynchronously(instance, () -> {
if (sender instanceof Player && VaultPermissions.hasPermission(Bukkit.getWorlds().get(0).getName(), player, "um.ban.exempt")) {
instance.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender);
return;
}
new Punishment(PunishmentType.BAN, durationFinal == 0 ? -1 : durationFinal, reason.equals("") ? null : reason)
.execute(sender, player);
});
return ReturnType.SUCCESS;
}

View File

@ -28,7 +28,7 @@ public class CommandUnBan extends AbstractCommand {
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
if (player == null) {
if (!player.hasPlayedBefore()) {
instance.getLocale().newMessage("That player does not exist.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}

View File

@ -64,7 +64,7 @@ public abstract class Storage {
}
for (Ticket ticket : instance.getTicketManager().getTickets()) {
prepareSaveItem("tickets", new StorageItem("id", ticket.getTicketId()),
prepareSaveItem("tickets", new StorageItem("id", String.valueOf(ticket.getTicketId())),
new StorageItem("player", ticket.getVictim().toString()),
new StorageItem("subject", ticket.getSubject()),
new StorageItem("type", ticket.getType()),
@ -72,7 +72,7 @@ public abstract class Storage {
new StorageItem("status", ticket.getStatus().toString()));
for (TicketResponse ticketResponse : ticket.getResponses()) {
prepareSaveItem("ticketresponses", new StorageItem("posted", ticketResponse.getPostedDate()),
prepareSaveItem("ticketresponses", new StorageItem("posted", String.valueOf(ticketResponse.getPostedDate())),
new StorageItem("ticketid", ticket.getTicketId()),
new StorageItem("author", ticketResponse.getAuthor().toString()),
new StorageItem("message", ticketResponse.getMessage()));