Merge branch 'development'

This commit is contained in:
Brianna 2020-08-28 18:06:27 -05:00
commit 72fb3c6217
24 changed files with 217 additions and 78 deletions

View File

@ -1,23 +0,0 @@
stages:
- build
variables:
name: "SongodaCore"
path: "/builds/$CI_PROJECT_PATH"
version: "2.4.3"
build:
stage: build
image: maven:3.5.3-jdk-8
script:
- sed -e "s/{REPO_USER}/$REPO_USER/g" -e "s/{REPO_PASS}/$REPO_PASS/g" $path/settings.xml > ~/.m2/settings.xml
- find $path/ -type f -name "*.xml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- find $path/ -type f -name "*.yml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- find $path/ -type f -name "*SongodaCore.java" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- mvn clean package
- find $path/ -depth -path '*original*' -delete
- mv $path/Core/target/*.jar $path/
artifacts:
name: $name-$version
paths:
- "$path/*.jar"

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../</relativePath> <relativePath>../</relativePath>
</parent> </parent>
@ -325,6 +325,12 @@
<version>2.1.50</version> <version>2.1.50</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>net</groupId>
<artifactId>coreprotect</artifactId>
<version>2.17.5</version>
<scope>provided</scope>
</dependency>
<!-- End Plugin Hooks --> <!-- End Plugin Hooks -->
<dependency> <dependency>
<groupId>com.googlecode.json-simple</groupId> <groupId>com.googlecode.json-simple</groupId>

View File

@ -50,7 +50,7 @@ public class SongodaCore {
* This has been added as of Rev 6 <br> * This has been added as of Rev 6 <br>
* This value is automatically filled in by gitlab-ci * This value is automatically filled in by gitlab-ci
*/ */
private final static String coreVersion = "maven-version-number"; private final static String coreVersion = "2.4.4";
/** /**
* This is specific to the website api * This is specific to the website api

View File

@ -23,14 +23,7 @@ public class HookManager<T extends Hook> {
* Load all supported plugins. * Load all supported plugins.
*/ */
public void load() { public void load() {
if (!loaded) { load(null);
registeredHooks.putAll(PluginHook.loadHooks(typeClass, null).entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> (T) e.getValue())));
if (!registeredHooks.isEmpty()) {
defaultHook = (T) registeredHooks.values().iterator().next();
}
loaded = true;
}
} }
/** /**
@ -40,7 +33,7 @@ public class HookManager<T extends Hook> {
public void load(Plugin hookingPlugin) { public void load(Plugin hookingPlugin) {
if (!loaded) { if (!loaded) {
registeredHooks.putAll(PluginHook.loadHooks(typeClass, hookingPlugin).entrySet().stream() registeredHooks.putAll(PluginHook.loadHooks(typeClass, hookingPlugin).entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> (T) e.getValue()))); .collect(Collectors.toMap(Map.Entry::getKey, e -> (T) e.getValue())));
if (!registeredHooks.isEmpty()) { if (!registeredHooks.isEmpty()) {
defaultHook = (T) registeredHooks.values().iterator().next(); defaultHook = (T) registeredHooks.values().iterator().next();
} }

View File

@ -0,0 +1,92 @@
package com.songoda.core.hooks;
import com.songoda.core.hooks.log.Log;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
/**
* A convenience class for static access to a Log HookManager
*/
public class LogManager {
private static final HookManager<Log> manager = new HookManager(Log.class);
/**
* Load all supported log plugins. <br />
* Note: This method should be called in your plugin's onEnable() section
*/
public static void load() {
manager.load();
}
public static HookManager getManager() {
return manager;
}
/**
* Grab the default log plugin. <br />
* NOTE: using a default log assumes that this library is shaded
*
* @return returns null if no plugin enabled
*/
public static Log getLog() {
return manager.getCurrentHook();
}
/**
* Check to see if there is a default log loaded. <br />
* NOTE: using a default log assumes that this library is shaded
*
* @return returns false if there are no supported log plugins
*/
public static boolean isEnabled() {
return manager.isEnabled();
}
/**
* Get the name of the log plugin being used. <br />
* NOTE: using a default log assumes that this library is shaded
*
* @return
*/
public static String getName() {
return manager.getName();
}
/**
* Log the placement of a block. <br />
* NOTE: using a default log assumes that this library is shaded
*
* @param player player to commit action
* @param block the block that is placed
*/
public static void logPlacement(OfflinePlayer player, Block block) {
if (manager.isEnabled())
manager.getCurrentHook().logPlacement(player, block);
}
/**
* Log the removal of a block. <br />
* NOTE: using a default log assumes that this library is shaded
*
* @param player player to commit actionremvedplaced
*/
public static void logRemoval(OfflinePlayer player, Block block) {
if (manager.isEnabled())
manager.getCurrentHook().logRemoval(player, block);
}
/**
* Log a player interaction. <br />
* NOTE: using a default log assumes that this library is shaded
*
* @param player player to commit action
* @param location the location that is interacted with
*/
public static void logInteraction(OfflinePlayer player, Location location) {
if (manager.isEnabled())
manager.getCurrentHook().logInteraction(player, location);
}
}

View File

