Skip to content

Commit

Permalink
Version 1.0.0 BETA
Browse files Browse the repository at this point in the history
- Massive Database Update
- Support for Sqlite, MySql and MariaDB
- Inventory Improvements
- DAO System
- Services Improvements
- Auditing improvements in console
- Fixed File configuration problems
- Fixed lots of other smalls bugs

- WARNING THIS RELEASE WILL HAVE A LOT OF BUGS IN-REGARDS TO
DATABASES AND HASN'T BEEN TESTED ON MYSQL AND MARIADB
  • Loading branch information
HuskyDreaming committed Sep 13, 2024
1 parent b20cb14 commit beafd15
Show file tree
Hide file tree
Showing 129 changed files with 3,511 additions and 1,709 deletions.
7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.huskydreaming</groupId>
<artifactId>Settlements</artifactId>
<version>0.8.4-ALPHA</version>
<version>1.0.0-BETA</version>
<build>
<plugins>
<plugin>
Expand All @@ -23,9 +23,10 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -58,24 +59,27 @@
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>LATEST</version>
<version>7.0.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.5</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>towny</artifactId>
<version>0.100.1.0</version>
<version>0.100.3.13</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<java.version>21</java.version>
<maven.compiler.source>21</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
</project>
24 changes: 14 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

<groupId>com.huskydreaming</groupId>
<artifactId>Settlements</artifactId>
<version>0.8.4-ALPHA</version>
<version>1.0.0-BETA</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<java.version>21</java.version>
</properties>

<build>
Expand All @@ -34,9 +37,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -72,12 +76,12 @@
<dependency>
<groupId>com.huskydreaming</groupId>
<artifactId>HuskyCore</artifactId>
<version>1.2-SNAPSHOT</version>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>24.0.1</version>
<version>24.1.0</version>
</dependency>
<dependency>
<groupId>fr.minuskube.inv</groupId>
Expand All @@ -87,19 +91,19 @@
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>LATEST</version>
<version>7.0.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.5</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>towny</artifactId>
<version>0.100.1.0</version>
<version>0.100.3.13</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
58 changes: 28 additions & 30 deletions src/main/java/com/huskydreaming/settlements/SettlementPlugin.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.huskydreaming.settlements;

import com.huskydreaming.huskycore.HuskyPlugin;
import com.huskydreaming.huskycore.implementations.DatabaseMigrationServiceImpl;
import com.huskydreaming.huskycore.implementations.DatabaseServiceImpl;
import com.huskydreaming.huskycore.interfaces.database.base.DatabaseMigrationService;
import com.huskydreaming.huskycore.interfaces.database.base.DatabaseService;
import com.huskydreaming.settlements.commands.BaseCommand;
import com.huskydreaming.settlements.commands.subcommands.*;
import com.huskydreaming.settlements.database.migrations._1_InitialMigration;
import com.huskydreaming.settlements.listeners.FlagListener;
import com.huskydreaming.settlements.listeners.LandListener;
import com.huskydreaming.settlements.listeners.MemberListener;
import com.huskydreaming.settlements.storage.persistence.Config;
import com.huskydreaming.settlements.services.implementations.*;
import com.huskydreaming.settlements.services.interfaces.*;
import com.sk89q.worldguard.protection.flags.Flag;

