mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
Add smite command and a few other fixes
This commit is contained in:
parent
6f7fcc5b51
commit
fb17c4c858
@ -109,7 +109,7 @@ public class Plex extends JavaPlugin
|
|||||||
|
|
||||||
system = config.getString("system");
|
system = config.getString("system");
|
||||||
|
|
||||||
PlexLog.log("Attempting to connect to DB: {0}", plugin.config.getString("data.central.storage"));
|
PlexLog.log("Attempting to connect to DB: {0}", plugin.config.getString("data.central.db"));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PlexUtils.testConnections();
|
PlexUtils.testConnections();
|
||||||
|
1
src/main/java/dev/plex/cache/DataUtils.java
vendored
1
src/main/java/dev/plex/cache/DataUtils.java
vendored
@ -44,7 +44,6 @@ public class DataUtils
|
|||||||
return PlayerCache.getPlexPlayerMap().get(uuid);
|
return PlayerCache.getPlexPlayerMap().get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Plex.get().getStorageType() == StorageType.MONGODB)
|
if (Plex.get().getStorageType() == StorageType.MONGODB)
|
||||||
{
|
{
|
||||||
return Plex.get().getMongoPlayerData().getByUUID(uuid);
|
return Plex.get().getMongoPlayerData().getByUUID(uuid);
|
||||||
|
@ -27,9 +27,9 @@ public class CommandSpyCMD extends PlexCommand
|
|||||||
PlexPlayer plexPlayer = DataUtils.getPlayer(playerSender.getUniqueId());
|
PlexPlayer plexPlayer = DataUtils.getPlayer(playerSender.getUniqueId());
|
||||||
plexPlayer.setCommandSpy(!plexPlayer.isCommandSpy());
|
plexPlayer.setCommandSpy(!plexPlayer.isCommandSpy());
|
||||||
DataUtils.update(plexPlayer);
|
DataUtils.update(plexPlayer);
|
||||||
return Component.text(PlexUtils.messageString("toggleCommandSpy")).color(NamedTextColor.GRAY)
|
send(sender, messageComponent("toggleCommandSpy")
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
.append(Component.text(plexPlayer.isCommandSpy() ? PlexUtils.messageString("enabled") : PlexUtils.messageString("disabled")).color(NamedTextColor.GRAY));
|
.append(plexPlayer.isCommandSpy() ? messageComponent("enabled") : messageComponent("disabled")));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -34,7 +37,8 @@ public class EntityWipeCMD extends PlexCommand
|
|||||||
List<String> entityWhitelist = new LinkedList<>(Arrays.asList(args));
|
List<String> entityWhitelist = new LinkedList<>(Arrays.asList(args));
|
||||||
|
|
||||||
EntityType[] entityTypes = EntityType.values();
|
EntityType[] entityTypes = EntityType.values();
|
||||||
entityWhitelist.removeIf(name -> {
|
entityWhitelist.removeIf(name ->
|
||||||
|
{
|
||||||
boolean res = Arrays.stream(entityTypes).noneMatch(entityType -> name.equalsIgnoreCase(entityType.name()));
|
boolean res = Arrays.stream(entityTypes).noneMatch(entityType -> name.equalsIgnoreCase(entityType.name()));
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
@ -53,15 +57,10 @@ public class EntityWipeCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (entity.getType() != EntityType.PLAYER)
|
if (entity.getType() != EntityType.PLAYER)
|
||||||
{
|
{
|
||||||
String type = entity.getType().name();
|
String type = entity.getName();
|
||||||
|
|
||||||
if (useBlacklist ? entityBlacklist.stream().noneMatch(entityName -> entityName.equalsIgnoreCase(type)) : entityWhitelist.stream().anyMatch(entityName -> entityName.equalsIgnoreCase(type)))
|
if (useBlacklist ? entityBlacklist.stream().noneMatch(entityName -> entityName.equalsIgnoreCase(type)) : entityWhitelist.stream().anyMatch(entityName -> entityName.equalsIgnoreCase(type)))
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
Location loc = entity.getLocation();
|
|
||||||
loc.setY(-500);
|
|
||||||
entity.teleportAsync(loc);
|
|
||||||
*/
|
|
||||||
entity.remove();
|
entity.remove();
|
||||||
|
|
||||||
entityCounts.put(type, entityCounts.getOrDefault(type, 0) + 1);
|
entityCounts.put(type, entityCounts.getOrDefault(type, 0) + 1);
|
||||||
@ -88,9 +87,25 @@ public class EntityWipeCMD extends PlexCommand
|
|||||||
PlexUtils.broadcast(messageComponent("removedEntitiesOfTypes", sender.getName(), entityCount, list));
|
PlexUtils.broadcast(messageComponent("removedEntitiesOfTypes", sender.getName(), entityCount, list));
|
||||||
}
|
}
|
||||||
|
|
||||||
entityCounts.forEach((entityName, numRemoved) -> {
|
/*entityCounts.forEach((entityName, numRemoved) -> {
|
||||||
sender.sendMessage(messageComponent("removedEntitiesOfType", sender.getName(), numRemoved, entityName));
|
sender.sendMessage(messageComponent("removedEntitiesOfType", sender.getName(), numRemoved, entityName));
|
||||||
});
|
});*/
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
List<String> entities = new ArrayList<>();
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
{
|
||||||
|
for (Entity entity : world.getEntities())
|
||||||
|
{
|
||||||
|
if (entity.getType() != EntityType.PLAYER)
|
||||||
|
{
|
||||||
|
entities.add(entity.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entities.stream().toList();
|
||||||
|
}
|
||||||
}
|
}
|
@ -33,12 +33,6 @@ public class MobPurgeCMD extends PlexCommand
|
|||||||
if (entity instanceof Mob)
|
if (entity instanceof Mob)
|
||||||
{
|
{
|
||||||
String type = entity.getType().name();
|
String type = entity.getType().name();
|
||||||
|
|
||||||
/*
|
|
||||||
Location loc = entity.getLocation();
|
|
||||||
loc.setY(-500);
|
|
||||||
entity.teleportAsync(loc);
|
|
||||||
*/
|
|
||||||
entity.remove();
|
entity.remove();
|
||||||
|
|
||||||
entityCounts.put(type, entityCounts.getOrDefault(type, 0) + 1);
|
entityCounts.put(type, entityCounts.getOrDefault(type, 0) + 1);
|
||||||
@ -50,9 +44,9 @@ public class MobPurgeCMD extends PlexCommand
|
|||||||
|
|
||||||
PlexUtils.broadcast(messageComponent("removedMobs", sender.getName(), entityCount));
|
PlexUtils.broadcast(messageComponent("removedMobs", sender.getName(), entityCount));
|
||||||
|
|
||||||
entityCounts.forEach((entityName, numRemoved) -> {
|
/*entityCounts.forEach((entityName, numRemoved) -> {
|
||||||
sender.sendMessage(messageComponent("removedEntitiesOfType", sender.getName(), numRemoved, entityName));
|
sender.sendMessage(messageComponent("removedEntitiesOfType", sender.getName(), numRemoved, entityName));
|
||||||
});
|
});*/
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -56,32 +56,17 @@ public class NotesCMD extends PlexCommand
|
|||||||
send(sender, mmString("<red>This player has no notes!"));
|
send(sender, mmString("<red>This player has no notes!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AtomicReference<Component> noteList = new AtomicReference<>(Component.text("Player notes for: " + plexPlayer.getName()).color(NamedTextColor.GREEN));
|
readNotes(sender, plexPlayer, notes);
|
||||||
for (Note note : notes)
|
|
||||||
{
|
|
||||||
Component noteLine = Component.text(note.getId() + " - Written by: " + DataUtils.getPlayer(note.getWrittenBy()).getName() + " on " + DATE_FORMAT.format(note.getTimestamp())).color(NamedTextColor.YELLOW).decoration(TextDecoration.ITALIC, false);
|
|
||||||
noteLine = noteLine.append(Component.text(note.getNote())).color(NamedTextColor.GOLD).decoration(TextDecoration.ITALIC, true);
|
|
||||||
noteList.set(noteList.get().append(Component.newline()));
|
|
||||||
noteList.set(noteList.get().append(noteLine));
|
|
||||||
}
|
|
||||||
send(sender, noteList.get());
|
|
||||||
});
|
});
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
List<Note> notes = plexPlayer.getNotes();
|
List<Note> notes = plexPlayer.getNotes();
|
||||||
if (notes.size() == 0)
|
if (notes.size() == 0)
|
||||||
{
|
{
|
||||||
return mmString("<red>This player has no notes!");
|
return mmString("<red>This player has no notes!");
|
||||||
}
|
}
|
||||||
AtomicReference<Component> noteList = new AtomicReference<>(Component.text("Player notes for: " + plexPlayer.getName()).color(NamedTextColor.GREEN));
|
readNotes(sender, plexPlayer, notes);
|
||||||
for (Note note : notes)
|
|
||||||
{
|
|
||||||
Component noteLine = Component.text(note.getId() + " - Written by: " + DataUtils.getPlayer(note.getWrittenBy()).getName() + " on " + DATE_FORMAT.format(note.getTimestamp())).color(NamedTextColor.YELLOW).decoration(TextDecoration.ITALIC, false);
|
|
||||||
noteLine = noteLine.append(Component.text(note.getNote())).color(NamedTextColor.GOLD).decoration(TextDecoration.ITALIC, true);
|
|
||||||
noteList.set(noteList.get().append(Component.newline()));
|
|
||||||
noteList.set(noteList.get().append(noteLine));
|
|
||||||
}
|
|
||||||
send(sender, noteList.get());
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -99,7 +84,8 @@ public class NotesCMD extends PlexCommand
|
|||||||
if (plugin.getStorageType() != StorageType.MONGODB)
|
if (plugin.getStorageType() != StorageType.MONGODB)
|
||||||
{
|
{
|
||||||
plugin.getSqlNotes().addNote(note);
|
plugin.getSqlNotes().addNote(note);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
DataUtils.update(plexPlayer);
|
DataUtils.update(plexPlayer);
|
||||||
}
|
}
|
||||||
@ -112,7 +98,8 @@ public class NotesCMD extends PlexCommand
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
id = Integer.parseInt(args[2]);
|
id = Integer.parseInt(args[2]);
|
||||||
} catch (NumberFormatException ignored)
|
}
|
||||||
|
catch (NumberFormatException ignored)
|
||||||
{
|
{
|
||||||
return Component.text("Invalid number: " + args[2]).color(NamedTextColor.RED);
|
return Component.text("Invalid number: " + args[2]).color(NamedTextColor.RED);
|
||||||
}
|
}
|
||||||
@ -126,14 +113,16 @@ public class NotesCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
plugin.getSqlNotes().deleteNote(id, plexPlayer.getUuid()).whenComplete((notes1, ex1) ->
|
plugin.getSqlNotes().deleteNote(id, plexPlayer.getUuid()).whenComplete((notes1, ex1) ->
|
||||||
send(sender, Component.text("Removed note with ID: " + id).color(NamedTextColor.GREEN)));
|
send(sender, Component.text("Removed note with ID: " + id).color(NamedTextColor.GREEN)));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
send(sender, mmString("<red>A note with this ID could not be found"));
|
send(sender, mmString("<red>A note with this ID could not be found"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plexPlayer.getNotes().removeIf(note -> note.getId() == id);
|
plexPlayer.getNotes().removeIf(note -> note.getId() == id);
|
||||||
});
|
});
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (plexPlayer.getNotes().removeIf(note -> note.getId() == id))
|
if (plexPlayer.getNotes().removeIf(note -> note.getId() == id))
|
||||||
{
|
{
|
||||||
@ -155,7 +144,9 @@ public class NotesCMD extends PlexCommand
|
|||||||
plexPlayer.getNotes().clear();
|
plexPlayer.getNotes().clear();
|
||||||
send(sender, Component.text("Cleared " + notes.size() + " note(s).").color(NamedTextColor.GREEN));
|
send(sender, Component.text("Cleared " + notes.size() + " note(s).").color(NamedTextColor.GREEN));
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
int count = plexPlayer.getNotes().size();
|
int count = plexPlayer.getNotes().size();
|
||||||
plexPlayer.getNotes().clear();
|
plexPlayer.getNotes().clear();
|
||||||
DataUtils.update(plexPlayer);
|
DataUtils.update(plexPlayer);
|
||||||
@ -170,6 +161,19 @@ public class NotesCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void readNotes(@NotNull CommandSender sender, PlexPlayer plexPlayer, List<Note> notes)
|
||||||
|
{
|
||||||
|
AtomicReference<Component> noteList = new AtomicReference<>(Component.text("Player notes for: " + plexPlayer.getName()).color(NamedTextColor.GREEN));
|
||||||
|
for (Note note : notes)
|
||||||
|
{
|
||||||
|
Component noteLine = Component.text(note.getId() + " - Written by: " + DataUtils.getPlayer(note.getWrittenBy()).getName() + " on " + DATE_FORMAT.format(note.getTimestamp())).color(NamedTextColor.YELLOW).decoration(TextDecoration.ITALIC, false);
|
||||||
|
noteLine = noteLine.append(Component.text(note.getNote())).color(NamedTextColor.GOLD).decoration(TextDecoration.ITALIC, true);
|
||||||
|
noteList.set(noteList.get().append(Component.newline()));
|
||||||
|
noteList.set(noteList.get().append(noteLine));
|
||||||
|
}
|
||||||
|
send(sender, noteList.get());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,9 @@ import dev.plex.command.annotation.System;
|
|||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -41,4 +44,14 @@ public class RankCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
return PlexUtils.getPlayerNameList();
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
150
src/main/java/dev/plex/command/impl/SmiteCMD.java
Normal file
150
src/main/java/dev/plex/command/impl/SmiteCMD.java
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import dev.plex.punishment.Punishment;
|
||||||
|
import dev.plex.punishment.PunishmentType;
|
||||||
|
import dev.plex.rank.enums.Rank;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.smite", source = RequiredCommandSource.ANY)
|
||||||
|
@CommandParameters(name = "smite", usage = "/<command> <player> [reason] [-ci | -q]", description = "Someone being a little bitch? Smite them down...")
|
||||||
|
public class SmiteCMD extends PlexCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
boolean silent = false;
|
||||||
|
boolean clearinv = false;
|
||||||
|
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
silent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 3)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args[args.length - 1].equalsIgnoreCase("-ci"))
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-ci"))
|
||||||
|
{
|
||||||
|
clearinv = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 3)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getNonNullPlayer(args[0]);
|
||||||
|
final PlexPlayer plexPlayer = getPlexPlayer(player);
|
||||||
|
|
||||||
|
Title title = Title.title(Component.text("You've been smitten.").color(NamedTextColor.RED), Component.text("Be sure to follow the rules!").color(NamedTextColor.YELLOW));
|
||||||
|
player.showTitle(title);
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
PlexUtils.broadcast(mmString("<red>" + player.getName() + " has been a naughty, naughty boy."));
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
PlexUtils.broadcast(mmString(" <red>Reason: " + "<yellow>" + reason));
|
||||||
|
}
|
||||||
|
PlexUtils.broadcast(mmString(" <red>Smitten by: " + "<yellow>" + sender.getName()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
send(sender, "Smitten " + player.getName() + " quietly.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deop
|
||||||
|
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||||
|
{
|
||||||
|
player.setOp(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set gamemode to survival
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
|
// Clear inventory
|
||||||
|
if (clearinv)
|
||||||
|
{
|
||||||
|
player.getInventory().clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strike with lightning effect
|
||||||
|
final Location targetPos = player.getLocation();
|
||||||
|
final World world = player.getWorld();
|
||||||
|
for (int x = -1; x <= 1; x++)
|
||||||
|
{
|
||||||
|
for (int z = -1; z <= 1; z++)
|
||||||
|
{
|
||||||
|
final Location strike_pos = new Location(world, targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||||
|
world.strikeLightning(strike_pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kill
|
||||||
|
player.setHealth(0.0);
|
||||||
|
|
||||||
|
Punishment punishment = new Punishment(plexPlayer.getUuid(), getUUID(sender));
|
||||||
|
punishment.setCustomTime(false);
|
||||||
|
punishment.setEndDate(LocalDateTime.now());
|
||||||
|
punishment.setType(PunishmentType.SMITE);
|
||||||
|
punishment.setPunishedUsername(player.getName());
|
||||||
|
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||||
|
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
punishment.setReason(reason);
|
||||||
|
send(player, mmString("<red>You've been smitten. Reason: <yellow>" + reason));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
|
{
|
||||||
|
if (checkTab(sender, Rank.ADMIN, "plex.smite") && args.length == 1)
|
||||||
|
{
|
||||||
|
return PlexUtils.getPlayerNameList();
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
@ -33,7 +33,8 @@ public class PlayerListener extends PlexListener
|
|||||||
{
|
{
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
PlexLog.debug("Automatically opped " + player.getName() + " since ranks are enabled.");
|
PlexLog.debug("Automatically opped " + player.getName() + " since ranks are enabled.");
|
||||||
} else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
}
|
||||||
|
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||||
{
|
{
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
PlexLog.debug("Automatically deopped " + player.getName() + " since ranks are disabled.");
|
PlexLog.debug("Automatically deopped " + player.getName() + " since ranks are disabled.");
|
||||||
@ -46,7 +47,8 @@ public class PlayerListener extends PlexListener
|
|||||||
plexPlayer.setName(player.getName()); // set the name of the player
|
plexPlayer.setName(player.getName()); // set the name of the player
|
||||||
plexPlayer.setIps(Arrays.asList(player.getAddress().getAddress().getHostAddress().trim())); // set the arraylist of ips
|
plexPlayer.setIps(Arrays.asList(player.getAddress().getAddress().getHostAddress().trim())); // set the arraylist of ips
|
||||||
DataUtils.insert(plexPlayer); // insert data in some wack db
|
DataUtils.insert(plexPlayer); // insert data in some wack db
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||||
List<String> ips = plexPlayer.getIps();
|
List<String> ips = plexPlayer.getIps();
|
||||||
|
@ -135,6 +135,10 @@ public class PunishmentManager extends PlexBase
|
|||||||
|
|
||||||
public boolean isBanned(UUID uuid)
|
public boolean isBanned(UUID uuid)
|
||||||
{
|
{
|
||||||
|
/*if (!DataUtils.hasPlayedBefore(uuid))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
return DataUtils.getPlayer(uuid).getPunishments().stream().anyMatch(punishment -> punishment.getType() == PunishmentType.BAN && punishment.isActive());
|
return DataUtils.getPlayer(uuid).getPunishments().stream().anyMatch(punishment -> punishment.getType() == PunishmentType.BAN && punishment.isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,5 +2,5 @@ package dev.plex.punishment;
|
|||||||
|
|
||||||
public enum PunishmentType
|
public enum PunishmentType
|
||||||
{
|
{
|
||||||
MUTE, FREEZE, BAN, KICK
|
MUTE, FREEZE, BAN, KICK, SMITE
|
||||||
}
|
}
|
||||||
|
@ -97,18 +97,21 @@ public class PlexUtils extends PlexBase
|
|||||||
if (Plex.get().getStorageType() == StorageType.MARIADB)
|
if (Plex.get().getStorageType() == StorageType.MARIADB)
|
||||||
{
|
{
|
||||||
PlexLog.log("Successfully enabled MySQL!");
|
PlexLog.log("Successfully enabled MySQL!");
|
||||||
} else if (Plex.get().getStorageType() == StorageType.SQLITE)
|
}
|
||||||
|
else if (Plex.get().getStorageType() == StorageType.SQLITE)
|
||||||
{
|
{
|
||||||
PlexLog.log("Successfully enabled SQLite!");
|
PlexLog.log("Successfully enabled SQLite!");
|
||||||
}
|
}
|
||||||
} catch (SQLException e)
|
}
|
||||||
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
if (Plex.get().getMongoConnection().getDatastore() != null)
|
if (Plex.get().getMongoConnection().getDatastore() != null)
|
||||||
{
|
{
|
||||||
PlexLog.log("Successfully enabled MongoDB!");
|
PlexLog.log("Successfully enabled MongoDB!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (Plex.get().getMongoConnection().getDatastore() != null)
|
if (Plex.get().getMongoConnection().getDatastore() != null)
|
||||||
{
|
{
|
||||||
@ -154,13 +157,9 @@ public class PlexUtils extends PlexBase
|
|||||||
{
|
{
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
/*for (Object object : objects)
|
|
||||||
{
|
|
||||||
f = f.replaceFirst("<v>", String.valueOf(object));
|
|
||||||
}*/
|
|
||||||
for (int i = 0; i < objects.length; i++)
|
for (int i = 0; i < objects.length; i++)
|
||||||
{
|
{
|
||||||
f = f.replace("{" + i + "}", PlainTextComponentSerializer.plainText().serialize(MiniMessage.miniMessage().deserialize(String.valueOf(objects[i]))));
|
f = f.replace("{" + i + "}", String.valueOf(objects[i]));
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
@ -219,10 +218,12 @@ public class PlexUtils extends PlexBase
|
|||||||
if (config.getString(path) == null)
|
if (config.getString(path) == null)
|
||||||
{
|
{
|
||||||
color = def;
|
color = def;
|
||||||
} else if (ChatColor.getByChar(config.getString(path)) == null)
|
}
|
||||||
|
else if (ChatColor.getByChar(config.getString(path)) == null)
|
||||||
{
|
{
|
||||||
color = def;
|
color = def;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
color = ChatColor.getByChar(config.getString(path));
|
color = ChatColor.getByChar(config.getString(path));
|
||||||
}
|
}
|
||||||
@ -274,7 +275,8 @@ public class PlexUtils extends PlexBase
|
|||||||
{
|
{
|
||||||
world.setGameRule(rule, value);
|
world.setGameRule(rule, value);
|
||||||
PlexLog.debug("Setting game rule " + gameRule + " for world " + world.getName() + " with value " + value);
|
PlexLog.debug("Setting game rule " + gameRule + " for world " + world.getName() + " with value " + value);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
PlexLog.error(String.format("Failed to set game rule %s for world %s with value %s!", gameRule, world.getName().toLowerCase(Locale.ROOT), value));
|
PlexLog.error(String.format("Failed to set game rule %s for world %s with value %s!", gameRule, world.getName().toLowerCase(Locale.ROOT), value));
|
||||||
}
|
}
|
||||||
@ -326,7 +328,8 @@ public class PlexUtils extends PlexBase
|
|||||||
in.close();
|
in.close();
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
return new JSONParser().parse(content.toString());
|
return new JSONParser().parse(content.toString());
|
||||||
} catch (IOException | ParseException ex)
|
}
|
||||||
|
catch (IOException | ParseException ex)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -359,12 +362,14 @@ public class PlexUtils extends PlexBase
|
|||||||
{
|
{
|
||||||
Class<?> clazz = Class.forName(info.getName());
|
Class<?> clazz = Class.forName(info.getName());
|
||||||
classes.add(clazz);
|
classes.add(clazz);
|
||||||
} catch (ClassNotFoundException ex)
|
}
|
||||||
|
catch (ClassNotFoundException ex)
|
||||||
{
|
{
|
||||||
PlexLog.error("Unable to find class " + info.getName() + " in " + packageName);
|
PlexLog.error("Unable to find class " + info.getName() + " in " + packageName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IOException ex)
|
}
|
||||||
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
PlexLog.error("Something went wrong while fetching classes from " + packageName);
|
PlexLog.error("Something went wrong while fetching classes from " + packageName);
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
|
@ -78,6 +78,7 @@ consoleMustDefinePlayer: "<red>You must define a player since you are running th
|
|||||||
newAdminAdded: "<aqua>{0} - Adding {1} to the admin list"
|
newAdminAdded: "<aqua>{0} - Adding {1} to the admin list"
|
||||||
# 0 - The command sender
|
# 0 - The command sender
|
||||||
# 1 - The player
|
# 1 - The player
|
||||||
|
# 2 - The rank name
|
||||||
adminReadded: "<aqua>{0} - Re-adding {1} to the admin list as rank: {2}"
|
adminReadded: "<aqua>{0} - Re-adding {1} to the admin list as rank: {2}"
|
||||||
# 0 - The command sender
|
# 0 - The command sender
|
||||||
# 1 - The player
|
# 1 - The player
|
||||||
|
Loading…
Reference in New Issue
Block a user