@ -5,13 +5,19 @@ import com.songoda.core.hooks.economies.PlayerPointsEconomy;
import com.songoda.core.hooks.economies.ReserveEconomy; import com.songoda.core.hooks.economies.ReserveEconomy;
import com.songoda.core.hooks.economies.VaultEconomy; import com.songoda.core.hooks.economies.VaultEconomy;
import com.songoda.core.hooks.holograms.CMIHolograms; import com.songoda.core.hooks.holograms.CMIHolograms;
import com.songoda.core.hooks.holograms.Holograms;
import com.songoda.core.hooks.holograms.HologramsHolograms;
import com.songoda.core.hooks.holograms.HolographicDisplaysHolograms;
import com.songoda.core.hooks.log.CoreProtectLog;
import com.songoda.core.hooks.log.Log;
import com.songoda.core.hooks.stackers.StackMob; import com.songoda.core.hooks.stackers.StackMob;
import com.songoda.core.hooks.stackers.Stacker; import com.songoda.core.hooks.stackers.Stacker;
import com.songoda.core.hooks.stackers.UltimateStacker; import com.songoda.core.hooks.stackers.UltimateStacker;
import com.songoda.core.hooks.stackers.WildStacker; import com.songoda.core.hooks.stackers.WildStacker;
import com.songoda.core.hooks.holograms.Holograms; import org.bukkit.Bukkit;
import com.songoda.core.hooks.holograms.HologramsHolograms; import org.bukkit.plugin.Plugin;
import com.songoda.core.hooks.holograms.HolographicDisplaysHolograms; import org.bukkit.plugin.PluginManager;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -20,11 +26,8 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
public final class PluginHook <T extends Class> { public final class PluginHook<T extends Class> {
public static final PluginHook ECO_VAULT = new PluginHook(Economy.class, "Vault", VaultEconomy.class); public static final PluginHook ECO_VAULT = new PluginHook(Economy.class, "Vault", VaultEconomy.class);
public static final PluginHook ECO_PLAYER_POINTS = new PluginHook(Economy.class, "PlayerPoints", PlayerPointsEconomy.class); public static final PluginHook ECO_PLAYER_POINTS = new PluginHook(Economy.class, "PlayerPoints", PlayerPointsEconomy.class);
@ -35,6 +38,7 @@ public final class PluginHook <T extends Class> {
public static final PluginHook HOLO_DISPLAYS = new PluginHook(Holograms.class, "HolographicDisplays", HolographicDisplaysHolograms.class); public static final PluginHook HOLO_DISPLAYS = new PluginHook(Holograms.class, "HolographicDisplays", HolographicDisplaysHolograms.class);
public static final PluginHook HOLO_HOLOGRAMS = new PluginHook(Holograms.class, "Holograms", HologramsHolograms.class); public static final PluginHook HOLO_HOLOGRAMS = new PluginHook(Holograms.class, "Holograms", HologramsHolograms.class);
public static final PluginHook HOLO_CMI = new PluginHook(Holograms.class, "CMI", CMIHolograms.class); public static final PluginHook HOLO_CMI = new PluginHook(Holograms.class, "CMI", CMIHolograms.class);
public static final PluginHook LOG_CORE_PROTECT = new PluginHook(Log.class, "CoreProtect", CoreProtectLog.class);
/******* Start Manager stuff *******/ /******* Start Manager stuff *******/
@ -87,6 +91,7 @@ public final class PluginHook <T extends Class> {
PluginManager pluginManager = Bukkit.getPluginManager(); PluginManager pluginManager = Bukkit.getPluginManager();
for (PluginHook hook : getHooks(type)) { for (PluginHook hook : getHooks(type)) {
System.out.println("Looking at " + hook.plugin);
if (pluginManager.isPluginEnabled(hook.plugin)) { if (pluginManager.isPluginEnabled(hook.plugin)) {
Hook handler = (Hook) (plugin != null ? hook.load(plugin) : hook.load()); Hook handler = (Hook) (plugin != null ? hook.load(plugin) : hook.load());
if (handler != null && handler.isEnabled()) { if (handler != null && handler.isEnabled()) {

View File

@ -0,0 +1,51 @@
package com.songoda.core.hooks.log;
import com.songoda.core.compatibility.ServerVersion;
import net.coreprotect.CoreProtect;
import net.coreprotect.CoreProtectAPI;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
public class CoreProtectLog extends Log {
private CoreProtectAPI api;
private boolean useDeprecatedMethod = ServerVersion.isServerVersionBelow(ServerVersion.V1_12);
public CoreProtectLog() {
this.api = CoreProtect.getInstance().getAPI();
}
@Override
public String getName() {
return "CoreProtect";
}
@Override
public boolean isEnabled() {
return api.isEnabled();
}
@Override
public void logPlacement(OfflinePlayer player, Block block) {
if (this.useDeprecatedMethod) {
this.api.logPlacement(player.getName(), block.getLocation(), block.getType(), block.getData());
} else {
this.api.logPlacement(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
}
}
@Override
public void logRemoval(OfflinePlayer player, Block block) {
if (this.useDeprecatedMethod) {
this.api.logRemoval(player.getName(), block.getLocation(), block.getType(), block.getData());
} else {
this.api.logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
}
}
@Override
public void logInteraction(OfflinePlayer player, Location location) {
this.api.logInteraction(player.getName(), location);
}
}

View File

@ -0,0 +1,15 @@
package com.songoda.core.hooks.log;
import com.songoda.core.hooks.Hook;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
public abstract class Log implements Hook {
public abstract void logPlacement(OfflinePlayer player, Block block);
public abstract void logRemoval(OfflinePlayer player, Block block);
public abstract void logInteraction(OfflinePlayer player, Location location);
}

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId> <artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version> <version>2.4.4</version>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging> <packaging>pom</packaging>