Skip to content

Commit

Permalink
Added MariaDB support
Browse files Browse the repository at this point in the history
  • Loading branch information
AerWyn81 committed Jan 24, 2024
1 parent 1190291 commit 9a6683e
Show file tree
Hide file tree
Showing 9 changed files with 716 additions and 23 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("java")
}

version = "2.4.2"
version = "2.4.3"

allprojects {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public boolean perform(CommandSender sender, String[] args) {
return true;
}

EnumTypeDatabase typeDatabase = EnumTypeDatabase.Of(args[2]);
EnumTypeDatabase typeDatabase = EnumTypeDatabase.of(args[2]);

if (typeDatabase == null) {
sender.sendMessage(MessageUtils.colorize(LanguageService.getPrefix() + " &cThe SQL type &e" + args[2] + " &cis not supported!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import fr.aerwyn81.headblocks.utils.message.MessageUtils;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

import java.util.ArrayList;
Expand All @@ -23,16 +24,21 @@ public class Remove implements Cmd {

@Override
public boolean perform(CommandSender sender, String[] args) {
Player player = (Player) sender;

if (args.length > 2) {
player.sendMessage(LanguageService.getMessage("Messages.ErrorCommand"));
sender.sendMessage(LanguageService.getMessage("Messages.ErrorCommand"));
return true;
}

HeadLocation head;

if (args.length == 1) {
if (sender instanceof ConsoleCommandSender) {
sender.sendMessage(LanguageService.getMessage("Messages.PlayerOnly"));
return true;
}

Player player = (Player) sender;

var targetHead = HeadService.getHeadAt(player.getTargetBlock(null, 25).getLocation());

if (targetHead == null) {
Expand All @@ -44,21 +50,22 @@ public boolean perform(CommandSender sender, String[] args) {
} else {
head = HeadService.getHeadByUUID(UUID.fromString(args[1]));
if (head == null) {
player.sendMessage(LanguageService.getMessage("Messages.RemoveLocationError"));
sender.sendMessage(LanguageService.getMessage("Messages.RemoveLocationError"));
return true;
}
}

Location loc = head.getLocation();

try {
HeadService.removeHeadLocation(head, ConfigService.shouldResetPlayerData());
} catch (InternalException ex) {
sender.sendMessage(LanguageService.getMessage("Messages.StorageError"));
HeadBlocks.log.sendMessage(MessageUtils.colorize("&cError while removing the head (" + head.getUuid().toString() + " at " + head.getLocation().toString() + ") from the storage: " + ex.getMessage()));
HeadBlocks.log.sendMessage(MessageUtils.colorize("&cError while removing the head (" + head.getUuid().toString() + " at " + loc.toString() + ") from the storage: " + ex.getMessage()));
return true;
}

Location loc = head.getLocation();
player.sendMessage(LocationUtils.parseLocationPlaceholders(LanguageService.getMessage("Messages.HeadRemoved"), loc));
sender.sendMessage(LocationUtils.parseLocationPlaceholders(LanguageService.getMessage("Messages.HeadRemoved"), loc));
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.aerwyn81.headblocks.databases;

public enum EnumTypeDatabase {
SQLite, MySQL;
SQLite, MySQL, MariaDB;

static public EnumTypeDatabase Of(String t) {
static public EnumTypeDatabase of(String t) {
EnumTypeDatabase[] types = EnumTypeDatabase.values();
for (EnumTypeDatabase type : types)
if (type.name().equals(t))
Expand Down
Loading

0 comments on commit 9a6683e

Please sign in to comment.