Skip to content

Commit

Permalink
Merge branch 'dev' into feature/optimize-loading-times
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/com/bgsoftware/superiorskyblock/database/serialization/IslandsDeserializer.java
  • Loading branch information
OmerBenGera committed Jan 15, 2022
2 parents 0b023a9 + 9612783 commit 4acf710
Show file tree
Hide file tree
Showing 160 changed files with 1,385 additions and 1,030 deletions.
Expand Up @@ -11,7 +11,8 @@ public class BlockStackEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();

private final Player player;
private final int originalCount, newCount;
private final int originalCount;
private final int newCount;
private boolean cancelled = false;

public BlockStackEvent(Block block, Player player, int originalCount, int newCount) {
Expand Down
Expand Up @@ -13,7 +13,8 @@ public class BlockUnstackEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();

private final Player player;
private final int originalCount, newCount;
private final int originalCount;
private final int newCount;
private boolean cancelled = false;

public BlockUnstackEvent(Block block, Player player, int originalCount, int newCount) {
Expand Down
Expand Up @@ -8,7 +8,8 @@
*/
public class IslandBanEvent extends IslandEvent {

private final SuperiorPlayer superiorPlayer, targetPlayer;
private final SuperiorPlayer superiorPlayer;
private final SuperiorPlayer targetPlayer;

/**
* The constructor of the event.
Expand Down
Expand Up @@ -12,7 +12,6 @@ public class IslandChatEvent extends IslandEvent implements Cancellable {

private final SuperiorPlayer superiorPlayer;
private String message;
private String format;
private boolean cancelled = false;

/**
Expand Down
Expand Up @@ -9,7 +9,8 @@
public class IslandChunkResetEvent extends IslandEvent {

private final World world;
private final int chunkX, chunkZ;
private final int chunkX;
private final int chunkZ;

/**
* The constructor of the event.
Expand Down
Expand Up @@ -9,7 +9,8 @@
*/
public class IslandCoopPlayerEvent extends IslandEvent implements Cancellable {

private final SuperiorPlayer player, target;
private final SuperiorPlayer player;
private final SuperiorPlayer target;
private boolean cancelled = false;

/**
Expand Down
Expand Up @@ -9,7 +9,8 @@
*/
public class IslandInviteEvent extends IslandEvent implements Cancellable {

private final SuperiorPlayer superiorPlayer, targetPlayer;
private final SuperiorPlayer superiorPlayer;
private final SuperiorPlayer targetPlayer;
private boolean cancelled = false;

/**
Expand Down
Expand Up @@ -8,7 +8,8 @@
*/
public class IslandKickEvent extends IslandEvent {

private final SuperiorPlayer superiorPlayer, targetPlayer;
private final SuperiorPlayer superiorPlayer;
private final SuperiorPlayer targetPlayer;

/**
* The constructor of the event.
Expand Down
Expand Up @@ -9,7 +9,8 @@
*/
public class IslandTransferEvent extends IslandEvent implements Cancellable {

private final SuperiorPlayer oldOwner, newOwner;
private final SuperiorPlayer oldOwner;
private final SuperiorPlayer newOwner;
private boolean cancelled = false;

/**
Expand Down
Expand Up @@ -11,7 +11,8 @@
*/
public class IslandUncoopPlayerEvent extends IslandEvent implements Cancellable {

private final SuperiorPlayer player, target;
private final SuperiorPlayer player;
private final SuperiorPlayer target;
private final UncoopReason uncoopReason;
private boolean cancelled = false;

Expand Down
Expand Up @@ -11,7 +11,8 @@
*/
public class IslandWorthCalculatedEvent extends IslandEvent {

private final BigDecimal level, worth;
private final BigDecimal level;
private final BigDecimal worth;
private final SuperiorPlayer player;

/**
Expand Down
Expand Up @@ -9,7 +9,10 @@
*/
public class IslandWorthUpdateEvent extends IslandEvent {

private final BigDecimal oldWorth, oldLevel, newWorth, newLevel;
private final BigDecimal oldWorth;
private final BigDecimal oldLevel;
private final BigDecimal newWorth;
private final BigDecimal newLevel;

/**
* The constructor of the event.
Expand Down
@@ -1,6 +1,7 @@
package com.bgsoftware.superiorskyblock.api.factory;

import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.island.algorithms.IslandBlocksTrackerAlgorithm;
import com.bgsoftware.superiorskyblock.api.island.algorithms.IslandCalculationAlgorithm;

public interface IslandsFactory {
Expand All @@ -19,4 +20,11 @@ public interface IslandsFactory {
*/
IslandCalculationAlgorithm createIslandCalculationAlgorithm(Island island);

/**
* Create a blocks-tracking algorithm for an island.
*
* @param island The island to set the algorithm to.
*/
IslandBlocksTrackerAlgorithm createIslandBlocksTrackerAlgorithm(Island island);

}
Expand Up @@ -551,10 +551,20 @@ public interface Island extends Comparable<Island>, IMissionsHolder {
*
* @param playerRole The role to set the permission to.
* @param islandPrivilege The permission to set.
* @param value The value to give the permission.
* @param value The value to give the permission (Unused)
* @deprecated See {@link #setPermission(PlayerRole, IslandPrivilege)}
*/
@Deprecated
void setPermission(PlayerRole playerRole, IslandPrivilege islandPrivilege, boolean value);

/**
* Set a permission to a specific role.
*
* @param playerRole The role to set the permission to.
* @param islandPrivilege The permission to set.
*/
void setPermission(PlayerRole playerRole, IslandPrivilege islandPrivilege);

/**
* Reset the roles permissions to default values.
*/
Expand Down Expand Up @@ -1171,6 +1181,13 @@ public interface Island extends Comparable<Island>, IMissionsHolder {
*/
int getExactBlockLimit(Key key);

/**
* Get the block key used as a limit for another block key.
*
* @param key The block's key to check.
*/
Key getBlockLimitKey(Key key);

/**
* Get all the blocks limits for the island.
*/
Expand Down
@@ -0,0 +1,63 @@
package com.bgsoftware.superiorskyblock.api.island.algorithms;

import com.bgsoftware.superiorskyblock.api.key.Key;

import java.math.BigInteger;
import java.util.Map;

public interface IslandBlocksTrackerAlgorithm {

/**
* Track a new block with a specific amount.
*
* @param key The block's key that should be tracked.
* @param amount The amount of the block.
* @return Whether the block was successfully tracked.
*/
boolean trackBlock(Key key, BigInteger amount);

/**
* Untrack a block with a specific amount.
*
* @param key The block's key that should be untracked.
* @param amount The amount of the block.
* @return Whether the block was successfully untracked.
*/
boolean untrackBlock(Key key, BigInteger amount);

/**
* Get the amount of blocks that are on the island.
*
* @param key The block's key to check.
*/
BigInteger getBlockCount(Key key);

/**
* Get the amount of blocks that are on the island.
* Unlike getBlockCount(Key), this method returns the count for
* the exactly block that is given as a parameter.
*
* @param key The block's key to check.
*/
BigInteger getExactBlockCount(Key key);

/**
* Get all the blocks that are on the island.
*/
Map<Key, BigInteger> getBlockCounts();

/**
* Clear all the block counts of the island.
*/
void clearBlockCounts();

/**
* Set whether the tracker should be in "loading data mode" or not.
* When loading mode is enabled, the tracker should only track blocks for the given blocks
* and not their variants (limits, global blocks, etc)
*
* @param loadingDataMode loading mode
*/
void setLoadingDataMode(boolean loadingDataMode);

}
Expand Up @@ -186,7 +186,7 @@ public boolean canComplete(SuperiorPlayer superiorPlayer) {
* @param section The mission's section in the config.
*/
public void saveProgress(ConfigurationSection section) {

// Should be overridden by missions.
}

/**
Expand All @@ -195,7 +195,7 @@ public void saveProgress(ConfigurationSection section) {
* @param section The mission's section in the config.
*/
public void loadProgress(ConfigurationSection section) {

// Should be overridden by missions.
}

/**
Expand Down Expand Up @@ -315,7 +315,7 @@ protected Set<Map.Entry<SuperiorPlayer, V>> entrySet() {
* @param itemStack The item of the mission.
*/
public void formatItem(SuperiorPlayer superiorPlayer, ItemStack itemStack) {

// Should be overridden by missions.
}

@Override
Expand Down
Expand Up @@ -18,7 +18,8 @@
*/
public abstract class PluginModule {

private final String moduleName, authorName;
private final String moduleName;
private final String authorName;

private File dataFolder;
private File moduleFile;
Expand Down Expand Up @@ -66,7 +67,7 @@ protected PluginModule(String moduleName, String authorName) {
* @param plugin Instance of the plugin.
*/
protected void onPluginInit(SuperiorSkyblock plugin) {

// Can be overridden by custom modules.
}

/**
Expand Down
Expand Up @@ -153,7 +153,7 @@ private static final class Slimefun4RelocationsProtectionModule implements

@Override
public void load() {

// Do nothing.
}

@Override
Expand Down
@@ -1,6 +1,5 @@
package com.bgsoftware.superiorskyblock.hooks.support;

import com.bgsoftware.superiorskyblock.SuperiorSkyblockPlugin;
import com.bgsoftware.superiorskyblock.utils.debug.PluginDebugger;
import com.bgsoftware.superiorskyblock.world.chunks.ChunkPosition;
import com.bgsoftware.wildstacker.api.WildStackerAPI;
Expand Down
27 changes: 15 additions & 12 deletions README.md
Expand Up @@ -6,7 +6,8 @@
<p align="center">
<a href="https://bg-software.com/discord/"><img src="https://img.shields.io/discord/293212540723396608?color=7289DA&label=Discord&logo=discord&logoColor=7289DA&link=https://bg-software.com/discord/"></a>
<a href="https://bg-software.com/patreon/"><img src="https://img.shields.io/badge/-Support_on_Patreon-F96854.svg?logo=patreon&style=flat&logoColor=white&link=https://bg-software.com/patreon/"></a><br>
<a href=""><img src="https://img.shields.io/maintenance/yes/2021"></a>
<a href=""><img src="https://img.shields.io/maintenance/yes/2022"></a>
<a href="https://www.codacy.com/gh/BG-Software-LLC/SuperiorSkyblock2/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=BG-Software-LLC/SuperiorSkyblock2&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/cf81db478cf74983abac6f3605dc53b4"/></a>
</p>

## Compiling
Expand All @@ -18,13 +19,14 @@ You can find already compiled jars on our [Jenkins](https://hub.bg-software.com/
When compiling you will receive errors about missing dependencies.<br>
These dependencies are premium plugins that cannot be published on a public repository.<br>
You can do either of the followings in order to solve it:

- Add manually all the jar files of the premium plugins.
- Purchase access to our private repository.
- Purchase access to our private repository.
- Disabling compiling of the modules of these dependencies in the `gradle.properties` file.

<br>

##### Private Jars:
### Private Jars

- AdvancedSpawners by GC [[link]](https://advancedplugins.net/item/2)
- CMI by Zrips [[link]](https://www.spigotmc.org/resources/3742/)
Expand All @@ -40,9 +42,10 @@ highly recommended to only use the API and not the compiled plugin, as the API m
will not get removed or changed unless they are marked as deprecated. This means that when using the API, you won't have
to do any additional changes to your code between updates.

##### Maven
### Maven

```xml

```
<repositories>
<repository>
<id>bg-repo</id>
Expand All @@ -51,17 +54,17 @@ to do any additional changes to your code between updates.
</repositories>

<dependencies>
<dependency>
<groupId>com.bgsoftware</groupId>
<artifactId>SuperiorSkyblockAPI</artifactId>
<version>latest</version>
</dependency>
<dependency>
<groupId>com.bgsoftware</groupId>
<artifactId>SuperiorSkyblockAPI</artifactId>
<version>latest</version>
</dependency>
</dependencies>
```

##### Gradle
### Gradle

```
```text
repositories {
maven { url 'https://repo.bg-software.com/repository/api/' }
}
Expand Down
Expand Up @@ -284,8 +284,7 @@ public static Location getLocation(CommandSender sender, World world, String x,
Location location = null;

try {
int i_x = Integer.parseInt(x), i_y = Integer.parseInt(y), i_z = Integer.parseInt(z);
location = new Location(world, i_x, i_y, i_z);
location = new Location(world, Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(z));
} catch (Throwable ex) {
Message.INVALID_BLOCK.send(sender, world.getName() + ", " + x + ", " + y + ", " + z);
}
Expand All @@ -306,7 +305,7 @@ public static IslandPrivilege getIslandPrivilege(CommandSender sender, String ar

try {
islandPrivilege = IslandPrivilege.getByName(argument);
} catch (IllegalArgumentException ignored) {
} catch (NullPointerException ignored) {
}

if (islandPrivilege == null)
Expand All @@ -332,7 +331,7 @@ public static IslandFlag getIslandFlag(CommandSender sender, String argument) {

try {
islandFlag = IslandFlag.getByName(argument);
} catch (IllegalArgumentException ignored) {
} catch (NullPointerException ignored) {
}

if (islandFlag == null)
Expand Down

0 comments on commit 4acf710

Please sign in to comment.