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>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version>
<version>2.4.4</version>
<relativePath>../</relativePath>
</parent>
@ -78,15 +78,15 @@
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<includes>
<include>com/</include>
<include>META-INF/MANIFEST.MF</include>
<include>META-INF/maven/com.songoda/SongodaCore/</include>
</includes>
</filter>
</filters>
<filter>
<artifact>*:*</artifact>
<includes>
<include>com/</include>
<include>META-INF/MANIFEST.MF</include>
<include>META-INF/maven/com.songoda/SongodaCore/</include>
</includes>
</filter>
</filters>
</configuration>
</execution>
</executions>
@ -325,6 +325,12 @@
<version>2.1.50</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net</groupId>
<artifactId>coreprotect</artifactId>
<version>2.17.5</version>
<scope>provided</scope>
</dependency>
<!-- End Plugin Hooks -->
<dependency>
<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 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

View File

@ -23,14 +23,7 @@ public class HookManager<T extends Hook> {
* Load all supported plugins.
*/
public void load() {
if (!loaded) {
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;
}
load(null);
}
/**
@ -40,7 +33,7 @@ public class HookManager<T extends Hook> {
public void load(Plugin hookingPlugin) {
if (!loaded) {
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()) {
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.VaultEconomy;
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.Stacker;
import com.songoda.core.hooks.stackers.UltimateStacker;
import com.songoda.core.hooks.stackers.WildStacker;
import com.songoda.core.hooks.holograms.Holograms;
import com.songoda.core.hooks.holograms.HologramsHolograms;
import com.songoda.core.hooks.holograms.HolographicDisplaysHolograms;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.LinkedHashMap;
@ -20,21 +26,19 @@ import java.util.Map;
import java.util.Objects;
import java.util.logging.Level;
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_PLAYER_POINTS = new PluginHook(Economy.class, "PlayerPoints", PlayerPointsEconomy.class);
public static final PluginHook ECO_RESERVE = new PluginHook(Economy.class, "Reserve", ReserveEconomy.class);
public static final PluginHook STACKER_ULTIMATE = new PluginHook(Stacker.class, "UltimateStacker", UltimateStacker.class);
public static final PluginHook STACKER_WILD = new PluginHook(Stacker.class, "WildStacker", WildStacker.class);
public static final PluginHook STACKER_STACK_MOB = new PluginHook(Stacker.class, "StackMob", StackMob.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_CMI = new PluginHook(Holograms.class, "CMI", CMIHolograms.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_RESERVE = new PluginHook(Economy.class, "Reserve", ReserveEconomy.class);
public static final PluginHook STACKER_ULTIMATE = new PluginHook(Stacker.class, "UltimateStacker", UltimateStacker.class);
public static final PluginHook STACKER_WILD = new PluginHook(Stacker.class, "WildStacker", WildStacker.class);
public static final PluginHook STACKER_STACK_MOB = new PluginHook(Stacker.class, "StackMob", StackMob.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_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 *******/
@ -71,11 +75,11 @@ public final class PluginHook <T extends Class> {
* NOTE: The class passed MUST extend Hook. <br>
* Permissible constructors are empty () or (org.bukkit.plugin.Plugin) <br>
* Each plugin defined must use a different handler class.
*
*
* @param <T>
* @param type Generic hook type for this plugin
* @param type Generic hook type for this plugin
* @param pluginName Plugin name
* @param handler Specific class that will handle this plugin, if enabled.
* @param handler Specific class that will handle this plugin, if enabled.
* @return instance of the PluginHook that was added
*/
public static <T extends Class> PluginHook addHook(T type, String pluginName, Class handler) {
@ -87,6 +91,7 @@ public final class PluginHook <T extends Class> {
PluginManager pluginManager = Bukkit.getPluginManager();
for (PluginHook hook : getHooks(type)) {
System.out.println("Looking at " + hook.plugin);
if (pluginManager.isPluginEnabled(hook.plugin)) {
Hook handler = (Hook) (plugin != null ? hook.load(plugin) : hook.load());
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>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>maven-version-number</version>
<version>2.4.4</version>
<relativePath>../../</relativePath>
</parent>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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