public class SettlementPlugin extends HuskyPlugin {

Expand All @@ -19,7 +22,11 @@ public void onEnable() {

registerServices();
registerCommands();
registerListeners(new LandListener(this), new MemberListener(this), new FlagListener(this));
registerListeners(
new LandListener(this),
new MemberListener(this),
new FlagListener(this)
);
}

@Override
Expand All @@ -28,26 +35,36 @@ public void onDisable() {
}

private void registerServices() {
// Setup database
DatabaseService databaseService = new DatabaseServiceImpl(this);
DatabaseMigrationService databaseMigrationService = new DatabaseMigrationServiceImpl();
databaseMigrationService.setConnector(databaseService.getDatabaseConnector());
databaseMigrationService.loadMigrations(new _1_InitialMigration());

serviceRegistry.register(ConfigService.class, new ConfigServiceImpl());
serviceRegistry.register(LocaleService.class, new LocaleServiceImpl(this));
serviceRegistry.register(LocaleService.class, new LocaleServiceImpl());
serviceRegistry.register(DatabaseService.class, databaseService);
serviceRegistry.register(DatabaseMigrationService.class, databaseMigrationService);
serviceRegistry.register(DependencyService.class, new DependencyServiceImpl());
serviceRegistry.register(HomeService.class, new HomeServiceImpl());
serviceRegistry.register(MemberService.class, new MemberServiceImpl());
serviceRegistry.register(SettlementService.class, new SettlementServiceImpl(this));
serviceRegistry.register(ClaimService.class, new ClaimServiceImpl(this));
serviceRegistry.register(ContainerService.class, new ContainerServiceImpl(this));
serviceRegistry.register(FlagService.class, new FlagServiceImpl(this));
serviceRegistry.register(HomeService.class, new HomeServiceImpl(this));
serviceRegistry.register(RoleService.class, new RoleServiceImpl(this));
serviceRegistry.register(MemberService.class, new MemberServiceImpl(this));
serviceRegistry.register(PermissionService.class, new PermissionServiceImpl(this));
serviceRegistry.register(NotificationService.class, new NotificationServiceImpl(this));
serviceRegistry.register(InvitationService.class, new InvitationServiceImpl());
serviceRegistry.register(RoleService.class, new RoleServiceImpl(this));
serviceRegistry.register(TrustService.class, new TrustServiceImpl());
serviceRegistry.register(ClaimService.class, new ClaimServiceImpl());
serviceRegistry.register(TrustService.class, new TrustServiceImpl(this));
serviceRegistry.register(BorderService.class, new BorderServiceImpl(this));
serviceRegistry.register(InventoryService.class, new InventoryServiceImpl(this));

serviceRegistry.deserialize(this);
}

private void registerCommands() {
commandRegistry.setCommandExecutor(new BaseCommand(this));
serviceRegistry.provide(ConfigService.class).setup(this);
commandRegistry.add(new AcceptCommand(this));
commandRegistry.add(new AdminCommand(this));
commandRegistry.add(new AutoClaimCommand(this));
Expand All @@ -65,27 +82,8 @@ private void registerCommands() {
commandRegistry.add(new ReloadCommand(this));
commandRegistry.add(new SetDescriptionCommand(this));
commandRegistry.add(new SetOwnerCommand(this));
commandRegistry.add(new SetRoleCommand(this));
commandRegistry.add(new SetTagCommand(this));

ConfigService configService = serviceRegistry.provide(ConfigService.class);
Config config = configService.getConfig();

if(config.isTeleportation()) {
commandRegistry.add(new SpawnCommand(this));
commandRegistry.add(new SetSpawnCommand(this));
}

if(config.isTrusting()) {
commandRegistry.add(new TrustCommand(this));
commandRegistry.add(new UnTrustCommand(this));
}

if(config.isHomes()) {
commandRegistry.add(new DeleteHomeCommand(this));
commandRegistry.add(new HomeCommand(this));
commandRegistry.add(new SetHomeCommand(this));
}

commandRegistry.add(new UnClaimCommand(this));
commandRegistry.deserialize(this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.huskydreaming.settlements.commands;

import com.huskydreaming.huskycore.HuskyPlugin;
import com.huskydreaming.huskycore.commands.CommandAnnotation;
import com.huskydreaming.huskycore.commands.abstraction.AbstractCommand;
import com.huskydreaming.huskycore.abstraction.AbstractCommand;
import com.huskydreaming.huskycore.annotations.CommandAnnotation;
import com.huskydreaming.huskycore.interfaces.Parseable;
import com.huskydreaming.settlements.commands.subcommands.HelpCommand;
import com.huskydreaming.settlements.services.interfaces.InventoryService;
import com.huskydreaming.settlements.services.interfaces.MemberService;
import com.huskydreaming.settlements.storage.types.Message;
import com.huskydreaming.settlements.enumeration.locale.Message;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class CommandLabel {
public final static String SET_DESCRIPTION = "setdescription";
public static final String SET_HOME = "sethome";
public final static String SET_OWNER = "setowner";
public final static String SET_ROLE = "setrole";
public final static String SET_SPAWN = "setspawn";
public final static String SET_TAG = "settag";
public final static String SETTLEMENTS = "settlements";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.huskydreaming.settlements.commands.subcommands;

import com.huskydreaming.huskycore.HuskyPlugin;
import com.huskydreaming.huskycore.commands.CommandAnnotation;
import com.huskydreaming.huskycore.commands.providers.PlayerCommandProvider;
import com.huskydreaming.huskycore.annotations.CommandAnnotation;
import com.huskydreaming.huskycore.interfaces.command.providers.PlayerCommandProvider;
import com.huskydreaming.settlements.commands.CommandLabel;
import com.huskydreaming.settlements.storage.persistence.Settlement;
import com.huskydreaming.settlements.database.entities.*;
import com.huskydreaming.settlements.services.interfaces.*;
import com.huskydreaming.settlements.storage.types.Message;
import com.huskydreaming.settlements.enumeration.locale.Message;
import org.bukkit.Chunk;
import org.bukkit.Color;
import org.bukkit.OfflinePlayer;
Expand All @@ -22,6 +22,7 @@ public class AcceptCommand implements PlayerCommandProvider {
private final ClaimService claimService;
private final MemberService memberService;
private final InvitationService invitationService;
private final RoleService roleService;
private final SettlementService settlementService;
private final TrustService trustService;

Expand All @@ -30,6 +31,7 @@ public AcceptCommand(HuskyPlugin plugin) {
claimService = plugin.provide(ClaimService.class);
memberService = plugin.provide(MemberService.class);
invitationService = plugin.provide(InvitationService.class);
roleService = plugin.provide(RoleService.class);
settlementService = plugin.provide(SettlementService.class);
trustService = plugin.provide(TrustService.class);
}
Expand All @@ -38,44 +40,50 @@ public AcceptCommand(HuskyPlugin plugin) {
public void onCommand(Player player, String[] strings) {
if (strings.length != 2) return;
String string = strings[1];
if (invitationService.hasNoInvitation(player, string)) {
player.sendMessage(Message.INVITATION_NULL.prefix(string));
return;
}

Settlement settlement = settlementService.getSettlement(string);
if (settlement == null) {
player.sendMessage(Message.NULL.prefix(string));
return;
}

for(OfflinePlayer offlinePlayer : memberService.getOfflinePlayers(string)) {
if (invitationService.hasNoInvitation(player, settlement)) {
player.sendMessage(Message.INVITATION_NULL.prefix(string));
return;
}

for(OfflinePlayer offlinePlayer : memberService.getOfflinePlayers(settlement)) {
if (!offlinePlayer.isOnline()) return;
Player onlinePlayer = offlinePlayer.getPlayer();

if (onlinePlayer == null) return;
onlinePlayer.sendMessage(Message.JOIN_PLAYER.prefix(player.getName()));
}

borderService.removePlayer(player);
invitationService.removeInvitation(player, string);
trustService.unTrust(player, string);
Role role = roleService.getRole(settlement.getRoleId());
if(role == null) {
player.sendMessage(Message.ROLE_DEFAULT.prefix(settlement.getName()));
return;
}

memberService.add(player, string, settlement.getDefaultRole());
borderService.removePlayer(player);
invitationService.removeInvitation(player, settlement);
trustService.unTrust(player, settlement);
memberService.addMember(player, role, settlement);
player.sendMessage(Message.JOIN.prefix(string));

Chunk chunk = player.getLocation().getChunk();
if (!claimService.isClaim(chunk)) return;
Claim claim = claimService.getClaim(settlement, chunk);
if(claim == null) return;

String claim = claimService.getClaim(player.getLocation().getChunk());
borderService.addPlayer(player, claim, claim.equalsIgnoreCase(string) ? Color.AQUA : Color.RED);
borderService.addPlayer(player, settlement, Color.GREEN);
}

@Override
public List<String> onTabComplete(Player player, String[] strings) {
if (strings.length == 2) {
Set<String> invitations = invitationService.getInvitations(player);
if(invitations != null) return invitations.stream().toList();
Set<Long> invitations = invitationService.getInvitations(player);
Set<Settlement> settlements = settlementService.getSettlements(invitations);
if(invitations != null) return settlements.stream().map(Settlement::getName).toList();
}
return List.of();
}
Expand Down
Loading

0 comments on commit beafd15

Please sign in to comment.